16 #include "libmesh/elem.h" 17 #include "libmesh/int_range.h" 18 #include "libmesh/unstructured_mesh.h" 27 params.
addParam<std::vector<Point>>(
"points",
"The points defining the polyline, in order");
29 params.
addParam<
bool>(
"loop",
false,
"Whether edges should form a closed loop");
32 "start_boundary",
"start",
"Boundary to assign to (non-looped) polyline start");
35 "end_boundary",
"end",
"Boundary to assign to (non-looped) polyline end");
38 "num_edges_between_points", 1,
"How many Edge elements to build between each point pair");
47 _points(getParam<
std::vector<Point>>(
"points")),
48 _loop(getParam<bool>(
"loop")),
49 _start_boundary(getParam<BoundaryName>(
"start_boundary")),
50 _end_boundary(getParam<BoundaryName>(
"end_boundary")),
51 _num_edges_between_points(getParam<unsigned
int>(
"num_edges_between_points"))
54 paramError(
"points",
"At least 2 points are needed to define a polyline");
57 paramError(
"points",
"At least 3 points are needed to define a polygon");
60 std::unique_ptr<MeshBase>
64 MeshBase &
mesh = *uptr_mesh;
66 const auto n_points =
_points.size();
73 if (!
_loop && (i + 1) == n_points)
76 const auto ip1 = (i + 1) % n_points;
87 const auto n_segments =
_loop ? n_points : (n_points - 1);
92 const auto ip1 = (i + 1) % max_nodes;
93 auto elem = Elem::build(
EDGE2);
94 elem->set_node(0,
mesh.node_ptr(i));
95 elem->set_node(1,
mesh.node_ptr(ip1));
97 mesh.add_elem(std::move(elem));
102 BoundaryInfo & bi =
mesh.get_boundary_info();
105 bi.add_side(
mesh.elem_ptr(0), 0, ids[0]);
106 bi.add_side(
mesh.elem_ptr(
n_elem - 1), 1, ids[1]);
109 mesh.prepare_for_use();
Generates a polyline (open ended or looped) of Edge elements through a series of nodal locations and ...
static InputParameters validParams()
registerMooseObject("MooseApp", PolyLineMeshGenerator)
const BoundaryName _start_boundary
Boundary names to assign to (non-looped) polyline start and end.
PolyLineMeshGenerator(const InputParameters ¶meters)
const bool _loop
Whether edges should form a closed loop.
std::vector< BoundaryID > getBoundaryIDs(const libMesh::MeshBase &mesh, const std::vector< BoundaryName > &boundary_name, bool generate_unknown, const std::set< BoundaryID > &mesh_boundary_ids)
Gets the boundary IDs with their names.
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 ...
static InputParameters validParams()
const BoundaryName _end_boundary
const std::vector< Point > _points
The points defining the polyline, in order.
IntRange< T > make_range(T beg, T end)
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
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.
void ErrorVector unsigned int
const unsigned int _num_edges_between_points
How many Edge elements to build between each point pair.