-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from aurora-multiphysics/EdwardPalmer99/impleme…
…nt-fespaces-and-gridfunctions Implements MFEMFESpaces, MFEMVariable, MFEMFECollections
- Loading branch information
Showing
14 changed files
with
217 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
#include "MFEMGeneralUserObject.h" | ||
#include "mfem.hpp" | ||
#include <string> | ||
|
||
/** | ||
* Constructs and stores an mfem::FiniteElementCollection object. Access using | ||
* the getFEC() accessor. | ||
*/ | ||
class MFEMFECollection : public MFEMGeneralUserObject | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
MFEMFECollection(const InputParameters & parameters); | ||
|
||
~MFEMFECollection() override = default; | ||
|
||
/// Returns a shared pointer to the constructed fec. | ||
inline std::shared_ptr<mfem::FiniteElementCollection> getFEC() const { return _fec; } | ||
|
||
protected: | ||
const int _fec_order; | ||
const std::string _fec_type; | ||
const std::string _fec_name; | ||
|
||
private: | ||
/// Constructs the fec name from the order and fespace type. | ||
const std::string buildFECName(); | ||
|
||
/// Constructs the fec from the fec name. | ||
const std::shared_ptr<mfem::FiniteElementCollection> buildFEC(); | ||
|
||
/// Stores the constructed fec. | ||
const std::shared_ptr<mfem::FiniteElementCollection> _fec{nullptr}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,38 @@ | ||
#pragma once | ||
#include "MFEMGeneralUserObject.h" | ||
#include "MFEMFECollection.h" | ||
|
||
/** | ||
* Constructs and stores an mfem::ParFiniteElementSpace object. Access using the | ||
* getFESpace() accessor. | ||
*/ | ||
class MFEMFESpace : public MFEMGeneralUserObject | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
MFEMFESpace(const InputParameters & parameters); | ||
virtual ~MFEMFESpace(); | ||
|
||
static const std::string createFECName(const std::string & fespace_type, const int order); | ||
const int order; | ||
const int vdim; | ||
const std::string fespace_type; | ||
const std::string fec_name; | ||
/// Returns a shared pointer to the constructed fespace. | ||
inline std::shared_ptr<mfem::ParFiniteElementSpace> getFESpace() const { return _fespace; } | ||
|
||
/// Returns a shared pointer to the constructed fec. | ||
inline std::shared_ptr<mfem::FiniteElementCollection> getFEC() const { return _fec.getFEC(); } | ||
|
||
protected: | ||
/// Vector dimension (number of unknowns per degree of freedom). | ||
const int _vdim; | ||
|
||
/// Type of ordering of the vector dofs when _vdim > 1. | ||
const int _ordering; | ||
|
||
/// Constructs and stores the fec. | ||
const MFEMFECollection _fec; | ||
|
||
private: | ||
/// Constructs the fespace. | ||
const std::shared_ptr<mfem::ParFiniteElementSpace> buildFESpace(); | ||
|
||
/// Stores the constructed fespace. | ||
const std::shared_ptr<mfem::ParFiniteElementSpace> _fespace{nullptr}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "MFEMFECollection.h" | ||
|
||
registerMooseObject("PlatypusApp", MFEMFECollection); | ||
|
||
InputParameters | ||
MFEMFECollection::validParams() | ||
{ | ||
InputParameters params = MFEMGeneralUserObject::validParams(); | ||
params.registerBase("MFEMFECollection"); | ||
|
||
MooseEnum fec_order( | ||
"CONSTANT FIRST SECOND THIRD FOURTH FIFTH SIXTH SEVENTH EIGHTH NINTH TENTH ELEVENTH TWELFTH" | ||
"THIRTEENTH FOURTEENTH FIFTEENTH SIXTEENTH SEVENTEENTH EIGHTTEENTH NINETEENTH TWENTIETH " | ||
"TWENTYFIRST TWENTYSECOND TWENTYTHIRD TWENTYFOURTH TWENTYFIFTH TWENTYSIXTH TWENTYSEVENTH " | ||
"TWENTYEIGHTH TWENTYNINTH THIRTIETH THIRTYFIRST THIRTYSECOND THIRTYTHIRD THIRTYFOURTH " | ||
"THIRTYFIFTH THIRTYSIXTH THIRTYSEVENTH THIRTYEIGHTH THIRTYNINTH FORTIETH FORTYFIRST" | ||
"FORTYSECOND FORTYTHIRD", | ||
"FIRST", | ||
true); | ||
params.addParam<MooseEnum>("fec_order", fec_order, "Order of the FE shape function to use."); | ||
|
||
MooseEnum fec_types("H1 ND RT L2", "H1", true); | ||
params.addParam<MooseEnum>( | ||
"fec_type", fec_types, "Specifies the family of FE shape functions (FE space)."); | ||
|
||
return params; | ||
} | ||
|
||
MFEMFECollection::MFEMFECollection(const InputParameters & parameters) | ||
: MFEMGeneralUserObject(parameters), | ||
_fec_order(parameters.get<MooseEnum>("fec_order")), | ||
_fec_type(parameters.get<MooseEnum>("fec_type")), | ||
_fec_name(buildFECName()), | ||
_fec(buildFEC()) | ||
{ | ||
} | ||
|
||
const std::string | ||
MFEMFECollection::buildFECName() | ||
{ | ||
return _fec_type + "_3D_P" + std::to_string(_fec_order); | ||
} | ||
|
||
const std::shared_ptr<mfem::FiniteElementCollection> | ||
MFEMFECollection::buildFEC() | ||
{ | ||
auto * fec_ptr = mfem::FiniteElementCollection::New(_fec_name.c_str()); | ||
return std::shared_ptr<mfem::FiniteElementCollection>(fec_ptr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.