https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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#include "MFEMProblem.h"
14
15namespace Moose::MFEM
16{
18 MFEMProblem & problem, const std::string & weak_form_name)
21 problem.getEquationSystem(weak_form_name)))
22{
24 mooseError("The weak form supplying this operator does not provide a "
25 "TimeDependentEquationSystem, which is required by "
26 "TimeDependentEquationSystemProblemOperator.");
27}
28
29void
36
37void
39{
41 // Set timestepper
42 auto & ode_solver = _problem_data.ode_solver;
43 ode_solver = std::make_unique<mfem::BackwardEulerSolver>();
44 ode_solver->Init(*(this));
45 SetTime(_problem.time());
46 SetImplicitVariableType(STATE);
47}
48
49void
51{
52 auto & dt = _problem.dt();
53 auto & gfs = _problem_data.gridfunctions;
55
56 // Initialise time derivative
57 for (const auto & trial_var_name : _trial_var_names)
58 gfs.GetRef(tdm.getTimeDerivativeName(trial_var_name)) = gfs.GetRef(trial_var_name);
59
60 // Advance time step of the MFEM problem. Time is also updated here, and
61 // _problem_operator->SetTime is called inside the ode_solver->Step method to
62 // update the time used by time dependent (function) coefficients.
64 // Synchonise time dependent GridFunctions with updated DoF data.
66
67 // Set time derivatives
68 for (const auto & trial_var_name : _trial_var_names)
69 (gfs.GetRef(tdm.getTimeDerivativeName(trial_var_name)) -= gfs.GetRef(trial_var_name)) /= -dt;
70}
71
72void
74 const mfem::Vector &,
75 mfem::Vector & X_new)
76{
78
79 {
80 TIME_SECTION(
81 "TimeDependentEquationSystemProblemOperator::FormSystem", 2, "Assembling MFEM System");
83 }
84
85 auto * const es = GetEquationSystem();
86
87 {
88 TIME_SECTION(
89 "TimeDependentEquationSystemProblemOperator::SolveSystem", 2, "Solving MFEM System");
91 }
92
93 X_new.MakeRef(_true_x, 0);
94}
95
96void
102
103} // namespace Moose::MFEM
104
105#endif
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
virtual Real & dt() const
virtual Real & time() const
void setTime(const mfem::real_t time)
const std::vector< std::string > & GetTrialVarNames() const
const std::vector< std::string > & GetTestVarNames() const
void FormSystem(mfem::BlockVector &trueX, mfem::BlockVector &trueRHS)
Build all weak-form components via BuildEquationSystem(), form the constrained linear part of the sys...
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.
MFEMProblem & _problem
Reference to the current problem.
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
virtual Moose::MFEM::TimeDependentEquationSystem * GetEquationSystem() const override
Returns a pointer to the operator's equation system.
virtual void ImplicitSolve(const mfem::real_t, const mfem::Vector &, mfem::Vector &) override
TimeDependentEquationSystemProblemOperator(MFEMProblem &problem, const std::string &weak_form_name="")
std::shared_ptr< Moose::MFEM::TimeDependentEquationSystem > _equation_system
void FormEquationSystemOperator(mfem::real_t dt)
Form equation-system state for the current implicit time step.
Class to store weak form components for time dependent PDEs.
Problem operator for time-dependent problems with no equation system.
Utilities for converting between vector(s) of libMesh Points and MFEM Vector(s).
Moose::MFEM::TimeDerivativeMap time_derivative_map
Moose::MFEM::CoefficientManager coefficients
std::unique_ptr< mfem::ODESolver > ode_solver
Moose::MFEM::GridFunctions gridfunctions