https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ComponentMeshTransformHelper.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11#include "RotationMatrix.h"
12#include "Factory.h"
13#include "MooseApp.h"
14
17{
18 auto params = ActionComponent::validParams();
19
20 // If your component is 0D, you should make these two parameters private!
21 params.addParam<RealVectorValue>(
22 "rotation",
23 "Rotation angles (XZX convention, in degrees NOT radians) to rotate the "
24 "mesh of this component with. Note that this rotation "
25 "is applied before the translation.");
26 params.addParam<RealVectorValue>(
27 "direction",
28 "Direction to orient the component mesh with, assuming it is initially oriented along the "
29 "X-axis (1, 0, 0). Note that this rotation is applied before the translation. Note that "
30 "specifying the direction is an alternative to specifying the 'rotation'");
31 // Position is widely applicable to components
32 params.addParam<Point>(
33 "position", Point(0., 0., 0.), "Vector to translate the mesh of this component by.");
34
35 params.addParamNamesToGroup("rotation direction position",
36 "Position and orientation of the component");
37 return params;
38}
39
41 : ActionComponent(params),
42 _rotation(queryParam<RealVectorValue>("rotation")),
43 _direction(queryParam<RealVectorValue>("direction")),
44 _translation(getParam<Point>("position"))
45{
46 addRequiredTask("add_mesh_generator");
47 checkSecondParamNotSetIfFirstOneSet("rotation", "direction");
48}
49
50void
52{
53 // Rotate the mesh as desired
54 if (_rotation || _direction)
55 {
56 InputParameters params = _factory.getValidParams("TransformGenerator");
57 params.set<MeshGeneratorName>("input") = _mg_names.back();
58
59 if (_rotation)
60 {
61 params.set<MooseEnum>("transform") = "ROTATE";
62 params.set<RealVectorValue>("vector_value") = *_rotation;
63 }
64 else
65 {
66 params.set<MooseEnum>("transform") = "ROTATE_WITH_MATRIX";
67
68 RealVectorValue angles;
69 const auto rotation_matrix =
70 RotationMatrix::rodriguesRotationMatrix<false>(RealVectorValue(1, 0, 0), *_direction);
71 params.set<RealTensorValue>("rotation_matrix") = rotation_matrix;
72 }
74 "TransformGenerator", name() + "_rotated", params);
75 _mg_names.push_back(name() + "_rotated");
76 }
77
78 // Add a translation
79 {
80 InputParameters params = _factory.getValidParams("TransformGenerator");
81 params.set<MeshGeneratorName>("input") = _mg_names.back();
82 params.set<MooseEnum>("transform") = "TRANSLATE";
83 params.set<RealVectorValue>("vector_value") = getParam<Point>("position");
85 "TransformGenerator", name() + "_translated", params);
86 _mg_names.push_back(name() + "_translated");
87 }
88
90}
Base class for components that are defined using an action.
std::vector< MeshGeneratorName > _mg_names
Name(s) of the final mesh generator(s) creating the mesh for the component.
void addRequiredTask(const std::string &task)
Add a new required task for all physics deriving from this class NOTE: This does not register the tas...
static InputParameters validParams()
void setCurrentTopLevelMeshGeneratorName(const MeshGeneratorName &mg_name)
Set the name of the final mesh generator that contains this component.
MooseApp & _app
The MOOSE application this is associated with.
Definition MooseBase.h:375
const RealVectorValue *const _direction
Direction vector (easier to conceptualize than rotation)
const RealVectorValue *const _rotation
Rotation angles.
ComponentMeshTransformHelper(const InputParameters &params)
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
Definition Factory.C:68
void checkSecondParamNotSetIfFirstOneSet(const std::string &param1, const std::string &param2) const
Check that a parameter is not set if the first one is set.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
void addMeshGenerator(const std::string &type, const std::string &name, const InputParameters &params)
Add a mesh generator that will act on the meshes in the system.
MeshGeneratorSystem & getMeshGeneratorSystem()
Gets the system that manages the MeshGenerators.
Definition MooseApp.h:886
const std::string & name() const
Get the name of the class.
Definition MooseBase.h:103
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
Factory & _factory
The Factory associated with the MooseApp.