LCOV - code coverage report
Current view: top level - src/actioncomponents - ComponentMeshTransformHelper.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 39 42 92.9 %
Date: 2026-05-29 20:35:17 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      10             : #include "ComponentMeshTransformHelper.h"
      11             : #include "RotationMatrix.h"
      12             : #include "Factory.h"
      13             : #include "MooseApp.h"
      14             : 
      15             : InputParameters
      16         424 : ComponentMeshTransformHelper::validParams()
      17             : {
      18         424 :   auto params = ActionComponent::validParams();
      19             : 
      20             :   // If your component is 0D, you should make these two parameters private!
      21        1696 :   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        1696 :   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        1272 :   params.addParam<Point>(
      33         848 :       "position", Point(0., 0., 0.), "Vector to translate the mesh of this component by.");
      34             : 
      35        1272 :   params.addParamNamesToGroup("rotation direction position",
      36             :                               "Position and orientation of the component");
      37         424 :   return params;
      38           0 : }
      39             : 
      40         388 : ComponentMeshTransformHelper::ComponentMeshTransformHelper(const InputParameters & params)
      41             :   : ActionComponent(params),
      42         388 :     _rotation(queryParam<RealVectorValue>("rotation")),
      43         776 :     _direction(queryParam<RealVectorValue>("direction")),
      44        1164 :     _translation(getParam<Point>("position"))
      45             : {
      46         776 :   addRequiredTask("add_mesh_generator");
      47        1552 :   checkSecondParamNotSetIfFirstOneSet("rotation", "direction");
      48         388 : }
      49             : 
      50             : void
      51         388 : ComponentMeshTransformHelper::addMeshGenerators()
      52             : {
      53             :   // Rotate the mesh as desired
      54         388 :   if (_rotation || _direction)
      55             :   {
      56         756 :     InputParameters params = _factory.getValidParams("TransformGenerator");
      57         756 :     params.set<MeshGeneratorName>("input") = _mg_names.back();
      58             : 
      59         378 :     if (_rotation)
      60             :     {
      61           0 :       params.set<MooseEnum>("transform") = "ROTATE";
      62           0 :       params.set<RealVectorValue>("vector_value") = *_rotation;
      63             :     }
      64             :     else
      65             :     {
      66        1134 :       params.set<MooseEnum>("transform") = "ROTATE_WITH_MATRIX";
      67             : 
      68         378 :       RealVectorValue angles;
      69             :       const auto rotation_matrix =
      70         378 :           RotationMatrix::rodriguesRotationMatrix<false>(RealVectorValue(1, 0, 0), *_direction);
      71         378 :       params.set<RealTensorValue>("rotation_matrix") = rotation_matrix;
      72         378 :     }
      73         756 :     _app.getMeshGeneratorSystem().addMeshGenerator(
      74         756 :         "TransformGenerator", name() + "_rotated", params);
      75         378 :     _mg_names.push_back(name() + "_rotated");
      76         378 :   }
      77             : 
      78             :   // Add a translation
      79             :   {
      80         776 :     InputParameters params = _factory.getValidParams("TransformGenerator");
      81        1164 :     params.set<MeshGeneratorName>("input") = _mg_names.back();
      82        1164 :     params.set<MooseEnum>("transform") = "TRANSLATE";
      83        1552 :     params.set<RealVectorValue>("vector_value") = getParam<Point>("position");
      84         776 :     _app.getMeshGeneratorSystem().addMeshGenerator(
      85         776 :         "TransformGenerator", name() + "_translated", params);
      86         388 :     _mg_names.push_back(name() + "_translated");
      87         388 :   }
      88             : 
      89         388 :   setCurrentTopLevelMeshGeneratorName(_mg_names.back());
      90         388 : }

Generated by: LCOV version 1.14