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");
registerMooseObjectAliased("MooseApp", FiniteDifferencePreconditioner, "FDP")
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
Finite difference preconditioner.
static InputParameters validParams()
FiniteDifferencePreconditioner(const InputParameters ¶ms)
MooseEnum _finite_difference_type
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Base class for MOOSE preconditioners.
FEProblemBase & _fe_problem
Subproblem this preconditioner is part of.
void setCouplingMatrix(std::unique_ptr< libMesh::CouplingMatrix > cm)
Setup the coupling matrix on the finite element problem.
static InputParameters validParams()
const unsigned int _nl_sys_num
The nonlinear system number whose linearization this preconditioner should be applied to.
Nonlinear system to be solved.
void addImplicitGeometricCouplingEntriesToJacobian(bool add=true)
If called with true this will add entries into the jacobian to link together degrees of freedom that ...
void useFiniteDifferencedPreconditioner(bool use=true)
If called with true this system will use a finite differenced form of the Jacobian as the preconditio...
void mooseWarning(Args &&... args) const
virtual unsigned int nVariables() const
Get the number of variables in this system.
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
processor_id_type n_processors() const