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");
31 "The x,y,z positions of the nodes");
33 "List of nodes to use for each element");
35 "elem_type",
elem_types,
"The type of element from libMesh to generate");
38 params.
addParam<SubdomainName>(
"subdomain_name",
"Subdomain name");
41 params.
addParam<
bool>(
"create_sidesets",
43 "Create separate sidesets for each side. " 44 "The side index is used as the boundary ID for each sideset.");
46 params.
addClassDescription(
"Generates individual elements given a list of nodal positions.");
53 _input(getMesh(
"input", true)),
54 _nodal_positions(getParam<
std::vector<Point>>(
"nodal_positions")),
55 _element_connectivity(getParam<
std::vector<
dof_id_type>>(
"element_connectivity")),
56 _elem_type(getParam<
MooseEnum>(
"elem_type"))
63 return Elem::build(Utility::string_to_enum<ElemType>(
type)).release();
66 std::unique_ptr<MeshBase>
69 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
75 MooseEnum elem_type_enum = getParam<MooseEnum>(
"elem_type");
77 elem->subdomain_id() = getParam<SubdomainID>(
"subdomain_id");
79 mesh->subdomain_name(getParam<SubdomainID>(
"subdomain_id")) =
80 getParam<SubdomainName>(
"subdomain_name");
82 mesh->set_mesh_dimension(
std::max((
unsigned int)elem->dim(),
mesh->mesh_dimension()));
84 std::vector<Node *> nodes;
90 nodes.push_back(
mesh->add_point(point));
94 auto n = elem->n_nodes();
98 for (
unsigned int j = 0; j < n; j++)
105 mesh->set_isnt_prepared();
107 if (getParam<bool>(
"create_sidesets"))
108 for (
const auto i_side :
make_range(elem->n_sides()))
109 mesh->get_boundary_info().add_side(elem, i_side, i_side);
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)
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
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()
IntRange< T > make_range(T beg, T end)
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.