diff --git a/doc/content/source/actions/AddCoefficientAction.md b/doc/content/source/actions/AddCoefficientAction.md deleted file mode 100644 index c2a9fa20..00000000 --- a/doc/content/source/actions/AddCoefficientAction.md +++ /dev/null @@ -1,16 +0,0 @@ -# AddCoefficientAction - -## Summary - -!syntax description /Coefficients/AddCoefficientAction - -## Overview - -Action called to add an MFEM coefficient to the problem, parsing content inside a `Coefficients` -block in the user input. Only has an effect if the `Problem` type is set to [`MFEMProblem`](source/problem/MFEMProblem.md). - -## Example Input File Syntax - -!listing test/tests/kernels/heatconduction.i block=Problem Functions Coefficients - -!syntax parameters /Coefficients/AddCoefficientAction diff --git a/doc/content/source/actions/AddVectorCoefficientAction.md b/doc/content/source/actions/AddVectorCoefficientAction.md deleted file mode 100644 index fef1bc87..00000000 --- a/doc/content/source/actions/AddVectorCoefficientAction.md +++ /dev/null @@ -1,17 +0,0 @@ -# AddVectorCoefficientAction - -## Summary - -!syntax description /VectorCoefficients/AddVectorCoefficientAction - -## Overview - -Action called to add an MFEM vector coefficient to the problem, parsing content inside a `VectorCoefficients` -block in the user input. Only has an effect if the `Problem` type is set to -[`MFEMProblem`](source/problem/MFEMProblem.md). - -## Example Input File Syntax - -!listing test/tests/kernels/curlcurl.i block=Problem Functions Coefficients - -!syntax parameters /VectorCoefficients/AddVectorCoefficientAction diff --git a/doc/content/source/bcs/MFEMScalarDirichletBC.md b/doc/content/source/bcs/MFEMScalarDirichletBC.md index 8d34e109..81b8bc63 100644 --- a/doc/content/source/bcs/MFEMScalarDirichletBC.md +++ b/doc/content/source/bcs/MFEMScalarDirichletBC.md @@ -7,7 +7,7 @@ ## Overview Boundary condition for enforcing an essential (Dirichlet) condition on a scalar variable on the -boundary, fixing its values to the input scalar coefficient on the boundary. +boundary, fixing its values to the input on the boundary. ## Example Input File Syntax diff --git a/doc/content/source/bcs/MFEMScalarFunctionDirichletBC.md b/doc/content/source/bcs/MFEMScalarFunctionDirichletBC.md new file mode 100644 index 00000000..eef43fb4 --- /dev/null +++ b/doc/content/source/bcs/MFEMScalarFunctionDirichletBC.md @@ -0,0 +1,19 @@ +# MFEMScalarFunctionDirichletBC + +## Summary + +!syntax description /BCs/MFEMScalarFunctionDirichletBC + +## Overview + +Boundary condition for enforcing an essential (Dirichlet) condition on +a scalar variable on the boundary, fixing its values to the input +scalar function on the boundary. + +## Example Input File Syntax + +!syntax parameters /BCs/MFEMScalarFunctionDirichletBC + +!syntax inputs /BCs/MFEMScalarFunctionDirichletBC + +!syntax children /BCs/MFEMScalarFunctionDirichletBC diff --git a/doc/content/source/bcs/MFEMVectorBoundaryIntegratedBC.md b/doc/content/source/bcs/MFEMVectorBoundaryIntegratedBC.md index 22e3aca1..6f914a9b 100644 --- a/doc/content/source/bcs/MFEMVectorBoundaryIntegratedBC.md +++ b/doc/content/source/bcs/MFEMVectorBoundaryIntegratedBC.md @@ -11,7 +11,7 @@ Adds the boundary integrator for integrating the linear form !equation (\vec f, \vec v)_{\partial\Omega} \,\,\, \forall \vec v \in V -where $v \in \vec H^1$ and $\vec f$ is a vector coefficient of the same dimension. +where $\vec v \in \vec H^1$ and $\vec f$ is a constant vector of the same dimension. ## Example Input File Syntax diff --git a/doc/content/source/bcs/MFEMVectorDirichletBC.md b/doc/content/source/bcs/MFEMVectorDirichletBC.md index 1a8e92fb..ca16cbb4 100644 --- a/doc/content/source/bcs/MFEMVectorDirichletBC.md +++ b/doc/content/source/bcs/MFEMVectorDirichletBC.md @@ -7,7 +7,7 @@ ## Overview Boundary condition for enforcing an essential (Dirichlet) boundary condition on all components of a -vector $H^1$ conforming variable on the boundary. +vector $H^1$ conforming variable on the boundary. The boundary value is constant in space and time. ## Example Input File Syntax diff --git a/doc/content/source/bcs/MFEMVectorDirichletBCBase.md b/doc/content/source/bcs/MFEMVectorDirichletBCBase.md index b46d1a93..6a2939cf 100644 --- a/doc/content/source/bcs/MFEMVectorDirichletBCBase.md +++ b/doc/content/source/bcs/MFEMVectorDirichletBCBase.md @@ -8,4 +8,5 @@ Base class for objects applying essential boundary conditions on vector variable Classes deriving from `MFEMVectorDirichletBCBase` are used for the application of Dirichlet-like BCs that remove degrees of freedom from vector variables in the problem on the specified boundary. These are commonly used when -strongly constraining the values a solution may take on boundaries. +strongly constraining the values a solution may take on boundaries. The imposed values are uniform in space and constant +in time. diff --git a/doc/content/source/bcs/MFEMVectorFunctionBoundaryIntegratedBC.md b/doc/content/source/bcs/MFEMVectorFunctionBoundaryIntegratedBC.md new file mode 100644 index 00000000..3e581f8e --- /dev/null +++ b/doc/content/source/bcs/MFEMVectorFunctionBoundaryIntegratedBC.md @@ -0,0 +1,22 @@ +# MFEMVectorFunctionBoundaryIntegratedBC + +## Summary + +!syntax description /BCs/MFEMVectorFunctionBoundaryIntegratedBC + +## Overview + +Adds the boundary integrator for integrating the linear form + +!equation +(\vec f, \vec v)_{\partial\Omega} \,\,\, \forall \vec v \in V + +where $v \in \vec H^1$ and $\vec f$ is a vector function of the same dimension. + +## Example Input File Syntax + +!syntax parameters /BCs/MFEMVectorFunctionBoundaryIntegratedBC + +!syntax inputs /BCs/MFEMVectorFunctionBoundaryIntegratedBC + +!syntax children /BCs/MFEMVectorFunctionBoundaryIntegratedBC diff --git a/doc/content/source/bcs/MFEMVectorFunctionDirichletBC.md b/doc/content/source/bcs/MFEMVectorFunctionDirichletBC.md new file mode 100644 index 00000000..c755682f --- /dev/null +++ b/doc/content/source/bcs/MFEMVectorFunctionDirichletBC.md @@ -0,0 +1,20 @@ +# MFEMVectorFunctionDirichletBC + +## Summary + +!syntax description /BCs/MFEMVectorFunctionDirichletBC + +## Overview + +Boundary condition for enforcing an essential (Dirichlet) boundary condition on all components of a +vector $H^1$ conforming variable on the boundary. The boundary value is a function of space and/or time. + +## Example Input File Syntax + +!listing test/tests/kernels/linearelasticity.i block=BCs + +!syntax parameters /BCs/MFEMVectorFunctionDirichletBC + +!syntax inputs /BCs/MFEMVectorFunctionDirichletBC + +!syntax children /BCs/MFEMVectorFunctionDirichletBC diff --git a/doc/content/source/bcs/MFEMVectorFunctionDirichletBCBase.md b/doc/content/source/bcs/MFEMVectorFunctionDirichletBCBase.md new file mode 100644 index 00000000..7d9221ed --- /dev/null +++ b/doc/content/source/bcs/MFEMVectorFunctionDirichletBCBase.md @@ -0,0 +1,11 @@ +# MFEMVectorFunctionDirichletBCBase + +## Summary + +Base class for objects applying essential boundary conditions on vector variables in an MFEM FE problem. + +## Overview + +Classes deriving from `MFEMVectorFunctionDirichletBCBase` are used for the application of Dirichlet-like BCs that +remove degrees of freedom from vector variables in the problem on the specified boundary. These are commonly used when +strongly constraining the values a solution may take on boundaries. The imposed values may vary in space and/or time. diff --git a/doc/content/source/bcs/MFEMVectorFunctionNormalDirichletBC.md b/doc/content/source/bcs/MFEMVectorFunctionNormalDirichletBC.md new file mode 100644 index 00000000..fc30dfb4 --- /dev/null +++ b/doc/content/source/bcs/MFEMVectorFunctionNormalDirichletBC.md @@ -0,0 +1,21 @@ +# MFEMVectorFunctionNormalDirichletBC + +## Summary + +!syntax description /BCs/MFEMVectorFunctionNormalDirichletBC + +## Overview + +Boundary condition for enforcing an essential (Dirichlet) boundary condition on the normal +components of a $H(\mathrm{div})$ conforming vector FE at a boundary. The imposed value is +a function of space and/or time. + +## Example Input File Syntax + +!listing test/tests/kernels/graddiv.i block=BCs + +!syntax parameters /BCs/MFEMVectorFunctionNormalDirichletBC + +!syntax inputs /BCs/MFEMVectorFunctionNormalDirichletBC + +!syntax children /BCs/MFEMVectorFunctionNormalDirichletBC diff --git a/doc/content/source/bcs/MFEMVectorFunctionNormalIntegratedBC.md b/doc/content/source/bcs/MFEMVectorFunctionNormalIntegratedBC.md new file mode 100644 index 00000000..7c5a584f --- /dev/null +++ b/doc/content/source/bcs/MFEMVectorFunctionNormalIntegratedBC.md @@ -0,0 +1,21 @@ +# MFEMVectorFunctionNormalIntegratedBC + +## Summary + +!syntax description /BCs/MFEMVectorFunctionNormalIntegratedBC + +## Overview + +Adds the boundary integrator for integrating the linear form + +!equation +(\vec f \cdot \hat n, v)_{\partial\Omega} \,\,\, \forall v \in V + +where $v \in H^1$, $\vec f$ is a vector function, and $\hat n$ is the outward facing unit normal +vector on the boundary. + +!syntax parameters /BCs/MFEMVectorFunctionNormalIntegratedBC + +!syntax inputs /BCs/MFEMVectorFunctionNormalIntegratedBC + +!syntax children /BCs/MFEMVectorFunctionNormalIntegratedBC diff --git a/doc/content/source/bcs/MFEMVectorFunctionTangentialDirichletBC.md b/doc/content/source/bcs/MFEMVectorFunctionTangentialDirichletBC.md new file mode 100644 index 00000000..bf283281 --- /dev/null +++ b/doc/content/source/bcs/MFEMVectorFunctionTangentialDirichletBC.md @@ -0,0 +1,21 @@ +# MFEMVectorFunctionTangentialDirichletBC + +## Summary + +!syntax description /BCs/MFEMVectorFunctionTangentialDirichletBC + +## Overview + +Boundary condition for enforcing an essential (Dirichlet) boundary condition on the tangential +components of a $H(\mathrm{curl})$ conforming vector FE at a boundary. The boundary value is +a function of space and/or time. + +## Example Input File Syntax + +!listing test/tests/kernels/curlcurl.i block=BCs + +!syntax parameters /BCs/MFEMVectorFunctionTangentialDirichletBC + +!syntax inputs /BCs/MFEMVectorFunctionTangentialDirichletBC + +!syntax children /BCs/MFEMVectorFunctionTangentialDirichletBC diff --git a/doc/content/source/bcs/MFEMVectorNormalDirichletBC.md b/doc/content/source/bcs/MFEMVectorNormalDirichletBC.md index 317bb642..8baf0e48 100644 --- a/doc/content/source/bcs/MFEMVectorNormalDirichletBC.md +++ b/doc/content/source/bcs/MFEMVectorNormalDirichletBC.md @@ -7,12 +7,11 @@ ## Overview Boundary condition for enforcing an essential (Dirichlet) boundary condition on the normal -components of a $H(\mathrm{div})$ conforming vector FE at a boundary. +components of a $H(\mathrm{div})$ conforming vector FE at a boundary. The imposed value is +constant in space and time. ## Example Input File Syntax -!listing test/tests/kernels/graddiv.i block=BCs - !syntax parameters /BCs/MFEMVectorNormalDirichletBC !syntax inputs /BCs/MFEMVectorNormalDirichletBC diff --git a/doc/content/source/bcs/MFEMVectorNormalIntegratedBC.md b/doc/content/source/bcs/MFEMVectorNormalIntegratedBC.md index eb3a97d5..2be8a43b 100644 --- a/doc/content/source/bcs/MFEMVectorNormalIntegratedBC.md +++ b/doc/content/source/bcs/MFEMVectorNormalIntegratedBC.md @@ -11,7 +11,7 @@ Adds the boundary integrator for integrating the linear form !equation (\vec f \cdot \hat n, v)_{\partial\Omega} \,\,\, \forall v \in V -where $v \in H^1$, $\vec f$ is a vector coefficient, and $\hat n$ is the outward facing unit normal +where $v \in H^1$, $\vec f$ is a vector value, and $\hat n$ is the outward facing unit normal vector on the boundary. !syntax parameters /BCs/MFEMVectorNormalIntegratedBC diff --git a/doc/content/source/bcs/MFEMVectorTangentialDirichletBC.md b/doc/content/source/bcs/MFEMVectorTangentialDirichletBC.md index 8ef1f967..6d10093c 100644 --- a/doc/content/source/bcs/MFEMVectorTangentialDirichletBC.md +++ b/doc/content/source/bcs/MFEMVectorTangentialDirichletBC.md @@ -7,12 +7,11 @@ ## Overview Boundary condition for enforcing an essential (Dirichlet) boundary condition on the tangential -components of a $H(\mathrm{curl})$ conforming vector FE at a boundary. +components of a $H(\mathrm{curl})$ conforming vector FE at a boundary. The boundary value is +constant in space and time. ## Example Input File Syntax -!listing test/tests/kernels/curlcurl.i block=BCs - !syntax parameters /BCs/MFEMVectorTangentialDirichletBC !syntax inputs /BCs/MFEMVectorTangentialDirichletBC diff --git a/include/actions/AddCoefficientAction.h b/include/actions/AddCoefficientAction.h deleted file mode 100644 index 21b113f5..00000000 --- a/include/actions/AddCoefficientAction.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "MooseObjectAction.h" -#include "MFEMProblem.h" -/** - * This class allows us to have a section of the input file like the - * following to add MFEM coefficients to the problem. - * - * [Coefficients] - * [] - */ -class AddCoefficientAction : public MooseObjectAction -{ -public: - static InputParameters validParams(); - - AddCoefficientAction(const InputParameters & parameters); - - virtual void act() override; -}; diff --git a/include/actions/AddVectorCoefficientAction.h b/include/actions/AddVectorCoefficientAction.h deleted file mode 100644 index 978ce573..00000000 --- a/include/actions/AddVectorCoefficientAction.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "MooseObjectAction.h" -#include "MFEMProblem.h" -/** - * This class allows us to have a section of the input file like the - * following to add MFEM coefficients to the problem. - * - * [Coefficients] - * [] - */ -class AddVectorCoefficientAction : public MooseObjectAction -{ -public: - static InputParameters validParams(); - - AddVectorCoefficientAction(const InputParameters & parameters); - - virtual void act() override; -}; diff --git a/include/bcs/MFEMConvectiveHeatFluxBC.h b/include/bcs/MFEMConvectiveHeatFluxBC.h index 1901ab80..7ecdd704 100644 --- a/include/bcs/MFEMConvectiveHeatFluxBC.h +++ b/include/bcs/MFEMConvectiveHeatFluxBC.h @@ -1,6 +1,5 @@ #pragma once #include "MFEMIntegratedBC.h" -#include "MFEMCoefficient.h" /* (h (T-T_inf), T') @@ -20,9 +19,7 @@ class MFEMConvectiveHeatFluxBC : public MFEMIntegratedBC virtual mfem::BilinearFormIntegrator * createBilinearFormIntegrator(); protected: - std::string _heat_transfer_coef_name; - std::string _T_inf_coef_name; - mfem::Coefficient & _heat_transfer_coef; - mfem::Coefficient & _T_inf_coef; - mfem::ProductCoefficient _external_heat_flux_coef; + std::shared_ptr _heat_transfer_coef; + std::shared_ptr _T_inf_coef; + std::shared_ptr _external_heat_flux_coef; }; diff --git a/include/bcs/MFEMScalarDirichletBC.h b/include/bcs/MFEMScalarDirichletBC.h index 87a250ec..24e8c20d 100644 --- a/include/bcs/MFEMScalarDirichletBC.h +++ b/include/bcs/MFEMScalarDirichletBC.h @@ -1,6 +1,5 @@ #pragma once #include "MFEMEssentialBC.h" -#include "MFEMFunctionCoefficient.h" class MFEMScalarDirichletBC : public MFEMEssentialBC { @@ -12,5 +11,5 @@ class MFEMScalarDirichletBC : public MFEMEssentialBC void ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * mesh_) override; protected: - MFEMCoefficient * _coef{nullptr}; + std::shared_ptr _coef{nullptr}; }; diff --git a/include/bcs/MFEMScalarFunctionDirichletBC.h b/include/bcs/MFEMScalarFunctionDirichletBC.h new file mode 100644 index 00000000..6c284cfa --- /dev/null +++ b/include/bcs/MFEMScalarFunctionDirichletBC.h @@ -0,0 +1,15 @@ +#pragma once +#include "MFEMEssentialBC.h" + +class MFEMScalarFunctionDirichletBC : public MFEMEssentialBC +{ +public: + static InputParameters validParams(); + + MFEMScalarFunctionDirichletBC(const InputParameters & parameters); + + void ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * mesh_) override; + +protected: + std::shared_ptr _coef{nullptr}; +}; diff --git a/include/bcs/MFEMVectorBoundaryIntegratedBC.h b/include/bcs/MFEMVectorBoundaryIntegratedBC.h index 37bdec4a..dca79d15 100644 --- a/include/bcs/MFEMVectorBoundaryIntegratedBC.h +++ b/include/bcs/MFEMVectorBoundaryIntegratedBC.h @@ -1,6 +1,5 @@ #pragma once #include "MFEMIntegratedBC.h" -#include "MFEMVectorFunctionCoefficient.h" class MFEMVectorBoundaryIntegratedBC : public MFEMIntegratedBC { @@ -17,6 +16,6 @@ class MFEMVectorBoundaryIntegratedBC : public MFEMIntegratedBC virtual mfem::BilinearFormIntegrator * createBilinearFormIntegrator(); protected: - std::string _vec_coef_name; - MFEMVectorCoefficient * _vec_coef; + std::vector _vec_value; + std::shared_ptr _vec_coef; }; diff --git a/include/bcs/MFEMVectorDirichletBCBase.h b/include/bcs/MFEMVectorDirichletBCBase.h index b606b150..026a0274 100644 --- a/include/bcs/MFEMVectorDirichletBCBase.h +++ b/include/bcs/MFEMVectorDirichletBCBase.h @@ -1,7 +1,6 @@ #pragma once #include "MFEMEssentialBC.h" -#include "MFEMVectorFunctionCoefficient.h" #include "boundary_conditions.h" class MFEMVectorDirichletBCBase : public MFEMEssentialBC @@ -13,5 +12,6 @@ class MFEMVectorDirichletBCBase : public MFEMEssentialBC protected: MFEMVectorDirichletBCBase(const InputParameters & parameters); - MFEMVectorCoefficient * _vec_coef{nullptr}; + std::vector _vec_value; + std::shared_ptr _vec_coef{nullptr}; }; diff --git a/include/bcs/MFEMVectorFunctionBoundaryIntegratedBC.h b/include/bcs/MFEMVectorFunctionBoundaryIntegratedBC.h new file mode 100644 index 00000000..59652394 --- /dev/null +++ b/include/bcs/MFEMVectorFunctionBoundaryIntegratedBC.h @@ -0,0 +1,20 @@ +#pragma once +#include "MFEMIntegratedBC.h" + +class MFEMVectorFunctionBoundaryIntegratedBC : public MFEMIntegratedBC +{ +public: + static InputParameters validParams(); + + MFEMVectorFunctionBoundaryIntegratedBC(const InputParameters & parameters); + + // Create a new MFEM integrator to apply to the RHS of the weak form. Ownership managed by the + // caller. + virtual mfem::LinearFormIntegrator * createLinearFormIntegrator(); + + // Create a new MFEM integrator to apply to LHS of the weak form. Ownership managed by the caller. + virtual mfem::BilinearFormIntegrator * createBilinearFormIntegrator(); + +protected: + std::shared_ptr _vec_coef{nullptr}; +}; diff --git a/include/bcs/MFEMVectorFunctionDirichletBC.h b/include/bcs/MFEMVectorFunctionDirichletBC.h new file mode 100644 index 00000000..9768dede --- /dev/null +++ b/include/bcs/MFEMVectorFunctionDirichletBC.h @@ -0,0 +1,11 @@ +#pragma once +#include "MFEMVectorFunctionDirichletBCBase.h" + +class MFEMVectorFunctionDirichletBC : public MFEMVectorFunctionDirichletBCBase +{ + +public: + MFEMVectorFunctionDirichletBC(const InputParameters & parameters); + ~MFEMVectorFunctionDirichletBC() override = default; + void ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * mesh_) override; +}; diff --git a/include/bcs/MFEMVectorFunctionDirichletBCBase.h b/include/bcs/MFEMVectorFunctionDirichletBCBase.h new file mode 100644 index 00000000..0055f64f --- /dev/null +++ b/include/bcs/MFEMVectorFunctionDirichletBCBase.h @@ -0,0 +1,16 @@ +#pragma once + +#include "MFEMEssentialBC.h" +#include "boundary_conditions.h" + +class MFEMVectorFunctionDirichletBCBase : public MFEMEssentialBC +{ +public: + static InputParameters validParams(); + + ~MFEMVectorFunctionDirichletBCBase() override = default; + +protected: + MFEMVectorFunctionDirichletBCBase(const InputParameters & parameters); + std::shared_ptr _vec_coef{nullptr}; +}; diff --git a/include/bcs/MFEMVectorFunctionNormalDirichletBC.h b/include/bcs/MFEMVectorFunctionNormalDirichletBC.h new file mode 100644 index 00000000..bf1a2335 --- /dev/null +++ b/include/bcs/MFEMVectorFunctionNormalDirichletBC.h @@ -0,0 +1,12 @@ +#pragma once + +#include "MFEMVectorFunctionDirichletBCBase.h" + +class MFEMVectorFunctionNormalDirichletBC : public MFEMVectorFunctionDirichletBCBase +{ +public: + static InputParameters validParams(); + MFEMVectorFunctionNormalDirichletBC(const InputParameters & parameters); + ~MFEMVectorFunctionNormalDirichletBC() override = default; + void ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * mesh_) override; +}; diff --git a/include/bcs/MFEMVectorFunctionNormalIntegratedBC.h b/include/bcs/MFEMVectorFunctionNormalIntegratedBC.h new file mode 100644 index 00000000..c9f369c4 --- /dev/null +++ b/include/bcs/MFEMVectorFunctionNormalIntegratedBC.h @@ -0,0 +1,20 @@ +#pragma once +#include "MFEMIntegratedBC.h" + +class MFEMVectorFunctionNormalIntegratedBC : public MFEMIntegratedBC +{ +public: + static InputParameters validParams(); + + MFEMVectorFunctionNormalIntegratedBC(const InputParameters & parameters); + + // Create a new MFEM integrator to apply to the RHS of the weak form. Ownership managed by the + // caller. + virtual mfem::LinearFormIntegrator * createLinearFormIntegrator(); + + // Create a new MFEM integrator to apply to LHS of the weak form. Ownership managed by the caller. + virtual mfem::BilinearFormIntegrator * createBilinearFormIntegrator(); + +protected: + std::shared_ptr _vec_coef; +}; diff --git a/include/bcs/MFEMVectorFunctionTangentialDirichletBC.h b/include/bcs/MFEMVectorFunctionTangentialDirichletBC.h new file mode 100644 index 00000000..9e14558d --- /dev/null +++ b/include/bcs/MFEMVectorFunctionTangentialDirichletBC.h @@ -0,0 +1,11 @@ +#pragma once + +#include "MFEMVectorFunctionDirichletBCBase.h" + +class MFEMVectorFunctionTangentialDirichletBC : public MFEMVectorFunctionDirichletBCBase +{ +public: + MFEMVectorFunctionTangentialDirichletBC(const InputParameters & parameters); + ~MFEMVectorFunctionTangentialDirichletBC() override = default; + void ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * mesh_) override; +}; diff --git a/include/bcs/MFEMVectorNormalIntegratedBC.h b/include/bcs/MFEMVectorNormalIntegratedBC.h index f5384f31..f64a1d8f 100644 --- a/include/bcs/MFEMVectorNormalIntegratedBC.h +++ b/include/bcs/MFEMVectorNormalIntegratedBC.h @@ -1,6 +1,5 @@ #pragma once #include "MFEMIntegratedBC.h" -#include "MFEMVectorFunctionCoefficient.h" class MFEMVectorNormalIntegratedBC : public MFEMIntegratedBC { @@ -17,6 +16,6 @@ class MFEMVectorNormalIntegratedBC : public MFEMIntegratedBC virtual mfem::BilinearFormIntegrator * createBilinearFormIntegrator(); protected: - std::string _vec_coef_name; - MFEMVectorCoefficient * _vec_coef; + std::vector _vec_value; + std::shared_ptr _vec_coef{nullptr}; }; diff --git a/include/coefficients/MFEMCoefficient.h b/include/coefficients/MFEMCoefficient.h deleted file mode 100644 index 4ff530be..00000000 --- a/include/coefficients/MFEMCoefficient.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include -#include "MFEMGeneralUserObject.h" -#include "Function.h" - -libMesh::Point PointFromMFEMVector(const mfem::Vector & vec); - -class MFEMCoefficient : public MFEMGeneralUserObject -{ -public: - static InputParameters validParams(); - - MFEMCoefficient(const InputParameters & parameters); - virtual ~MFEMCoefficient(); - - virtual std::shared_ptr getCoefficient() const - { - mooseError("Base class MFEMCoefficient cannot return a valid Coefficient. Use a child class."); - } -}; diff --git a/include/coefficients/MFEMConstantCoefficient.h b/include/coefficients/MFEMConstantCoefficient.h deleted file mode 100644 index ced3ac83..00000000 --- a/include/coefficients/MFEMConstantCoefficient.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -#include "MFEMCoefficient.h" -#include "MFEMContainers.h" - -class MFEMConstantCoefficient : public MFEMCoefficient -{ -public: - static InputParameters validParams(); - - MFEMConstantCoefficient(const InputParameters & parameters); - virtual ~MFEMConstantCoefficient(); - - std::shared_ptr getCoefficient() const override { return coefficient; } - -private: - std::shared_ptr coefficient{nullptr}; -}; diff --git a/include/coefficients/MFEMFunctionCoefficient.h b/include/coefficients/MFEMFunctionCoefficient.h deleted file mode 100644 index 204b6ab5..00000000 --- a/include/coefficients/MFEMFunctionCoefficient.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "MFEMCoefficient.h" - -class MFEMFunctionCoefficient : public MFEMCoefficient -{ -public: - static InputParameters validParams(); - - MFEMFunctionCoefficient(const InputParameters & parameters); - virtual ~MFEMFunctionCoefficient(); - - std::shared_ptr getCoefficient() const override { return _coefficient; }; - -private: - std::shared_ptr _coefficient{nullptr}; -}; diff --git a/include/coefficients/MFEMVectorCoefficient.h b/include/coefficients/MFEMVectorCoefficient.h deleted file mode 100644 index 4a568638..00000000 --- a/include/coefficients/MFEMVectorCoefficient.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include -#include "MFEMGeneralUserObject.h" -#include "Function.h" - -class MFEMVectorCoefficient : public MFEMGeneralUserObject -{ -public: - static InputParameters validParams(); - - MFEMVectorCoefficient(const InputParameters & parameters); - virtual ~MFEMVectorCoefficient(); - - virtual std::shared_ptr getVectorCoefficient() const - { - mooseError("Base class MFEMVectorCoefficient cannot return a valid VectorCoefficient. Use a " - "child class."); - } -}; diff --git a/include/coefficients/MFEMVectorConstantCoefficient.h b/include/coefficients/MFEMVectorConstantCoefficient.h deleted file mode 100644 index d87d279d..00000000 --- a/include/coefficients/MFEMVectorConstantCoefficient.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "MFEMVectorCoefficient.h" - -class MFEMVectorConstantCoefficient : public MFEMVectorCoefficient -{ -public: - static InputParameters validParams(); - - MFEMVectorConstantCoefficient(const InputParameters & parameters); - virtual ~MFEMVectorConstantCoefficient(); - - virtual std::shared_ptr getVectorCoefficient() const override - { - return _vector_coefficient; - } - -private: - const mfem::Vector _vector; - std::shared_ptr _vector_coefficient{nullptr}; -}; diff --git a/include/coefficients/MFEMVectorFunctionCoefficient.h b/include/coefficients/MFEMVectorFunctionCoefficient.h deleted file mode 100644 index 4b3389f7..00000000 --- a/include/coefficients/MFEMVectorFunctionCoefficient.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "MFEMVectorCoefficient.h" - -class MFEMVectorFunctionCoefficient : public MFEMVectorCoefficient -{ -public: - static InputParameters validParams(); - - MFEMVectorFunctionCoefficient(const InputParameters & parameters); - virtual ~MFEMVectorFunctionCoefficient(); - - std::shared_ptr getVectorCoefficient() const override - { - return _vector_coefficient; - } - -private: - std::shared_ptr _vector_coefficient{nullptr}; -}; diff --git a/include/materials/MFEMMaterial.h b/include/materials/MFEMMaterial.h index f24289ff..0ca52d2f 100644 --- a/include/materials/MFEMMaterial.h +++ b/include/materials/MFEMMaterial.h @@ -2,7 +2,6 @@ #include #include "MFEMGeneralUserObject.h" -#include "MFEMCoefficient.h" #include "PropertyManager.h" class MFEMMaterial : public MFEMGeneralUserObject diff --git a/include/problem/MFEMProblem.h b/include/problem/MFEMProblem.h index 07156557..0cb766da 100644 --- a/include/problem/MFEMProblem.h +++ b/include/problem/MFEMProblem.h @@ -4,8 +4,6 @@ #include "ExternalProblem.h" #include "MFEMProblemData.h" #include "MFEMMesh.h" -#include "MFEMCoefficient.h" -#include "MFEMVectorCoefficient.h" #include "MFEMMaterial.h" #include "MFEMVariable.h" #include "MFEMBoundaryCondition.h" @@ -49,21 +47,8 @@ class MFEMProblem : public ExternalProblem void addMaterial(const std::string & kernel_name, const std::string & name, - InputParameters & parameters); - - /** - * Add an MFEM coefficient to the problem. - */ - void addCoefficient(const std::string & user_object_name, - const std::string & name, - InputParameters & parameters); + InputParameters & parameters) override; - /** - * Add an MFEM vector coefficient to the problem. - */ - void addVectorCoefficient(const std::string & user_object_name, - const std::string & name, - InputParameters & parameters); /** * Add an MFEM FESpace to the problem. */ diff --git a/src/actions/AddCoefficientAction.C b/src/actions/AddCoefficientAction.C deleted file mode 100644 index 2af5c381..00000000 --- a/src/actions/AddCoefficientAction.C +++ /dev/null @@ -1,24 +0,0 @@ -#include "AddCoefficientAction.h" - -registerMooseAction("PlatypusApp", AddCoefficientAction, "add_mfem_coefficients"); - -InputParameters -AddCoefficientAction::validParams() -{ - InputParameters params = MooseObjectAction::validParams(); - params.addClassDescription("Add a MFEM Coefficient object to the simulation."); - return params; -} - -AddCoefficientAction::AddCoefficientAction(const InputParameters & parameters) - : MooseObjectAction(parameters) -{ -} - -void -AddCoefficientAction::act() -{ - MFEMProblem * mfem_problem = dynamic_cast(_problem.get()); - if (mfem_problem) - mfem_problem->addCoefficient(_type, _name, _moose_object_pars); -} diff --git a/src/actions/AddVectorCoefficientAction.C b/src/actions/AddVectorCoefficientAction.C deleted file mode 100644 index 6abea3d7..00000000 --- a/src/actions/AddVectorCoefficientAction.C +++ /dev/null @@ -1,24 +0,0 @@ -#include "AddVectorCoefficientAction.h" - -registerMooseAction("PlatypusApp", AddVectorCoefficientAction, "add_mfem_coefficients"); - -InputParameters -AddVectorCoefficientAction::validParams() -{ - InputParameters params = MooseObjectAction::validParams(); - params.addClassDescription("Add a MFEM VectorCoefficient object to the simulation."); - return params; -} - -AddVectorCoefficientAction::AddVectorCoefficientAction(const InputParameters & parameters) - : MooseObjectAction(parameters) -{ -} - -void -AddVectorCoefficientAction::act() -{ - MFEMProblem * mfem_problem = dynamic_cast(_problem.get()); - if (mfem_problem) - mfem_problem->addVectorCoefficient(_type, _name, _moose_object_pars); -} diff --git a/src/base/PlatypusApp.C b/src/base/PlatypusApp.C index 0bd90620..c509c84c 100644 --- a/src/base/PlatypusApp.C +++ b/src/base/PlatypusApp.C @@ -32,20 +32,6 @@ associateSyntaxInner(Syntax & syntax, ActionFactory & /*action_factory*/) addTaskDependency("add_elemental_field_variable", "add_mfem_problem_operator"); addTaskDependency("add_kernel", "add_mfem_problem_operator"); - // add coefficients - registerMooseObjectTask("add_mfem_coefficients", MFEMCoefficient, false); - registerSyntaxTask("AddCoefficientAction", "Coefficients/*", "add_mfem_coefficients"); - addTaskDependency("add_material", "add_mfem_coefficients"); - addTaskDependency("add_mfem_coefficients", "add_variable"); - addTaskDependency("add_mfem_coefficients", "add_aux_variable"); - addTaskDependency("add_mfem_coefficients", "add_ic"); - - // add vector coefficients - registerMooseObjectTask("add_mfem_vector_coefficients", MFEMVectorCoefficient, false); - registerSyntaxTask( - "AddVectorCoefficientAction", "VectorCoefficients/*", "add_mfem_vector_coefficients"); - addTaskDependency("add_material", "add_mfem_vector_coefficients"); - // add FESpaces registerMooseObjectTask("add_mfem_fespaces", MFEMFESpace, false); appendMooseObjectTask("add_mfem_fespaces", MFEMFECollection); diff --git a/src/bcs/MFEMConvectiveHeatFluxBC.C b/src/bcs/MFEMConvectiveHeatFluxBC.C index b6f5029d..eef0175c 100644 --- a/src/bcs/MFEMConvectiveHeatFluxBC.C +++ b/src/bcs/MFEMConvectiveHeatFluxBC.C @@ -7,24 +7,26 @@ InputParameters MFEMConvectiveHeatFluxBC::validParams() { InputParameters params = MFEMIntegratedBC::validParams(); + // FIXME: Should these really be specified via properties? T_infinity in particular? Use functions + // instead? params.addClassDescription( "Convective heat transfer boundary condition with temperature and heat " "transfer coefficent given by material properties to add to MFEM problems."); - params.addRequiredParam("T_infinity", "Material property for far-field temperature"); - params.addRequiredParam("heat_transfer_coefficient", - "Material property for heat transfer coefficient"); + params.addRequiredParam("T_infinity", "Function for far-field temperature"); + params.addRequiredParam("heat_transfer_coefficient", + "Function for heat transfer coefficient"); return params; } // TODO: Currently assumes the vector function coefficient is 3D MFEMConvectiveHeatFluxBC::MFEMConvectiveHeatFluxBC(const InputParameters & parameters) : MFEMIntegratedBC(parameters), - _heat_transfer_coef_name(getParam("heat_transfer_coefficient")), - _T_inf_coef_name(getParam("T_infinity")), - _heat_transfer_coef( - getMFEMProblem().getProperties().getScalarProperty(_heat_transfer_coef_name)), - _T_inf_coef(getMFEMProblem().getProperties().getScalarProperty(_T_inf_coef_name)), - _external_heat_flux_coef(_heat_transfer_coef, _T_inf_coef) + _heat_transfer_coef(getMFEMProblem().getScalarFunctionCoefficient( + getParam("heat_transfer_coefficient"))), + _T_inf_coef( + getMFEMProblem().getScalarFunctionCoefficient(getParam("T_infinity"))), + _external_heat_flux_coef(getMFEMProblem().makeScalarCoefficient( + *_heat_transfer_coef, *_T_inf_coef)) { } @@ -33,12 +35,12 @@ MFEMConvectiveHeatFluxBC::MFEMConvectiveHeatFluxBC(const InputParameters & param mfem::LinearFormIntegrator * MFEMConvectiveHeatFluxBC::createLinearFormIntegrator() { - return new mfem::BoundaryLFIntegrator(_external_heat_flux_coef); + return new mfem::BoundaryLFIntegrator(*_external_heat_flux_coef); } // Create a new MFEM integrator to apply to LHS of the weak form. Ownership managed by the caller. mfem::BilinearFormIntegrator * MFEMConvectiveHeatFluxBC::createBilinearFormIntegrator() { - return new mfem::BoundaryMassIntegrator(_heat_transfer_coef); -} \ No newline at end of file + return new mfem::BoundaryMassIntegrator(*_heat_transfer_coef); +} diff --git a/src/bcs/MFEMScalarDirichletBC.C b/src/bcs/MFEMScalarDirichletBC.C index 9dc4c0da..78b4376c 100644 --- a/src/bcs/MFEMScalarDirichletBC.C +++ b/src/bcs/MFEMScalarDirichletBC.C @@ -7,14 +7,14 @@ MFEMScalarDirichletBC::validParams() { InputParameters params = MFEMEssentialBC::validParams(); params.addClassDescription("Applies a Dirichlet condition to a scalar variable."); - params.addRequiredParam( - "coefficient", "The scalar MFEM coefficient to use in the Dirichlet condition"); + params.addRequiredParam("value", "The scalar value to use in the Dirichlet condition"); return params; } MFEMScalarDirichletBC::MFEMScalarDirichletBC(const InputParameters & parameters) : MFEMEssentialBC(parameters), - _coef(const_cast(&getUserObject("coefficient"))) + _coef( + getMFEMProblem().makeScalarCoefficient(getParam("value"))) { } @@ -23,5 +23,5 @@ MFEMScalarDirichletBC::ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * mesh_ { mfem::Array ess_bdrs(mesh_->bdr_attributes.Max()); ess_bdrs = GetMarkers(*mesh_); - gridfunc.ProjectBdrCoefficient(*_coef->getCoefficient(), ess_bdrs); + gridfunc.ProjectBdrCoefficient(*_coef, ess_bdrs); } diff --git a/src/bcs/MFEMScalarFunctionDirichletBC.C b/src/bcs/MFEMScalarFunctionDirichletBC.C new file mode 100644 index 00000000..dbef269e --- /dev/null +++ b/src/bcs/MFEMScalarFunctionDirichletBC.C @@ -0,0 +1,25 @@ +#include "MFEMScalarFunctionDirichletBC.h" + +registerMooseObject("PlatypusApp", MFEMScalarFunctionDirichletBC); + +InputParameters +MFEMScalarFunctionDirichletBC::validParams() +{ + InputParameters params = MFEMEssentialBC::validParams(); + params.addRequiredParam("function", "The forcing function."); + return params; +} + +MFEMScalarFunctionDirichletBC::MFEMScalarFunctionDirichletBC(const InputParameters & parameters) + : MFEMEssentialBC(parameters), + _coef(getMFEMProblem().getScalarFunctionCoefficient(getParam("function"))) +{ +} + +void +MFEMScalarFunctionDirichletBC::ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * mesh_) +{ + mfem::Array ess_bdrs(mesh_->bdr_attributes.Max()); + ess_bdrs = GetMarkers(*mesh_); + gridfunc.ProjectBdrCoefficient(*_coef, ess_bdrs); +} diff --git a/src/bcs/MFEMVectorBoundaryIntegratedBC.C b/src/bcs/MFEMVectorBoundaryIntegratedBC.C index b59aaa20..d32efd2e 100644 --- a/src/bcs/MFEMVectorBoundaryIntegratedBC.C +++ b/src/bcs/MFEMVectorBoundaryIntegratedBC.C @@ -8,17 +8,17 @@ MFEMVectorBoundaryIntegratedBC::validParams() InputParameters params = MFEMIntegratedBC::validParams(); params.addClassDescription("Adds the boundary integrator to an MFEM problem for the linear form " "$(\\vec f, \\vec v)_{\\partial\\Omega}$"); - params.addRequiredParam( - "vector_coefficient", "The vector MFEM coefficient which will be used in the integrated BC"); + params.addRequiredParam>( + "values", "The vector whose components will be used in the integrated BC"); return params; } // TODO: Currently assumes the vector function coefficient is 3D MFEMVectorBoundaryIntegratedBC::MFEMVectorBoundaryIntegratedBC(const InputParameters & parameters) : MFEMIntegratedBC(parameters), - _vec_coef_name(getParam("vector_coefficient")), - _vec_coef(const_cast( - &getUserObject("vector_coefficient"))) + _vec_value(getParam>("values")), + _vec_coef(getMFEMProblem().makeVectorCoefficient( + mfem::Vector(_vec_value.data(), _vec_value.size()))) { } @@ -27,7 +27,7 @@ MFEMVectorBoundaryIntegratedBC::MFEMVectorBoundaryIntegratedBC(const InputParame mfem::LinearFormIntegrator * MFEMVectorBoundaryIntegratedBC::createLinearFormIntegrator() { - return new mfem::VectorBoundaryLFIntegrator(*_vec_coef->getVectorCoefficient()); + return new mfem::VectorBoundaryLFIntegrator(*_vec_coef); } // Create a new MFEM integrator to apply to LHS of the weak form. Ownership managed by the caller. diff --git a/src/bcs/MFEMVectorDirichletBC.C b/src/bcs/MFEMVectorDirichletBC.C index c3c7953e..c5973c7d 100644 --- a/src/bcs/MFEMVectorDirichletBC.C +++ b/src/bcs/MFEMVectorDirichletBC.C @@ -22,5 +22,5 @@ MFEMVectorDirichletBC::ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * mesh_ { mfem::Array ess_bdrs(mesh_->bdr_attributes.Max()); ess_bdrs = GetMarkers(*mesh_); - gridfunc.ProjectBdrCoefficient(*_vec_coef->getVectorCoefficient(), ess_bdrs); + gridfunc.ProjectBdrCoefficient(*_vec_coef, ess_bdrs); } diff --git a/src/bcs/MFEMVectorDirichletBCBase.C b/src/bcs/MFEMVectorDirichletBCBase.C index 389cca06..a172bbec 100644 --- a/src/bcs/MFEMVectorDirichletBCBase.C +++ b/src/bcs/MFEMVectorDirichletBCBase.C @@ -4,15 +4,16 @@ InputParameters MFEMVectorDirichletBCBase::validParams() { InputParameters params = MFEMEssentialBC::validParams(); - params.addRequiredParam( - "vector_coefficient", "The vector MFEM coefficient to use in the Dirichlet condition"); + params.addRequiredParam>("values", + "The vector which will be used in the integrated BC"); return params; } // TODO: Currently assumes the vector function coefficient is 3D MFEMVectorDirichletBCBase::MFEMVectorDirichletBCBase(const InputParameters & parameters) : MFEMEssentialBC(parameters), - _vec_coef(const_cast( - &getUserObject("vector_coefficient"))) + _vec_value(getParam>("values")), + _vec_coef(getMFEMProblem().makeVectorCoefficient( + mfem::Vector(_vec_value.data(), _vec_value.size()))) { } diff --git a/src/bcs/MFEMVectorFunctionBoundaryIntegratedBC.C b/src/bcs/MFEMVectorFunctionBoundaryIntegratedBC.C new file mode 100644 index 00000000..f6264628 --- /dev/null +++ b/src/bcs/MFEMVectorFunctionBoundaryIntegratedBC.C @@ -0,0 +1,35 @@ +#include "MFEMVectorFunctionBoundaryIntegratedBC.h" + +registerMooseObject("PlatypusApp", MFEMVectorFunctionBoundaryIntegratedBC); + +InputParameters +MFEMVectorFunctionBoundaryIntegratedBC::validParams() +{ + InputParameters params = MFEMIntegratedBC::validParams(); + params.addRequiredParam("function", + "The values the components must take on the boundary."); + return params; +} + +// TODO: Currently assumes the vector function coefficient is 3D +MFEMVectorFunctionBoundaryIntegratedBC::MFEMVectorFunctionBoundaryIntegratedBC( + const InputParameters & parameters) + : MFEMIntegratedBC(parameters), + _vec_coef(getMFEMProblem().getVectorFunctionCoefficient(getParam("function"))) +{ +} + +// Create a new MFEM integrator to apply to the RHS of the weak form. Ownership managed by the +// caller. +mfem::LinearFormIntegrator * +MFEMVectorFunctionBoundaryIntegratedBC::createLinearFormIntegrator() +{ + return new mfem::VectorBoundaryLFIntegrator(*_vec_coef); +} + +// Create a new MFEM integrator to apply to LHS of the weak form. Ownership managed by the caller. +mfem::BilinearFormIntegrator * +MFEMVectorFunctionBoundaryIntegratedBC::createBilinearFormIntegrator() +{ + return nullptr; +} diff --git a/src/bcs/MFEMVectorFunctionDirichletBC.C b/src/bcs/MFEMVectorFunctionDirichletBC.C new file mode 100644 index 00000000..d2932f78 --- /dev/null +++ b/src/bcs/MFEMVectorFunctionDirichletBC.C @@ -0,0 +1,16 @@ +#include "MFEMVectorFunctionDirichletBC.h" + +registerMooseObject("PlatypusApp", MFEMVectorFunctionDirichletBC); + +MFEMVectorFunctionDirichletBC::MFEMVectorFunctionDirichletBC(const InputParameters & parameters) + : MFEMVectorFunctionDirichletBCBase(parameters) +{ +} + +void +MFEMVectorFunctionDirichletBC::ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * mesh_) +{ + mfem::Array ess_bdrs(mesh_->bdr_attributes.Max()); + ess_bdrs = GetMarkers(*mesh_); + gridfunc.ProjectBdrCoefficient(*_vec_coef, ess_bdrs); +} diff --git a/src/bcs/MFEMVectorFunctionDirichletBCBase.C b/src/bcs/MFEMVectorFunctionDirichletBCBase.C new file mode 100644 index 00000000..b0532ef6 --- /dev/null +++ b/src/bcs/MFEMVectorFunctionDirichletBCBase.C @@ -0,0 +1,18 @@ +#include "MFEMVectorFunctionDirichletBCBase.h" + +InputParameters +MFEMVectorFunctionDirichletBCBase::validParams() +{ + InputParameters params = MFEMEssentialBC::validParams(); + params.addRequiredParam("function", + "The values the components must take on the boundary."); + return params; +} + +// TODO: Currently assumes the vector function coefficient is 3D +MFEMVectorFunctionDirichletBCBase::MFEMVectorFunctionDirichletBCBase( + const InputParameters & parameters) + : MFEMEssentialBC(parameters), + _vec_coef(getMFEMProblem().getVectorFunctionCoefficient(getParam("function"))) +{ +} diff --git a/src/bcs/MFEMVectorFunctionNormalDirichletBC.C b/src/bcs/MFEMVectorFunctionNormalDirichletBC.C new file mode 100644 index 00000000..098507c3 --- /dev/null +++ b/src/bcs/MFEMVectorFunctionNormalDirichletBC.C @@ -0,0 +1,26 @@ +#include "MFEMVectorFunctionNormalDirichletBC.h" + +registerMooseObject("PlatypusApp", MFEMVectorFunctionNormalDirichletBC); + +InputParameters +MFEMVectorFunctionNormalDirichletBC::validParams() +{ + InputParameters params = MFEMVectorFunctionDirichletBCBase::validParams(); + params.addClassDescription( + "Applies a Dirichlet condition to the normal components of a vector variable."); + return params; +} + +MFEMVectorFunctionNormalDirichletBC::MFEMVectorFunctionNormalDirichletBC( + const InputParameters & parameters) + : MFEMVectorFunctionDirichletBCBase(parameters) +{ +} + +void +MFEMVectorFunctionNormalDirichletBC::ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * mesh_) +{ + mfem::Array ess_bdrs(mesh_->bdr_attributes.Max()); + ess_bdrs = GetMarkers(*mesh_); + gridfunc.ProjectBdrCoefficientNormal(*_vec_coef, ess_bdrs); +} diff --git a/src/bcs/MFEMVectorFunctionNormalIntegratedBC.C b/src/bcs/MFEMVectorFunctionNormalIntegratedBC.C new file mode 100644 index 00000000..b606ffd3 --- /dev/null +++ b/src/bcs/MFEMVectorFunctionNormalIntegratedBC.C @@ -0,0 +1,35 @@ +#include "MFEMVectorFunctionNormalIntegratedBC.h" + +registerMooseObject("PlatypusApp", MFEMVectorFunctionNormalIntegratedBC); + +InputParameters +MFEMVectorFunctionNormalIntegratedBC::validParams() +{ + InputParameters params = MFEMIntegratedBC::validParams(); + params.addRequiredParam( + "function", "The vector function whose normal component will be used in the integrated BC"); + return params; +} + +// TODO: Currently assumes the vector function coefficient is 3D +MFEMVectorFunctionNormalIntegratedBC::MFEMVectorFunctionNormalIntegratedBC( + const InputParameters & parameters) + : MFEMIntegratedBC(parameters), + _vec_coef(getMFEMProblem().getVectorFunctionCoefficient(getParam("function"))) +{ +} + +// Create a new MFEM integrator to apply to the RHS of the weak form. Ownership managed by the +// caller. +mfem::LinearFormIntegrator * +MFEMVectorFunctionNormalIntegratedBC::createLinearFormIntegrator() +{ + return new mfem::BoundaryNormalLFIntegrator(*_vec_coef); +} + +// Create a new MFEM integrator to apply to LHS of the weak form. Ownership managed by the caller. +mfem::BilinearFormIntegrator * +MFEMVectorFunctionNormalIntegratedBC::createBilinearFormIntegrator() +{ + return nullptr; +} diff --git a/src/bcs/MFEMVectorFunctionTangentialDirichletBC.C b/src/bcs/MFEMVectorFunctionTangentialDirichletBC.C new file mode 100644 index 00000000..07e1d0bf --- /dev/null +++ b/src/bcs/MFEMVectorFunctionTangentialDirichletBC.C @@ -0,0 +1,17 @@ +#include "MFEMVectorFunctionTangentialDirichletBC.h" + +registerMooseObject("PlatypusApp", MFEMVectorFunctionTangentialDirichletBC); + +MFEMVectorFunctionTangentialDirichletBC::MFEMVectorFunctionTangentialDirichletBC( + const InputParameters & parameters) + : MFEMVectorFunctionDirichletBCBase(parameters) +{ +} + +void +MFEMVectorFunctionTangentialDirichletBC::ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * mesh_) +{ + mfem::Array ess_bdrs(mesh_->bdr_attributes.Max()); + ess_bdrs = GetMarkers(*mesh_); + gridfunc.ProjectBdrCoefficientTangent(*_vec_coef, ess_bdrs); +} diff --git a/src/bcs/MFEMVectorNormalDirichletBC.C b/src/bcs/MFEMVectorNormalDirichletBC.C index e80b8d70..aafc14ae 100644 --- a/src/bcs/MFEMVectorNormalDirichletBC.C +++ b/src/bcs/MFEMVectorNormalDirichletBC.C @@ -21,5 +21,5 @@ MFEMVectorNormalDirichletBC::ApplyBC(mfem::GridFunction & gridfunc, mfem::Mesh * { mfem::Array ess_bdrs(mesh_->bdr_attributes.Max()); ess_bdrs = GetMarkers(*mesh_); - gridfunc.ProjectBdrCoefficientNormal(*_vec_coef->getVectorCoefficient(), ess_bdrs); + gridfunc.ProjectBdrCoefficientNormal(*_vec_coef, ess_bdrs); } diff --git a/src/bcs/MFEMVectorNormalIntegratedBC.C b/src/bcs/MFEMVectorNormalIntegratedBC.C index d5c1bd7c..d0283014 100644 --- a/src/bcs/MFEMVectorNormalIntegratedBC.C +++ b/src/bcs/MFEMVectorNormalIntegratedBC.C @@ -8,18 +8,17 @@ MFEMVectorNormalIntegratedBC::validParams() InputParameters params = MFEMIntegratedBC::validParams(); params.addClassDescription("Adds the boundary integrator to an MFEM problem for the linear form " "$(\\vec f \\cdot \\hat n, v)_{\\partial\\Omega}$"); - params.addRequiredParam( - "vector_coefficient", - "The vector MFEM coefficient whose normal component will be used in the integrated BC"); + params.addRequiredParam>( + "values", "The vector whose normal component will be used in the integrated BC"); return params; } // TODO: Currently assumes the vector function coefficient is 3D MFEMVectorNormalIntegratedBC::MFEMVectorNormalIntegratedBC(const InputParameters & parameters) : MFEMIntegratedBC(parameters), - _vec_coef_name(getParam("vector_coefficient")), - _vec_coef(const_cast( - &getUserObject("vector_coefficient"))) + _vec_value(getParam>("values")), + _vec_coef(getMFEMProblem().makeVectorCoefficient( + mfem::Vector(_vec_value.data(), _vec_value.size()))) { } @@ -28,7 +27,7 @@ MFEMVectorNormalIntegratedBC::MFEMVectorNormalIntegratedBC(const InputParameters mfem::LinearFormIntegrator * MFEMVectorNormalIntegratedBC::createLinearFormIntegrator() { - return new mfem::BoundaryNormalLFIntegrator(*_vec_coef->getVectorCoefficient()); + return new mfem::BoundaryNormalLFIntegrator(*_vec_coef); } // Create a new MFEM integrator to apply to LHS of the weak form. Ownership managed by the caller. diff --git a/src/bcs/MFEMVectorTangentialDirichletBC.C b/src/bcs/MFEMVectorTangentialDirichletBC.C index f5e9558d..86341084 100644 --- a/src/bcs/MFEMVectorTangentialDirichletBC.C +++ b/src/bcs/MFEMVectorTangentialDirichletBC.C @@ -21,5 +21,5 @@ MFEMVectorTangentialDirichletBC::ApplyBC(mfem::GridFunction & gridfunc, mfem::Me { mfem::Array ess_bdrs(mesh_->bdr_attributes.Max()); ess_bdrs = GetMarkers(*mesh_); - gridfunc.ProjectBdrCoefficientTangent(*_vec_coef->getVectorCoefficient(), ess_bdrs); + gridfunc.ProjectBdrCoefficientTangent(*_vec_coef, ess_bdrs); } diff --git a/src/coefficients/MFEMCoefficient.C b/src/coefficients/MFEMCoefficient.C deleted file mode 100644 index 06e74af5..00000000 --- a/src/coefficients/MFEMCoefficient.C +++ /dev/null @@ -1,26 +0,0 @@ -#include "MFEMCoefficient.h" - -registerMooseObject("PlatypusApp", MFEMCoefficient); - -libMesh::Point -PointFromMFEMVector(const mfem::Vector & vec) -{ - return libMesh::Point(vec.Elem(0), vec.Elem(1), vec.Elem(2)); -} - -InputParameters -MFEMCoefficient::validParams() -{ - InputParameters params = MFEMGeneralUserObject::validParams(); - params.addClassDescription( - "Base class for defining mfem::Coefficient objects to add to an MFEMProblem."); - params.registerBase("MFEMCoefficient"); - return params; -} - -MFEMCoefficient::MFEMCoefficient(const InputParameters & parameters) - : MFEMGeneralUserObject(parameters) -{ -} - -MFEMCoefficient::~MFEMCoefficient() {} diff --git a/src/coefficients/MFEMConstantCoefficient.C b/src/coefficients/MFEMConstantCoefficient.C deleted file mode 100644 index dd13a625..00000000 --- a/src/coefficients/MFEMConstantCoefficient.C +++ /dev/null @@ -1,23 +0,0 @@ -#include "MFEMConstantCoefficient.h" -#include "MFEMProblem.h" - -registerMooseObject("PlatypusApp", MFEMConstantCoefficient); - -InputParameters -MFEMConstantCoefficient::validParams() -{ - InputParameters params = MFEMCoefficient::validParams(); - params.addClassDescription( - "Class for defining an mfem::ConstantCoefficient object to add to an MFEMProblem."); - params.addRequiredParam("value", "Value for the ConstantCoefficient"); - return params; -} - -MFEMConstantCoefficient::MFEMConstantCoefficient(const InputParameters & parameters) - : MFEMCoefficient(parameters), - coefficient{getMFEMProblem().makeScalarCoefficient( - getParam("value"))} -{ -} - -MFEMConstantCoefficient::~MFEMConstantCoefficient() {} diff --git a/src/coefficients/MFEMFunctionCoefficient.C b/src/coefficients/MFEMFunctionCoefficient.C deleted file mode 100644 index c3277e93..00000000 --- a/src/coefficients/MFEMFunctionCoefficient.C +++ /dev/null @@ -1,22 +0,0 @@ -#include "MFEMFunctionCoefficient.h" -#include "MFEMProblem.h" - -registerMooseObject("PlatypusApp", MFEMFunctionCoefficient); - -InputParameters -MFEMFunctionCoefficient::validParams() -{ - InputParameters params = MFEMCoefficient::validParams(); - params.addClassDescription( - "Class for defining an mfem::FunctionCoefficient object to add to an MFEMProblem."); - params.addParam("function", 0, "The function to associated with the Dirichlet BC"); - return params; -} - -MFEMFunctionCoefficient::MFEMFunctionCoefficient(const InputParameters & parameters) - : MFEMCoefficient(parameters), - _coefficient(getMFEMProblem().getScalarFunctionCoefficient(getParam("function"))) -{ -} - -MFEMFunctionCoefficient::~MFEMFunctionCoefficient() {} diff --git a/src/coefficients/MFEMVectorCoefficient.C b/src/coefficients/MFEMVectorCoefficient.C deleted file mode 100644 index 62c19439..00000000 --- a/src/coefficients/MFEMVectorCoefficient.C +++ /dev/null @@ -1,20 +0,0 @@ -#include "MFEMVectorCoefficient.h" - -registerMooseObject("PlatypusApp", MFEMVectorCoefficient); - -InputParameters -MFEMVectorCoefficient::validParams() -{ - InputParameters params = MFEMGeneralUserObject::validParams(); - params.addClassDescription( - "Base class for defining mfem::VectorCoefficient objects to add to an MFEMProblem."); - params.registerBase("MFEMVectorCoefficient"); - return params; -} - -MFEMVectorCoefficient::MFEMVectorCoefficient(const InputParameters & parameters) - : MFEMGeneralUserObject(parameters) -{ -} - -MFEMVectorCoefficient::~MFEMVectorCoefficient() {} diff --git a/src/coefficients/MFEMVectorConstantCoefficient.C b/src/coefficients/MFEMVectorConstantCoefficient.C deleted file mode 100644 index 1f38b8c4..00000000 --- a/src/coefficients/MFEMVectorConstantCoefficient.C +++ /dev/null @@ -1,27 +0,0 @@ -#include "MFEMVectorConstantCoefficient.h" -#include "MFEMProblem.h" - -registerMooseObject("PlatypusApp", MFEMVectorConstantCoefficient); - -InputParameters -MFEMVectorConstantCoefficient::validParams() -{ - InputParameters params = MFEMVectorCoefficient::validParams(); - params.addClassDescription( - "Class for defining an mfem::VectorConstantCoefficient object to add to an MFEMProblem."); - params.addRequiredParam("value_x", "x component of the VectorConstantCoefficient"); - params.addRequiredParam("value_y", "y component of the VectorConstantCoefficient"); - params.addRequiredParam("value_z", "z component of the VectorConstantCoefficient"); - return params; -} - -MFEMVectorConstantCoefficient::MFEMVectorConstantCoefficient(const InputParameters & parameters) - : MFEMVectorCoefficient(parameters), - _vector( - {getParam("value_x"), getParam("value_y"), getParam("value_z")}), - _vector_coefficient{ - getMFEMProblem().makeVectorCoefficient(_vector)} -{ -} - -MFEMVectorConstantCoefficient::~MFEMVectorConstantCoefficient() {} diff --git a/src/coefficients/MFEMVectorFunctionCoefficient.C b/src/coefficients/MFEMVectorFunctionCoefficient.C deleted file mode 100644 index ded05192..00000000 --- a/src/coefficients/MFEMVectorFunctionCoefficient.C +++ /dev/null @@ -1,23 +0,0 @@ -#include "MFEMVectorFunctionCoefficient.h" -#include "MFEMProblem.h" - -registerMooseObject("PlatypusApp", MFEMVectorFunctionCoefficient); - -InputParameters -MFEMVectorFunctionCoefficient::validParams() -{ - InputParameters params = MFEMVectorCoefficient::validParams(); - params.addClassDescription( - "Class for defining an mfem::VectorFunctionCoefficient object to add to an MFEMProblem."); - params.addParam("function", 0, "The function to associated with the Dirichlet BC"); - return params; -} - -MFEMVectorFunctionCoefficient::MFEMVectorFunctionCoefficient(const InputParameters & parameters) - : MFEMVectorCoefficient(parameters), - _vector_coefficient( - getMFEMProblem().getVectorFunctionCoefficient(getParam("function"))) -{ -} - -MFEMVectorFunctionCoefficient::~MFEMVectorFunctionCoefficient() {} diff --git a/src/problem/MFEMProblem.C b/src/problem/MFEMProblem.C index b225df27..e3874fb5 100644 --- a/src/problem/MFEMProblem.C +++ b/src/problem/MFEMProblem.C @@ -111,22 +111,6 @@ MFEMProblem::addMaterial(const std::string & kernel_name, MFEMMaterial & mfem_material(getUserObject(name)); } -void -MFEMProblem::addCoefficient(const std::string & user_object_name, - const std::string & name, - InputParameters & parameters) -{ - FEProblemBase::addUserObject(user_object_name, name, parameters); -} - -void -MFEMProblem::addVectorCoefficient(const std::string & user_object_name, - const std::string & name, - InputParameters & parameters) -{ - FEProblemBase::addUserObject(user_object_name, name, parameters); -} - void MFEMProblem::addFESpace(const std::string & user_object_name, const std::string & name, diff --git a/test/tests/kernels/curlcurl.i b/test/tests/kernels/curlcurl.i index c795571e..6ffcb74b 100644 --- a/test/tests/kernels/curlcurl.i +++ b/test/tests/kernels/curlcurl.i @@ -50,21 +50,13 @@ [BCs] [tangential_E_bdr] - type = MFEMVectorTangentialDirichletBC + type = MFEMVectorFunctionTangentialDirichletBC variable = e_field boundary = '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24' - vector_coefficient = TangentialECoefficient - [] -[] - -[VectorCoefficients] - [TangentialECoefficient] - type = MFEMVectorFunctionCoefficient function = exact_e_field [] [] - [Materials] [Substance] type = MFEMGenericConstantMaterial diff --git a/test/tests/kernels/diffusion.i b/test/tests/kernels/diffusion.i index 188de73f..98d6df8c 100644 --- a/test/tests/kernels/diffusion.i +++ b/test/tests/kernels/diffusion.i @@ -23,29 +23,18 @@ [] [] -[Functions] - [value_bottom] - type = ParsedFunction - expression = 1.0 - [] - [value_top] - type = ParsedFunction - expression = 0.0 - [] -[] - [BCs] [bottom] type = MFEMScalarDirichletBC variable = diffused boundary = '1' - coefficient = BottomValue + value = 1.0 [] [low_terminal] type = MFEMScalarDirichletBC variable = diffused boundary = '2' - coefficient = TopValue + value = 0.0 [] [] @@ -57,17 +46,6 @@ [] [] -[Coefficients] - [TopValue] - type = MFEMFunctionCoefficient - function = value_top - [] - [BottomValue] - type = MFEMFunctionCoefficient - function = value_bottom - [] -[] - [Kernels] [diff] type = MFEMDiffusionKernel diff --git a/test/tests/kernels/diffusion_partial.i b/test/tests/kernels/diffusion_partial.i index a13d2f6c..68c3d45b 100644 --- a/test/tests/kernels/diffusion_partial.i +++ b/test/tests/kernels/diffusion_partial.i @@ -23,29 +23,18 @@ [] [] -[Functions] - [value_bottom] - type = ParsedFunction - expression = 1.0 - [] - [value_top] - type = ParsedFunction - expression = 0.0 - [] -[] - [BCs] [bottom] type = MFEMScalarDirichletBC variable = diffused boundary = '1' - coefficient = BottomValue + value = 1.0 [] [low_terminal] type = MFEMScalarDirichletBC variable = diffused boundary = '2' - coefficient = TopValue + value = 0.0 [] [] @@ -57,17 +46,6 @@ [] [] -[Coefficients] - [TopValue] - type = MFEMFunctionCoefficient - function = value_top - [] - [BottomValue] - type = MFEMFunctionCoefficient - function = value_bottom - [] -[] - [Kernels] [diff] type = MFEMDiffusionKernel diff --git a/test/tests/kernels/graddiv.i b/test/tests/kernels/graddiv.i index 256368ce..1e372466 100644 --- a/test/tests/kernels/graddiv.i +++ b/test/tests/kernels/graddiv.i @@ -52,10 +52,10 @@ [BCs] [dirichlet] - type = MFEMVectorNormalDirichletBC + type = MFEMVectorFunctionNormalDirichletBC variable = F boundary = '1 2 3' - vector_coefficient = F_exact + function = F_exact [] [] @@ -68,17 +68,6 @@ [] [] -[VectorCoefficients] - [f] - type = MFEMVectorFunctionCoefficient - function = f - [] - [F_exact] - type = MFEMVectorFunctionCoefficient - function = F_exact - [] -[] - [Kernels] [divdiv] type = MFEMDivDivKernel diff --git a/test/tests/kernels/heatconduction.i b/test/tests/kernels/heatconduction.i index 340258fd..dc5ca8be 100644 --- a/test/tests/kernels/heatconduction.i +++ b/test/tests/kernels/heatconduction.i @@ -23,29 +23,18 @@ [] [] -[Functions] - [value_bottom] - type = ParsedFunction - expression = 1.0 - [] - [value_top] - type = ParsedFunction - expression = 0.0 - [] -[] - [BCs] [bottom] type = MFEMScalarDirichletBC variable = temperature boundary = '1' - coefficient = BottomValue + value = 1.0 [] [low_terminal] type = MFEMScalarDirichletBC variable = temperature boundary = '2' - coefficient = TopValue + value = 0.0 [] [] @@ -57,17 +46,6 @@ [] [] -[Coefficients] - [TopValue] - type = MFEMFunctionCoefficient - function = value_top - [] - [BottomValue] - type = MFEMFunctionCoefficient - function = value_bottom - [] -[] - [Kernels] [diff] type = MFEMDiffusionKernel diff --git a/test/tests/kernels/heatconduction_element.i b/test/tests/kernels/heatconduction_element.i index 718bb43d..7895e25a 100644 --- a/test/tests/kernels/heatconduction_element.i +++ b/test/tests/kernels/heatconduction_element.i @@ -23,29 +23,18 @@ [] [] -[Functions] - [value_bottom] - type = ParsedFunction - expression = 1.0 - [] - [value_top] - type = ParsedFunction - expression = 0.0 - [] -[] - [BCs] [bottom] type = MFEMScalarDirichletBC variable = temperature boundary = '1' - coefficient = BottomValue + value = 1.0 [] [low_terminal] type = MFEMScalarDirichletBC variable = temperature boundary = '2' - coefficient = TopValue + value = 0.0 [] [] @@ -57,17 +46,6 @@ [] [] -[Coefficients] - [TopValue] - type = MFEMFunctionCoefficient - function = value_top - [] - [BottomValue] - type = MFEMFunctionCoefficient - function = value_bottom - [] -[] - [Kernels] [diff] type = MFEMDiffusionKernel diff --git a/test/tests/kernels/heattransfer.i b/test/tests/kernels/heattransfer.i index eda53ed0..668f33b7 100644 --- a/test/tests/kernels/heattransfer.i +++ b/test/tests/kernels/heattransfer.i @@ -24,16 +24,13 @@ [] [Functions] - [value_bottom] + [reservoir_far_temperature] type = ParsedFunction - expression = 1.0 + expression = 0.5 [] -[] - -[Coefficients] - [BottomValue] - type = MFEMFunctionCoefficient - function = value_bottom + [heat_transfer_coefficient] + type = ParsedFunction + expression = 5.0 [] [] @@ -55,14 +52,14 @@ type = MFEMScalarDirichletBC variable = temperature boundary = '1' - coefficient = BottomValue + value = 1.0 [] [top] type = MFEMConvectiveHeatFluxBC variable = temperature boundary = '2' - T_infinity = 'reservoir_far_temperature' - heat_transfer_coefficient = 'heat_transfer_coefficient' + T_infinity = reservoir_far_temperature + heat_transfer_coefficient = heat_transfer_coefficient [] [] @@ -72,11 +69,6 @@ prop_names = 'thermal_conductivity volumetric_heat_capacity' prop_values = '1.0 1.0' [] - [Boundary] - type = MFEMGenericConstantMaterial - prop_names = 'heat_transfer_coefficient reservoir_far_temperature' - prop_values = '5.0 0.5' - [] [] [Preconditioner] diff --git a/test/tests/kernels/linearelasticity.i b/test/tests/kernels/linearelasticity.i index e5f20d35..c0364d75 100644 --- a/test/tests/kernels/linearelasticity.i +++ b/test/tests/kernels/linearelasticity.i @@ -32,13 +32,13 @@ type = MFEMVectorDirichletBC variable = displacement boundary = '1' - vector_coefficient = FixedValue + values = '0.0 0.0 0.0' [] [pull_down] type = MFEMVectorBoundaryIntegratedBC variable = displacement boundary = '2' - vector_coefficient = PullDownValue + values = '0.0 0.0 -0.01' [] [] @@ -57,21 +57,6 @@ [] [] -[VectorCoefficients] - [FixedValue] - type = MFEMVectorConstantCoefficient - value_x = 0.0 - value_y = 0.0 - value_z = 0.0 - [] - [PullDownValue] - type = MFEMVectorConstantCoefficient - value_x = 0.0 - value_y = 0.0 - value_z = -0.01 - [] -[] - [Kernels] [diff] type = MFEMLinearElasticityKernel diff --git a/test/tests/outputs/datacollections.i b/test/tests/outputs/datacollections.i index 1a4382ac..4b85c655 100644 --- a/test/tests/outputs/datacollections.i +++ b/test/tests/outputs/datacollections.i @@ -23,29 +23,18 @@ [] [] -[Functions] - [value_bottom] - type = ParsedFunction - expression = 1.0 - [] - [value_top] - type = ParsedFunction - expression = 0.0 - [] -[] - [BCs] [bottom] type = MFEMScalarDirichletBC variable = diffused boundary = '1' - coefficient = BottomValue + value = 1.0 [] [low_terminal] type = MFEMScalarDirichletBC variable = diffused boundary = '2' - coefficient = TopValue + value = 0.0 [] [] @@ -57,17 +46,6 @@ [] [] -[Coefficients] - [TopValue] - type = MFEMFunctionCoefficient - function = value_top - [] - [BottomValue] - type = MFEMFunctionCoefficient - function = value_bottom - [] -[] - [Kernels] [diff] type = MFEMDiffusionKernel diff --git a/test/tests/variables/mfem_variables_from_moose.i b/test/tests/variables/mfem_variables_from_moose.i index 6ba30e76..e7fd9911 100644 --- a/test/tests/variables/mfem_variables_from_moose.i +++ b/test/tests/variables/mfem_variables_from_moose.i @@ -30,29 +30,18 @@ [] [] -[Functions] - [value_bottom] - type = ParsedFunction - expression = 1.0 - [] - [value_top] - type = ParsedFunction - expression = 0.0 - [] -[] - [BCs] [bottom] type = MFEMScalarDirichletBC variable = scalar_var boundary = '1' - coefficient = BottomValue + value = 1.0 [] [low_terminal] type = MFEMScalarDirichletBC variable = scalar_var boundary = '2' - coefficient = TopValue + value = 0.0 [] [] @@ -64,17 +53,6 @@ [] [] -[Coefficients] - [TopValue] - type = MFEMFunctionCoefficient - function = value_top - [] - [BottomValue] - type = MFEMFunctionCoefficient - function = value_bottom - [] -[] - [Kernels] [diff] type = MFEMDiffusionKernel diff --git a/unit/src/MFEMEssentialBCTest.C b/unit/src/MFEMEssentialBCTest.C new file mode 100644 index 00000000..43934cd3 --- /dev/null +++ b/unit/src/MFEMEssentialBCTest.C @@ -0,0 +1,380 @@ +#include "mfem-common.hpp" +#include "MFEMObjectUnitTest.h" +#include "MFEMScalarDirichletBC.h" +#include "MFEMScalarFunctionDirichletBC.h" +#include "MFEMVectorDirichletBC.h" +#include "MFEMVectorFunctionDirichletBC.h" +#include "MFEMVectorNormalDirichletBC.h" +#include "MFEMVectorFunctionNormalDirichletBC.h" +#include "MFEMVectorTangentialDirichletBC.h" +#include "MFEMVectorFunctionTangentialDirichletBC.h" + +class MFEMEssentialBCTest : public MFEMObjectUnitTest +{ +public: + mfem::common::H1_FESpace _scalar_fes; + mfem::common::H1_FESpace _vector_h1_fes; + mfem::common::ND_FESpace _vector_hcurl_fes; + mfem::common::RT_FESpace _vector_hdiv_fes; + mfem::GridFunction _scalar_gridfunc, _vector_h1_gridfunc, _vector_hcurl_gridfunc, + _vector_hdiv_gridfunc; + mfem::ConstantCoefficient _scalar_zero; + mfem::VectorConstantCoefficient _vector_zero; + + MFEMEssentialBCTest() + : MFEMObjectUnitTest("PlatypusApp"), + _scalar_fes(_mfem_mesh_ptr->getMFEMParMeshPtr().get(), 1, 3), + _vector_h1_fes( + _mfem_mesh_ptr->getMFEMParMeshPtr().get(), 1, 3, mfem::BasisType::GaussLobatto, 3), + _vector_hcurl_fes(_mfem_mesh_ptr->getMFEMParMeshPtr().get(), 2, 3), + _vector_hdiv_fes(_mfem_mesh_ptr->getMFEMParMeshPtr().get(), 2, 3), + _scalar_gridfunc(&_scalar_fes), + _vector_h1_gridfunc(&_vector_h1_fes), + _vector_hcurl_gridfunc(&_vector_hcurl_fes), + _vector_hdiv_gridfunc(&_vector_hdiv_fes), + _scalar_zero(0.), + _vector_zero(mfem::Vector({0., 0., 0.})) + { + InputParameters func_params = _factory.getValidParams("ParsedFunction"); + func_params.set("expression") = "x + y"; + _mfem_problem->addFunction("ParsedFunction", "func1", func_params); + _mfem_problem->getFunction("func1").initialSetup(); + InputParameters vecfunc_params = _factory.getValidParams("ParsedVectorFunction"); + vecfunc_params.set("expression_x") = "x + y"; + vecfunc_params.set("expression_y") = "x + y + 1"; + vecfunc_params.set("expression_z") = "x + y + 2"; + _mfem_problem->addFunction("ParsedVectorFunction", "func2", vecfunc_params); + _mfem_problem->getFunction("func2").initialSetup(); + _scalar_gridfunc.ProjectCoefficient(_scalar_zero); + _vector_h1_gridfunc.ProjectCoefficient(_vector_zero); + _vector_hcurl_gridfunc.ProjectCoefficient(_vector_zero); + _vector_hdiv_gridfunc.ProjectCoefficient(_vector_zero); + } + + void check_boundary(int bound, + mfem::FiniteElementSpace & fespace, + std::function error_func, + double tolerance) + { + for (int be = 0; be < _mfem_mesh_ptr->getMFEMParMeshPtr()->GetNBE(); be++) + { + mfem::Element * elem = _mfem_mesh_ptr->getMFEMParMeshPtr()->GetBdrElement(be); + if (elem->GetAttribute() != 1) + continue; + mfem::ElementTransformation * transform = + _mfem_mesh_ptr->getMFEMParMeshPtr()->GetBdrElementTransformation(be); + const mfem::FiniteElement * fe = fespace.GetBE(be); + const mfem::IntegrationRule & ir = + mfem::IntRules.Get(fe->GetGeomType(), 2 * fe->GetOrder() + 2); + double total_error = 0.0; + for (int j = 0; j < ir.GetNPoints(); j++) + { + const mfem::IntegrationPoint point = ir.IntPoint(j); + transform->SetIntPoint(&point); + const double error = error_func(transform, point); + total_error += error * error; + } + EXPECT_LT(total_error, tolerance); + } + } + + mfem::Vector calc_normal(mfem::ElementTransformation * transform) const + { + mfem::Vector normal(3); + mfem::CalcOrtho(transform->Jacobian(), normal); + return normal; + } +}; + +/** + * Test MFEMScalarDirichletBC can be constructed and applied successfully + */ +TEST_F(MFEMEssentialBCTest, MFEMScalarDirichletBC) +{ + // Construct boundary condition + InputParameters bc_params = _factory.getValidParams("MFEMScalarDirichletBC"); + bc_params.set("variable") = "test_variable_name"; + bc_params.set("value") = 1.; + bc_params.set>("boundary") = {"1"}; + auto & essential_bc = addObject("MFEMScalarDirichletBC", "bc1", bc_params); + + EXPECT_EQ(essential_bc.getTrialVariableName(), "test_variable_name"); + EXPECT_EQ(essential_bc.getTestVariableName(), "test_variable_name"); + + // Test applying the BC + essential_bc.ApplyBC(_scalar_gridfunc, _mfem_mesh_ptr->getMFEMParMeshPtr().get()); + + // Check the correct boundary values have been applied + mfem::GridFunctionCoefficient scalar_variable(&_scalar_gridfunc); + check_boundary( + 1, + _scalar_fes, + [&scalar_variable](mfem::ElementTransformation * transform, + const mfem::IntegrationPoint & point) + { return scalar_variable.Eval(*transform, point) - 1.; }, + 1e-8); +} + +/** + * Test MFEMScalarFunctionDirichletBC can be constructed and applied successfully + */ +TEST_F(MFEMEssentialBCTest, MFEMScalarFunctionDirichletBC) +{ + // Construct boundary condition + InputParameters bc_params = _factory.getValidParams("MFEMScalarFunctionDirichletBC"); + bc_params.set("variable") = "test_variable_name"; + bc_params.set("function") = "func1"; + bc_params.set>("boundary") = {"1"}; + auto & essential_bc = + addObject("MFEMScalarFunctionDirichletBC", "bc1", bc_params); + + EXPECT_EQ(essential_bc.getTrialVariableName(), "test_variable_name"); + EXPECT_EQ(essential_bc.getTestVariableName(), "test_variable_name"); + + // Test applying the BC + essential_bc.ApplyBC(_scalar_gridfunc, _mfem_mesh_ptr->getMFEMParMeshPtr().get()); + + // Check the correct boundary values have been applied + mfem::GridFunctionCoefficient scalar_variable(&_scalar_gridfunc); + std::shared_ptr expected = + _mfem_problem->getScalarFunctionCoefficient("func1"); + check_boundary( + 1, + _scalar_fes, + [&scalar_variable, expected](mfem::ElementTransformation * transform, + const mfem::IntegrationPoint & point) + { return scalar_variable.Eval(*transform, point) - expected->Eval(*transform, point); }, + 1e-8); +} + +/** + * Test MFEMVectorDirichletBC can be constructed and applied successfully + */ +TEST_F(MFEMEssentialBCTest, MFEMVectorDirichletBC) +{ + // Construct boundary condition + InputParameters bc_params = _factory.getValidParams("MFEMVectorDirichletBC"); + bc_params.set("variable") = "test_variable_name"; + bc_params.set>("values") = {1., 2., 3.}; + bc_params.set>("boundary") = {"1"}; + auto & essential_bc = addObject("MFEMVectorDirichletBC", "bc1", bc_params); + + EXPECT_EQ(essential_bc.getTrialVariableName(), "test_variable_name"); + EXPECT_EQ(essential_bc.getTestVariableName(), "test_variable_name"); + + // Test applying the BC + essential_bc.ApplyBC(_vector_h1_gridfunc, _mfem_mesh_ptr->getMFEMParMeshPtr().get()); + + // Check the correct boundary values have been applied + mfem::VectorGridFunctionCoefficient variable(&_vector_h1_gridfunc); + mfem::Vector expected({1., 2., 3.}); + check_boundary( + 1, + _vector_h1_fes, + [&variable, &expected](mfem::ElementTransformation * transform, + const mfem::IntegrationPoint & point) + { + mfem::Vector actual(3); + variable.Eval(actual, *transform, point); + actual -= expected; + return actual.Norml2(); + }, + 1e-8); +} + +/** + * Test MFEMVectorFunctionDirichletBC can be constructed and applied successfully + */ +TEST_F(MFEMEssentialBCTest, MFEMVectorFunctionDirichletBC) +{ + // Construct boundary condition + InputParameters bc_params = _factory.getValidParams("MFEMVectorFunctionDirichletBC"); + bc_params.set("variable") = "test_variable_name"; + bc_params.set("function") = "func2"; + bc_params.set>("boundary") = {"1"}; + auto & essential_bc = + addObject("MFEMVectorFunctionDirichletBC", "bc1", bc_params); + + EXPECT_EQ(essential_bc.getTrialVariableName(), "test_variable_name"); + EXPECT_EQ(essential_bc.getTestVariableName(), "test_variable_name"); + + // Test applying the BC + essential_bc.ApplyBC(_vector_h1_gridfunc, _mfem_mesh_ptr->getMFEMParMeshPtr().get()); + + // Check the correct boundary values have been applied + mfem::VectorGridFunctionCoefficient variable(&_vector_h1_gridfunc); + std::shared_ptr function = + _mfem_problem->getVectorFunctionCoefficient("func2"); + check_boundary( + 1, + _vector_h1_fes, + [&variable, &function](mfem::ElementTransformation * transform, + const mfem::IntegrationPoint & point) + { + mfem::Vector actual(3), expected(3); + variable.Eval(actual, *transform, point); + function->Eval(expected, *transform, point); + actual -= expected; + return actual.Norml2(); + }, + 1e-8); +} + +/** + * Test MFEMVectorNormalDirichletBC can be constructed and applied successfully + */ +TEST_F(MFEMEssentialBCTest, MFEMVectorNormalDirichletBC) +{ + // Construct boundary condition + InputParameters bc_params = _factory.getValidParams("MFEMVectorNormalDirichletBC"); + bc_params.set("variable") = "test_variable_name"; + bc_params.set>("values") = {1., 2., 3.}; + bc_params.set>("boundary") = {"1"}; + auto & essential_bc = + addObject("MFEMVectorNormalDirichletBC", "bc1", bc_params); + + EXPECT_EQ(essential_bc.getTrialVariableName(), "test_variable_name"); + EXPECT_EQ(essential_bc.getTestVariableName(), "test_variable_name"); + + // Test applying the BC + essential_bc.ApplyBC(_vector_hdiv_gridfunc, _mfem_mesh_ptr->getMFEMParMeshPtr().get()); + + // Check the correct boundary values have been applied + mfem::VectorGridFunctionCoefficient variable(&_vector_hdiv_gridfunc); + mfem::Vector assigned_val({1., 2., 3.}); + check_boundary( + 1, + _vector_hdiv_fes, + [this, &variable, &assigned_val](mfem::ElementTransformation * transform, + const mfem::IntegrationPoint & point) + { + mfem::Vector actual(3), expected(3), normal = calc_normal(transform); + variable.Eval(actual, *transform, point); + expected = assigned_val; + actual -= expected; + // (actual - expected) should be perpendicular to the normal and have a dot product of 0. + return normal[0] * actual[0] + normal[1] * actual[1] + normal[2] * actual[2]; + }, + 1e-8); +} + +/** + * Test MFEMVectorFunctionNormalDirichletBC can be constructed and applied successfully + */ +TEST_F(MFEMEssentialBCTest, MFEMVectorFunctionNormalDirichletBC) +{ + // Construct boundary condition + InputParameters bc_params = _factory.getValidParams("MFEMVectorFunctionNormalDirichletBC"); + bc_params.set("variable") = "test_variable_name"; + bc_params.set("function") = "func2"; + bc_params.set>("boundary") = {"1"}; + auto & essential_bc = addObject( + "MFEMVectorFunctionNormalDirichletBC", "bc1", bc_params); + + EXPECT_EQ(essential_bc.getTrialVariableName(), "test_variable_name"); + EXPECT_EQ(essential_bc.getTestVariableName(), "test_variable_name"); + + // Test applying the BC + essential_bc.ApplyBC(_vector_hdiv_gridfunc, _mfem_mesh_ptr->getMFEMParMeshPtr().get()); + + // Check the correct boundary values have been applied + mfem::VectorGridFunctionCoefficient variable(&_vector_hdiv_gridfunc); + std::shared_ptr function = + _mfem_problem->getVectorFunctionCoefficient("func2"); + check_boundary( + 1, + _vector_hdiv_fes, + [this, &variable, &function](mfem::ElementTransformation * transform, + const mfem::IntegrationPoint & point) + { + mfem::Vector actual(3), expected(3), normal = calc_normal(transform); + variable.Eval(actual, *transform, point); + function->Eval(expected, *transform, point); + actual -= expected; + // (actual - expected) should be perpendicular to the normal and have a dot product of 0. + return normal[0] * actual[0] + normal[1] * actual[1] + normal[2] * actual[2]; + }, + 1e-8); +} + +/** + * Test MFEMVectorTangentialDirichletBC can be constructed and applied successfully + */ +TEST_F(MFEMEssentialBCTest, MFEMVectorTangentialDirichletBC) +{ + // Construct boundary condition + InputParameters bc_params = _factory.getValidParams("MFEMVectorTangentialDirichletBC"); + bc_params.set("variable") = "test_variable_name"; + bc_params.set>("values") = {1., 2., 3.}; + bc_params.set>("boundary") = {"1"}; + auto & essential_bc = addObject( + "MFEMVectorTangentialDirichletBC", "bc1", bc_params); + + EXPECT_EQ(essential_bc.getTrialVariableName(), "test_variable_name"); + EXPECT_EQ(essential_bc.getTestVariableName(), "test_variable_name"); + + // Test applying the BC + essential_bc.ApplyBC(_vector_hcurl_gridfunc, _mfem_mesh_ptr->getMFEMParMeshPtr().get()); + // Check the correct boundary values have been applied + mfem::VectorGridFunctionCoefficient variable(&_vector_hcurl_gridfunc); + mfem::Vector expected({1., 2., 3.}); + check_boundary( + 1, + _vector_hcurl_fes, + [this, &variable, &expected](mfem::ElementTransformation * transform, + const mfem::IntegrationPoint & point) + { + mfem::Vector actual(3), normal = calc_normal(transform), cross_prod(3); + variable.Eval(actual, *transform, point); + actual -= expected; + // (actual - expected) should be parallel to the normal and have a cross product of 0. + cross_prod = normal[1] * actual[2] - normal[2] * actual[1]; + cross_prod = normal[2] * actual[0] - normal[0] * actual[2]; + cross_prod = normal[0] * actual[1] - normal[1] * actual[0]; + return cross_prod.Norml2(); + }, + 1e-8); +} + +/** + * Test MFEMVectorFunctionTangentialDirichletBC can be constructed and applied successfully + */ +TEST_F(MFEMEssentialBCTest, MFEMVectorFunctionTangentialDirichletBC) +{ + // Construct boundary condition + InputParameters bc_params = _factory.getValidParams("MFEMVectorFunctionTangentialDirichletBC"); + bc_params.set("variable") = "test_variable_name"; + bc_params.set("function") = "func2"; + bc_params.set>("boundary") = {"1"}; + auto & essential_bc = addObject( + "MFEMVectorFunctionTangentialDirichletBC", "bc1", bc_params); + + EXPECT_EQ(essential_bc.getTrialVariableName(), "test_variable_name"); + EXPECT_EQ(essential_bc.getTestVariableName(), "test_variable_name"); + + // Test applying the BC + essential_bc.ApplyBC(_vector_hcurl_gridfunc, _mfem_mesh_ptr->getMFEMParMeshPtr().get()); + + // Check the correct boundary values have been applied + mfem::VectorGridFunctionCoefficient variable(&_vector_hcurl_gridfunc); + std::shared_ptr function = + _mfem_problem->getVectorFunctionCoefficient("func2"); + check_boundary( + 1, + _vector_hcurl_fes, + [this, &variable, &function](mfem::ElementTransformation * transform, + const mfem::IntegrationPoint & point) + { + mfem::Vector actual(3), expected(3), normal = calc_normal(transform), cross_prod(3); + variable.Eval(actual, *transform, point); + function->Eval(expected, *transform, point); + actual -= expected; + // (actual - expected) should be parallel to the normal and have a cross product of 0. + cross_prod = normal[1] * actual[2] - normal[2] * actual[1]; + cross_prod = normal[2] * actual[0] - normal[0] * actual[2]; + cross_prod = normal[0] * actual[1] - normal[1] * actual[0]; + return cross_prod.Norml2(); + }, + 1e-8); +} diff --git a/unit/src/MFEMIntegratedBCTest.C b/unit/src/MFEMIntegratedBCTest.C index ae0dedd9..83db3ce8 100644 --- a/unit/src/MFEMIntegratedBCTest.C +++ b/unit/src/MFEMIntegratedBCTest.C @@ -1,6 +1,8 @@ #include "MFEMObjectUnitTest.h" #include "MFEMVectorBoundaryIntegratedBC.h" #include "MFEMVectorNormalIntegratedBC.h" +#include "MFEMVectorFunctionBoundaryIntegratedBC.h" +#include "MFEMVectorFunctionNormalIntegratedBC.h" #include "MFEMConvectiveHeatFluxBC.h" class MFEMIntegratedBCTest : public MFEMObjectUnitTest @@ -14,18 +16,10 @@ public: */ TEST_F(MFEMIntegratedBCTest, MFEMVectorNormalIntegratedBC) { - // Build required BC inputs - InputParameters vec_coef_params = _factory.getValidParams("MFEMVectorConstantCoefficient"); - vec_coef_params.set("value_x") = 1.0; - vec_coef_params.set("value_y") = 2.0; - vec_coef_params.set("value_z") = 3.0; - _mfem_problem->addVectorCoefficient( - "MFEMVectorConstantCoefficient", "vec_coef1", vec_coef_params); - // Construct boundary condition InputParameters bc_params = _factory.getValidParams("MFEMVectorNormalIntegratedBC"); bc_params.set("variable") = "test_variable_name"; - bc_params.set("vector_coefficient") = "vec_coef1"; + bc_params.set>("values") = {1., 2., 3.}; bc_params.set>("boundary") = {"1"}; MFEMVectorNormalIntegratedBC & integrated_bc = addObject("MFEMVectorNormalIntegratedBC", "bc1", bc_params); @@ -41,22 +35,55 @@ TEST_F(MFEMIntegratedBCTest, MFEMVectorNormalIntegratedBC) delete blf_integrator; } +/** + * Test MFEMVectorNormalIntegratedBC creates an mfem::BoundaryNormalLFIntegrator successfully. + */ +TEST_F(MFEMIntegratedBCTest, MFEMVectorFunctionNormalIntegratedBC) +{ + // Construct boundary condition + InputParameters func_params = _factory.getValidParams("ParsedVectorFunction"); + func_params.set("expression_x") = "x + y"; + func_params.set("expression_y") = "x + y + 1"; + func_params.set("expression_z") = "x + y + 2"; + _mfem_problem->addFunction("ParsedVectorFunction", "func1", func_params); + InputParameters bc_params = _factory.getValidParams("MFEMVectorFunctionNormalIntegratedBC"); + bc_params.set("variable") = "test_variable_name"; + bc_params.set("function") = "func1"; + bc_params.set>("boundary") = {"1"}; + MFEMVectorFunctionNormalIntegratedBC & integrated_bc = + addObject( + "MFEMVectorFunctionNormalIntegratedBC", "bc1", bc_params); + + // Test MFEMVectorNormalIntegratedBC returns an integrator of the expected type + auto lf_integrator = + dynamic_cast(integrated_bc.createLinearFormIntegrator()); + ASSERT_NE(lf_integrator, nullptr); + delete lf_integrator; + + auto blf_integrator = integrated_bc.createBilinearFormIntegrator(); + ASSERT_EQ(blf_integrator, nullptr); + delete blf_integrator; +} + /** * Test MFEMConvectiveHeatFluxBC creates the expected mfem::BoundaryIntegrators successfully. */ TEST_F(MFEMIntegratedBCTest, MFEMConvectiveHeatFluxBC) { // Build required BC inputs - InputParameters coef_params = _factory.getValidParams("MFEMGenericConstantMaterial"); - coef_params.set>("prop_names") = {"htc", "Tinf"}; - coef_params.set>("prop_values") = {1.0, 3.0}; - _mfem_problem->addMaterial("MFEMGenericConstantMaterial", "material1", coef_params); + InputParameters htc_params = _factory.getValidParams("ParsedFunction"); + htc_params.set("expression") = "1.0"; + _mfem_problem->addFunction("ParsedFunction", "htc", htc_params); + _mfem_problem->getFunction("htc").initialSetup(); + InputParameters Tinf_params = _factory.getValidParams("ParsedFunction"); + Tinf_params.set("expression") = "3.0"; + _mfem_problem->addFunction("ParsedFunction", "Tinf", Tinf_params); // Construct boundary condition InputParameters bc_params = _factory.getValidParams("MFEMConvectiveHeatFluxBC"); bc_params.set("variable") = "test_variable_name"; - bc_params.set("heat_transfer_coefficient") = "htc"; - bc_params.set("T_infinity") = "Tinf"; + bc_params.set("heat_transfer_coefficient") = "htc"; + bc_params.set("T_infinity") = "Tinf"; bc_params.set>("boundary") = {"1"}; MFEMConvectiveHeatFluxBC & integrated_bc = addObject("MFEMConvectiveHeatFluxBC", "bc1", bc_params); @@ -75,19 +102,11 @@ TEST_F(MFEMIntegratedBCTest, MFEMConvectiveHeatFluxBC) TEST_F(MFEMIntegratedBCTest, MFEMVectorBoundaryIntegratedBC) { - // Build required BC inputs - InputParameters vec_coef_params = _factory.getValidParams("MFEMVectorConstantCoefficient"); - vec_coef_params.set("value_x") = 1.0; - vec_coef_params.set("value_y") = 2.0; - vec_coef_params.set("value_z") = 3.0; - _mfem_problem->addVectorCoefficient( - "MFEMVectorConstantCoefficient", "vec_coef1", vec_coef_params); - // Construct boundary condition InputParameters bc_params = _factory.getValidParams("MFEMVectorBoundaryIntegratedBC"); bc_params.set("variable") = "test_variable_name"; bc_params.set>("boundary") = {"1"}; - bc_params.set("vector_coefficient") = "vec_coef1"; + bc_params.set>("values") = {1., 2., 3.}; auto & bc = addObject("MFEMVectorBoundaryIntegratedBC", "bc1", bc_params); @@ -101,3 +120,31 @@ TEST_F(MFEMIntegratedBCTest, MFEMVectorBoundaryIntegratedBC) ASSERT_EQ(blf_integrator, nullptr); delete blf_integrator; } + +TEST_F(MFEMIntegratedBCTest, MFEMVectorFunctionBoundaryIntegratedBC) +{ + // Build required BC inputs + InputParameters func_params = _factory.getValidParams("ParsedVectorFunction"); + func_params.set("expression_x") = "x + y"; + func_params.set("expression_y") = "x + y + 1"; + func_params.set("expression_z") = "x + y + 2"; + _mfem_problem->addFunction("ParsedVectorFunction", "func1", func_params); + + // Construct boundary condition + InputParameters bc_params = _factory.getValidParams("MFEMVectorFunctionBoundaryIntegratedBC"); + bc_params.set("variable") = "test_variable_name"; + bc_params.set>("boundary") = {"1"}; + bc_params.set("function") = "func1"; + auto & bc = addObject( + "MFEMVectorFunctionBoundaryIntegratedBC", "bc1", bc_params); + + // Test MFEMVectorBoundaryIntegratedBC returns an integrator of the expected type + auto lf_integrator = + dynamic_cast(bc.createLinearFormIntegrator()); + ASSERT_NE(lf_integrator, nullptr); + delete lf_integrator; + + auto blf_integrator = bc.createBilinearFormIntegrator(); + ASSERT_EQ(blf_integrator, nullptr); + delete blf_integrator; +}