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.
derivatives_utilities.h
Go to the documentation of this file.
1 // KRATOS ______ __ __ _____ __ __ __
2 // / ____/___ ____ / /_____ ______/ /_/ ___// /________ _______/ /___ ___________ _/ /
3 // / / / __ \/ __ \/ __/ __ `/ ___/ __/\__ \/ __/ ___/ / / / ___/ __/ / / / ___/ __ `/ /
4 // / /___/ /_/ / / / / /_/ /_/ / /__/ /_ ___/ / /_/ / / /_/ / /__/ /_/ /_/ / / / /_/ / /
5 // \____/\____/_/ /_/\__/\__,_/\___/\__//____/\__/_/ \__,_/\___/\__/\__,_/_/ \__,_/_/ MECHANICS
6 //
7 // License: BSD License
8 // license: ContactStructuralMechanicsApplication/license.txt
9 //
10 // Main authors: Vicente Mataix Ferrandiz
11 //
12 
13 #pragma once
14 
15 // System includes
16 
17 // External includes
18 
19 // Project includes
21 
22 /* Includes */
23 #include "includes/model_part.h"
25 
26 /* Geometries */
27 #include "geometries/line_2d_2.h"
29 
30 namespace Kratos
31 {
34 
38 
40  using SizeType = std::size_t;
41 
45 
49 
61 template< const SizeType TDim, const SizeType TNumNodes, bool TFrictional, const bool TNormalVariation, const SizeType TNumNodesMaster = TNumNodes>
62 class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) DerivativesUtilities
63 {
64 public:
67 
69  using IndexType = std::size_t;
70 
73 
76 
79 
82 
85 
88 
90  using ConditionArrayListType = typename std::vector<ConditionArrayType>;
91 
94 
97 
100 
102  using DerivativeDataType = typename std::conditional<TFrictional, DerivativeDataFrictional<TDim, TNumNodes, TNumNodesMaster>, DerivativeData<TDim, TNumNodes, TNumNodesMaster> >::type;
103 
106 
109 
112 
113  // The threshold coefficient considered for checking
114  static constexpr double CheckThresholdCoefficient = 1.0e-12;
115 
117  static constexpr double ZeroTolerance = std::numeric_limits<double>::epsilon();
118 
121 
125 
132  static void CalculateDeltaDetjSlave(
133  const DecompositionType& DecompGeom,
134  const GeneralVariables& rVariables,
135  DerivativeDataType& rDerivativeData
136  );
137 
145  static inline array_1d<array_1d<double, 3>, TDim * TNumNodes> GPDeltaNormalSlave(
146  const Matrix& rJacobian,
147  const Matrix& rDNDe
148  );
149 
158  static inline array_1d<array_1d<double, 3>, TDim * TNumNodesMaster> GPDeltaNormalMaster(
159  const Matrix& rJacobian,
160  const Matrix& rDNDe
161  );
162 
167  static array_1d<array_1d<double, 3>, TDim * TNumNodes> DeltaNormalCenter(const GeometryType& rThisGeometry);
168 
174  static void CalculateDeltaNormalSlave(
175  array_1d<BoundedMatrix<double, TNumNodes, TDim>, TNumNodes * TDim>& rDeltaNormal,
176  GeometryType& rThisGeometry
177  );
178 
185  static void CalculateDeltaNormalMaster(
186  array_1d<BoundedMatrix<double, TNumNodesMaster, TDim>, TNumNodesMaster * TDim>& rDeltaNormal,
187  const GeometryType& rThisGeometry
188  );
189 
214  static void CalculateDeltaCellVertex(
215  const GeneralVariables& rVariables,
216  DerivativeDataType& rDerivativeData,
217  const array_1d<BelongType, TDim>& rTheseBelongs,
218  const NormalDerivativesComputation ConsiderNormalVariation,
219  const GeometryType& rSlaveGeometry,
220  const GeometryType& rMasterGeometry,
221  const array_1d<double, 3>& rNormal
222  );
223 
236  static inline void CalculateDeltaN1(
237  const GeneralVariables& rVariables,
238  DerivativeDataType& rDerivativeData,
239  const GeometryType& rSlaveGeometry,
240  const GeometryType& rMasterGeometry,
241  const array_1d<double, 3>& rSlaveNormal,
242  const DecompositionType& rDecompGeom,
243  const PointType& rLocalPointDecomp,
244  const PointType& rLocalPointParent,
246  );
247 
262  static void CalculateDeltaN(
263  const GeneralVariables& rVariables,
264  DerivativeDataType& rDerivativeData,
265  const GeometryType& rSlaveGeometry,
266  const GeometryType& rMasterGeometry,
267  const array_1d<double, 3>& rSlaveNormal,
268  const array_1d<double, 3>& rMasterNormal,
269  const DecompositionType& rDecompGeom,
270  const PointType& rLocalPointDecomp,
271  const PointType& rLocalPointParent,
273  const bool DualLM = false
274  );
275 
282  Matrix& CalculateDeltaPosition(
283  Matrix& rDeltaPosition,
284  const GeometryType& rThisGeometry,
285  const ConditionArrayType& rLocalCoordinates
286  );
287 
293  static inline Matrix& CalculateDeltaPosition(
294  Matrix& rDeltaPosition,
295  const GeometryType& ThisGeometry
296  );
297 
305  static inline void CalculateDeltaPosition(
306  Vector& rDeltaPosition,
307  const GeometryType& rSlaveGeometry,
308  const GeometryType& rMasterGeometry,
309  const IndexType IndexNode
310  );
311 
320  static inline void CalculateDeltaPosition(
321  Vector& rDeltaPosition,
322  const GeometryType& rSlaveGeometry,
323  const GeometryType& rMasterGeometry,
324  const IndexType IndexNode,
325  const IndexType iDoF
326  );
327 
336  static inline void CalculateDeltaPosition(
337  double& rDeltaPosition,
338  const GeometryType& rSlaveGeometry,
339  const GeometryType& rMasterGeometry,
340  const IndexType IndexNode,
341  const IndexType iDoF
342  );
343 
356  static bool CalculateAeAndDeltaAe(
357  const GeometryType& rSlaveGeometry,
358  const array_1d<double, 3>& rSlaveNormal,
359  const GeometryType& rMasterGeometry,
360  DerivativeDataType& rDerivativeData,
361  GeneralVariables& rVariables,
362  const NormalDerivativesComputation ConsiderNormalVariation,
363  ConditionArrayListType& rConditionsPointsSlave,
364  GeometryData::IntegrationMethod ThisIntegrationMethod,
365  const double AxiSymCoeff = 1.0
366  );
367 
368 private:
374 
378 
382 
395  static inline array_1d<double, 3> LocalDeltaVertex(
396  const array_1d<double, 3>& rNormal,
397  const array_1d<double, 3>& rDeltaNormal,
398  const IndexType iDoF,
399  const IndexType iBelong,
400  const NormalDerivativesComputation ConsiderNormalVariation,
401  const GeometryType& rSlaveGeometry,
402  const GeometryType& rMasterGeometry,
403  double Coeff = 1.0
404  );
405 
412  static inline BoundedMatrix<double, 3, 3> ComputeRenormalizerMatrix(
413  const array_1d<double, 3>& rDiffVector,
414  const array_1d<double, 3>& rDeltaNormal
415  );
416 
423  static inline array_1d<double, 3> PreviousNormalGeometry(
424  const GeometryType& rThisGeometry,
425  const GeometryType::CoordinatesArrayType& rPointLocal
426  );
427 
436  static inline void ConvertAuxHashIndex(
437  const IndexType AuxIndex,
438  IndexType& riBelongSlaveStart,
439  IndexType& riBelongSlaveEnd,
440  IndexType& riBelongMasterStart,
441  IndexType& riBelongMasterEnd
442  );
443 
452  static inline void DeltaPointLocalCoordinatesSlave(
453  array_1d<double, 2>& rResult,
454  const array_1d<double, 3>& rDeltaPoint,
455  const Matrix& rDNDe,
456  const GeometryType& rThisGeometry,
457  const array_1d<double, 3>& rThisNormal
458  );
467  static inline void DeltaPointLocalCoordinatesMaster(
468  array_1d<double, 2>& rResult,
469  const array_1d<double, 3>& rDeltaPoint,
470  const Matrix& rDNDe,
471  const GeometryType& rThisGeometry,
472  const array_1d<double, 3>& rThisNormal
473  );
474 
489  static inline double LocalDeltaSegmentN1(
490  const array_1d<array_1d<double, 3>, TDim * TNumNodes>& rDeltaNormal,
491  const array_1d<double, 3>& rSlaveNormal,
492  const GeometryType& rSlaveGeometry,
493  const GeometryType& rMasterGeometry,
494  const Vector& rN1,
495  const Matrix& rDNDe1,
496  const IndexType MortarNode,
497  const IndexType iNode,
498  const IndexType iDoF,
499  const NormalDerivativesComputation ConsiderNormalVariation
500  );
501 
516  static inline double LocalDeltaSegmentN2(
517  const array_1d<array_1d<double, 3>, TDim * TNumNodes>& rDeltaNormal,
518  const array_1d<double, 3>& rSlaveNormal,
519  const GeometryType& rSlaveGeometry,
520  const GeometryType& rMasterGeometry,
521  const Vector& rN2,
522  const Matrix& rDNDe2,
523  const IndexType MortarNode,
524  const IndexType iNode,
525  const IndexType iDoF,
526  const NormalDerivativesComputation ConsiderNormalVariation
527  );
528 
530 };// class DerivativesUtilities
531 
541 {
542 public:
545 
547  static constexpr double ZeroTolerance = std::numeric_limits<double>::epsilon();
548 
552 
560  template<const SizeType TNumNodes1, const SizeType TNumNodes2>
562  const BoundedMatrix<double, TNumNodes1, 3>& rDiffMatrix,
563  const BoundedMatrix<double, TNumNodes2, 3>& rDeltaNormal,
564  const IndexType iGeometry
565  )
566  {
567  KRATOS_TRY
568 
569  BoundedMatrix<double, 3, 3> aux_matrix;
570  for (IndexType itry = 0; itry < 3; ++itry) {
571  if (rDeltaNormal(iGeometry, itry) > ZeroTolerance) {
572 
573  const IndexType aux_index_1 = itry == 2 ? 0 : itry + 1;
574  const IndexType aux_index_2 = itry == 2 ? 1 : (itry == 1 ? 0 : 2);
575 
576  const double diff = rDeltaNormal(iGeometry, aux_index_1) + rDeltaNormal(iGeometry, aux_index_2);
577  const double coeff = rDeltaNormal(iGeometry, itry);
578 
579  aux_matrix(0, aux_index_1) = 1.0;
580  aux_matrix(0, aux_index_2) = 1.0;
581  aux_matrix(1, aux_index_1) = 1.0;
582  aux_matrix(1, aux_index_2) = 1.0;
583  aux_matrix(2, aux_index_1) = 1.0;
584  aux_matrix(2, aux_index_2) = 1.0;
585 
586  aux_matrix(0, itry) = (rDiffMatrix(iGeometry, 0) - diff)/coeff;
587  aux_matrix(1, itry) = (rDiffMatrix(iGeometry, 1) - diff)/coeff;
588  aux_matrix(2, itry) = (rDiffMatrix(iGeometry, 2) - diff)/coeff;
589 
590  return aux_matrix;
591  }
592  }
593 
594  return IdentityMatrix(3, 3);
595 
596  KRATOS_CATCH("")
597  }
598 
600 }; // class ImplementationDerivativesUtilities
601 
602 } // namespace Kratos
This data will be used to compute the derivatives.
Definition: mortar_classes.h:638
This utilities are used in order to compute the directional derivatives during mortar contact.
Definition: derivatives_utilities.h:63
typename std::conditional< TFrictional, DerivativeDataFrictional< TDim, TNumNodes, TNumNodesMaster >, DerivativeData< TDim, TNumNodes, TNumNodesMaster > >::type DerivativeDataType
The derivative data type.
Definition: derivatives_utilities.h:102
std::size_t IndexType
The index type.
Definition: derivatives_utilities.h:69
typename std::conditional< TNumNodes==2, PointBelongsLine2D2N, typename std::conditional< TNumNodes==3, typename std::conditional< TNumNodesMaster==3, PointBelongsTriangle3D3N, PointBelongsTriangle3D3NQuadrilateral3D4N >::type, typename std::conditional< TNumNodesMaster==3, PointBelongsQuadrilateral3D4NTriangle3D3N, PointBelongsQuadrilateral3D4N >::type >::type >::type BelongType
The belong type (for derivatives definition)
Definition: derivatives_utilities.h:78
typename std::conditional< TDim==2, LineType, TriangleType >::type DecompositionType
The geometry for decomposition (line in 2D and triangle for 3D)
Definition: derivatives_utilities.h:99
KRATOS_CLASS_POINTER_DEFINITION(DerivativesUtilities)
Pointer definition of DerivativesUtilities.
typename std::vector< ConditionArrayType > ConditionArrayListType
The definition of an array pf conditions.
Definition: derivatives_utilities.h:90
This is the definition dual lagrange multiplier operators including the derivatives.
Definition: mortar_classes.h:1718
IntegrationMethod
Definition: geometry_data.h:76
Geometry base class.
Definition: geometry.h:71
Auxiliary implementation for DerivativesUtilities.
Definition: derivatives_utilities.h:541
static BoundedMatrix< double, 3, 3 > ComputeRenormalizerMatrix(const BoundedMatrix< double, TNumNodes1, 3 > &rDiffMatrix, const BoundedMatrix< double, TNumNodes2, 3 > &rDeltaNormal, const IndexType iGeometry)
This method computes the auxiliary matrix used to keep unitary the normal.
Definition: derivatives_utilities.h:561
An two node 2D line geometry with linear shape functions.
Definition: line_2d_2.h:65
MortarKinematicVariablesWithDerivatives.
Definition: mortar_classes.h:490
This class derives from the MortarOperator class and it includes the derived operators.
Definition: mortar_classes.h:1273
Custom Point container to be used by the mapper.
Definition: mortar_classes.h:1952
Point class.
Definition: point.h:59
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
A three node 3D triangle geometry with linear shape functions.
Definition: triangle_3d_3.h:77
Short class definition.
Definition: array_1d.h:61
#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::IdentityMatrix< double > IdentityMatrix
Definition: amatrix_interface.h:564
NormalDerivativesComputation
An enumeration of the different options for normal derivatives computation.
Definition: contact_structural_mechanics_application_variables.h:57
@ NO_DERIVATIVES_COMPUTATION
No computation of normal derivatives.
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
list coeff
Definition: bombardelli_test.py:41
type
Definition: generate_gid_list_file.py:35