https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
19class SubProblem;
20class FEProblemBase;
21
23
25{
26public:
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
76 void applyFixedPointRelaxation(const Real relaxation_factor,
77 const Moose::SolutionIterationType iteration_type);
78
83 void setPCSide(MooseEnum pcs);
84
88 Moose::PCSideType getPCSide() { return _pc_side; }
89
94 void setMooseKSPNormType(MooseEnum kspnorm);
95
100
101 virtual const NumericVector<Number> * const & currentSolution() const override final;
102
103 virtual void compute(ExecFlagType type) override;
104
105protected:
107
108 virtual NumericVector<Number> & solutionInternal() const override final;
109
114 virtual bool matrixFromColoring() const { return false; }
115
117 const NumericVector<Number> * _current_solution;
118
123
126};
127
128inline const NumericVector<Number> * const &
133
134inline NumericVector<Number> &
136{
137 return *system().solution;
138}
unsigned int TagID
Definition MooseTypes.h:238
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Class for containing MooseEnum item information.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
virtual void stopSolve(const ExecFlagType &exec_flag, const std::set< TagID > &vector_tags_to_close)=0
Quit the current solve as soon as possible.
void setPCSide(MooseEnum pcs)
Set the side on which the preconditioner is applied to.
void setSolution(const NumericVector< Number > &soln)
Set the solution to a given vector.
virtual const NumericVector< Number > *const & currentSolution() const override final
The solution vector that is currently being operated on.
virtual std::vector< std::string > timeKernelVariableNames()=0
Returns the names of the variables that have time derivative kernels in the system.
virtual void compute(ExecFlagType type) override
Compute time derivatives, auxiliary variables, etc.
virtual NumericVector< Number > & solutionInternal() const override final
Internal getter for solution owned by libMesh.
virtual void preInit() override
This is called prior to the libMesh system has been init'd.
void checkInvalidSolution()
virtual bool containsTimeKernel()=0
If the system has a kernel that corresponds to a time derivative.
virtual bool matrixFromColoring() const
Whether a system matrix is formed from coloring.
const NumericVector< Number > * _current_solution
solution vector from solver
void serializeSolution()
Moose::MooseKSPNormType getMooseKSPNormType()
Get the norm in which the linear convergence is measured.
void applyFixedPointRelaxation(const Real relaxation_factor, const Moose::SolutionIterationType iteration_type)
Apply solution under/over-relaxation for fixed point iterations.
Moose::PCSideType getPCSide()
Get the current preconditioner side.
virtual ~SolverSystem()
void setMooseKSPNormType(MooseEnum kspnorm)
Set the norm in which the linear convergence will be measured.
virtual bool converged()=0
Returns the convergence state.
Moose::PCSideType _pc_side
Preconditioning side.
virtual void restoreSolutions() override final
Restore current solutions (call after your solve failed)
bool _solution_is_invalid
Boolean to see if solution is invalid.
Moose::MooseKSPNormType _ksp_norm
KSP norm type.
Generic class for solving transient nonlinear problems.
Definition SubProblem.h:79
Base class for a system (of equations)
Definition SystemBase.h:87
SubProblem & subproblem()
Definition SystemBase.h:102
virtual const std::string & name() const
virtual libMesh::System & system()=0
Get the reference to the libMesh system.
std::unique_ptr< NumericVector< Number > > solution
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
PCSideType
Preconditioning side.
Definition MooseTypes.h:874
MooseKSPNormType
Norm type for converge test.
Definition MooseTypes.h:885
VarKindType
Framework-wide stuff.
Definition MooseTypes.h:769