13 #include "libmesh/replicated_mesh.h" 14 #include "libmesh/distributed_mesh.h" 15 #include "libmesh/boundary_info.h" 16 #include "libmesh/mesh_modification.h" 17 #include "libmesh/bounding_box.h" 18 #include "libmesh/mesh_tools.h" 19 #include "libmesh/point.h" 35 "The meshes we want to stitch together");
37 params.
addParam<
Real>(
"bottom_height", 0,
"The height of the bottom of the final mesh");
40 params.
addParam<BoundaryName>(
"top_boundary",
"top",
"name of the top (y) boundary");
41 params.
addParam<BoundaryName>(
"bottom_boundary",
"bottom",
"name of the bottom (y) boundary");
44 params.
addParam<BoundaryName>(
"front_boundary",
"front",
"name of the front (z) boundary");
45 params.
addParam<BoundaryName>(
"back_boundary",
"back",
"name of the back (z) boundary");
55 _mesh_ptrs(getMeshes(
"inputs")),
56 _input_names(getParam<
std::vector<MeshGeneratorName>>(
"inputs")),
57 _bottom_height(getParam<
Real>(
"bottom_height"))
61 std::unique_ptr<MeshBase>
66 mooseError(
"StackGenerator only works with ReplicatedMesh : mesh from Meshgenerator ",
68 "is not a ReplicatedMesh.");
70 int dim =
static_cast<int>(
_dim);
72 if (
dim !=
int(
mesh->mesh_dimension()))
74 "incompatible mesh dimensions: dim=",
76 " and first mesh dimension is ",
77 mesh->mesh_dimension());
90 mooseError(
"StackGenerator only works with ReplicatedMesh : mesh from Meshgenerator ",
92 "is not a ReplicatedMesh.");
93 if (static_cast<int>(
_meshes[i]->mesh_dimension()) !=
dim)
98 std::vector<BoundaryName> boundary_names = {getParam<BoundaryName>(
"top_boundary"),
99 getParam<BoundaryName>(
"bottom_boundary")};
101 boundary_names = {getParam<BoundaryName>(
"front_boundary"),
102 getParam<BoundaryName>(
"back_boundary")};
104 std::vector<boundary_id_type> ids =
107 mooseAssert(ids.size() == boundary_names.size(),
108 "Unexpected number of ids returned for MooseMeshUtils::getBoundaryIDs");
113 std::vector<Real> heights;
135 MeshTools::Modification::translate(*
_meshes[i], 0, heights[i], 0);
138 MeshTools::Modification::translate(*
_meshes[i], 0, 0, heights[i]);
142 *
_meshes[i], first, second, TOLERANCE,
true);
151 BoundingBox bbox = MeshTools::create_bounding_box(
mesh);
152 return bbox.max()(
dim - 1) - bbox.min()(
dim - 1);
const std::vector< MeshGeneratorName > & _input_names
The meshgenerators to read.
StackGenerator(const InputParameters ¶meters)
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
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.
registerMooseObject("MooseApp", StackGenerator)
const std::vector< std::unique_ptr< MeshBase > * > _mesh_ptrs
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
std::vector< std::unique_ptr< ReplicatedMesh > > _meshes
The meshes to be stitched together.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
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 ...
const Real _bottom_height
Height (z) of the bottom of the final mesh.
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
Real computeWidth(const MeshBase &mesh, const int &dim)
static InputParameters validParams()
MeshGenerators are objects that can modify or add to an existing mesh.
const MooseEnum _dim
The dimension of the mesh.
Take several 3D meshes and stitch them on top of each other like a stack.