11 #include "libmesh/mesh_modification.h" 14 #include "libmesh/mesh_tools.h" 21 MooseEnum transforms(
"TRANSLATE=1 TRANSLATE_CENTER_ORIGIN=2 TRANSLATE_MIN_ORIGIN=3 ROTATE=4 " 22 "SCALE=5 ROTATE_WITH_MATRIX=6 ROTATE_EXT=7");
26 params.
addRequiredParam<MeshGeneratorName>(
"input",
"The mesh we want to modify");
31 "The type of transformation to perform (TRANSLATE, TRANSLATE_CENTER_ORIGIN, " 32 "TRANSLATE_MIN_ORIGIN, ROTATE, SCALE, ROTATE_WITH_MATRIX, ROTATE_EXT)");
35 "The value to use for the transformation. When using TRANSLATE or SCALE, the " 36 "xyz coordinates are applied in each direction respectively. When using " 37 "ROTATE, the values are interpreted as the Euler angles phi, theta and psi " 38 "given in degrees. For ROTATE_EXT, an extrinsic rotation is carried out using prescribed " 39 "Euler angles alpha, beta, and gamma in degrees.");
42 "Precomputed extrinsic rotation matrix to be applied to mesh (ROTATE_WITH_MATRIX option).");
49 _input(getMesh(
"input")),
50 _transform(getParam<
MooseEnum>(
"transform"))
56 "The parameter 'vector_value' must be supplied with 'transform' = ",
60 std::unique_ptr<MeshBase>
63 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
69 const auto bbox = MeshTools::create_bounding_box(*
mesh);
71 vector_value = -0.5 * (bbox.max() + bbox.min());
73 vector_value = -bbox.min();
76 rotation_matrix = getParam<RealTensorValue>(
"rotation_matrix");
78 vector_value = getParam<RealVectorValue>(
"vector_value");
82 mesh->clear_point_locator();
89 MeshTools::Modification::translate(*
mesh, vector_value(0), vector_value(1), vector_value(2));
94 mesh->unset_has_cached_elem_data();
97 MeshTools::Modification::rotate(*
mesh, vector_value(0), vector_value(1), vector_value(2));
103 mesh->unset_has_cached_elem_data();
106 MeshTools::Modification::scale(*
mesh, vector_value(0), vector_value(1), vector_value(2));
110 mesh->unset_has_cached_elem_data();
120 mesh->unset_is_prepared();
131 const auto R = RealTensorValue::extrinsic_rotation_matrix(
137 mesh.unset_has_cached_elem_data();
139 for (
auto & node :
mesh.node_ptr_range())
147 "MeshTools::Modification::rotate() requires libMesh to be compiled with LIBMESH_DIM==3");
158 mesh.unset_has_cached_elem_data();
160 for (
auto & node :
mesh.node_ptr_range())
163 pt = rotation_matrix * pt;
169 "MeshTools::Modification::rotate() requires libMesh to be compiled with LIBMESH_DIM==3");
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 ...
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.
Moose::GenericType< RealTensorValue, is_ad > GenericRealTensorValue
TensorValue< Real > RealTensorValue
void libmesh_ignore(const Args &...)
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
static InputParameters validParams()
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
MeshGenerators are objects that can modify or add to an existing mesh.