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.
contact_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
20 #include "includes/model_part.h"
22 
23 namespace Kratos
24 {
27 
31 
35 
39 
43 
50 class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) ContactUtilities
51 {
52 public:
55 
56  // Some geometrical definitions
58 
61 
65 
67  using IndexType = std::size_t;
68 
70  using SizeType = std::size_t;
71 
74 
78 
80 
84  ContactUtilities() = default;
85 
87  virtual ~ContactUtilities() = default;
88 
92 
96 
101  static double CalculateRelativeSizeMesh(ModelPart& rModelPart);
102 
107  static double CalculateMaxNodalH(ModelPart& rModelPart);
108 
113  static double CalculateMeanNodalH(ModelPart& rModelPart);
114 
119  static double CalculateMinimalNodalH(ModelPart& rModelPart);
120 
127  template<class TPointType>
128  static void ScaleNode(
129  TPointType& rPointToScale,
130  const array_1d<double, 3>& rNormal,
131  const double LengthSearch
132  )
133  {
134  noalias(rPointToScale.Coordinates()) = rPointToScale.Coordinates() + rNormal * LengthSearch;
135  }
136 
142  static double DistancePoints(
143  const GeometryType::CoordinatesArrayType& rPointOrigin,
144  const GeometryType::CoordinatesArrayType& rPointDestiny
145  );
146 
153  static void ComputeStepJump(
154  ModelPart& rModelPart,
155  const double DeltaTime,
156  const bool HalfJump = true
157  );
158 
164  static bool CheckActivity(
165  ModelPart& rModelPart,
166  const bool ThrowError = true
167  );
168 
174  static bool CheckModelPartHasRotationDoF(ModelPart& rModelPart);
175 
181  static void CleanContactModelParts(ModelPart& rModelPart);
182 
187  static void ComputeExplicitContributionConditions(ModelPart& rModelPart);
188 
193  static void ActivateConditionWithActiveNodes(ModelPart& rModelPart);
194 
200  static array_1d<double, 3> GetHalfJumpCenter(GeometryType& rThisGeometry);
201 
208  template< std::size_t TDim, std::size_t TNumNodes>
210  const GeometryType& rGeometry,
211  const std::size_t StepSlip = 1
212  )
213  {
214  /* DEFINITIONS */
215  // Zero tolerance
216  const double zero_tolerance = std::numeric_limits<double>::epsilon();
217  // Tangent matrix
219 
220  for (IndexType i_node = 0; i_node < TNumNodes; ++i_node) {
221  const array_1d<double, 3>& r_gt = rGeometry[i_node].FastGetSolutionStepValue(WEIGHTED_SLIP, StepSlip);
222  const double norm_slip = norm_2(r_gt);
223  if (norm_slip > zero_tolerance) { // Non zero r_gt
224  const array_1d<double, 3> tangent_slip = r_gt/norm_slip;
225  for (std::size_t i_dof = 0; i_dof < TDim; ++i_dof)
226  tangent_matrix(i_node, i_dof) = tangent_slip[i_dof];
227  } else { // We consider the tangent direction as auxiliary
228  const array_1d<double, 3>& r_normal = rGeometry[i_node].FastGetSolutionStepValue(NORMAL);
229  array_1d<double, 3> tangent_xi, tangent_eta;
230  MathUtils<double>::OrthonormalBasis(r_normal, tangent_xi, tangent_eta);
231  if constexpr (TDim == 3) {
232  for (std::size_t i_dof = 0; i_dof < 3; ++i_dof)
233  tangent_matrix(i_node, i_dof) = tangent_xi[i_dof];
234  } else {
235  if (std::abs(tangent_xi[2]) > std::numeric_limits<double>::epsilon()) {
236  for (std::size_t i_dof = 0; i_dof < 2; ++i_dof)
237  tangent_matrix(i_node, i_dof) = tangent_eta[i_dof];
238  } else {
239  for (std::size_t i_dof = 0; i_dof < 2; ++i_dof)
240  tangent_matrix(i_node, i_dof) = tangent_xi[i_dof];
241  }
242  }
243  }
244  }
245 
246  return tangent_matrix;
247  }
248 
249 protected:
252 
256 
260 
264 
268 
272 
277 
278 private:
281 
285 
289 
293 
299  static Matrix GetVariableMatrix(
300  const GeometryType& rNodes,
301  const Variable<array_1d<double,3> >& rVarName
302  );
303 
308 
312 
316 
320 };// class ContactUtilities
321 
322 }
This class includes some utilities used for contact computations.
Definition: contact_utilities.h:51
KRATOS_CLASS_POINTER_DEFINITION(ContactUtilities)
Pointer definition of ExactMortarIntegrationUtility.
std::size_t SizeType
Size type definition.
Definition: contact_utilities.h:70
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: contact_utilities.h:64
std::size_t IndexType
Index type definition.
Definition: contact_utilities.h:67
virtual ~ContactUtilities()=default
Destructor.
ContactUtilities()=default
Constructor.
ModelPart::NodesContainerType NodesArrayType
The containers of the components of the model parts.
Definition: contact_utilities.h:63
static BoundedMatrix< double, TNumNodes, TDim > ComputeTangentMatrixSlip(const GeometryType &rGeometry, const std::size_t StepSlip=1)
It calculates the matrix containing the tangent vector of the r_gt (for frictional contact)
Definition: contact_utilities.h:209
static void ScaleNode(TPointType &rPointToScale, const array_1d< double, 3 > &rNormal, const double LengthSearch)
This function scales the points according to a factor (to increase the bounding box)
Definition: contact_utilities.h:128
Geometry base class.
Definition: geometry.h:71
Definition: amatrix_interface.h:41
static void OrthonormalBasis(const T1 &c, T2 &a, T3 &b, const IndexType Type=0)
This computes a orthonormal basis from a given vector (Frisvad method)
Definition: math_utils.h:848
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
BaseType CoordinatesArrayType
Definition: point.h:75
Variable class contains all information needed to store and retrive data from a data container.
Definition: variable.h:63
Short class definition.
Definition: array_1d.h:61
BoundedMatrix< double, TNumNodes, TDim > GetVariableMatrix(const GeometryType &rGeometry, const Variable< array_1d< double, 3 > > &rVariable, const unsigned int Step)
It calculates the matrix of a variable of a geometry.
Definition: mortar_utilities.h:433
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484