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' = ",
60std::unique_ptr<MeshBase>
63 std::unique_ptr<MeshBase>
mesh = std::move(
_input);
65 RealVectorValue vector_value;
66 RealTensorValue rotation_matrix;
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();
121 return dynamic_pointer_cast<MeshBase>(
mesh);
131 const auto R = RealTensorValue::extrinsic_rotation_matrix(
137 mesh.unset_has_cached_elem_data();
139 for (
auto & node :
mesh.node_ptr_range())
145 libmesh_ignore(
mesh, alpha, beta, gamma);
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;
167 libmesh_ignore(
mesh, phi, theta, psi);
169 "MeshTools::Modification::rotate() requires libMesh to be compiled with LIBMESH_DIM==3");
Moose::GenericType< RealTensorValue, is_ad > GenericRealTensorValue
MeshGenerators are objects that can modify or add to an existing mesh.
static InputParameters validParams()
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 ...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...