13 #include "libmesh/replicated_mesh.h" 14 #include "libmesh/string_to_enum.h" 27 params.
addParam<MeshGeneratorName>(
"input",
"Optional input mesh to add the elements to");
30 "The x,y,z positions of the nodes");
33 "List of nodes to use for each element");
36 "elem_type",
elem_types,
"The type of element from libMesh to generate");
38 params.
addClassDescription(
"Generates individual elements given a list of nodal positions.");
45 _input(getMesh(
"input", true)),
46 _nodal_positions(getParam<
std::vector<Point>>(
"nodal_positions")),
47 _element_connectivity(getParam<
std::vector<
dof_id_type>>(
"element_connectivity")),
48 _elem_type(getParam<
MooseEnum>(
"elem_type"))
55 return Elem::build(Utility::string_to_enum<ElemType>(
type)).release();
58 std::unique_ptr<MeshBase>
61 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
67 MooseEnum elem_type_enum = getParam<MooseEnum>(
"elem_type");
70 mesh->set_mesh_dimension(
std::max((
unsigned int)elem->dim(),
mesh->mesh_dimension()));
72 std::vector<Node *> nodes;
78 nodes.push_back(
mesh->add_point(point));
82 auto n = elem->n_nodes();
86 for (
unsigned int j = 0; j < n; j++)
90 elem->subdomain_id() = 0;
const std::string LIST_GEOM_ELEM
Elem * getElemType(const std::string &type)
std::unique_ptr< MeshBase > & _input
Mesh that possibly comes from another generator.
const std::vector< Point > & _nodal_positions
The nodal positions.
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
ElementGenerator(const InputParameters ¶meters)
const std::vector< dof_id_type > & _element_connectivity
The connectivity of the elements to the nodes.
auto max(const L &left, const R &right)
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
Generates individual elements given a list of nodal positions.
registerMooseObject("MooseApp", ElementGenerator)
const std::string & type() const
Get the type of this class.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
static InputParameters validParams()
static InputParameters validParams()
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
Build a MeshBase object whose underlying type will be determined by the Mesh input file block...
MeshGenerators are objects that can modify or add to an existing mesh.