https://mooseframework.inl.gov
MFEMProblem.h
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 MFEM_ENABLED
11 
12 #pragma once
13 #include "ExternalProblem.h"
14 #include "MFEMProblemData.h"
15 #include "MFEMMesh.h"
16 #include "MFEMExecutioner.h"
17 
19 {
20 public:
22 
23  MFEMProblem(const InputParameters & params);
24  virtual ~MFEMProblem() {}
25 
26  virtual void initialSetup() override;
27  virtual void externalSolve() override {}
28  virtual bool nlConverged(const unsigned int) override { return true; }
29  virtual void syncSolutions(Direction) override {}
30 
35  virtual MFEMMesh & mesh() override;
36  virtual const MFEMMesh & mesh() const override;
38 
43  virtual std::vector<VariableName> getAuxVariableNames();
44 
45  void addBoundaryCondition(const std::string & bc_name,
46  const std::string & name,
47  InputParameters & parameters) override;
48 
49  void addMaterial(const std::string & material_name,
50  const std::string & name,
51  InputParameters & parameters) override;
52 
53  void addFunctorMaterial(const std::string & material_name,
54  const std::string & name,
55  InputParameters & parameters) override;
56 
60  void addFESpace(const std::string & user_object_name,
61  const std::string & name,
66  void setDevice();
67 
71  void setMesh();
72 
76  void initProblemOperator();
77 
78  void addSubMesh(const std::string & user_object_name,
79  const std::string & name,
81 
85  void addTransfer(const std::string & transfer_name,
86  const std::string & name,
87  InputParameters & parameters) override;
92  void addVariable(const std::string & var_type,
93  const std::string & var_name,
94  InputParameters & parameters) override;
95 
99  void addGridFunction(const std::string & var_type,
100  const std::string & var_name,
102 
108  void addAuxVariable(const std::string & var_type,
109  const std::string & var_name,
110  InputParameters & parameters) override;
111 
117  void addKernel(const std::string & kernel_name,
118  const std::string & name,
119  InputParameters & parameters) override;
120 
126  void addAuxKernel(const std::string & kernel_name,
127  const std::string & name,
128  InputParameters & parameters) override;
129 
135  void addFunction(const std::string & type,
136  const std::string & name,
137  InputParameters & parameters) override;
138 
139  void addInitialCondition(const std::string & ic_name,
140  const std::string & name,
141  InputParameters & parameters) override;
142 
148  void addPostprocessor(const std::string & type,
149  const std::string & name,
150  InputParameters & parameters) override;
151 
155  void addMFEMPreconditioner(const std::string & user_object_name,
156  const std::string & name,
158 
162  void addMFEMSolver(const std::string & user_object_name,
163  const std::string & name,
165 
170  void addMFEMNonlinearSolver();
171 
178 
185 
191 
195  void displaceMesh();
196 
200  std::optional<std::reference_wrapper<mfem::ParGridFunction const>>
202 
203  Moose::FEBackend feBackend() const override { return Moose::FEBackend::MFEM; }
204 
205  std::string solverTypeString(unsigned int solver_sys_num) override;
206 
210  std::shared_ptr<mfem::ParGridFunction> getGridFunction(const std::string & name);
211 
212 protected:
214 };
215 
216 #endif
void addGridFunction(const std::string &var_type, const std::string &var_name, InputParameters &parameters)
Adds one MFEM GridFunction to be used in the MFEM solve.
Definition: MFEMProblem.C:189
void addMFEMPreconditioner(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
Method called in AddMFEMPreconditionerAction which will create the solver.
Definition: MFEMProblem.C:72
virtual void syncSolutions(Direction) override
Method to transfer data to/from the external application to the associated transfer mesh...
Definition: MFEMProblem.h:29
Base problem data struct.
MFEMProblemData & getProblemData()
Method to get the current MFEMProblemData object storing the current data specifying the FE problem...
Definition: MFEMProblem.h:190
std::shared_ptr< mfem::ParGridFunction > getGridFunction(const std::string &name)
Definition: MFEMProblem.C:517
void addPostprocessor(const std::string &type, const std::string &name, InputParameters &parameters) override
Override of ExternalProblem::addPostprocessor.
Definition: MFEMProblem.C:379
void addFunction(const std::string &type, const std::string &name, InputParameters &parameters) override
Override of ExternalProblem::addFunction.
Definition: MFEMProblem.C:340
InputParameters addMFEMFESpaceFromMOOSEVariable(InputParameters &moosevar_params)
Method used to get an mfem FEC depending on the variable family specified in the input file...
Definition: MFEMProblem.C:391
static InputParameters validParams()
Definition: MFEMProblem.C:25
virtual MFEMMesh & mesh() override
Overwritten mesh() method from base MooseMesh to retrieve the correct mesh type, in this case MFEMMes...
Definition: MFEMProblem.C:480
void addVariable(const std::string &var_type, const std::string &var_name, InputParameters &parameters) override
Override of ExternalProblem::addVariable.
Definition: MFEMProblem.C:174
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::string solverTypeString(unsigned int solver_sys_num) override
Return solver type as a human readable string.
Definition: MFEMProblem.C:532
Front-end class for creating and storing MFEM coefficients.
void initProblemOperator()
Initialise the required ProblemOperator used in the Executioner to solve the problem.
Definition: MFEMProblem.C:57
void displaceMesh()
Displace the mesh, if mesh displacement is enabled.
Definition: MFEMProblem.C:448
virtual void addAuxVariable(const std::string &var_type, const std::string &var_name, InputParameters &params)
Canonical method for adding an auxiliary variable.
MFEMProblemData _problem_data
Definition: MFEMProblem.h:213
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
void addSubMesh(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
Definition: MFEMProblem.C:494
void addMFEMNonlinearSolver()
Add the nonlinear solver to the system.
Definition: MFEMProblem.C:91
Moose::MFEM::CoefficientManager coefficients
Moose::MFEM::CoefficientManager & getCoefficients()
Method to get the PropertyManager object for storing material properties and converting them to MFEM ...
Definition: MFEMProblem.h:184
void addMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters) override
Definition: MFEMProblem.C:145
virtual void initialSetup() override
Definition: MFEMProblem.C:40
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:51
void setMesh()
Set the mesh used by MFEM.
Definition: MFEMProblem.C:47
void addMFEMSolver(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
Method called in AddMFEMSolverAction which will create the solver.
Definition: MFEMProblem.C:80
Moose::FEBackend feBackend() const override
Definition: MFEMProblem.h:203
void addAuxKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters) override
Override of ExternalProblem::addAuxKernel.
Definition: MFEMProblem.C:229
virtual ~MFEMProblem()
Definition: MFEMProblem.h:24
void addFESpace(const std::string &user_object_name, const std::string &name, InputParameters &parameters)
Add an MFEM FESpace to the problem.
Definition: MFEMProblem.C:161
MFEMProblem(const InputParameters &params)
Definition: MFEMProblem.C:33
void addFunctorMaterial(const std::string &material_name, const std::string &name, InputParameters &parameters) override
Definition: MFEMProblem.C:152
MFEMMesh.
Definition: MFEMMesh.h:33
virtual std::vector< VariableName > getAuxVariableNames()
Returns all the variable names from the auxiliary system base.
Definition: MFEMProblem.C:474
void setDevice()
Set the device to use to solve the FE problem.
void addBoundaryCondition(const std::string &bc_name, const std::string &name, InputParameters &parameters) override
Definition: MFEMProblem.C:104
virtual MooseMesh & mesh() override
const InputParameters & parameters() const
Get the parameters of the object.
virtual void externalSolve() override
New interface for solving an External problem.
Definition: MFEMProblem.h:27
void addKernel(const std::string &kernel_name, const std::string &name, InputParameters &parameters) override
Override of ExternalProblem::addKernel.
Definition: MFEMProblem.C:237
std::optional< std::reference_wrapper< mfem::ParGridFunction const > > getMeshDisplacementGridFunction()
Returns optional reference to the displacement GridFunction to apply to nodes.
Definition: MFEMProblem.C:459
void addAuxVariable(const std::string &var_type, const std::string &var_name, InputParameters &parameters) override
Override of ExternalProblem::addAuxVariable.
Definition: MFEMProblem.C:220
virtual bool nlConverged(const unsigned int) override
Definition: MFEMProblem.h:28
void addTransfer(const std::string &transfer_name, const std::string &name, InputParameters &parameters) override
Add transfers between MultiApps and/or MFEM SubMeshes.
Definition: MFEMProblem.C:506
void addInitialCondition(const std::string &ic_name, const std::string &name, InputParameters &parameters) override
Definition: MFEMProblem.C:523