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.
clear_point_contact_conditions_process.hpp
Go to the documentation of this file.
1 //
2 // Project Name: KratosContactMechanicsApplication $
3 // Created by: $Author: JMCarbonell $
4 // Last modified by: $Co-Author: $
5 // Date: $Date: July 2016 $
6 // Revision: $Revision: 0.0 $
7 //
8 //
9 
10 #if !defined(KRATOS_CLEAR_POINT_CONTACT_CONDITIONS_PROCESS_H_INCLUDED )
11 #define KRATOS_CLEAR_POINT_CONTACT_CONDITIONS_PROCESS_H_INCLUDED
12 
13 
14 // System includes
15 
16 // External includes
17 
18 // Project includes
19 
20 #include "includes/model_part.h"
22 
24 //Data:
25 //StepData:
26 //Flags: (checked)
27 // (set)
28 // (modified)
29 // (reset)
30 
31 
32 namespace Kratos
33 {
34 
37 
44 
48 
52 
56 
58 
61  : public Process
62  {
63  public:
66 
69 
73 
76  int EchoLevel = 0)
77  : mrModelPart(rModelPart)
78  {
79  mEchoLevel = EchoLevel;
80  }
81 
84  {
85  }
86 
87 
91 
92  void operator()()
93  {
94  Execute();
95  }
96 
97 
101 
102  void Execute() override
103  {
104  KRATOS_TRY
105 
106  this->ClearPointContactConditions();
107 
108  KRATOS_CATCH(" ")
109  };
110 
111 
114  void ExecuteInitialize() override
115  {
116  KRATOS_TRY
117 
118  this->Execute();
119 
120  KRATOS_CATCH( "" )
121  }
122 
123 
126  void ExecuteFinalize() override
127  {
128  KRATOS_TRY
129 
130  // Clear Contact Forces
131  this->ClearPointContactForces();
132 
133  // Clear Contact Normals
134  this->ClearPointContactNormals();
135 
136  KRATOS_CATCH(" ")
137  }
138 
142 
143 
147 
148 
152 
154  std::string Info() const override
155  {
156  return "ClearPointContactConditionsProcess";
157  }
158 
160  void PrintInfo(std::ostream& rOStream) const override
161  {
162  rOStream << "ClearPointContactConditionsProcess";
163  }
164 
166  void PrintData(std::ostream& rOStream) const override
167  {
168  }
169 
170 
174 
175 
177 
178  protected:
181 
182 
186 
187 
191 
192 
196 
197 
201 
202 
206 
207 
211 
212 
214 
215  private:
218 
222 
223  ModelPart& mrModelPart;
224 
225  int mEchoLevel;
226 
230 
234 
235 
236  //**************************************************************************
237  //**************************************************************************
238 
239  void ClearPointContactForces()
240  {
241  KRATOS_TRY
242 
243 
244  ModelPart::NodesContainerType& rNodes = mrModelPart.Nodes();
245 
246  // create contact condition for rigid and deformable bodies
247  for(ModelPart::NodesContainerType::ptr_iterator nd = rNodes.ptr_begin(); nd != rNodes.ptr_end(); ++nd)
248  {
249  if( (*nd)->Is(BOUNDARY) && (*nd)->IsNot(CONTACT) ){
250  array_1d<double, 3> & ContactForce = (*nd)->FastGetSolutionStepValue(CONTACT_FORCE);
251  ContactForce.clear();
252  }
253 
254  }
255 
256  KRATOS_CATCH( "" )
257 
258  }
259 
260  //**************************************************************************
261  //**************************************************************************
262 
263  void ClearPointContactNormals()
264  {
265  KRATOS_TRY
266 
267 
268  ModelPart::NodesContainerType& rNodes = mrModelPart.Nodes();
269 
270  // create contact condition for rigid and deformable bodies
271  for(ModelPart::NodesContainerType::ptr_iterator nd = rNodes.ptr_begin(); nd != rNodes.ptr_end(); ++nd)
272  {
273  if( (*nd)->Is(BOUNDARY) && (*nd)->IsNot(CONTACT) ){
274  array_1d<double, 3> & ContactNormal = (*nd)->FastGetSolutionStepValue(CONTACT_NORMAL);
275  ContactNormal.clear();
276  }
277 
278  }
279 
280  KRATOS_CATCH( "" )
281 
282  }
283 
284  //**************************************************************************
285  //**************************************************************************
286 
287  void ClearPointContactConditions()
288  {
289 
290  KRATOS_TRY
291 
292  std::string ModelPartName;
293 
294  //Clear contact conditions from computing domain
295  for(ModelPart::SubModelPartIterator i_mp= mrModelPart.SubModelPartsBegin(); i_mp!=mrModelPart.SubModelPartsEnd(); i_mp++)
296  {
297  if(i_mp->Is(SOLID) && i_mp->Is(ACTIVE))
298  ModelPartName = i_mp->Name();
299  }
300 
301  ClearPointContactConditions(mrModelPart.GetSubModelPart(ModelPartName));
302 
303  //Clear contact conditions from the main domain
304  ClearPointContactConditions(mrModelPart);
305 
306  KRATOS_CATCH( "" )
307 
308  }
309 
310  //**************************************************************************
311  //**************************************************************************
312 
313  void ClearPointContactConditions(ModelPart& rModelPart)
314  {
315 
316  KRATOS_TRY
317 
318  //*******************************************************************
319  //clearing contact conditions
320  //
321 
322  if( mEchoLevel > 1 ){
323  std::cout<<" ["<<rModelPart.Name()<<" :: CONDITIONS [OLD:"<<rModelPart.NumberOfConditions();
324  }
325 
326  ModelPart::ConditionsContainerType PreservedConditions;
327 
328  for(ModelPart::ConditionsContainerType::iterator ic = rModelPart.ConditionsBegin(); ic!= rModelPart.ConditionsEnd(); ic++)
329  {
330  if( !(ic->Is(CONTACT) && ic->GetGeometry().size() == 1) ){
331  PreservedConditions.push_back(*(ic.base()));
332  }
333  }
334 
335  rModelPart.Conditions().swap(PreservedConditions);
336 
337  //rModelPart.Conditions().Sort();
338  //rModelPart.Conditions().Unique();
339 
340  if( mEchoLevel > 1 ){
341  std::cout<<" / NEW:"<<rModelPart.NumberOfConditions()<<"] "<<std::endl;
342  }
343 
344  KRATOS_CATCH( "" )
345 
346  }
347 
348 
352 
353 
357 
358 
362 
365 
367  //ClearPointContactConditionsProcess(ClearPointContactConditionsProcess const& rOther);
368 
369 
371 
372  }; // Class ClearPointContactConditionsProcess
373 
375 
378 
379 
383 
384 
386  inline std::istream& operator >> (std::istream& rIStream,
388 
390  inline std::ostream& operator << (std::ostream& rOStream,
392  {
393  rThis.PrintInfo(rOStream);
394  rOStream << std::endl;
395  rThis.PrintData(rOStream);
396 
397  return rOStream;
398  }
400 
401 
402 } // namespace Kratos.
403 
404 #endif // CONTACT_CLEAR_POINT_CONTACT_CONDITIONS_PROCESS_H_INCLUDED defined
Short class definition.
Definition: clear_point_contact_conditions_process.hpp:62
void ExecuteFinalize() override
Definition: clear_point_contact_conditions_process.hpp:126
std::string Info() const override
Turn back information as a string.
Definition: clear_point_contact_conditions_process.hpp:154
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: clear_point_contact_conditions_process.hpp:102
void operator()()
Definition: clear_point_contact_conditions_process.hpp:92
KRATOS_CLASS_POINTER_DEFINITION(ClearPointContactConditionsProcess)
Pointer definition of ClearPointContactConditionsProcess.
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: clear_point_contact_conditions_process.hpp:160
virtual ~ClearPointContactConditionsProcess()
Destructor.
Definition: clear_point_contact_conditions_process.hpp:83
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: clear_point_contact_conditions_process.hpp:166
ClearPointContactConditionsProcess(ModelPart &rModelPart, int EchoLevel=0)
Default constructor.
Definition: clear_point_contact_conditions_process.hpp:75
void ExecuteInitialize() override
Definition: clear_point_contact_conditions_process.hpp:114
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::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
SubModelPartsContainerType::iterator SubModelPartIterator
Iterator over the sub model parts of this model part.
Definition: model_part.h:258
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
void push_back(TPointerType x)
Adds a pointer to the end of the set.
Definition: pointer_vector_set.h:544
The base class for all processes in Kratos.
Definition: process.h:49
BOOST_UBLAS_INLINE void clear()
Definition: array_1d.h:325
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
ModelPart::NodesContainerType NodesContainerType
Definition: find_conditions_neighbours_process.h:44
ModelPart::ConditionsContainerType ConditionsContainerType
Definition: find_conditions_neighbours_process.h:45
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
ModelPart::ElementsContainerType ElementsContainerType
Definition: clear_contact_conditions_mesher_process.hpp:43
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432