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.
qs_vms_derivative_utilities.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: Suneth Warnakulasuriya
11 //
12 
13 #pragma once
14 
15 // System includes
16 #include <array>
17 
18 // External includes
19 
20 // Project includes
21 #include "containers/variable.h"
23 #include "geometries/geometry.h"
25 #include "includes/node.h"
26 #include "includes/process_info.h"
29 
30 // Application includes
32 
33 namespace Kratos
34 {
37 
51 template <unsigned int TDim>
53 {
54 public:
57 
58  using NodeType = Node;
59 
61 
62  using IndexType = std::size_t;
63 
64  using DependentVariablesListType = std::vector<
65  std::tuple<
66  const Variable<double>&,
67  std::vector<const Variable<double>*>
68  >
69  >;
70 
71  using DerivativeGradientsArray = std::array<const Variable<double>*, 9>;
72 
73  constexpr static IndexType TStrainSize = (TDim - 1) * 3; // 3 in 2D, 6 in 3D
74 
78 
79  // Ask Ruben: This is redundant code, can we agree to
80  // create qvms_utilities.h, and store this there to be used in primal and adjoint analysis?
81  static void CalculateStrainRate(
82  Vector& rOutput,
83  const Matrix& rNodalVelocity,
84  const Matrix& rdNdX);
85 
86  static const std::array<const Variable<double>*, TStrainSize> GetStrainRateVariables();
87 
91 
99  template<unsigned int TComponentIndex = 0>
101  {
102  public:
105 
106  static constexpr IndexType ComponentIndex = TComponentIndex;
107 
111 
112  Derivative(
113  const IndexType NodeIndex,
114  const GeometryType& rGeometry,
115  const double W,
116  const Vector& rN,
117  const Matrix& rdNdX,
118  const double WDerivative,
119  const double DetJDerivative,
120  const Matrix& rdNdXDerivative);
121 
125 
127 
129 
130  protected:
133 
136  const double mW;
137  const Vector& mrN;
138  const Matrix& mrdNdX;
139  const double mWDerivative;
140  const double mDetJDerivative;
142 
144  };
145 
155  template<unsigned int TNumNodes, unsigned int TComponentIndex>
156  class VelocityDerivative : public Derivative<TComponentIndex>
157  {
158  public:
161 
163 
165 
166  static constexpr double VelocityDerivativeFactor = 1.0;
167 
168  static constexpr double PressureDerivativeFactor = 0.0;
169 
170  static constexpr unsigned int TDerivativeDimension = TDim;
171 
175 
177  const IndexType NodeIndex,
178  const GeometryType& rGeometry,
179  const double W,
180  const Vector& rN,
181  const Matrix& rdNdX,
182  const double WDerivative,
183  const double DetJDerivative,
184  const Matrix& rdNdXDerivative)
185  : BaseType(NodeIndex, rGeometry, W, rN, rdNdX, WDerivative, DetJDerivative, rdNdXDerivative)
186  {
187  }
188 
192 
194 
196 
197  double CalculateElementLengthDerivative(const double ElementLength) const;
198 
200  Vector& rOutput,
201  const Matrix& rNodalVelocity) const;
202 
204  };
205 
214  template<unsigned int TNumNodes>
215  class PressureDerivative : public Derivative<0>
216  {
217  public:
220 
222 
224 
225  static constexpr double VelocityDerivativeFactor = 0.0;
226 
227  static constexpr double PressureDerivativeFactor = 1.0;
228 
229  static constexpr unsigned int TDerivativeDimension = 1;
230 
234 
236  const IndexType NodeIndex,
237  const GeometryType& rGeometry,
238  const double W,
239  const Vector& rN,
240  const Matrix& rdNdX,
241  const double WDerivative,
242  const double DetJDerivative,
243  const Matrix& rdNdXDerivative)
244  : BaseType(NodeIndex, rGeometry, W, rN, rdNdX, WDerivative, DetJDerivative, rdNdXDerivative)
245  {
246  }
247 
251 
252  const Variable<double>& GetDerivativeVariable() const { return PRESSURE; }
253 
255 
256  double CalculateElementLengthDerivative(const double ElementLength) const;
257 
259  Vector& rOutput,
260  const Matrix& rNodalVelocity) const;
261 
263  };
264 
274  template<unsigned int TNumNodes, unsigned int TComponentIndex>
275  class ShapeDerivative : public Derivative<TComponentIndex>
276  {
277  public:
280 
282 
284 
285  static constexpr double VelocityDerivativeFactor = 0.0;
286 
287  static constexpr double PressureDerivativeFactor = 0.0;
288 
289  static constexpr unsigned int TDerivativeDimension = TDim;
290 
294 
296  const IndexType NodeIndex,
297  const GeometryType& rGeometry,
298  const double W,
299  const Vector& rN,
300  const Matrix& rdNdX,
301  const double WDerivative,
302  const double DetJDerivative,
303  const Matrix& rdNdXDerivative)
304  : BaseType(NodeIndex, rGeometry, W, rN, rdNdX, WDerivative, DetJDerivative, rdNdXDerivative)
305  {
306  }
307 
311 
313 
315 
316  double CalculateElementLengthDerivative(const double ElementLength) const;
317 
319  Vector& rOutput,
320  const Matrix& rNodalVelocity) const;
321 
323  };
324 
326 private:
329 
330  static void CalculateStrainRateVelocityDerivative(
331  Vector& rOutput,
332  const IndexType DerivativeNodeIndex,
333  const IndexType DerivativeDirectionIndex,
334  const Matrix& rdNdX);
335 
337 };
338 
340 
341 } // namespace Kratos
Geometry base class.
Definition: geometry.h:71
This class defines the node.
Definition: node.h:65
Base class for Derivatives.
Definition: qs_vms_derivative_utilities.h:101
const double mWDerivative
Definition: qs_vms_derivative_utilities.h:139
DependentVariablesListType GetEffectiveViscosityDependentVariables() const
Definition: qs_vms_derivative_utilities.h:126
static constexpr IndexType ComponentIndex
Definition: qs_vms_derivative_utilities.h:106
Derivative(const IndexType NodeIndex, const GeometryType &rGeometry, const double W, const Vector &rN, const Matrix &rdNdX, const double WDerivative, const double DetJDerivative, const Matrix &rdNdXDerivative)
Definition: qs_vms_derivative_utilities.cpp:217
const Matrix & mrdNdXDerivative
Definition: qs_vms_derivative_utilities.h:141
const double mW
Definition: qs_vms_derivative_utilities.h:136
const IndexType mNodeIndex
Definition: qs_vms_derivative_utilities.h:134
const GeometryType & mrGeometry
Definition: qs_vms_derivative_utilities.h:135
const Vector & mrN
Definition: qs_vms_derivative_utilities.h:137
const Matrix & mrdNdX
Definition: qs_vms_derivative_utilities.h:138
const double mDetJDerivative
Definition: qs_vms_derivative_utilities.h:140
Pressure derivative computation container.
Definition: qs_vms_derivative_utilities.h:216
static constexpr unsigned int TDerivativeDimension
Definition: qs_vms_derivative_utilities.h:229
const Variable< double > & GetDerivativeVariable() const
Definition: qs_vms_derivative_utilities.h:252
static constexpr double VelocityDerivativeFactor
Definition: qs_vms_derivative_utilities.h:225
array_1d< double, TDim > CalculateEffectiveVelocityDerivative(const array_1d< double, TDim > &rVelocity) const
Definition: qs_vms_derivative_utilities.cpp:310
static constexpr IndexType ComponentIndex
Definition: qs_vms_derivative_utilities.h:223
double CalculateElementLengthDerivative(const double ElementLength) const
Definition: qs_vms_derivative_utilities.cpp:319
PressureDerivative(const IndexType NodeIndex, const GeometryType &rGeometry, const double W, const Vector &rN, const Matrix &rdNdX, const double WDerivative, const double DetJDerivative, const Matrix &rdNdXDerivative)
Definition: qs_vms_derivative_utilities.h:235
void CalculateStrainRateDerivative(Vector &rOutput, const Matrix &rNodalVelocity) const
Definition: qs_vms_derivative_utilities.cpp:327
static constexpr double PressureDerivativeFactor
Definition: qs_vms_derivative_utilities.h:227
Shape derivative computation container.
Definition: qs_vms_derivative_utilities.h:276
static constexpr double PressureDerivativeFactor
Definition: qs_vms_derivative_utilities.h:287
double CalculateElementLengthDerivative(const double ElementLength) const
Definition: qs_vms_derivative_utilities.cpp:353
ShapeDerivative(const IndexType NodeIndex, const GeometryType &rGeometry, const double W, const Vector &rN, const Matrix &rdNdX, const double WDerivative, const double DetJDerivative, const Matrix &rdNdXDerivative)
Definition: qs_vms_derivative_utilities.h:295
void CalculateStrainRateDerivative(Vector &rOutput, const Matrix &rNodalVelocity) const
Definition: qs_vms_derivative_utilities.cpp:361
static constexpr unsigned int TDerivativeDimension
Definition: qs_vms_derivative_utilities.h:289
const Variable< double > & GetDerivativeVariable() const
Definition: qs_vms_derivative_utilities.cpp:336
static constexpr double VelocityDerivativeFactor
Definition: qs_vms_derivative_utilities.h:285
array_1d< double, TDim > CalculateEffectiveVelocityDerivative(const array_1d< double, TDim > &rVelocity) const
Definition: qs_vms_derivative_utilities.cpp:344
static constexpr IndexType ComponentIndex
Definition: qs_vms_derivative_utilities.h:283
Velocity derivative computation container.
Definition: qs_vms_derivative_utilities.h:157
array_1d< double, TDim > CalculateEffectiveVelocityDerivative(const array_1d< double, TDim > &rVelocity) const
Definition: qs_vms_derivative_utilities.cpp:282
VelocityDerivative(const IndexType NodeIndex, const GeometryType &rGeometry, const double W, const Vector &rN, const Matrix &rdNdX, const double WDerivative, const double DetJDerivative, const Matrix &rdNdXDerivative)
Definition: qs_vms_derivative_utilities.h:176
double CalculateElementLengthDerivative(const double ElementLength) const
Definition: qs_vms_derivative_utilities.cpp:292
static constexpr double PressureDerivativeFactor
Definition: qs_vms_derivative_utilities.h:168
const Variable< double > & GetDerivativeVariable() const
Definition: qs_vms_derivative_utilities.cpp:274
static constexpr IndexType ComponentIndex
Definition: qs_vms_derivative_utilities.h:164
void CalculateStrainRateDerivative(Vector &rOutput, const Matrix &rNodalVelocity) const
Definition: qs_vms_derivative_utilities.cpp:300
static constexpr unsigned int TDerivativeDimension
Definition: qs_vms_derivative_utilities.h:170
static constexpr double VelocityDerivativeFactor
Definition: qs_vms_derivative_utilities.h:166
These are helper classes to define derivatives of coefficients of Navier-Stokes.
Definition: qs_vms_derivative_utilities.h:53
std::vector< std::tuple< const Variable< double > &, std::vector< const Variable< double > * > > > DependentVariablesListType
Definition: qs_vms_derivative_utilities.h:69
std::array< const Variable< double > *, 9 > DerivativeGradientsArray
Definition: qs_vms_derivative_utilities.h:71
static const std::array< const Variable< double > *, TStrainSize > GetStrainRateVariables()
static void CalculateStrainRate(Vector &rOutput, const Matrix &rNodalVelocity, const Matrix &rdNdX)
std::size_t IndexType
Definition: qs_vms_derivative_utilities.h:62
constexpr static IndexType TStrainSize
Definition: qs_vms_derivative_utilities.h:73
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21