10 #include "libmesh/petsc_macro.h" 20 #include "libmesh/libmesh_common.h" 21 #include "libmesh/petsc_nonlinear_solver.h" 22 #include "libmesh/coupling_matrix.h" 33 "topsplit",
"Entrance to splits, the top split will specify how splits will go.");
37 "Set to true if you want the full set of couplings between variables " 38 "simply for convenience so you don't have to set every off_diag_row " 39 "and off_diag_column combination.");
45 _top_split(getParam<
std::vector<
std::string>>(
"topsplit")),
46 _nl(_fe_problem.getNonlinearSystemBase(_nl_sys_num))
53 bool full = getParam<bool>(
"full");
56 std::unique_ptr<CouplingMatrix> cm = std::make_unique<CouplingMatrix>(
n_vars);
62 const auto off_diag_rows = getParam<std::vector<NonlinearVariableName>>(
"off_diag_row");
63 const auto off_diag_columns = getParam<std::vector<NonlinearVariableName>>(
"off_diag_column");
66 for (
unsigned int i = 0; i <
n_vars; i++)
70 std::vector<std::vector<unsigned int>> off_diag(
n_vars);
71 if (off_diag_rows.size() * off_diag_columns.size() != 0 &&
72 off_diag_rows.size() == off_diag_columns.size())
77 (*cm)(row, column) = 1;
83 for (
unsigned int i = 0; i <
n_vars; i++)
84 for (
unsigned int j = 0; j <
n_vars; j++)
Implements a preconditioner designed to map onto PETSc's PCFieldSplit.
unsigned int number() const
Get variable number coming from libMesh.
void setupFieldDecomposition()
FieldSplitPreconditioner(const InputParameters ¶meters)
void setDecomposition(const std::vector< std::string > &decomposition)
If called with a single string, it is used as the name of a the top-level decomposition split...
void useFieldSplitPreconditioner(bool use=true)
If called with true this system will use a field split preconditioner matrix.
Base class for MOOSE preconditioners.
NonlinearSystemBase & _nl
The nonlinear system this FSP is associated with (convenience reference)
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.
static InputParameters validParams()
std::vector< std::string > _top_split
top split
static InputParameters validParams()
Constructor.
registerMooseObjectAliased("MooseApp", FieldSplitPreconditioner, "FSP")
MooseVariableFieldBase & getVariable(THREAD_ID tid, const std::string &var_name) const
Gets a reference to a variable of with specified name.
void setCouplingMatrix(std::unique_ptr< CouplingMatrix > cm)
Setup the coupling matrix on the finite element problem.
auto index_range(const T &sizable)