10#ifdef MOOSE_MFEM_ENABLED
24 params.
addParam<
unsigned int>(
"nx", 1,
"Number of elements in the x direction.");
25 params.
addParam<
unsigned int>(
"ny", 1,
"Number of elements in the y direction.");
26 params.
addParam<
unsigned int>(
"nz", 1,
"Number of elements in the z direction.");
28 params.
addParam<Real>(
"xmax", 1.0,
"Upper bound of the domain in the x direction.");
29 params.
addParam<Real>(
"ymax", 1.0,
"Upper bound of the domain in the y direction.");
30 params.
addParam<Real>(
"zmax", 1.0,
"Upper bound of the domain in the z direction.");
37 MooseEnum elem_types(
"EDGE=1 TRI=2 QUAD=3 TET=4 HEX=5");
40 "Element type. Use EDGE for 1D meshes, TRI or QUAD for 2D meshes, "
41 "TET or HEX for 3D meshes. If not specified, defaults to EDGE for "
42 "1D, QUAD for 2D, and HEX for 3D.");
44 params.
addClassDescription(
"Generates a structured Cartesian MFEM mesh (line, rectangle, or box) "
45 "with uniformly spaced elements.");
53 _nx(getParam<unsigned
int>(
"nx")),
54 _ny(getParam<unsigned
int>(
"ny")),
55 _nz(getParam<unsigned
int>(
"nz")),
56 _xmax(getParam<Real>(
"xmax")),
57 _ymax(getParam<Real>(
"ymax")),
58 _zmax(getParam<Real>(
"zmax")),
66 return mfem::Element::SEGMENT;
68 return mfem::Element::QUADRILATERAL;
69 return mfem::Element::HEXAHEDRON;
72 const auto elem_type = getParam<MooseEnum>(
"elem_type").getEnum<mfem::Element::Type>();
73 if ((
_dim == 1 && elem_type != mfem::Element::SEGMENT) ||
74 (
_dim == 2 && elem_type != mfem::Element::TRIANGLE &&
75 elem_type != mfem::Element::QUADRILATERAL) ||
76 (
_dim == 3 && elem_type != mfem::Element::TETRAHEDRON &&
77 elem_type != mfem::Element::HEXAHEDRON))
79 "Use EDGE for 1D meshes, TRI or QUAD for 2D meshes, "
80 "and TET or HEX for 3D meshes.");
89addBdrSet(mfem::Mesh & mesh,
int attr,
const std::string & name)
91 mesh.bdr_attribute_sets.SetAttributeSet(name, mfem::Array<int>{attr});
95std::unique_ptr<mfem::Mesh>
100 auto mesh = std::make_unique<mfem::Mesh>(mfem::Mesh::MakeCartesian1D(
_nx,
_xmax));
101 addBdrSet(*
mesh, 1,
"left");
102 addBdrSet(*
mesh, 2,
"right");
108 auto mesh = std::make_unique<mfem::Mesh>(
110 addBdrSet(*
mesh, 1,
"bottom");
111 addBdrSet(*
mesh, 2,
"right");
112 addBdrSet(*
mesh, 3,
"top");
113 addBdrSet(*
mesh, 4,
"left");
118 auto mesh = std::make_unique<mfem::Mesh>(
120 addBdrSet(*
mesh, 1,
"bottom");
121 addBdrSet(*
mesh, 2,
"front");
122 addBdrSet(*
mesh, 3,
"right");
123 addBdrSet(*
mesh, 4,
"back");
124 addBdrSet(*
mesh, 5,
"left");
125 addBdrSet(*
mesh, 6,
"top");
registerMooseObject("MooseApp", MFEMGeneratedMeshGenerator)
void ErrorVector unsigned int
Generates a structured Cartesian MFEM mesh: a line (1D), rectangle (2D), or box (3D) with uniformly s...
const Real _ymax
Upper bound of the domain in the y direction (lower bound is 0)
const unsigned int _dim
Mesh dimension (1, 2, or 3)
const unsigned int _ny
Number of elements in the y direction.
const Real _xmax
Upper bound of the domain in the x direction (lower bound is 0)
const unsigned int _nz
Number of elements in the z direction.
const unsigned int _nx
Number of elements in the x direction.
const Real _zmax
Upper bound of the domain in the z direction (lower bound is 0)
static InputParameters validParams()
std::unique_ptr< mfem::Mesh > generateMFEMMesh() override
Implement this to produce the mfem::Mesh for this generator.
MFEMGeneratedMeshGenerator(const InputParameters ¶meters)
const mfem::Element::Type _elem_type
Element type (resolved from user input or dimension-based default); unused for dim == 1.
Abstract base class for MFEM-native mesh generators.
static InputParameters validParams()
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
bool isParamSetByUser(const std::string &name) const
Test if the supplied parameter is set by a user, as opposed to not set or set to default.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...