13 #if !defined(KRATOS_FLUID_CALCULATION_UTILITIES_H)
14 #define KRATOS_FLUID_CALCULATION_UTILITIES_H
18 #include <type_traits>
47 template<
class TDataType>
74 template <
class... TRefVariableValuePairArgs>
77 const Vector& rShapeFunction,
79 const TRefVariableValuePairArgs&... rValueVariablePairs)
83 const auto& r_node = rGeometry[0];
84 const double shape_function_value = rShapeFunction[0];
86 (std::apply([&](
auto&&...
args) {((std::get<0>(
args) = std::get<1>(
args) * shape_function_value), ...);}, GetComponentsArray(std::get<0>(rValueVariablePairs), r_node.FastGetSolutionStepValue(std::get<1>(rValueVariablePairs), Step))), ...);
89 const auto& r_node = rGeometry[
c];
90 const double shape_function_value = rShapeFunction[
c];
92 (std::apply([&](
auto&&...
args) {((std::get<0>(
args) += std::get<1>(
args) * shape_function_value), ...);}, GetComponentsArray(std::get<0>(rValueVariablePairs), r_node.FastGetSolutionStepValue(std::get<1>(rValueVariablePairs), Step))), ...);
117 template <
class... TRefVariableValuePairArgs>
120 const Vector& rShapeFunction,
121 const TRefVariableValuePairArgs&... rValueVariablePairs)
123 EvaluateInPoint<TRefVariableValuePairArgs...>(
124 rGeometry, rShapeFunction, 0, rValueVariablePairs...);
146 template <
class... TRefVariableValuePairArgs>
149 const Vector& rShapeFunction,
150 const TRefVariableValuePairArgs&... rValueVariablePairs)
154 const auto& r_node = rGeometry[0];
155 const double shape_function_value = rShapeFunction[0];
157 (std::apply([&](
auto&&...
args) {((std::get<0>(
args) = std::get<1>(
args) * shape_function_value), ...);}, GetComponentsArray(std::get<0>(rValueVariablePairs), r_node.GetValue(std::get<1>(rValueVariablePairs)))), ...);
160 const auto& r_node = rGeometry[
c];
161 const double shape_function_value = rShapeFunction[
c];
163 (std::apply([&](
auto&&...
args) {((std::get<0>(
args) += std::get<1>(
args) * shape_function_value), ...);}, GetComponentsArray(std::get<0>(rValueVariablePairs), r_node.GetValue(std::get<1>(rValueVariablePairs)))), ...);
195 template <
class... TRefVariableValuePairArgs>
198 const Matrix& rShapeFunctionDerivatives,
200 const TRefVariableValuePairArgs&... rValueVariablePairs)
204 const auto& r_node = rGeometry[0];
205 const Vector& shape_function_derivative =
row(rShapeFunctionDerivatives, 0);
207 for (
IndexType i = 0;
i < rShapeFunctionDerivatives.size2(); ++
i) {
208 (std::apply([&](
auto&&...
args) {((std::get<0>(
args) = std::get<1>(
args) * shape_function_derivative[
i]), ...);}, GetComponentsArray(std::get<0>(rValueVariablePairs), r_node.FastGetSolutionStepValue(std::get<1>(rValueVariablePairs), Step),
i)), ...);
212 const auto& r_node = rGeometry[
c];
213 const Vector& shape_function_derivative =
row(rShapeFunctionDerivatives,
c);
215 for (
IndexType i = 0;
i < rShapeFunctionDerivatives.size2(); ++
i) {
216 (std::apply([&](
auto&&...
args) {((std::get<0>(
args) += std::get<1>(
args) * shape_function_derivative[
i]), ...);}, GetComponentsArray(std::get<0>(rValueVariablePairs), r_node.FastGetSolutionStepValue(std::get<1>(rValueVariablePairs), Step),
i)), ...);
249 template <
class... TRefVariableValuePairArgs>
252 const Matrix& rShapeFunctionDerivatives,
253 const TRefVariableValuePairArgs&... rValueVariablePairs)
255 EvaluateGradientInPoint<TRefVariableValuePairArgs...>(
256 rGeometry, rShapeFunctionDerivatives, 0, rValueVariablePairs...);
284 template <
class... TRefVariableValuePairArgs>
287 const Matrix& rShapeFunctionDerivatives,
288 const TRefVariableValuePairArgs&... rValueVariablePairs)
292 const auto& r_node = rGeometry[0];
293 const Vector& shape_function_derivative =
row(rShapeFunctionDerivatives, 0);
295 for (
IndexType i = 0;
i < rShapeFunctionDerivatives.size2(); ++
i) {
296 (std::apply([&](
auto&&...
args) {((std::get<0>(
args) = std::get<1>(
args) * shape_function_derivative[
i]), ...);}, GetComponentsArray(std::get<0>(rValueVariablePairs), r_node.GetValue(std::get<1>(rValueVariablePairs)),
i)), ...);
300 const auto& r_node = rGeometry[
c];
301 const Vector& shape_function_derivative =
row(rShapeFunctionDerivatives,
c);
303 for (
IndexType i = 0;
i < rShapeFunctionDerivatives.size2(); ++
i) {
304 (std::apply([&](
auto&&...
args) {((std::get<0>(
args) += std::get<1>(
args) * shape_function_derivative[
i]), ...);}, GetComponentsArray(std::get<0>(rValueVariablePairs), r_node.GetValue(std::get<1>(rValueVariablePairs)),
i)), ...);
322 template <
unsigned int TSize>
331 <<
"rInput size is not enough for sub vector retireval. [ "
333 << rInput.size() <<
", Requested Position = " << Position
334 <<
", Requested vector size = " << TSize <<
" ].\n";
337 rOutput[
i] = rInput[Position +
i];
357 template<
unsigned int TSize>
361 const unsigned int RowIndex,
362 const unsigned int ColumnIndex)
367 <<
"RowIndex is larger than or equal to rOutput number of rows. [ "
369 << rOutput.size1() <<
", RowIndex = " << RowIndex <<
" ].\n";
372 <<
"rOutput matrix does not have sufficient number of columns [ "
374 << rOutput.size2() <<
", ColumnIndex = " << ColumnIndex
375 <<
", TSize = " << TSize <<
" ].\n";
377 for (
unsigned int i = 0;
i < TSize; ++
i) {
378 rOutput(RowIndex, ColumnIndex +
i) += rInput[
i];
403 const int MaxIterations = 20,
404 const double Tolerance = 1
e-6);
443 static double CalculateLogarithmicYPlus(
444 const double WallVelocityMagnitude,
445 const double WallHeight,
446 const double KinematicViscosity,
449 const double YPlusLimit,
450 const int MaxIterations = 20,
451 const double Tolerance = 1
e-6);
460 static auto inline GetComponentsArray(
double& rOutput,
const double& rInput) {
return std::array<ComponentDataType<double>, 1>{std::tie(rOutput, rInput)};}
461 static auto inline GetComponentsArray(array_1d<double, 2>& rOutput,
const array_1d<double, 3>& rInput) {
return std::array<ComponentDataType<double>, 2>{std::tie(rOutput[0], rInput[0]), std::tie(rOutput[1], rInput[1])};}
462 static auto inline GetComponentsArray(array_1d<double, 3>& rOutput,
const array_1d<double, 3>& rInput) {
return std::array<ComponentDataType<double>, 3>{std::tie(rOutput[0], rInput[0]), std::tie(rOutput[1], rInput[1]), std::tie(rOutput[2], rInput[2])};}
463 static auto inline GetComponentsArray(
Vector& rOutput,
const Vector& rInput) {
return std::array<ComponentDataType<Vector>, 1>{std::tie(rOutput, rInput)};}
464 static auto inline GetComponentsArray(
Matrix& rOutput,
const Matrix& rInput) {
return std::array<ComponentDataType<Matrix>, 1>{std::tie(rOutput, rInput)};}
467 static auto inline GetComponentsArray(array_1d<double, 2>& rOutput,
const double& rInput,
const IndexType DerivativeIndex) {
return std::array<ComponentDataType<double>, 1>{std::tie(rOutput[DerivativeIndex], rInput)};}
468 static auto inline GetComponentsArray(array_1d<double, 3>& rOutput,
const double& rInput,
const IndexType DerivativeIndex) {
return std::array<ComponentDataType<double>, 1>{std::tie(rOutput[DerivativeIndex], rInput)};}
469 static auto inline GetComponentsArray(BoundedMatrix<double, 2, 2>& rOutput,
const array_1d<double, 3>& rInput,
const IndexType DerivativeIndex) {
return std::array<ComponentDataType<double>, 2>{std::tie(rOutput(0, DerivativeIndex), rInput[0]), std::tie(rOutput(1, DerivativeIndex), rInput[1])};}
470 static auto inline GetComponentsArray(BoundedMatrix<double, 3, 3>& rOutput,
const array_1d<double, 3>& rInput,
const IndexType DerivativeIndex) {
return std::array<ComponentDataType<double>, 3>{std::tie(rOutput(0, DerivativeIndex), rInput[0]), std::tie(rOutput(1, DerivativeIndex), rInput[1]), std::tie(rOutput(2, DerivativeIndex), rInput[2])};}
Definition: fluid_calculation_utilities.h:36
Geometry base class.
Definition: geometry.h:71
SizeType PointsNumber() const
Definition: geometry.h:528
This class defines the node.
Definition: node.h:65
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
static void EvaluateGradientInPoint(const GeometryType &rGeometry, const Matrix &rShapeFunctionDerivatives, const TRefVariableValuePairArgs &... rValueVariablePairs)
Evaluates gradients of given list of variable pairs at gauss point locations at current step.
Definition: fluid_calculation_utilities.h:250
static void EvaluateNonHistoricalInPoint(const GeometryType &rGeometry, const Vector &rShapeFunction, const TRefVariableValuePairArgs &... rValueVariablePairs)
Evaluates given list of non historical variable pairs at gauss point locations.
Definition: fluid_calculation_utilities.h:147
static void EvaluateInPoint(const GeometryType &rGeometry, const Vector &rShapeFunction, const int Step, const TRefVariableValuePairArgs &... rValueVariablePairs)
Evaluates given list of variable pairs at gauss point locations at step.
Definition: fluid_calculation_utilities.h:75
static void AddSubVector(Matrix &rOutput, const BoundedVector< double, TSize > &rInput, const unsigned int RowIndex, const unsigned int ColumnIndex)
Adds values of a vector to a given matrix.
Definition: fluid_calculation_utilities.h:358
std::size_t IndexType
Definition: fluid_calculation_utilities.h:41
static void EvaluateNonHistoricalGradientInPoint(const GeometryType &rGeometry, const Matrix &rShapeFunctionDerivatives, const TRefVariableValuePairArgs &... rValueVariablePairs)
Evaluates non historical gradients of given list of variable pairs at gauss point locations.
Definition: fluid_calculation_utilities.h:285
static void EvaluateInPoint(const GeometryType &rGeometry, const Vector &rShapeFunction, const TRefVariableValuePairArgs &... rValueVariablePairs)
Evaluates given list of variable pairs at gauss point locations at current step.
Definition: fluid_calculation_utilities.h:118
std::tuple< TDataType &, const TDataType & > ComponentDataType
Definition: fluid_calculation_utilities.h:48
static void EvaluateGradientInPoint(const GeometryType &rGeometry, const Matrix &rShapeFunctionDerivatives, const int Step, const TRefVariableValuePairArgs &... rValueVariablePairs)
Evaluates gradients of given list of variable pairs at gauss point locations at step.
Definition: fluid_calculation_utilities.h:196
static void ReadSubVector(BoundedVector< double, TSize > &rOutput, const Vector &rInput, const IndexType Position)
Get a sub vector from a vector.
Definition: fluid_calculation_utilities.h:323
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
#define KRATOS_DEBUG_ERROR_IF(conditional)
Definition: exception.h:171
double CalculateLogarithmicYPlusLimit(const double Kappa, const double Beta, const int MaxIterations, const double Tolerance)
Definition: rans_calculation_utilities.cpp:168
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
Internals::Matrix< double, AMatrix::dynamic, 1 > Vector
Definition: amatrix_interface.h:472
Internals::Matrix< double, AMatrix::dynamic, AMatrix::dynamic > Matrix
Definition: amatrix_interface.h:470
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649
args
Definition: generate_gid_list_file.py:37
Kappa
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:11
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
def Beta(n, j)
Definition: quadrature.py:104
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31