https://mooseframework.inl.gov
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Moose::MFEM::TimeDependentProblemOperator Class Reference

Problem operator for time-dependent problems with no equation system. More...

#include <TimeDependentProblemOperator.h>

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

Public Member Functions

 TimeDependentProblemOperator (MFEMProblem &problem)
 
virtual void SetGridFunctions () override
 
virtual void Solve () override
 
virtual void ImplicitSolve (const mfem::real_t, const mfem::Vector &, mfem::Vector &) override
 
virtual void SetTrialVariablesFromTrueVectors ()
 
virtual void Init (mfem::BlockVector &X)
 

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. More...
 
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. More...
 

Protected Attributes

MFEMProblem_problem
 Reference to the current problem. More...
 
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. More...
 
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

Problem operator for time-dependent problems with no equation system.

The user will need to subclass this since the solve is not implemented.

Definition at line 21 of file TimeDependentProblemOperator.h.

Constructor & Destructor Documentation

◆ TimeDependentProblemOperator()

Moose::MFEM::TimeDependentProblemOperator::TimeDependentProblemOperator ( MFEMProblem problem)
inline

Definition at line 24 of file TimeDependentProblemOperator.h.

24 : ProblemOperatorBase(problem) {}
ProblemOperatorBase(MFEMProblem &problem)

Member Function Documentation

◆ ImplicitSolve()

virtual void Moose::MFEM::TimeDependentProblemOperator::ImplicitSolve ( const mfem::real_t  ,
const mfem::Vector &  ,
mfem::Vector &   
)
inlineoverridevirtual

◆ Init()

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

Reimplemented in Moose::MFEM::TimeDependentEquationSystemProblemOperator.

Definition at line 49 of file ProblemOperatorBase.C.

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

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 }
mfem::Array< int > _block_true_offsets_trial
std::vector< mfem::ParGridFunction * > _trial_variables
auto index_range(const T &sizable)

◆ SetGridFunctions()

void Moose::MFEM::TimeDependentProblemOperator::SetGridFunctions ( )
overridevirtual

◆ SetTrialVariablesFromTrueVectors()

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

Definition at line 66 of file ProblemOperatorBase.C.

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

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 }
std::vector< mfem::ParGridFunction * > _trial_variables

◆ Solve()

virtual void Moose::MFEM::TimeDependentProblemOperator::Solve ( )
inlineoverridevirtual

◆ SolveWithOperator() [1/2]

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

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

Definition at line 78 of file ProblemOperatorBase.C.

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

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

◆ SolveWithOperator() [2/2]

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

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.

Member Data Documentation

◆ _block_true_offsets_test

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

◆ _block_true_offsets_trial

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

◆ _problem

MFEMProblem& Moose::MFEM::ProblemOperatorBase::_problem
protectedinherited

◆ _problem_data

MFEMProblemData& Moose::MFEM::ProblemOperatorBase::_problem_data
protectedinherited

◆ _test_var_names

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

◆ _test_variables

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

◆ _trial_true_vector

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

◆ _trial_var_names

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

◆ _trial_variables

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

◆ _true_rhs

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

◆ _true_x

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

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