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.
fluid_adjoint_slip_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 #if !defined(KRATOS_FLUID_ADJOINT_SLIP_UTILITIES_H)
14 #define KRATOS_FLUID_ADJOINT_SLIP_UTILITIES_H
15 
16 // System includes
17 
18 // External includes
19 
20 // Project includes
21 #include "geometries/geometry.h"
22 #include "includes/node.h"
25 
26 // Application includes
28 
29 
30 namespace Kratos
31 {
34 
37 
38 class KRATOS_API(FLUID_DYNAMICS_APPLICATION) FluidAdjointSlipUtilities
39 {
40 public:
43 
44  using NodeType = Node;
45 
46  using IndexType = std::size_t;
47 
49 
51 
55 
57  const IndexType Dimension,
58  const IndexType BlockSize);
59 
63 
79  void CalculateRotatedSlipConditionAppliedSlipVariableDerivatives(
80  Matrix& rOutput,
81  const Matrix& rResidualDerivatives,
82  const GeometryType& rGeometry) const;
83 
99  void CalculateRotatedSlipConditionAppliedNonSlipVariableDerivatives(
100  Matrix& rOutput,
101  const Matrix& rResidualDerivatives,
102  const GeometryType& rGeometry) const;
103 
116  Matrix& rOutput,
117  const Matrix& rResidualDerivatives,
118  const IndexType NodeStartIndex,
119  const NodeType& rNode) const
120  {
121  (this->*(this->mAddNodalRotationDerivativesMethod))(rOutput, rResidualDerivatives, NodeStartIndex, rNode);
122  }
123 
134  void AddNodalApplySlipConditionDerivatives(
135  Matrix& rOutput,
136  const IndexType NodeStartIndex,
137  const NodeType& rNode) const;
138 
149  void AddNodalResidualDerivatives(
150  Matrix& rOutput,
151  const Matrix& rResidualDerivatives,
152  const IndexType NodeStartIndex) const;
153 
160  void ClearNodalResidualDerivatives(
161  Matrix& rOutput,
162  const IndexType ResidualIndex) const;
163 
165 private:
168 
169  const IndexType mDimension;
170  const IndexType mBlockSize;
171 
172  const CoordinateTransformationUtilities mRotationTool;
173 
174  void (FluidAdjointSlipUtilities::*mAddNodalRotationDerivativesMethod)(
175  Matrix&,
176  const Matrix&,
177  const IndexType,
178  const NodeType&) const;
179 
183 
184  template<unsigned int TDim>
185  void TemplatedAddNodalRotationDerivatives(
186  Matrix& rOutput,
187  const Matrix& rResidualDerivatives,
188  const IndexType NodeStartIndex,
189  const NodeType& rNode) const
190  {
191  KRATOS_TRY
192 
193  BoundedVector<double, TDim> residual_derivative, aux_vector;
194  BoundedMatrix<double, TDim, TDim> rotation_matrix;
195  mRotationTool.LocalRotationOperatorPure(rotation_matrix, rNode);
196 
197  // add rotated residual derivative contributions
198  for (IndexType c = 0; c < rResidualDerivatives.size1(); ++c) {
199  // get the residual derivative relevant for node
200  FluidCalculationUtilities::ReadSubVector<TDim>(
201  residual_derivative, row(rResidualDerivatives, c), NodeStartIndex);
202 
203  // rotate residual derivative
204  noalias(aux_vector) = prod(rotation_matrix, residual_derivative);
205 
206  // add rotated residual derivative to local matrix
207  FluidCalculationUtilities::AddSubVector<TDim>(rOutput, aux_vector, c, NodeStartIndex);
208 
209  // add rest of the equation derivatives
210  for (IndexType a = TDim; a < mBlockSize; ++a) {
211  rOutput(c, NodeStartIndex + a) += rResidualDerivatives(c, NodeStartIndex + a);
212  }
213  }
214 
215  KRATOS_CATCH("");
216  }
217 
219 };
220 
222 
224 
225 } // namespace Kratos
226 
227 #endif // KRATOS_FLUID_ADJOINT_SLIP_UTILITIES_H
Definition: coordinate_transformation_utilities.h:57
Definition: fluid_adjoint_slip_utilities.h:39
void AddNodalRotationDerivatives(Matrix &rOutput, const Matrix &rResidualDerivatives, const IndexType NodeStartIndex, const NodeType &rNode) const
Rotates residual derivatives.
Definition: fluid_adjoint_slip_utilities.h:115
std::size_t IndexType
Definition: fluid_adjoint_slip_utilities.h:46
Geometry base class.
Definition: geometry.h:71
This class defines the node.
Definition: node.h:65
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
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
AMatrix::MatrixProductExpression< TExpression1Type, TExpression2Type > prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:568
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649
a
Definition: generate_stokes_twofluid_element.py:77
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108