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.
element_size_calculator.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 author: Jordi Cotela
11 //
12 
13 #if !defined(KRATOS_ELEMENT_SIZE_CALCULATOR_H )
14 #define KRATOS_ELEMENT_SIZE_CALCULATOR_H
15 
16 // External includes
17 
18 // Project includes
19 #include "includes/node.h"
20 #include "includes/define.h"
21 #include "geometries/geometry.h"
22 #include "utilities/math_utils.h"
23 
24 
25 namespace Kratos
26 {
29 
32 
36 
40 
44 
48 
50 template< std::size_t TDim, std::size_t TNumNodes >
51 class KRATOS_API(KRATOS_CORE) ElementSizeCalculator {
52 public:
55 
58 
60 
64 
65  // Deleted default constructor
67 
70 
73 
77 
80 
84 
86 
89  static double MinimumElementSize(const Geometry<Node >& rGeometry);
90 
92 
98  const unsigned int DerivativeNodeIndex,
99  const unsigned int DerivativeDirectionIndex,
100  const Geometry<Node >& rGeometry);
101 
103 
106  static double AverageElementSize(const Geometry<Node >& rGeometry);
107 
109 
115  const unsigned int DerivativeNodeIndex,
116  const unsigned int DerivativeDirectionIndex,
117  const Geometry<Node >& rGeometry);
118 
120 
124  static double ProjectedElementSize(const Geometry<Node >& rGeometry, const array_1d<double,3>& rVelocity);
125 
127 
130  static double GradientsElementSize(const BoundedMatrix<double, 3, 2>& rDN_DX);
131 
132 
134 
137  static double GradientsElementSize(const BoundedMatrix<double, 4, 3>& rDN_DX);
138 
140 
141 private:
144 
145  static inline double HsqDerivative2D(
146  const double Vx,
147  const double VxDerivative,
148  const double Nx,
149  const double NxDerivative,
150  const double Vy,
151  const double VyDerivative,
152  const double Ny,
153  const double NyDerivative)
154  {
155  return 2 * (Vx * Nx + Vy * Ny) *
156  (VxDerivative * Nx + Vx * NxDerivative + VyDerivative * Ny +
157  Vy * NyDerivative) / (Nx * Nx + Ny * Ny) -
158  std::pow((Vx * Nx + Vy * Ny) / (Nx * Nx + Ny * Ny), 2) *
159  (2 * Nx * NxDerivative + 2 * Ny * NyDerivative);
160  }
161 
162  static inline double HsqDerivative3D(
163  const double Vx,
164  const double VxDerivative,
165  const double Nx,
166  const double NxDerivative,
167  const double Vy,
168  const double VyDerivative,
169  const double Ny,
170  const double NyDerivative,
171  const double Vz,
172  const double VzDerivative,
173  const double Nz,
174  const double NzDerivative)
175  {
176  return 2 * (Vx * Nx + Vy * Ny + Vz * Nz) *
177  (VxDerivative * Nx + Vx * NxDerivative + VyDerivative * Ny +
178  Vy * NyDerivative + VzDerivative * Nz + Vz * NzDerivative) / (Nx * Nx + Ny * Ny + Nz * Nz) -
179  std::pow((Vx * Nx + Vy * Ny + Vz * Nz) / (Nx * Nx + Ny * Ny + Nz * Nz), 2) *
180  (2 * Nx * NxDerivative + 2 * Ny * NyDerivative + 2 * Nz * NzDerivative);
181  }
182 
183  static inline double NormSquareDerivative(
184  const array_1d<double, 3>& rValue,
185  const array_1d<double, 3>& rValueDerivative)
186  {
187  return 2 * inner_prod(rValue, rValueDerivative);
188  }
189 
190  static inline double EdgeLengthDerivative(
191  const unsigned int DerivativeNodeIndex,
192  const unsigned int DerivativeDirectionIndex,
193  const unsigned int NodeIndexA,
194  const unsigned int NodeIndexB,
195  const unsigned int EdgeDirection)
196  {
197  return ((DerivativeNodeIndex == NodeIndexA) - (DerivativeNodeIndex == NodeIndexB)) * (DerivativeDirectionIndex == EdgeDirection);
198  }
199 
201 
202 }; // Class ElementSizeCalculator
203 
205 
207 
208 } // namespace Kratos.
209 
210 #endif // KRATOS_ELEMENT_SIZE_CALCULATOR_H defined
A collection of functions to compute element size, to be used as the h parameter in stabilized CFD fo...
Definition: element_size_calculator.h:51
static double MinimumElementSizeDerivative(const unsigned int DerivativeNodeIndex, const unsigned int DerivativeDirectionIndex, const Geometry< Node > &rGeometry)
Minimum element size derivative based on the geometry.
BoundedMatrix< double, TNumNodes, TDim > ShapeDerivativesType
Definition: element_size_calculator.h:59
static double AverageElementSize(const Geometry< Node > &rGeometry)
Average element size based on the geometry.
static double AverageElementSizeDerivative(const unsigned int DerivativeNodeIndex, const unsigned int DerivativeDirectionIndex, const Geometry< Node > &rGeometry)
Average element size derivative based on the geometry.
static double MinimumElementSize(const Geometry< Node > &rGeometry)
Minimum element size based on the geometry.
ElementSizeCalculator & operator=(ElementSizeCalculator const &rOther)=delete
Deleted assignment operator.
KRATOS_CLASS_POINTER_DEFINITION(ElementSizeCalculator)
Pointer definition of ElementSizeCalculator.
ElementSizeCalculator(ElementSizeCalculator const &rOther)=delete
Deleted copy constructor.
static double ProjectedElementSize(const Geometry< Node > &rGeometry, const array_1d< double, 3 > &rVelocity)
Projected element size in the direction of the velocity vector.
Geometry base class.
Definition: geometry.h:71
Definition: amatrix_interface.h:41
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592