10 #if !defined(KRATOS_BUILD_CONTACT_MODEL_PART_PROCESS_H_INCLUDED )
11 #define KRATOS_BUILD_CONTACT_MODEL_PART_PROCESS_H_INCLUDED
19 #include <boost/timer.hpp>
80 std::vector<std::string>& rContactModelParts,
82 : mrModelPart(rModelPart)
83 ,mrRemesh(rRemeshingParameters)
84 ,mrContactModelParts(rContactModelParts)
87 mMasterConditionsInitialized =
false;
93 :mrModelPart(rOther.mrModelPart)
94 ,mrRemesh(rOther.mrRemesh)
95 ,mrContactModelParts(rOther.mrContactModelParts)
96 ,mEchoLevel(rOther.mEchoLevel)
97 ,mMasterConditionsInitialized(rOther.mMasterConditionsInitialized)
126 std::cout<<
" [ CONSTRUCT CONTACT MODEL_PART: "<<std::endl;
131 rModelPart.
Set(CONTACT);
140 std::cout<<
" CONSTRUCT CONTACT MODEL_PART ]; "<<std::endl;
162 std::string
Info()
const override
164 return "BuildContactModelPartProcess";
170 rOStream <<
"BuildContactModelPartProcess";
235 std::vector<std::string> mrContactModelParts;
239 bool mMasterConditionsInitialized;
253 unsigned int count_nodes = 0;
254 unsigned int count_conditions = 0;
256 for(std::vector<std::string>::const_iterator n_mp = mrContactModelParts.begin(); n_mp!=mrContactModelParts.end(); ++n_mp)
259 ModelPart& i_mp = mrModelPart.GetSubModelPart(*n_mp);
261 for(ModelPart::NodesContainerType::iterator i_node = i_mp.
NodesBegin() ; i_node != i_mp.
NodesEnd() ; i_node++)
263 if( i_node->Is(BOUNDARY) )
269 if( i_cond->Is(BOUNDARY) && i_cond->IsNot(CONTACT) )
275 bool build_is_needed =
false;
276 if( count_nodes != rModelPart.
Nodes().size() || count_conditions != rModelPart.
Conditions().size() )
277 build_is_needed =
true;
280 if( rProcessInfo[MESHING_STEP_TIME] == rProcessInfo[TIME] )
281 build_is_needed =
true;
283 if( build_is_needed ){
288 rModelPart.
Nodes().clear();
295 for(std::vector<std::string>::const_iterator n_mp = mrContactModelParts.begin(); n_mp!=mrContactModelParts.end(); ++n_mp)
298 ModelPart& i_mp = mrModelPart.GetSubModelPart(*n_mp);
300 for(ModelPart::NodesContainerType::iterator i_node = i_mp.NodesBegin() ; i_node != i_mp.NodesEnd() ; i_node++)
302 if( i_node->Is(BOUNDARY) )
303 rModelPart.
AddNode(*(i_node.base()));
306 for(ModelPart::ConditionsContainerType::iterator i_cond = i_mp.ConditionsBegin() ; i_cond != i_mp.ConditionsEnd() ; i_cond++)
308 if( i_cond->Is(BOUNDARY) && i_cond->IsNot(CONTACT) )
314 for(ModelPart::ConditionsContainerType::iterator i_cond = PreservedConditions.begin(); i_cond!= PreservedConditions.end(); i_cond++)
316 if(i_cond->Is(CONTACT)){
317 rModelPart.
Conditions().push_back(*(i_cond.base()));
341 void Transfer(ModelPart& rModelPart)
348 MeshDataTransferUtilities DataTransferUtilities;
350 MeshDataTransferUtilities::TransferParameters::Pointer rParameters = mrRemesh.
GetTransferParameters();
353 if(!mMasterConditionsInitialized){
354 rParameters->Options.Set(MeshDataTransferUtilities::INITIALIZE_MASTER_CONDITION,
true);
355 DataTransferUtilities.TransferBoundaryData(*rParameters, rModelPart);
356 mMasterConditionsInitialized =
true;
359 rParameters->Options.Set(MeshDataTransferUtilities::MASTER_ELEMENT_TO_MASTER_CONDITION,
true);
360 DataTransferUtilities.TransferBoundaryData(*rParameters, mrModelPart);
377 std::vector<BoundedVector<double, 3> > Holes;
378 BoundedVector<double, 3> Point;
380 for(std::vector<std::string>::const_iterator n_mp = mrContactModelParts.begin(); n_mp!=mrContactModelParts.end(); ++n_mp)
383 ModelPart& i_mp = mrModelPart.GetSubModelPart(*n_mp);
386 unsigned int dimension = i_mp.GetProcessInfo()[SPACE_DIMENSION];
387 if(i_mp.NumberOfConditions()){
388 ModelPart::ConditionsContainerType::iterator element_begin = i_mp.ConditionsBegin();
389 dimension = element_begin->GetGeometry().WorkingSpaceDimension();
392 bool hole_found =
false;
393 for(ModelPart::NodesContainerType::iterator i_node = i_mp.NodesBegin() ; i_node != i_mp.NodesEnd() ; i_node++)
395 if( i_node->IsNot(BOUNDARY) ){
396 Point[0] = i_node->X();
397 Point[1] = i_node->Y();
400 Point[2] = i_node->Z();
403 Holes.push_back(Point);
410 for(ModelPart::NodesContainerType::iterator i_node = i_mp.NodesBegin() ; i_node != i_mp.NodesEnd() ; i_node++)
412 if( i_node->Is(BOUNDARY) ){
414 array_1d<double, 3>& Normal = i_node->FastGetSolutionStepValue(NORMAL);
415 double Nodal_H = i_node->FastGetSolutionStepValue(NODAL_H);
416 double tolerance = 0.5 * Nodal_H;
420 Point[0] = i_node->X() - Normal[0] * tolerance;
421 Point[1] = i_node->Y() - Normal[1] * tolerance;
423 Point[2] = i_node->Z() - Normal[2] * tolerance;
425 Holes.push_back(Point);
491 rOStream << std::endl;
Base class for all Conditions.
Definition: condition.h:59
void Set(const Flags ThisFlag)
Definition: flags.cpp:33
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
ConditionIterator ConditionsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1361
void AddNode(NodeType::Pointer pNewNode, IndexType ThisIndex=0)
Definition: model_part.cpp:211
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
void AddCondition(ConditionType::Pointer pNewCondition, IndexType ThisIndex=0)
Definition: model_part.cpp:1436
SizeType NumberOfConditions(IndexType ThisIndex=0) const
Definition: model_part.h:1218
ModelPart & GetSubModelPart(std::string const &SubModelPartName)
Definition: model_part.cpp:2029
SizeType NumberOfNodes(IndexType ThisIndex=0) const
Definition: model_part.h:341
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
ConditionIterator ConditionsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1371
void swap(PointerVectorSet &rOther)
Swaps the contents of this PointerVectorSet with another.
Definition: pointer_vector_set.h:532
The base class for all processes in Kratos.
Definition: process.h:49
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
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
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
ProcessInfo
Definition: edgebased_PureConvection.py:116
int dimension
Definition: isotropic_damage_automatic_differentiation.py:123
Definition: mesher_utilities.hpp:631
TransferParametersType::Pointer GetTransferParameters()
Definition: mesher_utilities.hpp:828
std::string SubModelPartName
Definition: mesher_utilities.hpp:642
void SetHoles(std::vector< BoundedVector< double, 3 >> &rHoles)
Definition: mesher_utilities.hpp:803