https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MFEMWeakFormBase.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
12#include "MFEMWeakFormBase.h"
13#include "MFEMProblem.h"
14
17{
19 params.addClassDescription("Base class for MFEM weak forms, which build the EquationSystem "
20 "solved by an MFEM problem operator.");
21 params.registerBase("MFEMWeakFormBase");
22 params.registerSystemAttributeName("MFEMWeakFormBase");
23 params.addParam<std::vector<MFEMBoundaryConditionName>>(
24 "bcs", {}, "List of boundary conditions to add to the weak form");
25 params.addParam<std::vector<MFEMKernelName>>(
26 "kernels", {}, "List of kernels to add to the weak form");
27 return params;
28}
29
31 : MFEMObject(parameters),
32 _bc_names(getParam<std::vector<MFEMBoundaryConditionName>>("bcs")),
33 _kernel_names(getParam<std::vector<MFEMKernelName>>("kernels"))
34{
35}
36
37std::shared_ptr<Moose::MFEM::EquationSystem>
44
45void
47{
48 auto & problem_data = getMFEMProblem().getProblemData();
49 if (_bc_names.empty()) // default to all BCs added by user
50 for (const auto & [bc_name, bc] : problem_data.bcs)
51 addBoundaryCondition(bc_name, bc);
52 else
53 for (const auto & bc_name : _bc_names)
54 {
55 if (!problem_data.bcs.Has(bc_name))
57 "bcs", "No boundary condition named '", bc_name, "' has been added to the problem.");
58 addBoundaryCondition(bc_name, problem_data.bcs.GetShared(bc_name));
59 }
60
61 if (_kernel_names.empty()) // default to all kernels added by user
62 for (const auto & [kernel_name, kernel] : problem_data.kernels)
63 addKernel(kernel_name, kernel);
64 else
65 for (const auto & kernel_name : _kernel_names)
66 {
67 if (!problem_data.kernels.Has(kernel_name))
68 paramError("kernels", "No kernel named '", kernel_name, "' has been added to the problem.");
69 addKernel(kernel_name, problem_data.kernels.GetShared(kernel_name));
70 }
71
72 if (problem_data.nonlinear_solver)
73 _equation_system->SetGradientRequired(problem_data.nonlinear_solver->RequiresGradient());
74
75 _equation_system->SetCoefficientManager(problem_data.coefficients);
76
77 // Set up initial conditions
78 _equation_system->Init(problem_data.gridfunctions,
79 problem_data.cmplx_gridfunctions,
80 getMFEMProblem().assemblyLevel());
81}
82
83#endif
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void registerSystemAttributeName(const std::string &value)
This method is used to define the MOOSE system name that is used by the TheWarehouse object for stori...
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object.
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
Thin base for MFEM objects backed directly by MooseObject instead of UserObject.
Definition MFEMObject.h:30
static InputParameters validParams()
Declare the common parameters required by MFEM MooseObject-backed classes.
Definition MFEMObject.C:17
MFEMProblem & getMFEMProblem()
Return the owning MFEM problem.
Definition MFEMObject.h:45
MFEMProblemData & getProblemData()
Method to get the current MFEMProblemData object storing the current data specifying the FE problem.
MFEMWeakFormBase(const InputParameters &parameters)
std::vector< MFEMKernelName > _kernel_names
virtual std::shared_ptr< Moose::MFEM::EquationSystem > makeEquationSystem()=0
Constructs the empty EquationSystem of the type this weak form builds.
std::shared_ptr< Moose::MFEM::EquationSystem > _equation_system
Stores the constructed EquationSystem.
virtual void addBoundaryCondition(const std::string &name, std::shared_ptr< MFEMBoundaryCondition > bc)=0
void initEquationSystem()
Initialise the equation system. TODO: move all setup into EquationSystem constructors.
virtual void addKernel(const std::string &name, std::shared_ptr< MFEMKernel > kernel)=0
static InputParameters validParams()
std::shared_ptr< Moose::MFEM::EquationSystem > createEquationSystem()
Constructs the EquationSystem, adds the requested kernels and boundary conditions to it,...
std::vector< MFEMBoundaryConditionName > _bc_names
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition MooseBase.h:457