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.
base_contact_search_process.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"
25 #include "spatial_containers/spatial_containers.h" // kd-tree
26 
27 namespace Kratos
28 {
31 
35 
37  using SizeType = std::size_t;
38 
42 
46 
50 
62 template<SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster = TNumNodes>
63 class KRATOS_API(CONTACT_STRUCTURAL_MECHANICS_APPLICATION) BaseContactSearchProcess
64  : public Process
65 {
66 public:
69 
73 
76 
78  using IndexType = std::size_t;
79 
82  using PointTypePointer = typename PointType::Pointer;
83  using PointVector = std::vector<PointTypePointer>;
84 
88 
91 
93  static constexpr double GapThreshold = 2.0e-3;
94 
96  static constexpr double ZeroTolerance = std::numeric_limits<double>::epsilon();
97 
100 
102  KRATOS_DEFINE_LOCAL_FLAG( INVERTED_SEARCH );
103  KRATOS_DEFINE_LOCAL_FLAG( CREATE_AUXILIAR_CONDITIONS );
104  KRATOS_DEFINE_LOCAL_FLAG( MULTIPLE_SEARCHS );
105  KRATOS_DEFINE_LOCAL_FLAG( PREDEFINE_MASTER_SLAVE );
107 
111 
115  enum class SearchTreeType {
116  KdtreeInRadius = 0,
117  KdtreeInBox = 1,
118  KdtreeInRadiusWithOBB = 2,
119  KdtreeInBoxWithOBB = 3,
120  OctreeWithOBB = 4,
121  Kdop = 5
122  };
123 
127  enum class CheckResult {
128  Fail = 0,
129  AlreadyInTheMap = 1,
130  OK = 2
131  };
132 
136  enum class CheckGap {
137  NoCheck = 0,
138  DirectCheck = 1,
139  MappingCheck = 2
140  };
141 
145  enum class TypeSolution {
146  NormalContactStress = 0,
147  ScalarLagrangeMultiplier = 1,
148  VectorLagrangeMultiplier = 2,
149  FrictionlessPenaltyMethod = 3,
150  FrictionalPenaltyMethod = 4,
151  OtherFrictionless = 5,
152  OtherFrictional = 6
153  };
154 
158 
176  ModelPart& rMainModelPart,
177  Parameters ThisParameters = Parameters(R"({})"),
178  Properties::Pointer pPairedProperties = nullptr
179  );
180 
182  ~BaseContactSearchProcess() override = default;
183 
187 
188  void operator()()
189  {
190  Execute();
191  }
192 
196 
200  void Execute() override;
201 
205  void ExecuteInitialize() override;
206 
210  void ExecuteInitializeSolutionStep() override;
211 
215  void ExecuteFinalizeSolutionStep() override;
216 
220  void InitializeMortarConditions();
221 
225  virtual void ClearMortarConditions();
226 
230  virtual void CheckContactModelParts();
231 
235  void CreatePointListMortar();
236 
240  void UpdatePointListMortar();
241 
245  void UpdateMortarConditions();
246 
250  void CheckMortarConditions();
251 
255  void InvertSearch();
256 
260  virtual void ResetContactOperators();
261 
265  const Parameters GetDefaultParameters() const override;
266 
270 
274 
278 
283  std::string Info() const override
284  {
285  return "BaseContactSearchProcess";
286  }
287 
292  void PrintInfo(std::ostream& rOStream) const override
293  {
294  rOStream << Info();
295  }
296 
300 
302 
303 protected:
304 
307 
311 
316  PairedCondition const* mpReferenceCondition = nullptr;
318 
319  Properties::Pointer mpPairedProperties = nullptr;
320 
324 
328 
333  virtual void CleanModelPart(ModelPart& rModelPart);
334 
340  virtual void CheckPairing(
341  ModelPart& rComputingModelPart,
342  IndexType& rConditionId
343  );
344 
348  virtual void ComputeActiveInactiveNodes();
349 
356  virtual void SetActiveNode(
357  Node& rNode,
358  const double CommonEpsilon,
359  const double ScaleFactor = 1.0
360  );
361 
366  virtual void SetInactiveNode(Node& rNode);
367 
380  virtual Condition::Pointer AddPairing(
381  ModelPart& rComputingModelPart,
382  IndexType& rConditionId,
383  GeometricalObject::Pointer pObjectSlave,
384  const array_1d<double, 3>& rSlaveNormal,
385  GeometricalObject::Pointer pObjectMaster,
386  const array_1d<double, 3>& rMasterNormal,
387  IndexMap::Pointer pIndexesPairs,
388  Properties::Pointer pProperties
389  );
390 
396  CheckGap ConvertCheckGap(const std::string& str);
397 
401 
406  bool IsPureSlip();
407 
412  bool IsNotPureSlip();
413 
418  bool IsMultipleSearchs();
419 
424  bool IsNotMultipleSearchs();
425 
430  bool IsInvertedSearch();
431 
436  bool IsNotInvertedSearch();
437 
441 
445 
447 
448 private:
451 
455 
459 
463 
469  void SearchUsingKDTree(
470  ModelPart& rSubContactModelPart,
471  ModelPart& rSubComputingContactModelPart
472  );
473 
479  void SearchUsingOcTree(
480  ModelPart& rSubContactModelPart,
481  ModelPart& rSubComputingContactModelPart
482  );
483 
489  void SetOriginDestinationModelParts(ModelPart& rModelPart);
490 
495  void ClearScalarMortarConditions(NodesArrayType& rNodesArray);
496 
501  void ClearComponentsMortarConditions(NodesArrayType& rNodesArray);
502 
507  void ClearALMFrictionlessMortarConditions(NodesArrayType& rNodesArray);
508 
517  inline CheckResult CheckGeometricalObject(
518  IndexMap::Pointer pIndexesPairs,
519  const GeometricalObject::Pointer pGeometricalObject1,
520  const GeometricalObject::Pointer pGeometricalObject2,
521  const bool InvertedSearch = false
522  );
523 
532  inline CheckResult CheckCondition(
533  IndexMap::Pointer pIndexesPairs,
534  const Condition::Pointer pCond1,
535  const Condition::Pointer pCond2,
536  const bool InvertedSearch = false
537  );
538 
542  void FillPointListDestination();
543 
548  void ClearDestinationListAndAssignFlags(ModelPart& rSubContactModelPart);
549 
560  inline IndexType PerformKDTreeSearch(
561  KDTree& rTreePoints,
562  PointVector& rPointsFound,
563  GeometryType& rGeometry,
564  const SearchTreeType TypeSearch = SearchTreeType::KdtreeInBox,
565  const double SearchFactor = 3.5,
566  const IndexType AllocationSize = 1000,
567  const bool Dynamic = false
568  );
569 
573  inline IndexType GetMaximumConditionsIds();
574 
588  void AddPotentialPairing(
589  ModelPart& rComputingModelPart,
590  IndexType& rConditionId,
591  GeometricalObject::Pointer pObjectSlave,
592  const array_1d<double, 3>& rSlaveNormal,
593  GeometricalObject::Pointer pObjectMaster,
594  const array_1d<double, 3>& rMasterNormal,
595  IndexMap::Pointer pIndexesPairs,
596  Properties::Pointer pProperties,
597  const double ActiveCheckFactor,
598  const bool FrictionalProblem
599  );
600 
605  inline void ComputeMappedGap(const bool SearchOrientation);
606 
610  inline void ComputeWeightedReaction();
611 
618  inline void CreateAuxiliaryConditions(
619  ModelPart& rContactModelPart,
620  ModelPart& rComputingModelPart,
621  IndexType& rConditionId
622  );
623 
629  void CreateDebugFile(
630  ModelPart& rModelPart,
631  const std::string& rName
632  );
633 
638  static inline double Radius(GeometryType& ThisGeometry);
639 
645  SearchTreeType ConvertSearchTree(const std::string& str);
646 
650 
654 
658 
660 
661 }; // Class BaseContactSearchProcess
662 
664 
667 
668 
672 
673 /****************************** INPUT STREAM FUNCTION ******************************/
674 /***********************************************************************************/
675 
676 template<SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster>
677 inline std::istream& operator >> (std::istream& rIStream,
679 
680 /***************************** OUTPUT STREAM FUNCTION ******************************/
681 /***********************************************************************************/
682 
683 template<SizeType TDim, SizeType TNumNodes, SizeType TNumNodesMaster>
684 inline std::ostream& operator << (std::ostream& rOStream,
686 {
687  return rOStream;
688 }
689 
691 
692 } // namespace Kratos.
void ExecuteFinalizeSolutionStep() override
this function will be executed at every time step AFTER performing the solve phase
Definition: periodic_interface_process.hpp:55
void ExecuteInitialize() override
Definition: periodic_interface_process.hpp:37
std::string Info() const override
Turn back information as a string.
Definition: periodic_interface_process.hpp:93
This process has as objective to create the contact conditions.
Definition: base_contact_search_process.h:65
KRATOS_DEFINE_LOCAL_FLAG(PREDEFINE_MASTER_SLAVE)
~BaseContactSearchProcess() override=default
Destructor.
KRATOS_DEFINE_LOCAL_FLAG(INVERTED_SEARCH)
Local Flags.
std::vector< PointTypePointer > PointVector
Point type pointer definition.
Definition: base_contact_search_process.h:83
SearchTreeType
An enumeration of the different types of search trees that can be used in the contact search process.
Definition: base_contact_search_process.h:115
void PrintInfo(std::ostream &rOStream) const override
Prints information about the contact search process to an output stream.
Definition: base_contact_search_process.h:292
CheckGap mCheckGap
The configuration parameters.
Definition: base_contact_search_process.h:314
Parameters mThisParameters
The main model part.
Definition: base_contact_search_process.h:313
std::string Info() const override
Returns a string with information about the contact search process.
Definition: base_contact_search_process.h:283
TypeSolution
An enumeration of the different types of solutions that can be used in the contact search process.
Definition: base_contact_search_process.h:145
void operator()()
Definition: base_contact_search_process.h:188
KRATOS_CLASS_POINTER_DEFINITION(BaseContactSearchProcess)
Pointer definition of BaseContactSearchProcess.
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: base_contact_search_process.h:72
KRATOS_DEFINE_LOCAL_FLAG(CREATE_AUXILIAR_CONDITIONS)
PointVector mPointListDestination
The prototype reference condition to be created.
Definition: base_contact_search_process.h:317
ModelPart & mrMainModelPart
Definition: base_contact_search_process.h:312
CheckGap
An enumeration of the different types of gap checks that can be performed during the contact search p...
Definition: base_contact_search_process.h:136
TypeSolution mTypeSolution
If the gap is checked during the search.
Definition: base_contact_search_process.h:315
CheckResult
An enumeration of the possible results of a check during the contact search process.
Definition: base_contact_search_process.h:127
typename PointType::Pointer PointTypePointer
Point type definition.
Definition: base_contact_search_process.h:82
ModelPart::NodesContainerType NodesArrayType
Containers definition.
Definition: base_contact_search_process.h:71
KRATOS_DEFINE_LOCAL_FLAG(MULTIPLE_SEARCHS)
Short class definition.
Definition: bucket.h:57
std::size_t IndexType
Definition: flags.h:74
Geometry base class.
Definition: geometry.h:71
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
This class defines the node.
Definition: node.h:65
This process computes the normal gap.
Definition: normal_gap_process.h:57
This is a base class for the conditions paired.
Definition: paired_condition.h:53
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Custom Point container to be used by the search.
Definition: point_object.h:56
The base class for all processes in Kratos.
Definition: process.h:49
A generic tree data structure for spatial partitioning.
Definition: tree.h:190
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
ScaleFactor
Definition: generate_frictional_mortar_condition.py:131
str
Definition: generate_gid_list_file.py:35