https://mooseframework.inl.gov
SolverSystem.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "SystemBase.h"
13 #include "MooseTypes.h"
14 
15 #include "libmesh/system.h"
16 
17 #include <string>
18 
19 class SubProblem;
20 class FEProblemBase;
21 
23 
24 class SolverSystem : public SystemBase
25 {
26 public:
28  FEProblemBase & fe_problem,
29  const std::string & name,
30  Moose::VarKindType var_kind);
31  virtual ~SolverSystem();
32 
33  virtual void preInit() override;
34  virtual void restoreSolutions() override final;
35 
36  void serializeSolution();
37 
41  virtual void stopSolve(const ExecFlagType & exec_flag,
42  const std::set<TagID> & vector_tags_to_close) = 0;
43 
48  virtual bool converged() = 0;
49 
53  virtual bool containsTimeKernel() = 0;
54 
59  virtual std::vector<std::string> timeKernelVariableNames() = 0;
60 
65  void setSolution(const NumericVector<Number> & soln);
66 
77  void setFixedPointRelaxationFactor(const Real relaxation_factor);
81 
86  void setPCSide(MooseEnum pcs);
87 
92 
97  void setMooseKSPNormType(MooseEnum kspnorm);
98 
103 
104  virtual const NumericVector<Number> * const & currentSolution() const override final;
105 
106  virtual void compute(ExecFlagType type) override;
107 
108 protected:
109  void checkInvalidSolution();
110 
111  virtual NumericVector<Number> & solutionInternal() const override final;
112 
117  virtual bool matrixFromColoring() const { return false; }
118 
121 
126 
129 
132 };
133 
134 inline const NumericVector<Number> * const &
136 {
137  return _current_solution;
138 }
139 
140 inline NumericVector<Number> &
142 {
143  return *system().solution;
144 }
SolverSystem(SubProblem &subproblem, FEProblemBase &fe_problem, const std::string &name, Moose::VarKindType var_kind)
Definition: SolverSystem.C:18
Moose::PCSideType _pc_side
Preconditioning side.
Definition: SolverSystem.h:123
void checkInvalidSolution()
Definition: SolverSystem.C:165
virtual ~SolverSystem()
void serializeSolution()
Definition: SolverSystem.C:52
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
void setSolution(const NumericVector< Number > &soln)
Set the solution to a given vector.
Definition: SolverSystem.C:67
void setPCSide(MooseEnum pcs)
Set the side on which the preconditioner is applied to.
Definition: SolverSystem.C:133
Base class for a system (of equations)
Definition: SystemBase.h:85
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
virtual bool matrixFromColoring() const
Whether a system matrix is formed from coloring.
Definition: SolverSystem.h:117
virtual std::vector< std::string > timeKernelVariableNames()=0
Returns the names of the variables that have time derivative kernels in the system.
MooseKSPNormType
Norm type for converge test.
Definition: MooseTypes.h:879
virtual const std::string & name() const
Definition: SystemBase.C:1342
virtual const NumericVector< Number > *const & currentSolution() const override final
The solution vector that is currently being operated on.
Definition: SolverSystem.h:135
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:763
SubProblem & subproblem()
Definition: SystemBase.h:102
virtual NumericVector< Number > & solutionInternal() const override final
Internal getter for solution owned by libMesh.
Definition: SolverSystem.h:141
std::unique_ptr< NumericVector< Number > > solution
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:54
void saveOldSolutionForFixedPointRelaxation()
Definition: SolverSystem.C:91
virtual void restoreSolutions() override final
Restore current solutions (call after your solve failed)
Definition: SolverSystem.C:43
bool _solution_is_invalid
Boolean to see if solution is invalid.
Definition: SolverSystem.h:128
const NumericVector< Number > * _current_solution
solution vector from solver
Definition: SolverSystem.h:120
Real _fixed_point_relaxation_factor
Used for relaxing entire system solution during fixed point (multi-)system iterations.
Definition: SolverSystem.h:131
virtual bool containsTimeKernel()=0
If the system has a kernel that corresponds to a time derivative.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Generic class for solving transient nonlinear problems.
Definition: SubProblem.h:78
virtual void stopSolve(const ExecFlagType &exec_flag, const std::set< TagID > &vector_tags_to_close)=0
Quit the current solve as soon as possible.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:18
virtual void compute(ExecFlagType type) override
Compute time derivatives, auxiliary variables, etc.
Definition: SolverSystem.C:188
void applyFixedPointRelaxation()
Definition: SolverSystem.C:109
virtual void preInit() override
This is called prior to the libMesh system has been init&#39;d.
Definition: SolverSystem.C:32
PCSideType
Preconditioning side.
Definition: MooseTypes.h:868
Real Number
Moose::MooseKSPNormType getMooseKSPNormType()
Get the norm in which the linear convergence is measured.
Definition: SolverSystem.h:102
Moose::MooseKSPNormType _ksp_norm
KSP norm type.
Definition: SolverSystem.h:125
virtual bool converged()=0
Returns the convergence state.
void clearFixedPointRelaxation()
Definition: SolverSystem.C:85
Moose::PCSideType getPCSide()
Get the current preconditioner side.
Definition: SolverSystem.h:91
void setMooseKSPNormType(MooseEnum kspnorm)
Set the norm in which the linear convergence will be measured.
Definition: SolverSystem.C:148
void setFixedPointRelaxationFactor(const Real relaxation_factor)
Enable solution under/over-relaxation for fixed point iterations.
Definition: SolverSystem.C:79