17 #include "libmesh/coupling_matrix.h" 26 params.
addClassDescription(
"Finite difference preconditioner (FDP) builds a numerical Jacobian " 27 "for preconditioning, only use for testing and verification.");
29 params.
addParam<
bool>(
"implicit_geometric_coupling",
31 "Set to true if you want to add entries into the " 32 "matrix for degrees of freedom that might be coupled " 33 "by inspection of the geometric search objects.");
35 MooseEnum finite_difference_type(
"standard coloring",
"coloring");
37 finite_difference_type,
38 "standard: standard finite difference" 39 "coloring: finite difference based on coloring");
46 _finite_difference_type(getParam<
MooseEnum>(
"finite_difference_type"))
49 mooseWarning(
"Finite differencing to assemble the Jacobian is MUCH MUCH slower than forming " 50 "the Jacobian by hand, so don't complain about performance if you use it!");
55 std::unique_ptr<CouplingMatrix> cm = std::make_unique<CouplingMatrix>(
n_vars);
57 bool full = getParam<bool>(
"full");
66 for (
unsigned int i = 0; i <
n_vars; i++)
70 std::vector<std::vector<unsigned int>> off_diag(
n_vars);
73 for (
const auto i :
index_range(
getParam<std::vector<NonlinearVariableName>>(
"off_diag_row")))
81 (*cm)(row, column) = 1;
88 for (
unsigned int i = 0; i <
n_vars; i++)
89 for (
unsigned int j = 0; j <
n_vars; j++)
95 bool implicit_geometric_coupling = getParam<bool>(
"implicit_geometric_coupling");
MooseEnum _finite_difference_type
void addImplicitGeometricCouplingEntriesToJacobian(bool add=true)
If called with true this will add entries into the jacobian to link together degrees of freedom that ...
unsigned int number() const
Get variable number coming from libMesh.
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.
FiniteDifferencePreconditioner(const InputParameters ¶ms)
void mooseWarning(Args &&... args) const
Emits a warning prefixed with object name and type.
Base class for MOOSE preconditioners.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
virtual unsigned int nVariables() const
Get the number of variables in this system.
Nonlinear system to be solved.
processor_id_type n_processors() const
void useFiniteDifferencedPreconditioner(bool use=true)
If called with true this system will use a finite differenced form of the Jacobian as the preconditio...
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
static InputParameters validParams()
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
static InputParameters validParams()
Finite difference preconditioner.
void setCouplingMatrix(std::unique_ptr< libMesh::CouplingMatrix > cm)
Setup the coupling matrix on the finite element problem.
registerMooseObjectAliased("MooseApp", FiniteDifferencePreconditioner, "FDP")
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
auto index_range(const T &sizable)