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.
hm_parametric_wall_contact_search_process.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosContactMechanicsApplication $
3 // Created by: $Author: LMonforte $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: January 2018 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_HM_PARAMETRIC_WALL_CONTACT_SEARCH_PROCESS_H_INCLUDED )
11 #define KRATOS_HM_PARAMETRIC_WALL_CONTACT_SEARCH_PROCESS_H_INCLUDED
12 
13 
14 // External includes
15 
16 // System includes
17 #ifdef _OPENMP
18 #include <omp.h>
19 #endif
20 
21 // Project includes
22 #include "includes/model_part.h"
23 #include "utilities/openmp_utils.h"
24 #include "geometries/point_2d.h"
25 #include "geometries/point_3d.h"
26 
28 
31 
33 
34 namespace Kratos
35 {
38 
42 
46 
50 
51 
54 
56 
65  {
66  public:
69 
72 
79  //typedef FrictionLaw::pointer FrictionLawType;
80 
84 
87 
88 
90  std::string rSubModelPartName,
91  SpatialBoundingBox::Pointer pParametricWall,
92  Parameters CustomParameters)
93  : ParametricWallContactSearchProcess( rMainModelPart, rSubModelPartName, pParametricWall, CustomParameters)
94  {
96 
97  mpConditionType->SetValue( HYDRAULIC, false);
98 
99  mpHydraulicConditionType = CreateConditionPrototypeHM( CustomParameters );
100  mpHydraulicConditionType->SetValue(HYDRAULIC, true);
101 
102  KRATOS_CATCH(" ")
103 
104  }
105 
108 
109 
113 
115  void operator()()
116  {
117  Execute();
118  }
119 
120 
124 
125 
129 
130 
134 
135 
139 
141  virtual std::string Info() const override
142  {
143  return "HMParametricWallContactSearchProcess";
144  }
145 
147  virtual void PrintInfo(std::ostream& rOStream) const override
148  {
149  rOStream << "HMParametricWallContactSearchProcess";
150  }
151 
153  virtual void PrintData(std::ostream& rOStream) const override
154  {
155  }
156 
157 
161 
162 
164 
165  protected:
168 
169 
173 
174 
178 
179 
180 
181  virtual void CreateContactConditions() override
182  {
183  KRATOS_TRY
184 
185  ProcessInfo& rCurrentProcessInfo= mrMainModelPart.GetProcessInfo();
186  double Dimension = rCurrentProcessInfo[SPACE_DIMENSION];
187 
188  ModelPart::ConditionsContainerType ContactConditions;
189 
191 
192  if( mEchoLevel > 1 ){
193  std::cout<<" ["<<rContactModelPart.Name()<<" :: CONDITIONS [OLD:"<<rContactModelPart.NumberOfConditions();
194  }
195 
196  unsigned int id = mrMainModelPart.Conditions().back().Id() + 1;
197 
199 
200  // create contact condition for rigid and deformable bodies
201  for(ModelPart::NodesContainerType::ptr_iterator nd = rNodes.ptr_begin(); nd != rNodes.ptr_end(); ++nd)
202  {
203  if( (*nd)->Is(BOUNDARY) && (*nd)->Is(CONTACT) ){
204 
205  ConditionType::Pointer pCondition;
206 
207  if( (*nd)->Is(RIGID) ){ //rigid wall contacting with a rigid body
208 
209  GeometryType::Pointer pGeometry;
210  if( Dimension == 2 )
211  pGeometry = Kratos::make_shared<Point2DType>(*nd);
212  else if( Dimension == 3 )
213  pGeometry = Kratos::make_shared<Point3DType>(*nd);
214 
215  //pCondition= Kratos::make_intrusive<RigidBodyPointRigidContactCondition>(id, pGeometry, mpProperties, mpParametricWall);
216 
217  ContactConditions.push_back(pCondition);
218 
219  }
220  else{ //rigid wall contacting with a deformable body
221 
222  Condition::NodesArrayType pConditionNode;
223  pConditionNode.push_back( (*nd) );
224 
225  ConditionType::Pointer pConditionType = FindPointConditionHM(rContactModelPart, (*nd) , false);
226  pCondition = pConditionType->Clone(id, pConditionNode);
227  pCondition->Set(CONTACT);
228  pCondition->SetValue(HYDRAULIC, false);
229  ContactConditions.push_back(pCondition);
230 
231  pConditionType = FindPointConditionHM(rContactModelPart, (*nd) , true);
232  pCondition = pConditionType->Clone(id+1, pConditionNode);
233  pCondition->Set(CONTACT);
234  pCondition->SetValue(HYDRAULIC, true);
235  ContactConditions.push_back(pCondition);
236  }
237 
238  id +=2;
239  }
240 
241  }
242 
243 
244  rContactModelPart.Conditions().swap(ContactConditions);
245 
246 
247  if( mEchoLevel > 1 ){
248  std::cout<<" / NEW:"<<rContactModelPart.NumberOfConditions()<<"] "<<std::endl;
249  }
250 
251  std::string ModelPartName;
252 
253  //Add contact conditions to computing domain
255  {
256  if(i_mp->Is(SOLID) && i_mp->Is(ACTIVE))
257  ModelPartName = i_mp->Name();
258  }
259 
260  AddContactConditions(rContactModelPart, mrMainModelPart.GetSubModelPart(ModelPartName));
261 
262  //Add contact conditions to main domain( with AddCondition are already added )
263  //AddContactConditions(rContactModelPart, mrMainModelPart);
264 
265  if( mEchoLevel >= 1 )
266  std::cout<<" [CONTACT CANDIDATES : "<<rContactModelPart.NumberOfConditions()<<"] ("<<mContactModelPartName<<") "<<std::endl;
267 
268  KRATOS_CATCH( "" )
269 
270  }
271 
272 
276 
277 
281 
282 
286 
287 
291 
292 
294 
295  private:
298 
302 
303  ConditionType::Pointer mpHydraulicConditionType;
304 
308 
309  //**************************************************************************
310  //**************************************************************************
311 
312  ConditionType::Pointer CreateConditionPrototypeHM( Parameters& CustomParameters )
313  {
314  KRATOS_TRY
315 
316 
317 
318 
319  ProcessInfo& rCurrentProcessInfo= mrMainModelPart.GetProcessInfo();
320  double Dimension = rCurrentProcessInfo[SPACE_DIMENSION];
321 
322  // create geometry prototype for the contact conditions
323  GeometryType::Pointer pGeometry;
324  if( Dimension == 2 )
325  pGeometry = Kratos::make_shared<Point2DType>(*((mrMainModelPart.Nodes().begin()).base()));
326  else if( Dimension == 3 )
327  pGeometry = Kratos::make_shared<Point3DType>(*((mrMainModelPart.Nodes().begin()).base()));
328 
329 
330  unsigned int LastConditionId = 1;
332  LastConditionId = mrMainModelPart.Conditions().back().Id() + 1;
333 
334  std::string ConditionName = CustomParameters["hydraulic_condition_type"].GetString();
335 
336  if ( ConditionName == "HydraulicPointContactCondition2D1N" ) {
337  return Kratos::make_intrusive<HydraulicRigidContactPenalty3DCondition>(LastConditionId, pGeometry, mpProperties, mpParametricWall);
338  }
339  else if ( ConditionName == "HydraulicAxisymPointContactCondition2D1N") {
340  return Kratos::make_intrusive<HydraulicAxisymRigidContactPenalty2DCondition>(LastConditionId, pGeometry, mpProperties, mpParametricWall);
341  } else {
342  std::cout << ConditionName << std::endl;
343  KRATOS_ERROR << "the specified hydraulic contact condition does not exist " << std::endl;
344  }
345 
346  return NULL;
347 
348  KRATOS_CATCH( "" )
349  }
350 
351 
355 
356  ConditionType::Pointer FindPointConditionHM(ModelPart & rModelPart, Node::Pointer pPoint, bool rHydraulic)
357  {
358  KRATOS_TRY
359 
360  for(ModelPart::ConditionsContainerType::iterator i_cond =rModelPart.ConditionsBegin(); i_cond!= rModelPart.ConditionsEnd(); ++i_cond)
361  {
362  if( i_cond->Is(CONTACT) && i_cond->GetGeometry().size() == 1 ){
363  if( i_cond->GetGeometry()[0].Id() == pPoint->Id() ){
364  if ( i_cond->GetValue(HYDRAULIC) == rHydraulic) {
365  return ( *(i_cond.base()) );
366  }
367  }
368  }
369  }
370 
371  if ( rHydraulic == false) {
372  return mpConditionType;
373  }
374  return mpHydraulicConditionType;
375 
376  KRATOS_CATCH("")
377  }
378 
379 
383 
384 
388 
389 
393 
396 
398  //Process(Process const& rOther);
399 
400 
402 
403  }; // Class Process
404 
406 
409 
410 
414 
415 
417  inline std::istream& operator >> (std::istream& rIStream,
419 
421  inline std::ostream& operator << (std::ostream& rOStream,
423  {
424  rThis.PrintInfo(rOStream);
425  rOStream << std::endl;
426  rThis.PrintData(rOStream);
427 
428  return rOStream;
429  }
431 
432 
433 } // namespace Kratos.
434 
435 #endif // KRATOS_HM_PARAMETRIC_WALL_CONTACT_SEARCH_PROCESS_H_INCLUDED defined
Base class for all Conditions.
Definition: condition.h:59
Geometry base class.
Definition: geometry.h:71
The base class for all processes in Kratos.
Definition: hm_parametric_wall_contact_search_process.hpp:65
ConditionType::GeometryType GeometryType
Definition: hm_parametric_wall_contact_search_process.hpp:76
HMParametricWallContactSearchProcess(ModelPart &rMainModelPart)
Default constructor.
Definition: hm_parametric_wall_contact_search_process.hpp:86
virtual std::string Info() const override
Turn back information as a string.
Definition: hm_parametric_wall_contact_search_process.hpp:141
KRATOS_CLASS_POINTER_DEFINITION(HMParametricWallContactSearchProcess)
Pointer definition of Process.
HMParametricWallContactSearchProcess(ModelPart &rMainModelPart, std::string rSubModelPartName, SpatialBoundingBox::Pointer pParametricWall, Parameters CustomParameters)
Definition: hm_parametric_wall_contact_search_process.hpp:89
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: hm_parametric_wall_contact_search_process.hpp:115
virtual void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: hm_parametric_wall_contact_search_process.hpp:153
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: hm_parametric_wall_contact_search_process.hpp:147
ModelPart::NodeType NodeType
Definition: hm_parametric_wall_contact_search_process.hpp:73
ModelPart::PropertiesType PropertiesType
Definition: hm_parametric_wall_contact_search_process.hpp:75
ModelPart::ConditionType ConditionType
Definition: hm_parametric_wall_contact_search_process.hpp:74
virtual void CreateContactConditions() override
Definition: hm_parametric_wall_contact_search_process.hpp:181
Point2D< ModelPart::NodeType > Point2DType
Definition: hm_parametric_wall_contact_search_process.hpp:77
Point3D< ModelPart::NodeType > Point3DType
Definition: hm_parametric_wall_contact_search_process.hpp:78
virtual ~HMParametricWallContactSearchProcess()
Destructor.
Definition: hm_parametric_wall_contact_search_process.hpp:107
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
SubModelPartIterator SubModelPartsEnd()
Definition: model_part.h:1708
SubModelPartIterator SubModelPartsBegin()
Definition: model_part.h:1698
std::string & Name()
Definition: model_part.h:1811
SubModelPartsContainerType::iterator SubModelPartIterator
Iterator over the sub model parts of this model part.
Definition: model_part.h:258
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
SizeType NumberOfConditions(IndexType ThisIndex=0) const
Definition: model_part.h:1218
ModelPart & GetSubModelPart(std::string const &SubModelPartName)
Definition: model_part.cpp:2029
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
std::string GetString() const
This method returns the string contained in the current Parameter.
Definition: kratos_parameters.cpp:684
The base class for all processes in Kratos.
Definition: parametric_wall_contact_search_process.hpp:78
ConditionType::Pointer mpConditionType
Definition: parametric_wall_contact_search_process.hpp:336
PropertiesType::Pointer mpProperties
Definition: parametric_wall_contact_search_process.hpp:338
SpatialBoundingBox::Pointer mpParametricWall
Definition: parametric_wall_contact_search_process.hpp:334
int mEchoLevel
Definition: parametric_wall_contact_search_process.hpp:342
void AddContactConditions(ModelPart &rOriginModelPart, ModelPart &rDestinationModelPart)
Definition: parametric_wall_contact_search_process.hpp:441
std::string mContactModelPartName
Definition: parametric_wall_contact_search_process.hpp:340
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: parametric_wall_contact_search_process.hpp:171
ModelPart & mrMainModelPart
Definition: parametric_wall_contact_search_process.hpp:332
Definition: point_2d.h:53
Definition: point_3d.h:53
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
void push_back(const TPointerType &x)
Definition: pointer_vector.h:270
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
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