Skip to content

Commit

Permalink
Actually commit MFEMScalarIC
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayad committed Nov 27, 2024
1 parent 4a7bd76 commit 894287a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/ics/MFEMScalarIC.h
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;
};
32 changes: 32 additions & 0 deletions src/ics/MFEMScalarIC.C
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);
}

0 comments on commit 894287a

Please sign in to comment.