16 #include "libmesh/coupling_matrix.h" 17 #include "libmesh/numeric_vector.h" 25 MooseEnum pc_side(
"left right symmetric default",
"default");
27 MooseEnum ksp_norm(
"none preconditioned unpreconditioned natural default",
"unpreconditioned");
29 "ksp_norm", ksp_norm,
"Sets the norm that is used for convergence testing");
32 params.
addParam<std::vector<NonlinearVariableName>>(
34 "The variable names for the off-diagonal rows you want to add into the matrix; they will be " 35 "associated with an off-diagonal column from the same position in off_diag_column.");
36 params.
addParam<std::vector<NonlinearVariableName>>(
38 "The variable names for the off-diagonal columns you want to add into the matrix; they " 39 "will be associated with an off-diagonal row from the same position in off_diag_row.");
42 "Set to true if you want the full set of couplings between variables " 43 "simply for convenience so you don't have to set every off_diag_row " 44 "and off_diag_column combination.");
45 params.
addParam<NonlinearSystemName>(
47 "The nonlinear system whose linearization this preconditioner should be applied to.");
58 _fe_problem(*params.getCheckedPointerParam<
FEProblemBase *>(
"_fe_problem_base")),
60 isParamValid(
"nl_sys") ? _fe_problem.nlSysNum(getParam<NonlinearSystemName>(
"nl_sys")) : 0),
61 _nl(_fe_problem.getNonlinearSystemBase(_nl_sys_num))
67 bool full = getParam<bool>(
"full");
71 paramError(
"off_diag_row",
"Set full=false to specify the off-diagonal rows manually");
73 paramError(
"off_diag_column",
"Set full=false to specify the off-diagonal columns manually");
81 getParam<NonlinearVariableName, NonlinearVariableName>(
"off_diag_row",
"off_diag_column");
85 "If off-diagonal rows are specified, matching off-diagonal " 86 "columns must be specified as well");
90 "If off-diagonal columns are specified, matching off-diagonal " 91 "rows must be specified as well");
99 const unsigned int from_system,
100 const unsigned int from_var,
102 const unsigned int to_system,
103 const unsigned int to_var,
106 for (
auto & node :
mesh.local_node_ptr_range())
108 unsigned int n_comp = node->n_comp(from_system, from_var);
110 mooseAssert(node->n_comp(from_system, from_var) == node->n_comp(to_system, to_var),
111 "Number of components does not match in each system");
113 for (
unsigned int i = 0; i < n_comp; i++)
115 dof_id_type from_dof = node->dof_number(from_system, from_var, i);
116 dof_id_type to_dof = node->dof_number(to_system, to_var, i);
118 to_vector.
set(to_dof, from_vector(from_dof));
122 for (
auto & elem :
as_range(
mesh.local_elements_begin(),
mesh.local_elements_end()))
124 unsigned int n_comp = elem->n_comp(from_system, from_var);
126 mooseAssert(elem->n_comp(from_system, from_var) == elem->n_comp(to_system, to_var),
127 "Number of components does not match in each system");
129 for (
unsigned int i = 0; i < n_comp; i++)
131 dof_id_type from_dof = elem->dof_number(from_system, from_var, i);
132 dof_id_type to_dof = elem->dof_number(to_system, to_var, i);
134 to_vector.
set(to_dof, from_vector(from_dof));
NonlinearSystemBase & _nl
The nonlinear system whose linearization this preconditioner should be applied to.
static void copyVarValues(MeshBase &mesh, const unsigned int from_system, const unsigned int from_var, const NumericVector< Number > &from_vector, const unsigned int to_system, const unsigned int to_var, NumericVector< Number > &to_vector)
Helper function for copying values associated with variables in vectors from two different systems...
A class for creating restricted objects.
void setSolveTypeFromParams(FEProblemBase &fe_problem, const InputParameters ¶ms)
Sets the FE problem's solve type from the input params.
void setPCSide(MooseEnum pcs)
Set the side on which the preconditioner is applied to.
const unsigned int _nl_sys_num
The nonlinear system number whose linearization this preconditioner should be applied to...
FEProblemBase & _fe_problem
Subproblem this preconditioner is part of.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
MoosePreconditioner(const InputParameters ¶ms)
Every object that can be built by the factory should be derived from this class.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
static InputParameters validParams()
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
void setCouplingMatrix(std::unique_ptr< libMesh::CouplingMatrix > cm, const unsigned int nl_sys_num)
Set custom coupling matrix.
Interface for objects interacting with the PerfGraph.
InputParameters getPetscValidParams()
Returns the PETSc options that are common between Executioners and Preconditioners.
virtual void initialSetup()
Perform some setup tasks such as storing the PETSc options.
std::string prefix() const
void setCouplingMatrix(std::unique_ptr< libMesh::CouplingMatrix > cm)
Setup the coupling matrix on the finite element problem.
virtual void set(const numeric_index_type i, const Number value)=0
void storePetscOptions(FEProblemBase &fe_problem, const std::string &prefix, const ParallelParamObject ¶m_object)
Stores the PETSc options supplied from the parameter object on the problem.
static InputParameters validParams()
void setMooseKSPNormType(MooseEnum kspnorm)
Set the norm in which the linear convergence will be measured.