diff --git a/include/ics/MFEMScalarIC.h b/include/ics/MFEMScalarIC.h new file mode 100644 index 00000000..843d27ce --- /dev/null +++ b/include/ics/MFEMScalarIC.h @@ -0,0 +1,9 @@ +#include "MFEMGeneralUserObject.h" + +class MFEMScalarIC : public MFEMGeneralUserObject +{ +public: + static InputParameters validParams(); + MFEMScalarIC(const InputParameters & params); + virtual void execute() override; +}; diff --git a/src/ics/MFEMScalarIC.C b/src/ics/MFEMScalarIC.C new file mode 100644 index 00000000..271013fc --- /dev/null +++ b/src/ics/MFEMScalarIC.C @@ -0,0 +1,32 @@ +#include "MFEMScalarIC.h" +#include "MFEMProblem.h" +#include +#include + +registerMooseObject("PlatypusApp", MFEMScalarIC); + +InputParameters +MFEMScalarIC::validParams() +{ + auto params = MFEMGeneralUserObject::validParams(); + params.addRequiredParam("variable", + "The variable to apply the initial condition for"); + params.addRequiredParam("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("execute_on") = {EXEC_INITIAL}; + params.suppressParameter("execute_on"); + return params; +} + +MFEMScalarIC::MFEMScalarIC(const InputParameters & params) : MFEMGeneralUserObject(params) {} + +void +MFEMScalarIC::execute() +{ + auto coeff = getMFEMProblem().getCoefficient(getParam("coefficient")); + auto grid_function = getMFEMProblem().getGridFunction(getParam("variable")); + grid_function->ProjectCoefficient(*coeff); +}