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.
metrics_math_utils.h
Go to the documentation of this file.
1 // KRATOS __ __ _____ ____ _ _ ___ _ _ ____
2 // | \/ | ____/ ___|| | | |_ _| \ | |/ ___|
3 // | |\/| | _| \___ \| |_| || || \| | | _
4 // | | | | |___ ___) | _ || || |\ | |_| |
5 // |_| |_|_____|____/|_| |_|___|_| \_|\____| APPLICATION
6 //
7 // License: BSD License
8 // license: MeshingApplication/license.txt
9 //
10 // Main authors: Vicente Mataix Ferrandiz
11 //
12 
13 #if !defined(KRATOS_METRICS_MATH_UTILS)
14 #define KRATOS_METRICS_MATH_UTILS
15 
16 // Project includes
17 #include "utilities/math_utils.h"
18 
19 namespace Kratos
20 {
23 
27 
29  typedef std::size_t SizeType;
30 
34 
38 
42 
49 template<SizeType TDim>
51 {
52 public:
55 
57  typedef typename std::conditional<TDim == 2, array_1d<double, 3>, array_1d<double, 6>>::type TensorArrayType;
58 
61 
65 
69 
73 
81  const TensorArrayType& rMetric1,
82  const TensorArrayType& rMetric2
83  )
84  {
87 
88  MatrixType auxmat, emat;
89 
90  double auxdet;
91  MatrixType inv_metric1_matrix;
92  MathUtils<double>::InvertMatrix(metric1_matrix, inv_metric1_matrix, auxdet);
93  const MatrixType n_matrix = prod(inv_metric1_matrix, metric2_matrix);
94 
95  MathUtils<double>::GaussSeidelEigenSystem(n_matrix, emat, auxmat, 1e-18, 20);
96 
97  MatrixType lambdamat;
98  MathUtils<double>::BDBtProductOperation(lambdamat, metric1_matrix, emat);
99  MatrixType mumat;
100  MathUtils<double>::BDBtProductOperation(mumat, metric2_matrix, emat);
101 
102  for (std::size_t i = 0; i < TDim; ++i) {
103  auxmat(i, i) = std::max(lambdamat(i, i), mumat(i, i));
104  }
105 
106  MatrixType invemat;
107  MathUtils<double>::InvertMatrix(emat, invemat, auxdet);
108 
109  MatrixType intersection_matrix;
110  MathUtils<double>::BDBtProductOperation(intersection_matrix, auxmat, invemat);
111 
113 
114  return intersection;
115  }
116 
120 
121 
125 
126 
130 
131 protected:
134 
138 
142 
146 
150 
154 
158 
160 };// class MetricsMathUtils
162 
165 
166 
170 
171 }// namespace Kratos.
172 #endif /* KRATOS_METRICS_MATH_UTILS defined */
Definition: amatrix_interface.h:41
Various mathematical utilitiy functions.
Definition: math_utils.h:62
static void BDBtProductOperation(TMatrixType1 &rA, const TMatrixType2 &rD, const TMatrixType3 &rB)
Calculates the product operation BDB'.
Definition: math_utils.h:1543
static BoundedMatrix< double, TDim, TDim > InvertMatrix(const BoundedMatrix< double, TDim, TDim > &rInputMatrix, double &rInputMatrixDet, const double Tolerance=ZeroTolerance)
Calculates the inverse of a 2x2, 3x3 and 4x4 matrices (using bounded matrix for performance)
Definition: math_utils.h:197
static bool GaussSeidelEigenSystem(const TMatrixType1 &rA, TMatrixType2 &rEigenVectorsMatrix, TMatrixType2 &rEigenValuesMatrix, const double Tolerance=1.0e-18, const SizeType MaxIterations=20)
Calculates the eigenvectors and eigenvalues of given symmetric matrix.
Definition: math_utils.h:1587
This class is used to compute some mathematical operations needed for the metrics computing.
Definition: metrics_math_utils.h:51
static TensorArrayType IntersectMetrics(const TensorArrayType &rMetric1, const TensorArrayType &rMetric2)
It computes the intersection between two metrics.
Definition: metrics_math_utils.h:80
std::conditional< TDim==2, array_1d< double, 3 >, array_1d< double, 6 > >::type TensorArrayType
The type of array considered for the tensor.
Definition: metrics_math_utils.h:57
BoundedMatrix< double, TDim, TDim > MatrixType
The definition of the matrix type.
Definition: metrics_math_utils.h:60
static double max(double a, double b)
Definition: GeometryFunctions.h:79
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
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
type
Definition: generate_gid_list_file.py:35
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31