KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
parametric_affine_transform.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main Authors: Máté Kelemen
11 //
12 
13 #pragma once
14 
15 // Project includes
18 #include "utilities/quaternion.h"
20 
21 namespace Kratos
22 {
23 
26 
27 
34 class KRATOS_API(MESH_MOVING_APPLICATION) ParametricAffineTransform : protected AffineTransform
35 {
36 public:
39 
41 
43 
47 
55  const Parameters angle,
56  const Parameters referencePoint,
57  const Parameters translationVector);
58 
65  ParametricAffineTransform(const Parameters eulerAngles,
66  const Parameters referencePoint,
67  const Parameters translationVector);
68 
72 
81  array_1d<double,3> Apply(const array_1d<double,3>& rPoint,
82  const double t,
83  const double X = 0.0,
84  const double Y = 0.0,
85  const double Z = 0.0);
86 
88 
89 private:
90 
93 
94  // Necessary to parse constants
95  static std::string ExtractFunctionBody(const Parameters parameters);
96 
98  template <std::size_t ArraySize>
99  class VectorFunction : public std::array<FunctionType::Pointer,ArraySize>
100  {
101  public:
102  VectorFunction(const Parameters rFunctions)
103  {
104  KRATOS_TRY
105 
106  KRATOS_ERROR_IF_NOT(rFunctions.IsArray()) << "VectorFunction can only be constructed from a parameter array";
107 
108  // Assign components - bounds checks are performed in Parameters::GetArrayItem
109  for (std::size_t i=0; i<ArraySize; ++i) {
110  const std::string function_string = ExtractFunctionBody(rFunctions.GetArrayItem(i));
111  this->at(i) = std::make_shared<GenericFunctionUtility>(function_string);
112  }
113 
114  KRATOS_CATCH("");
115  }
116 
117  VectorFunction(const VectorFunction<ArraySize>& rOther) = default;
118 
119  array_1d<double,ArraySize> operator()(const double x,
120  const double y,
121  const double z,
122  const double t,
123  const double X,
124  const double Y,
125  const double Z)
126  {
127  KRATOS_TRY
128 
129  array_1d<double,ArraySize> output;
130 
131  for (std::size_t i=0; i<ArraySize; ++i) {
132  output[i] = this->at(i)->CallFunction(x, y, z, t, X, Y, Z);
133  }
134 
135  return output;
136 
137  KRATOS_CATCH("");
138  }
139  }; // class VectorFunction
140 
144 
145  VectorFunction<3> mReferencePointFunction;
146 
147  VectorFunction<3> mTranslationVectorFunction;
148 
149  // The quaternion getter has to be defined at runtime, depending on how the rotation was defined
150  std::function<Quaternion<double>(const double, const double, const double, const double, const double, const double, const double)> mQuaternionFunction;
151 
152  // Store the last quaternion to compare to new ones
153  Quaternion<double> mQuaternion;
154 
156 }; // class ParametricAffineTransform
157 
158 
160 
161 } // namespace Kratos
Class for applying affine transformations.
Definition: affine_transform.h:41
GenericFunctionUtility.
Definition: function_parser_utility.h:208
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Parameters GetArrayItem(const IndexType Index)
This method returns an array item given an index.
Definition: kratos_parameters.cpp:1020
bool IsArray() const
This method checks if the parameter is an array.
Definition: kratos_parameters.cpp:576
Class for applying parametrically defined affine transformations.
Definition: parametric_affine_transform.h:35
KRATOS_CLASS_POINTER_DEFINITION(ParametricAffineTransform)
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR_IF_NOT(conditional)
Definition: exception.h:163
z
Definition: GenerateWind.py:163
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
axis
Definition: all_t_win_vs_m_fixed_error.py:239
parameters
Definition: fluid_chimera_analysis.py:35
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
output
Definition: generate_frictional_mortar_condition.py:444
int t
Definition: ode_solve.py:392
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17