Go to the documentation of this file.
13 #include "libmesh/replicated_mesh.h"
17 #include "libmesh/edge_edge2.h"
18 #include "libmesh/edge_edge3.h"
19 #include "libmesh/edge_edge4.h"
20 #include "libmesh/face_quad4.h"
21 #include "libmesh/face_quad8.h"
22 #include "libmesh/face_quad9.h"
23 #include "libmesh/face_tri3.h"
24 #include "libmesh/face_tri6.h"
25 #include "libmesh/cell_hex8.h"
26 #include "libmesh/cell_hex20.h"
27 #include "libmesh/cell_hex27.h"
28 #include "libmesh/cell_tet4.h"
29 #include "libmesh/cell_tet10.h"
30 #include "libmesh/cell_prism6.h"
31 #include "libmesh/cell_prism15.h"
32 #include "libmesh/cell_prism18.h"
33 #include "libmesh/cell_pyramid5.h"
34 #include "libmesh/cell_pyramid13.h"
35 #include "libmesh/cell_pyramid14.h"
46 MooseEnum elem_types(
"EDGE2 EDGE3 EDGE4 QUAD4 QUAD8 QUAD9 TRI3 TRI6 HEX8 HEX20 HEX27 TET4 TET10 "
47 "PRISM6 PRISM15 PRISM18 PYRAMID5 PYRAMID13 PYRAMID14");
49 params.
addParam<MeshGeneratorName>(
"input",
"Optional input mesh to add the elements to");
52 "The x,y,z positions of the nodes");
55 "List of nodes to use for each element");
59 "The type of element from libMesh to "
67 _input(getMesh(
"input")),
68 _nodal_positions(getParam<
std::vector<Point>>(
"nodal_positions")),
69 _element_connectivity(getParam<
std::vector<dof_id_type>>(
"element_connectivity")),
70 _elem_type(getParam<
MooseEnum>(
"elem_type"))
79 Elem * elem =
new Edge2;
84 Elem * elem =
new Edge3;
89 Elem * elem =
new Edge4;
94 Elem * elem =
new Quad4;
99 Elem * elem =
new Quad8;
104 Elem * elem =
new Quad9;
109 Elem * elem =
new Tri3;
114 Elem * elem =
new Tri6;
119 Elem * elem =
new Hex8;
124 Elem * elem =
new Hex20;
129 Elem * elem =
new Hex27;
134 Elem * elem =
new Tet4;
139 Elem * elem =
new Tet10;
142 if (
type ==
"PRISM6")
144 Elem * elem =
new Prism6;
147 if (
type ==
"PRISM15")
149 Elem * elem =
new Prism15;
152 if (
type ==
"PRISM18")
154 Elem * elem =
new Prism18;
157 if (
type ==
"PYRAMID5")
159 Elem * elem =
new Pyramid5;
162 if (
type ==
"PYRAMID13")
164 Elem * elem =
new Pyramid13;
167 if (
type ==
"PYRAMID14")
169 Elem * elem =
new Pyramid14;
173 mooseError(
"This element type is not available.");
176 std::unique_ptr<MeshBase>
179 std::unique_ptr<MeshBase> mesh = std::move(
_input);
183 mesh =
_mesh->buildMeshBaseObject();
185 MooseEnum elem_type_enum = getParam<MooseEnum>(
"elem_type");
188 mesh->set_mesh_dimension(std::max((
unsigned int)elem->dim(), mesh->mesh_dimension()));
190 std::vector<Node *> nodes;
196 nodes.push_back(mesh->add_point(point));
198 mesh->add_elem(elem);
200 auto n = elem->n_nodes();
204 for (
unsigned int j = 0; j <
n; j++)
208 elem->subdomain_id() = 0;
211 return dynamic_pointer_cast<MeshBase>(mesh);
ElementGenerator(const InputParameters ¶meters)
static InputParameters validParams()
void mooseError(Args &&... args) const
const std::string & type() const
Get the type of this object.
MeshGenerators are objects that can modify or add to an existing mesh.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
defineLegacyParams(ElementGenerator)
std::shared_ptr< MooseMesh > & _mesh
References to the mesh and displaced mesh (currently in the ActionWarehouse)
registerMooseObject("MooseApp", ElementGenerator)
Elem * getElemType(const std::string &type)
Generates individual elements given a list of nodal positions.
const std::vector< Point > & _nodal_positions
The nodal positions.
static InputParameters validParams()
Constructor.
const std::vector< dof_id_type > & _element_connectivity
The connectivity of the elements to the nodes.
std::unique_ptr< MeshBase > & _input
Mesh that possibly comes from another generator.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.