https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Moose::MFEM::ProblemOperatorBase Class Referenceabstract

Connects MFEMProblem's MOOSE solver objects to EquationSystem's mathematics. More...

#include <ProblemOperatorBase.h>

Inheritance diagram for Moose::MFEM::ProblemOperatorBase:
[legend]

Public Member Functions

 ProblemOperatorBase (MFEMProblem &problem)
 
virtual ~ProblemOperatorBase ()=default
 
virtual void SetGridFunctions ()
 
virtual void SetTrialVariablesFromTrueVectors ()
 
virtual void Init (mfem::BlockVector &X)
 
virtual void Solve ()=0
 

Public Attributes

mfem::Array< int_block_true_offsets_test
 
mfem::Array< int_block_true_offsets_trial
 
mfem::BlockVector _true_x
 
mfem::BlockVector _true_rhs
 

Protected Member Functions

void SolveWithOperator (mfem::Operator &system_operator, mfem::Operator &linear_operator, const mfem::Vector &rhs, mfem::Vector &x)
 Solve the current system operator using the configured nonlinear and linear solvers.
 
void SolveWithOperator (mfem::Operator &system_operator, const mfem::Vector &rhs, mfem::Vector &x)
 Solve the current system operator using system_operator.GetGradient(x) as the linear operator.
 

Protected Attributes

MFEMProblem_problem
 Reference to the current problem.
 
MFEMProblemData_problem_data
 
std::vector< std::string > _trial_var_names
 Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector during solve.
 
std::vector< std::string > _test_var_names
 
std::vector< mfem::ParGridFunction * > _trial_variables
 
std::vector< mfem::ParGridFunction * > _test_variables
 
mfem::Vector * _trial_true_vector = nullptr
 

Detailed Description

Connects MFEMProblem's MOOSE solver objects to EquationSystem's mathematics.

Three distinct layers collaborate to run an MFEM solve inside MOOSE:

Definition at line 52 of file ProblemOperatorBase.h.

Constructor & Destructor Documentation

◆ ProblemOperatorBase()

Moose::MFEM::ProblemOperatorBase::ProblemOperatorBase ( MFEMProblem problem)

Definition at line 19 of file ProblemOperatorBase.C.

20 : _problem(problem), _problem_data(problem.getProblemData())
21{
22}
MFEMProblemData & getProblemData()
Method to get the current MFEMProblemData object storing the current data specifying the FE problem.
MFEMProblem & _problem
Reference to the current problem.

◆ ~ProblemOperatorBase()

virtual Moose::MFEM::ProblemOperatorBase::~ProblemOperatorBase ( )
virtualdefault

Member Function Documentation

◆ Init()

void Moose::MFEM::ProblemOperatorBase::Init ( mfem::BlockVector &  X)
virtual

Reimplemented in Moose::MFEM::TimeDependentEquationSystemProblemOperator.

Definition at line 49 of file ProblemOperatorBase.C.

50{
52 for (const auto i : index_range(_trial_variables))
53 X.GetBlock(i) = _trial_variables[i]->GetTrueVector();
54 // Sync the flags from the global vector with the sub-vectors (copies to global vector location)
55 X.SyncFromBlocks();
56
57 // After initial assignment of X from the grid function, which may contain initial conditions,
58 // we alias the grid function to X
59 for (const auto i : index_range(_trial_variables))
60 _trial_variables[i]->MakeTRef(
61 _trial_variables[i]->ParFESpace(), X, _block_true_offsets_trial[i]);
63}
std::vector< mfem::ParGridFunction * > _trial_variables
auto index_range(const T &sizable)

Referenced by Moose::MFEM::TimeDependentEquationSystemProblemOperator::Init().

◆ SetGridFunctions()

void Moose::MFEM::ProblemOperatorBase::SetGridFunctions ( )
virtual

Reimplemented in Moose::MFEM::ComplexEquationSystemProblemOperator, Moose::MFEM::EquationSystemProblemOperator, Moose::MFEM::ProblemOperator, Moose::MFEM::TimeDependentEquationSystemProblemOperator, and Moose::MFEM::TimeDependentProblemOperator.

Definition at line 25 of file ProblemOperatorBase.C.

26{
29
30 // Set operator size and block structure for trial spaces
33 for (const auto ind : index_range(_trial_variables))
34 _block_true_offsets_trial[ind + 1] = _trial_variables.at(ind)->ParFESpace()->TrueVSize();
35 _block_true_offsets_trial.PartialSum();
36
37 // Set operator size and block structure for test spaces
38 _block_true_offsets_test.SetSize(_test_variables.size() + 1);
40 for (const auto ind : index_range(_test_variables))
41 _block_true_offsets_test[ind + 1] = _test_variables.at(ind)->ParFESpace()->TrueVSize();
42 _block_true_offsets_test.PartialSum();
43
46}
T * Get(const std::string &field_name) const
Returns a non-owning pointer to the field. This is guaranteed to return a non-null pointer.
std::vector< mfem::ParGridFunction * > _test_variables
std::vector< std::string > _trial_var_names
Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector dur...
std::vector< std::string > _test_var_names
Moose::MFEM::GridFunctions gridfunctions

