-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "MFEMGeneralUserObject.h" | ||
|
||
class MFEMScalarIC : public MFEMGeneralUserObject | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
MFEMScalarIC(const InputParameters & params); | ||
virtual void execute() override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "MFEMScalarIC.h" | ||
#include "MFEMProblem.h" | ||
#include <libmesh/libmesh_common.h> | ||
#include <mfem.hpp> | ||
|
||
registerMooseObject("PlatypusApp", MFEMScalarIC); | ||
|
||
InputParameters | ||
MFEMScalarIC::validParams() | ||
{ | ||
auto params = MFEMGeneralUserObject::validParams(); | ||
params.addRequiredParam<std::string>("variable", | ||
"The variable to apply the initial condition for"); | ||
params.addRequiredParam<std::string>("coefficient", "The scalar coefficient"); | ||
params.registerBase("InitialCondition"); | ||
// We cannot generally execute this at construction time since the coefficient may depend on, for | ||
// instance, a MOOSE function which is not itself setup until its initialSetup is called. | ||
// UserObject initial execution occurs after function initialSetup | ||
params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL}; | ||
params.suppressParameter<ExecFlagEnum>("execute_on"); | ||
return params; | ||
} | ||
|
||
MFEMScalarIC::MFEMScalarIC(const InputParameters & params) : MFEMGeneralUserObject(params) {} | ||
|
||
void | ||
MFEMScalarIC::execute() | ||
{ | ||
auto coeff = getMFEMProblem().getCoefficient(getParam<std::string>("coefficient")); | ||
auto grid_function = getMFEMProblem().getGridFunction(getParam<std::string>("variable")); | ||
grid_function->ProjectCoefficient(*coeff); | ||
} |