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 
71  void setPCSide(MooseEnum pcs);
72 
77 
82  void setMooseKSPNormType(MooseEnum kspnorm);
83 
88 
89  virtual const NumericVector<Number> * const & currentSolution() const override final;
90 
91  virtual void compute(ExecFlagType type) override;
92 
93 protected:
94  void checkInvalidSolution();
95 
96  virtual NumericVector<Number> & solutionInternal() const override final;
97 
102  virtual bool matrixFromColoring() const { return false; }
103 
106 
111 
114 };
115 
116 inline const NumericVector<Number> * const &
118 {
119  return _current_solution;
120 }
121 
122 inline NumericVector<Number> &
124 {
125  return *system().solution;
126 }
SolverSystem(SubProblem &subproblem, FEProblemBase &fe_problem, const std::string &name, Moose::VarKindType var_kind)
Definition: SolverSystem.C:17
Moose::PCSideType _pc_side
Preconditioning side.
Definition: SolverSystem.h:108
void checkInvalidSolution()
Definition: SolverSystem.C:111
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:79
Base class for a system (of equations)
Definition: SystemBase.h:84
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:102
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:830
virtual const std::string & name() const
Definition: SystemBase.C:1330
virtual const NumericVector< Number > *const & currentSolution() const override final
The solution vector that is currently being operated on.
Definition: SolverSystem.h:117
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:714
SubProblem & subproblem()
Definition: SystemBase.h:101
virtual NumericVector< Number > & solutionInternal() const override final
Internal getter for solution owned by libMesh.
Definition: SolverSystem.h:123
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:33
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:113
const NumericVector< Number > * _current_solution
solution vector from solver
Definition: SolverSystem.h:105
virtual bool containsTimeKernel()=0
If the system has a kernel that corresponds to a time derivative.
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:134
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:819
Real Number
Moose::MooseKSPNormType getMooseKSPNormType()
Get the norm in which the linear convergence is measured.
Definition: SolverSystem.h:87
Moose::MooseKSPNormType _ksp_norm
KSP norm type.
Definition: SolverSystem.h:110
virtual bool converged()=0
Returns the convergence state.
Moose::PCSideType getPCSide()
Get the current preconditioner side.
Definition: SolverSystem.h:76
void setMooseKSPNormType(MooseEnum kspnorm)
Set the norm in which the linear convergence will be measured.
Definition: SolverSystem.C:94