Referenced by Moose::MFEM::ProblemOperator::SetGridFunctions(), and Moose::MFEM::TimeDependentProblemOperator::SetGridFunctions().

◆ SetTrialVariablesFromTrueVectors()

void Moose::MFEM::ProblemOperatorBase::SetTrialVariablesFromTrueVectors ( )
virtual

Definition at line 66 of file ProblemOperatorBase.C.

67{
68 mooseAssert(_trial_true_vector, "The true vector should already have been set");
69 for (const auto trial_var : _trial_variables)
70 {
71 // Sync the memory flags from the global true vector to the gridfunction aliases
72 trial_var->GetTrueVector().SyncMemory(*_trial_true_vector);
73 trial_var->SetFromTrueVector();
74 }
75}

Referenced by Moose::MFEM::TimeDependentEquationSystemProblemOperator::Solve().

◆ Solve()

virtual void Moose::MFEM::ProblemOperatorBase::Solve ( )
pure virtual

◆ SolveWithOperator() [1/2]

void Moose::MFEM::ProblemOperatorBase::SolveWithOperator ( mfem::Operator &  system_operator,
const mfem::Vector &  rhs,
mfem::Vector &  x 
)
inlineprotected

Solve the current system operator using system_operator.GetGradient(x) as the linear operator.

Definition at line 77 of file ProblemOperatorBase.h.

78 {
79 return SolveWithOperator(system_operator, system_operator.GetGradient(x), rhs, x);
80 }
void SolveWithOperator(mfem::Operator &system_operator, mfem::Operator &linear_operator, const mfem::Vector &rhs, mfem::Vector &x)
Solve the current system operator using the configured nonlinear and linear solvers.

◆ SolveWithOperator() [2/2]

void Moose::MFEM::ProblemOperatorBase::SolveWithOperator ( mfem::Operator &  system_operator,
mfem::Operator &  linear_operator,
const mfem::Vector &  rhs,
mfem::Vector &  x 
)
protected

Solve the current system operator using the configured nonlinear and linear solvers.

Definition at line 78 of file ProblemOperatorBase.C.

82{
83 // Nonlinear solver path for both linear and nonlinear problems. (as a linear problem may still
84 // intentionally be solved through the nonlinear solver machinery when one is provided)
86 {
87 auto & nonlinear_solver = *_problem_data.nonlinear_solver;
88 if (nonlinear_solver.RequiresExternalLinearSolver())
89 {
91 mooseError("The configured MFEM nonlinear solver requires an external linear solver, but "
92 "none was provided.");
93 auto & linear_solver = *_problem_data.jacobian_solver;
94 linear_solver.SetOperator(linear_operator);
95 nonlinear_solver.SetLinearSolver(linear_solver.GetSolver());
96 }
97
98 nonlinear_solver.SetOperator(system_operator);
99 nonlinear_solver.Mult(rhs, x);
100 }
101 // Linear solver path for linear problems.
102 else
103 {
105 mooseError("A linear MFEM solve requires a linear solver, but none was provided.");
106
107 auto & linear_solver = *_problem_data.jacobian_solver;
108 linear_solver.SetOperator(linear_operator);
109 linear_solver.Mult(rhs, x);
110 }
111}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
std::shared_ptr< Moose::MFEM::LinearSolverBase > jacobian_solver
std::shared_ptr< Moose::MFEM::NonlinearSolverBase > nonlinear_solver

Referenced by Moose::MFEM::TimeDependentEquationSystemProblemOperator::ImplicitSolve(), Moose::MFEM::ComplexEquationSystemProblemOperator::Solve(), Moose::MFEM::EquationSystemProblemOperator::Solve(), and SolveWithOperator().

Member Data Documentation

◆ _block_true_offsets_test

mfem::Array<int> Moose::MFEM::ProblemOperatorBase::_block_true_offsets_test

◆ _block_true_offsets_trial

mfem::Array<int> Moose::MFEM::ProblemOperatorBase::_block_true_offsets_trial

◆ _problem

MFEMProblem& Moose::MFEM::ProblemOperatorBase::_problem
protected

◆ _problem_data

MFEMProblemData& Moose::MFEM::ProblemOperatorBase::_problem_data
protected

◆ _test_var_names

std::vector<std::string> Moose::MFEM::ProblemOperatorBase::_test_var_names
protected

◆ _test_variables

std::vector<mfem::ParGridFunction *> Moose::MFEM::ProblemOperatorBase::_test_variables
protected

◆ _trial_true_vector

mfem::Vector* Moose::MFEM::ProblemOperatorBase::_trial_true_vector = nullptr
protected

◆ _trial_var_names

std::vector<std::string> Moose::MFEM::ProblemOperatorBase::_trial_var_names
protected

◆ _trial_variables

std::vector<mfem::ParGridFunction *> Moose::MFEM::ProblemOperatorBase::_trial_variables
protected

◆ _true_rhs

mfem::BlockVector Moose::MFEM::ProblemOperatorBase::_true_rhs

◆ _true_x

mfem::BlockVector Moose::MFEM::ProblemOperatorBase::_true_x

The documentation for this class was generated from the following files: