Skip to content

Commit

Permalink
Add helper methods to MFEMGeneralUserObject for fetching properties
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderianblair committed Dec 18, 2024
1 parent db110ed commit 09b9c4c
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 21 deletions.
6 changes: 6 additions & 0 deletions include/userobjects/MFEMGeneralUserObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// MOOSE includes
#include "GeneralUserObject.h"
#include "mfem.hpp"

// Forwards declaration.
class MFEMProblem;
Expand All @@ -20,6 +21,11 @@ class MFEMGeneralUserObject : public GeneralUserObject
// FIXME: Should this be marked as const if it is returning a non-const reference?
MFEMProblem & getMFEMProblem() const { return _mfem_problem; }

/// Returns references to coefficients stored in the MFEMProblem PropertiesManager.
mfem::Coefficient & getScalarProperty(const std::string & name);
mfem::VectorCoefficient & getVectorProperty(const std::string & name);
mfem::MatrixCoefficient & getMatrixProperty(const std::string & name);

void execute() override {}

void initialize() override {}
Expand Down
5 changes: 2 additions & 3 deletions src/bcs/MFEMConvectiveHeatFluxBC.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ MFEMConvectiveHeatFluxBC::validParams()
// TODO: Currently assumes the vector function coefficient is 3D
MFEMConvectiveHeatFluxBC::MFEMConvectiveHeatFluxBC(const InputParameters & parameters)
: MFEMIntegratedBC(parameters),
_heat_transfer_coef(getMFEMProblem().getProperties().getScalarProperty(
_heat_transfer_coef(getScalarProperty(
getParam<platypus::MFEMScalarCoefficientName>("heat_transfer_coefficient"))),
_T_inf_coef(getMFEMProblem().getProperties().getScalarProperty(
getParam<platypus::MFEMScalarCoefficientName>("T_infinity"))),
_T_inf_coef(getScalarProperty(getParam<platypus::MFEMScalarCoefficientName>("T_infinity"))),
_external_heat_flux_coef(getMFEMProblem().makeScalarCoefficient<mfem::ProductCoefficient>(
_heat_transfer_coef, _T_inf_coef))
{
Expand Down
2 changes: 1 addition & 1 deletion src/bcs/MFEMScalarFunctorDirichletBC.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MFEMScalarFunctorDirichletBC::validParams()
MFEMScalarFunctorDirichletBC::MFEMScalarFunctorDirichletBC(const InputParameters & parameters)
: MFEMEssentialBC(parameters),
_coef_name(getParam<platypus::MFEMScalarCoefficientName>("coefficient")),
_coef(getMFEMProblem().getProperties().getScalarProperty(_coef_name))
_coef(getScalarProperty(_coef_name))
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/bcs/MFEMVectorFunctorBoundaryIntegratedBC.C
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ MFEMVectorFunctorBoundaryIntegratedBC::validParams()
MFEMVectorFunctorBoundaryIntegratedBC::MFEMVectorFunctorBoundaryIntegratedBC(
const InputParameters & parameters)
: MFEMIntegratedBC(parameters),
_vec_coef(getMFEMProblem().getProperties().getVectorProperty(
getParam<platypus::MFEMVectorCoefficientName>("vector_coefficient")))
_vec_coef(
getVectorProperty(getParam<platypus::MFEMVectorCoefficientName>("vector_coefficient")))
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/bcs/MFEMVectorFunctorDirichletBCBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ MFEMVectorFunctorDirichletBCBase::validParams()
MFEMVectorFunctorDirichletBCBase::MFEMVectorFunctorDirichletBCBase(
const InputParameters & parameters)
: MFEMEssentialBC(parameters),
_vec_coef(getMFEMProblem().getProperties().getVectorProperty(
getParam<platypus::MFEMVectorCoefficientName>("vector_coefficient")))
_vec_coef(
getVectorProperty(getParam<platypus::MFEMVectorCoefficientName>("vector_coefficient")))
{
}
4 changes: 2 additions & 2 deletions src/bcs/MFEMVectorFunctorNormalIntegratedBC.C
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ MFEMVectorFunctorNormalIntegratedBC::validParams()
MFEMVectorFunctorNormalIntegratedBC::MFEMVectorFunctorNormalIntegratedBC(
const InputParameters & parameters)
: MFEMIntegratedBC(parameters),
_vec_coef(getMFEMProblem().getProperties().getVectorProperty(
getParam<platypus::MFEMVectorCoefficientName>("vector_coefficient")))
_vec_coef(
getVectorProperty(getParam<platypus::MFEMVectorCoefficientName>("vector_coefficient")))
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MFEMCurlCurlKernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MFEMCurlCurlKernel::MFEMCurlCurlKernel(const InputParameters & parameters)
_coef_name(getParam<platypus::MFEMScalarCoefficientName>("coefficient")),
// FIXME: The MFEM bilinear form can also handle vector and matrix
// coefficients, so ideally we'd handle all three too.
_coef(getMFEMProblem().getProperties().getScalarProperty(_coef_name))
_coef(getScalarProperty(_coef_name))
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MFEMDiffusionKernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ MFEMDiffusionKernel::MFEMDiffusionKernel(const InputParameters & parameters)
_coef_name(getParam<platypus::MFEMScalarCoefficientName>("coefficient")),
// FIXME: The MFEM bilinear form can also handle vector and matrix
// coefficients, so ideally we'd handle all three too.
_coef(getMFEMProblem().getProperties().getScalarProperty(_coef_name))
_coef(getScalarProperty(_coef_name))
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MFEMDivDivKernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ MFEMDivDivKernel::MFEMDivDivKernel(const InputParameters & parameters)
_coef_name(getParam<platypus::MFEMScalarCoefficientName>("coefficient")),
// FIXME: The MFEM bilinear form can also handle vector and matrix
// coefficients, so ideally we'd handle all three too.
_coef(getMFEMProblem().getProperties().getScalarProperty(_coef_name))
_coef(getScalarProperty(_coef_name))
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/kernels/MFEMLinearElasticityKernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ MFEMLinearElasticityKernel::MFEMLinearElasticityKernel(const InputParameters & p
: MFEMKernel(parameters),
_lambda_name(getParam<platypus::MFEMScalarCoefficientName>("lambda")),
_mu_name(getParam<platypus::MFEMScalarCoefficientName>("mu")),
_lambda(getMFEMProblem().getProperties().getScalarProperty(_lambda_name)),
_mu(getMFEMProblem().getProperties().getScalarProperty(_mu_name))
_lambda(getScalarProperty(_lambda_name)),
_mu(getScalarProperty(_mu_name))
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MFEMMassKernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ MFEMMassKernel::validParams()
MFEMMassKernel::MFEMMassKernel(const InputParameters & parameters)
: MFEMKernel(parameters),
_coef_name(getParam<platypus::MFEMScalarCoefficientName>("coefficient")),
_coef(getMFEMProblem().getProperties().getScalarProperty(_coef_name))
_coef(getScalarProperty(_coef_name))
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MFEMMixedVectorGradientKernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MFEMMixedVectorGradientKernel::MFEMMixedVectorGradientKernel(const InputParamete
_coef_name(getParam<platypus::MFEMScalarCoefficientName>("coefficient")),
// FIXME: The MFEM bilinear form can also handle vector and matrix
// coefficients, so ideally we'd handle all three too.
_coef(getMFEMProblem().getProperties().getScalarProperty(_coef_name))
_coef(getScalarProperty(_coef_name))
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/kernels/MFEMVectorFEDomainLFKernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ MFEMVectorFEDomainLFKernel::validParams()

MFEMVectorFEDomainLFKernel::MFEMVectorFEDomainLFKernel(const InputParameters & parameters)
: MFEMKernel(parameters),
_vec_coef(getMFEMProblem().getProperties().getVectorProperty(
getParam<platypus::MFEMVectorCoefficientName>("vector_coefficient")))
_vec_coef(
getVectorProperty(getParam<platypus::MFEMVectorCoefficientName>("vector_coefficient")))
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MFEMVectorFEMassKernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ MFEMVectorFEMassKernel::MFEMVectorFEMassKernel(const InputParameters & parameter
_coef_name(getParam<platypus::MFEMScalarCoefficientName>("coefficient")),
// FIXME: The MFEM bilinear form can also handle vector and matrix
// coefficients, so ideally we'd handle all three too.
_coef(getMFEMProblem().getProperties().getScalarProperty(_coef_name))
_coef(getScalarProperty(_coef_name))
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/kernels/MFEMVectorFEWeakDivergenceKernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ MFEMVectorFEWeakDivergenceKernel::MFEMVectorFEWeakDivergenceKernel(
const InputParameters & parameters)
: MFEMKernel(parameters),
_coef_name(getParam<platypus::MFEMScalarCoefficientName>("coefficient")),
_coef(getMFEMProblem().getProperties().getScalarProperty(_coef_name))
_coef(getScalarProperty(_coef_name))
{
}

Expand Down
18 changes: 18 additions & 0 deletions src/userobjects/MFEMGeneralUserObject.C
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,21 @@ MFEMGeneralUserObject::MFEMGeneralUserObject(const InputParameters & parameters)
: GeneralUserObject(parameters), _mfem_problem(static_cast<MFEMProblem &>(_fe_problem))
{
}

mfem::Coefficient &
MFEMGeneralUserObject::getScalarProperty(const std::string & name)
{
return getMFEMProblem().getProperties().getScalarProperty(name);
}

mfem::VectorCoefficient &
MFEMGeneralUserObject::getVectorProperty(const std::string & name)
{
return getMFEMProblem().getProperties().getVectorProperty(name);
}

mfem::MatrixCoefficient &
MFEMGeneralUserObject::getMatrixProperty(const std::string & name)

Check warning on line 32 in src/userobjects/MFEMGeneralUserObject.C

View check run for this annotation

Codecov / codecov/patch

src/userobjects/MFEMGeneralUserObject.C#L32

Added line #L32 was not covered by tests
{
return getMFEMProblem().getProperties().getMatrixProperty(name);

Check warning on line 34 in src/userobjects/MFEMGeneralUserObject.C

View check run for this annotation

Codecov / codecov/patch

src/userobjects/MFEMGeneralUserObject.C#L34

Added line #L34 was not covered by tests
}

0 comments on commit 09b9c4c

Please sign in to comment.