https://mooseframework.inl.gov
TimeDependentEquationSystemProblemOperator.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #ifdef MOOSE_MFEM_ENABLED
11 
13 
14 namespace Moose::MFEM
15 {
16 void
18 {
22 }
23 
24 void
26 {
28  // Set timestepper
29  auto & ode_solver = _problem_data.ode_solver;
30  ode_solver = std::make_unique<mfem::BackwardEulerSolver>();
31  ode_solver->Init(*(this));
32  SetTime(_problem.time());
33  SetImplicitVariableType(STATE);
34 }
35 
36 void
38 {
39  auto & dt = _problem.dt();
40  auto & gfs = _problem_data.gridfunctions;
42 
43  // Initialise time derivative
44  for (const auto & trial_var_name : _trial_var_names)
45  gfs.GetRef(tdm.getTimeDerivativeName(trial_var_name)) = gfs.GetRef(trial_var_name);
46 
47  // Advance time step of the MFEM problem. Time is also updated here, and
48  // _problem_operator->SetTime is called inside the ode_solver->Step method to
49  // update the time used by time dependent (function) coefficients.
51  // Synchonise time dependent GridFunctions with updated DoF data.
53 
54  // Set time derivatives
55  for (const auto & trial_var_name : _trial_var_names)
56  (gfs.GetRef(tdm.getTimeDerivativeName(trial_var_name)) -= gfs.GetRef(trial_var_name)) /= -dt;
57 }
58 
59 void
61  const mfem::Vector &,
62  mfem::Vector & X_new)
63 {
66 
67  if (_problem_data.jacobian_solver->isLOR() && GetEquationSystem()->GetTestVarNames().size() > 1)
68  mooseError("LOR solve is only supported for single-variable systems");
69  _problem_data.jacobian_solver->updateSolver(
70  *GetEquationSystem()->_blfs.Get(GetEquationSystem()->GetTestVarNames().at(0)),
72 
73  _problem_data.nonlinear_solver->SetPreconditioner(_problem_data.jacobian_solver->getSolver());
76 
77  X_new.MakeRef(_true_x, 0);
78 }
79 
80 void
82 {
86 }
87 
88 } // namespace Moose::MFEM
89 
90 #endif
std::vector< std::string > _test_var_names
virtual Real & time() const
std::vector< std::string > _trial_var_names
Vector of names of state gridfunctions used in formulation, ordered by appearance in block vector dur...
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< mfem::IterativeSolver > nonlinear_solver
std::unique_ptr< mfem::ODESolver > ode_solver
void BuildEquationSystemOperator(mfem::real_t dt)
Add kernels/bcs and assemble the linear part of the equation system.
std::vector< mfem::Array< int > > _ess_tdof_lists
Moose::MFEM::CoefficientManager coefficients
void FormSystem(mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Assemble the linear part of the operator, assemble the right-hand side, apply essential and eliminate...
void setTime(const mfem::real_t time)
virtual void BuildEquationSystem()
Build all forms comprising this EquationSystem.
virtual Moose::MFEM::TimeDependentEquationSystem * GetEquationSystem() const override
Returns a pointer to the operator&#39;s equation system.
MFEMProblem & _problem
Reference to the current problem.
virtual void Init(mfem::BlockVector &X)
const std::vector< std::string > & GetTrialVarNames() const
const std::vector< std::string > & GetTestVarNames() const
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).
virtual void ImplicitSolve(const mfem::real_t, const mfem::Vector &, mfem::Vector &) override
Moose::MFEM::GridFunctions gridfunctions
virtual Real & dt() const
Moose::MFEM::TimeDerivativeMap time_derivative_map
std::shared_ptr< MFEMSolverBase > jacobian_solver