10 #if !defined(KRATOS_REMOVE_NODES_MESHER_PROCESS_H_INCLUDED )
11 #define KRATOS_REMOVE_NODES_MESHER_PROCESS_H_INCLUDED
122 std::cout<<
" [ REMOVE CLOSE NODES: "<<std::endl;
136 bool any_node_removed =
false;
137 bool any_condition_removed =
false;
143 if (
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_NODES) || (
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_BOUNDARY_NODES)) )
145 bool any_node_removed_on_error =
false;
147 if (
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_NODES_ON_ERROR) &&
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_NODES) )
153 bool any_convex_condition_removed =
false;
155 if (
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_BOUNDARY_NODES))
157 any_convex_condition_removed = this->RemoveNonConvexBoundary(
mrModelPart);
162 bool any_node_removed_on_distance =
false;
164 if (
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_NODES_ON_DISTANCE) ||
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_BOUNDARY_NODES_ON_DISTANCE))
174 if (
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_BOUNDARY_NODES_ON_DISTANCE) )
177 if ( any_node_removed_on_contact || any_node_removed_on_distance)
178 any_node_removed_on_distance =
true;
182 if(any_node_removed_on_error || any_node_removed_on_distance)
183 any_node_removed =
true;
185 std::cout <<
" any_node_removed " << any_node_removed << std::endl;
186 if(any_convex_condition_removed || any_condition_removed)
187 any_condition_removed =
true;
190 if(any_node_removed || any_condition_removed){
191 std::cout<<
" Removed Nodes: ( error "<<any_node_removed_on_error<<
" distance "<<any_node_removed_on_distance<<
" conv_cond "<<any_convex_condition_removed<<
" cond "<< any_condition_removed<<
")"<<std::endl;
195 if(any_condition_removed){
203 if(i_cond->IsNot(TO_ERASE)){
205 PreservedConditions.push_back(*i_cond.base());
209 std::cout<<
" Condition RELEASED:"<<i_cond->Id()<<std::endl;
224 if( i_node.Is(TO_ERASE) && i_node.Is(BLOCKED) )
225 std::cout<<
" REMOVE NOT ALLOWED entity NODE : "<<i_node.Id()<<
" "<<i_node.Coordinates()<<std::endl;
236 std::cout<<
" [ CONDITIONS ( removed : "<<RemovedConditions<<
" ) ]"<<std::endl;
237 std::cout<<
" [ NODES ( removed : "<<
mrRemesh.
Info->RemovedNodes<<
" ) ]"<<std::endl;
245 std::cout<<
" REMOVE CLOSE NODES ]; "<<std::endl;
268 std::string
Info()
const override
270 return "RemoveNodesMesherProcess";
276 rOStream <<
"RemoveNodesMesherProcess";
324 temporal_nodes.reserve(rModelPart.
Nodes().size());
326 temporal_nodes.swap(rModelPart.
Nodes());
328 for(
auto i_node(temporal_nodes.begin()); i_node != temporal_nodes.end(); ++i_node)
330 if( i_node->IsNot(TO_ERASE) ){
331 rModelPart.
Nodes().push_back(*i_node.base());
334 if( i_node->Is(BOUNDARY) ) {
336 std::cout<<
" BOUNDARY NODE RELEASED "<<i_node->Id()<<std::endl;
337 std::cout <<
" Removing Boundary " << i_node->Id() <<
" :: " << i_node->X() <<
" , " << i_node->Y() << std::endl;
339 std::cout <<
" Removing NONboundary " << i_node->Id() <<
" :: " << i_node->X() <<
" , " << i_node->Y() << std::endl;
344 rModelPart.
Nodes().Sort();
360 double size_for_distance_inside = 1.0 *
mrRemesh.
Refine->CriticalRadius;
361 double size_for_distance_boundary = 1.5 * size_for_distance_inside;
364 bool any_node_removed =
false;
367 unsigned int bucket_size = 20;
370 std::vector<Node::Pointer> list_of_nodes;
372 for(
auto i_node(rModelPart.
Nodes().begin()); i_node != rModelPart.
Nodes().end(); ++i_node)
374 list_of_nodes.push_back(*i_node.base());
377 KdtreeType nodes_tree(list_of_nodes.begin(),list_of_nodes.end(), bucket_size);
382 unsigned int num_neighbours = 100;
384 std::vector<Node::Pointer> neighbours (num_neighbours);
385 std::vector<double> neighbour_distances(num_neighbours);
390 Node work_point(0,0.0,0.0,0.0);
391 unsigned int n_points_in_radius;
394 for(
auto& i_node : rModelPart.
Nodes())
397 bool on_contact_tip =
false;
398 bool contact_active =
false;
400 if( i_node.SolutionStepsDataHas(CONTACT_FORCE) ){
402 if(
norm_2(ContactForceNormal)>0)
403 contact_active =
true;
406 if(contact_active || i_node.Is(CONTACT) )
407 on_contact_tip =
true;
409 if( i_node.IsNot(NEW_ENTITY) && i_node.IsNot(BLOCKED) && i_node.IsNot(TO_ERASE) )
411 radius = size_for_distance_inside;
413 work_point[0]=i_node.
X();
414 work_point[1]=i_node.
Y();
415 work_point[2]=i_node.
Z();
417 n_points_in_radius = nodes_tree.
SearchInRadius(work_point,
radius, neighbours.begin(),neighbour_distances.begin(), num_neighbours);
419 if (n_points_in_radius>1)
422 if( i_node.IsNot(BOUNDARY) )
424 if(
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_NODES_ON_DISTANCE) ){
426 if( !this->
CheckEngagedNode(i_node,neighbours,neighbour_distances,n_points_in_radius) ){
427 i_node.Set(TO_ERASE);
428 any_node_removed =
true;
429 inside_nodes_removed++;
437 else if ( (
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_BOUNDARY_NODES) &&
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_BOUNDARY_NODES_ON_DISTANCE)) )
446 for(std::vector<Node::Pointer>::iterator i_nnode=neighbours.begin(); i_nnode!=neighbours.begin() + n_points_in_radius ; ++i_nnode)
448 bool nn_on_contact_tip =
false;
449 bool contact_active =
false;
451 if( (*i_nnode)->SolutionStepsDataHas(CONTACT_FORCE) ){
452 array_1d<double, 3 > & ContactForceNormal = (*i_nnode)->FastGetSolutionStepValue(CONTACT_FORCE);
453 if(
norm_2(ContactForceNormal)>0)
454 contact_active =
true;
457 if(contact_active || (*i_nnode)->Is(CONTACT) )
458 nn_on_contact_tip =
true;
461 if ( (*i_nnode)->Is(BOUNDARY) && !nn_on_contact_tip && neighbour_distances[
k] < size_for_distance_boundary && neighbour_distances[
k] > 0.0 )
464 if((*i_nnode)->IsNot(TO_ERASE)){
473 if(
counter > 1 && !on_contact_tip ){
474 i_node.Set(TO_ERASE);
476 any_node_removed =
true;
477 boundary_nodes_removed++;
491 if(boundary_nodes_removed){
497 return any_node_removed;
506 virtual bool CheckEngagedNode(
Node& rNode, std::vector<Node::Pointer>& rNeighbours, std::vector<double>& rNeighbourDistances,
unsigned int& rn_points_in_radius)
511 bool engaged_node =
false;
516 unsigned int closest_node = 0;
518 for(std::vector<double>::iterator nd=rNeighbourDistances.begin(); nd!=rNeighbourDistances.begin()+rn_points_in_radius; ++nd)
520 if( (*nd) < min_distance && (*nd) > 0.0 ){
521 min_distance = (*nd);
528 if( rNeighbours[closest_node]->
Is(TO_ERASE) && rNeighbours[closest_node]->
IsNot(BOUNDARY) ){
533 unsigned int erased_node = 0;
534 for(std::vector<Node::Pointer>::iterator i_nnode=rNeighbours.begin(); i_nnode!=rNeighbours.begin()+rn_points_in_radius; ++i_nnode)
536 if( (*i_nnode)->IsNot(BOUNDARY) && (*i_nnode)->Is(TO_ERASE) )
546 if( rNeighbourDistances[closest_node] * 5 < rNeighbourDistances[erased_node] ){
547 engaged_node =
false;
566 double size_for_criterion_error = 2.0 *
mrRemesh.
Refine->CriticalRadius;
568 bool any_node_removed =
false;
573 std::vector<double> NodalError(rModelPart.
NumberOfNodes()+1);
575 unsigned int number_of_nodes = 0;
582 std::vector<int> nodes_ids(number_of_nodes);
587 for(
auto& i_node : rModelPart.
Nodes())
592 for(
auto& i_nnode : nNodes)
594 if(i_nnode.Is(TO_ERASE))
599 if(i_node.IsNot(BOUNDARY) && erased_nodes < 1)
601 double& MeanError = i_node.FastGetSolutionStepValue(MEAN_ERROR);
602 MeanError = NodalError[nodes_ids[i_node.Id()]];
605 double mean_node_radius = 0;
606 for(
auto& i_nelem : nElements)
613 if(NodalError[nodes_ids[i_node.Id()]] <
mrRemesh.
Refine->ReferenceError && mean_node_radius < size_for_criterion_error)
617 i_node.Set(TO_ERASE);
618 any_node_removed =
true;
619 error_removed_nodes++;
624 return any_node_removed;
633 virtual bool RemoveNodesOnContact(
ModelPart& rModelPart,
unsigned int& inside_nodes_removed,
unsigned int& boundary_nodes_removed,
bool& any_condition_removed)
639 std::cout<<
" [ REMOVE NODES ON CONTACT AND BEYOND : "<<std::endl;
640 std::cout<<
" Starting Conditions : "<<rModelPart.
Conditions().size()<<std::endl;
644 double size_for_distance_inside = 1.0 *
mrRemesh.
Refine->CriticalRadius;
645 double size_for_distance_boundary = 1.5 * size_for_distance_inside;
647 double size_for_wall_tip_contact_side = (0.5 *
mrRemesh.
Refine->CriticalSide);
648 size_for_wall_tip_contact_side *= 0.5;
649 size_for_wall_tip_contact_side = size_for_wall_tip_contact_side * size_for_wall_tip_contact_side;
652 size_for_wall_tip_contact_side *= SF*SF;
655 bool any_node_removed =
false;
658 unsigned int bucket_size = 20;
661 std::vector<Node::Pointer> list_of_nodes;
665 list_of_nodes.push_back(*i_node.base());
668 KdtreeType nodes_tree(list_of_nodes.begin(),list_of_nodes.end(), bucket_size);
673 unsigned int num_neighbours = 100;
675 std::vector<Node::Pointer> neighbours (num_neighbours);
676 std::vector<double> neighbour_distances(num_neighbours);
681 Node work_point(0,0.0,0.0,0.0);
682 unsigned int n_points_in_radius;
687 bool on_contact_tip =
false;
690 if(
norm_2(ContactForceNormal)>0 || in->Is(CONTACT) )
691 on_contact_tip =
true;
693 bool on_contact_tip_strict =
false;
694 if (
norm_2(ContactForceNormal) > 0)
695 on_contact_tip_strict =
true;
697 if( in->IsNot(NEW_ENTITY) )
699 radius = size_for_distance_inside;
701 work_point[0]=in->
X();
702 work_point[1]=in->
Y();
703 work_point[2]=in->
Z();
705 n_points_in_radius = nodes_tree.
SearchInRadius(work_point,
radius, neighbours.begin(),neighbour_distances.begin(), num_neighbours);
707 if (n_points_in_radius>1)
710 if ( in->IsNot(BOUNDARY) )
713 if(
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_NODES_ON_DISTANCE) ){
715 unsigned int contact_nodes = 0;
716 unsigned int erased_nodes = 0;
717 unsigned int near_to_contact_nodes = 0;
719 for(std::vector<Node::Pointer>::iterator nn=neighbours.begin(); nn!=neighbours.begin() + n_points_in_radius ; ++nn)
721 if( (*nn)->Is(BOUNDARY) && (*nn)->Is(CONTACT) )
724 if( (*nn)->Is(TO_ERASE) )
728 if ( (*nn)->Is(BOUNDARY) && (*nn)->Is(CONTACT) && (neighbour_distances[kk] < SF*size_for_wall_tip_contact_side) )
729 near_to_contact_nodes += 1;
735 if ( erased_nodes < 1 && contact_nodes < 2 && near_to_contact_nodes == 1)
739 any_node_removed =
true;
740 inside_nodes_removed++;
741 std::cout <<
" RemovingC0, an interior node very very near to a (possibly) contacting node " << in->Id() << std::endl;
742 std::cout <<
" X: " << in->X() <<
" Y: " << in->Y() << std::endl;
748 else if ( (
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_BOUNDARY_NODES) &&
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_BOUNDARY_NODES_ON_DISTANCE)) && (in)->IsNot(TO_ERASE))
757 unsigned int counterC2 = 0, counterC3 = 0;
758 for(std::vector<Node::Pointer>::iterator nn=neighbours.begin(); nn!=neighbours.begin() + n_points_in_radius ; ++nn)
762 bool nn_on_contact_tip =
false;
765 if(
norm_2(ContactForceNormal)>0 || (*nn)->Is(CONTACT) )
766 nn_on_contact_tip =
true;
768 bool nn_on_contact_tip_strict =
false;
769 if (
norm_2(ContactForceNormal)>0)
770 nn_on_contact_tip_strict =
true;
772 if ( (*nn)->Is(BOUNDARY) && neighbour_distances[
k] > 0.0 && (*nn)->IsNot(TO_ERASE) )
775 if ( neighbour_distances[
k] < size_for_wall_tip_contact_side ) {
776 if ( nn_on_contact_tip_strict && (*nn)->IsNot(NEW_ENTITY) ) {
779 if ( nn_on_contact_tip && nn_on_contact_tip_strict && neighbour_distances[
k] < SF*size_for_distance_boundary ) {
788 if ( counterC2 > 1 && in->IsNot(NEW_ENTITY) && on_contact_tip_strict) {
790 std::cout <<
" RemovingC2: three contacting nodes where close, removing the middle one [" << in->Id() <<
"]" << std::endl;
791 any_node_removed =
true;
792 boundary_nodes_removed++;
793 std::cout <<
" X: " << in->X() <<
" Y: " << in->Y() << std::endl;
795 else if ( counterC3 > 0 && in->IsNot(NEW_ENTITY) && on_contact_tip && !on_contact_tip_strict ) {
798 any_node_removed =
true;
799 boundary_nodes_removed++;
800 std::cout <<
" RemovingC3: a non_contacting_node was to close to a contacting. removing the non_contacting " << in->Id() << std::endl;
801 std::cout <<
" X: " << in->X() <<
" Y: " << in->Y() << std::endl;
812 if (
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_BOUNDARY_NODES) &&
mrRemesh.
Refine->RemovingOptions.Is(MesherUtilities::REMOVE_BOUNDARY_NODES_ON_DISTANCE) )
817 bool on_contact_tip =
false;
820 if(
norm_2(ContactForceNormal)>0 || in->Is(CONTACT) )
821 on_contact_tip =
true;
823 bool on_contact_tip_strict =
false;
824 if (
norm_2(ContactForceNormal) > 0)
825 on_contact_tip_strict =
true;
827 if ( in->IsNot(NEW_ENTITY) && in->IsNot(TO_ERASE) && in->Is(BOUNDARY) && on_contact_tip )
829 radius = size_for_distance_inside;
831 work_point[0]=in->
X();
832 work_point[1]=in->
Y();
833 work_point[2]=in->
Z();
835 n_points_in_radius = nodes_tree.
SearchInRadius(work_point,
radius, neighbours.begin(),neighbour_distances.begin(), num_neighbours);
837 if (n_points_in_radius>1)
840 unsigned int counterC4 = 0;
841 for (std::vector<Node::Pointer>::iterator nn = neighbours.begin(); nn!=neighbours.begin() + n_points_in_radius; ++nn)
843 bool nn_on_contact_tip =
false;
847 if(
norm_2(ContactForceNormal)>0 || (*nn)->Is(CONTACT) )
848 nn_on_contact_tip =
true;
849 bool nn_on_contact_tip_strict =
false;
850 if (
norm_2(ContactForceNormal) > 0)
851 nn_on_contact_tip_strict =
true;
853 if ( (*nn)->IsNot(NEW_ENTITY) && (*nn)->IsNot(TO_ERASE) && (*nn)->Is(BOUNDARY) && neighbour_distances[
k] > 0.0)
855 if ( nn_on_contact_tip && nn_on_contact_tip_strict && neighbour_distances[
k] < SF*SF*size_for_wall_tip_contact_side)
858 std::cout <<
" THIS IS THE CONTRARY NODE: " << (*nn)->X() <<
" " << (*nn)->Y() << std::endl;
859 std::cout <<
" THIS IS THE CONTRARY FORCE: " << ContactForceNormal << std::endl;
860 std::cout <<
" module " <<
norm_2(ContactForceNormal) << std::endl;
866 if (counterC4 > 0 && in->IsNot(NEW_ENTITY) && on_contact_tip && on_contact_tip_strict )
869 any_node_removed =
true;
870 boundary_nodes_removed++;
871 std::cout <<
" RemovingC4: two contacting nodes are very very near, removing one " << in->Id() << std::endl;
872 std::cout <<
" X: " << in->X() <<
" Y: " << in->Y() << std::endl;
881 std::cout <<
" inside nodes removed " << inside_nodes_removed << std::endl;
882 std::cout <<
" boundary_nodes_removed " << boundary_nodes_removed << std::endl;
883 std::cout<<
" REMOVE NODES ON CONTACT AND BEYOND ]; "<<std::endl;
887 if(boundary_nodes_removed){
893 return any_node_removed;
904 bool any_condition_removed =
false;
906 unsigned int number_of_nodes = 0;
912 std::vector<std::vector<Condition::Pointer> > node_shared_conditions(number_of_nodes);
914 for(
auto i_cond(rModelPart.
Conditions().begin()); i_cond != rModelPart.
Conditions().end(); ++i_cond)
916 if(i_cond->IsNot(NEW_ENTITY) && i_cond->IsNot(TO_ERASE)){
918 for(
unsigned int i=0;
i<rConditionGeom.
size(); ++
i){
920 if(rConditionGeom[
i].
Is(TO_ERASE)){
922 std::cout<<
" Released node condition ["<<rConditionGeom[
i].
Id()<<
"]: WARNING "<<std::endl;
925 node_shared_conditions[rConditionGeom[
i].
Id()].push_back(*i_cond.base());
937 unsigned int initial_cond_size = 0;
944 unsigned int new_id = 0;
946 for(ModelPart::NodesContainerType::const_iterator in = rModelPart.
NodesBegin(); in != rModelPart.
NodesEnd(); ++in)
949 if( in->Is(BOUNDARY) && in->IsNot(MODIFIED) && in->IsNot(NEW_ENTITY) && in->Is(TO_ERASE) ){
951 unsigned int nodeId = in->Id();
953 if(node_shared_conditions[nodeId].size()>=2){
956 if(node_shared_conditions[nodeId][0]->
IsNot(TO_ERASE) && node_shared_conditions[nodeId][1]->
IsNot(TO_ERASE)){
958 if(node_shared_conditions[nodeId][0]->GetGeometry()[0].Id() == in->Id()){
968 Geometry< Node >& rConditionGeom1 = node_shared_conditions[nodeId][
i]->GetGeometry();
969 Geometry< Node >& rConditionGeom2 = node_shared_conditions[nodeId][
j]->GetGeometry();
973 Node::Pointer pNode0 = rConditionGeom1(0);
974 Node::Pointer pNode2 = rConditionGeom2(1);
976 node_shared_conditions[nodeId][
i]->Set(TO_ERASE);
977 node_shared_conditions[nodeId][
j]->Set(TO_ERASE);
980 any_condition_removed =
true;
982 Condition::Pointer NewCond = node_shared_conditions[nodeId][
i];
984 pNode0->Set(MODIFIED);
985 pNode2->Set(MODIFIED);
994 new_id = initial_cond_size + id;
996 Condition::Pointer pcond = NewCond->Clone(new_id, face);
999 pcond->Set(NEW_ENTITY);
1000 if ( pcond->Is(TO_ERASE) ) {
1001 pcond->Reset(TO_ERASE);
1007 pcond->SetValue(NORMAL, NewCond->GetValue(NORMAL) );
1008 pcond->SetValue(MASTER_NODES, NewCond->GetValue(MASTER_NODES) );
1019 in->Set(TO_ERASE,
false);
1020 std::cout <<
"FINALLY NOT Removing " << in->Id() << std::endl;
1021 std::cout <<
" is boundary?? " << in->Is(BOUNDARY) << std::endl;
1022 std::cout <<
" is blocked?? " << in->IsNot(BLOCKED) << std::endl;
1023 std::cout <<
" is NEW_ENDITY " << in->IsNot(NEW_ENTITY) << std::endl;
1024 std::cout <<
" to erase " << in->Is(TO_ERASE) << std::endl;
1033 return any_condition_removed;
1068 bool RemoveNonConvexBoundary(
ModelPart& rModelPart)
1073 std::cout<<
" [ REMOVE NON CONVEX BOUNDARY : "<<std::endl;
1080 double critical_angle = -120;
1084 unsigned int number_of_nodes = 0;
1091 std::vector<std::vector<Condition::Pointer> > node_shared_conditions(number_of_nodes);
1097 if(ic->IsNot(NEW_ENTITY) && ic->IsNot(TO_ERASE)){
1098 Geometry< Node >& rConditionGeom = ic->GetGeometry();
1099 for(
unsigned int i=0;
i<rConditionGeom.size(); ++
i){
1101 if(rConditionGeom[
i].
Is(TO_ERASE))
1102 std::cout<<
" WARNING: Released node condition "<<std::endl;
1104 node_shared_conditions[rConditionGeom[
i].Id()].push_back(*(ic.base()));
1107 else if ( ic->Is(TO_ERASE))
1109 std::cout <<
" we are here with a condition to erase " << ic->Id() << std::endl;
1121 array_1d<double,3> S1;
1122 array_1d<double,3> S2;
1127 array_1d<double,3> N1;
1128 array_1d<double,3> N2;
1137 unsigned int initial_cond_size = 0;
1144 unsigned int id = 1;
1145 unsigned int new_id = 0;
1146 int RemovedNodes =0;
1148 for(ModelPart::NodesContainerType::const_iterator in = rModelPart.
NodesBegin(); in != rModelPart.
NodesEnd(); ++in)
1152 double condition_angle = 0;
1154 if( in->Is(BOUNDARY) && in->IsNot(MODIFIED) && in->IsNot(NEW_ENTITY) )
1156 unsigned int nodeId = in->Id();
1158 if(node_shared_conditions[nodeId].size()>=2){
1161 if(node_shared_conditions[nodeId][0]->
IsNot(TO_ERASE) && node_shared_conditions[nodeId][1]->
IsNot(TO_ERASE)){
1163 if(node_shared_conditions[nodeId][0]->GetGeometry()[0].Id() == in->Id()){
1176 N1 = node_shared_conditions[nodeId][
i]->GetValue(NORMAL);
1178 N2 = node_shared_conditions[nodeId][
j]->GetValue(NORMAL);
1184 Geometry< Node >& rConditionGeom1 = node_shared_conditions[nodeId][
i]->GetGeometry();
1185 Geometry< Node >& rConditionGeom2 = node_shared_conditions[nodeId][
j]->GetGeometry();
1189 Node::Pointer pNode0 = rConditionGeom1(0);
1190 Node::Pointer pNode2 = rConditionGeom2(1);
1197 S1[0] = rConditionGeom1[1].X() - rConditionGeom1[0].X();
1198 S1[1] = rConditionGeom1[1].Y() - rConditionGeom1[0].Y();
1202 S2[0] = rConditionGeom2[1].X() - rConditionGeom2[0].X();
1203 S2[1] = rConditionGeom2[1].Y() - rConditionGeom2[0].Y();
1210 bool remove_S1 =
false;
1211 if(
norm_2(S1)<size_for_side_normal)
1214 bool remove_S2 =
false;
1215 if(
norm_2(S2)<size_for_side_normal)
1225 if(remove_S1 || remove_S2){
1227 node_shared_conditions[nodeId][
i]->Set(TO_ERASE);
1228 node_shared_conditions[nodeId][
j]->Set(TO_ERASE);
1231 Condition::Pointer NewCond = node_shared_conditions[nodeId][
i];
1233 pNode0->Set(MODIFIED);
1234 pNode2->Set(MODIFIED);
1240 face.push_back(rConditionGeom1(0));
1241 face.push_back(rConditionGeom2(1));
1243 new_id = initial_cond_size + id;
1245 Condition::Pointer pcond = NewCond->Clone(new_id, face);
1248 pcond->Set(NEW_ENTITY);
1249 if ( pcond->Is(TO_ERASE) ) {
1250 std::cout <<
" was to erase? " << pcond->Is(TO_ERASE) << std::endl;
1251 pcond->Reset(TO_ERASE);
1252 std::cout <<
" but now is like " << pcond->Is(TO_ERASE) << std::endl;
1257 pcond->SetValue(NORMAL, NewCond->GetValue(NORMAL) );
1258 pcond->SetValue(MASTER_NODES, NewCond->GetValue(MASTER_NODES) );
1260 MeshDataTransferUtilities TransferUtilities;
1261 TransferUtilities.TransferBoundaryData(pcond, NewCond,*(
mrRemesh.
Transfer));
1273 double projection_normals =
inner_prod(N1,N2);
1274 double relative_angle = 0;
1276 if(projection_normals!=0)
1277 relative_angle = projection_sides/projection_normals;
1279 if(relative_angle<=1 && relative_angle>=-1 )
1280 condition_angle = (180.0/3.14159) * std::acos(relative_angle);
1283 condition_angle *=(-1);
1291 if( condition_angle < -40 ){
1301 pNode0->Set(INSIDE);
1302 pNode2->Set(INSIDE);
1306 if(condition_angle<critical_angle){
1312 node_shared_conditions[nodeId][
i]->Set(TO_ERASE);
1313 node_shared_conditions[nodeId][
j]->Set(TO_ERASE);
1316 pNode2->Set(TO_ERASE);
1319 std::cout<<
" Node Release/Modify i "<<in->Id()<<std::endl;
1320 std::cout<<
" Node Release/Modify j "<<pNode2->Id()<<std::endl;
1324 pNode0->Coordinates() = 0.5 * (pNode0->Coordinates() + pNode2->Coordinates());
1330 PointsArray.push_back( *(in.base()) );
1332 PointsArray.push_back( rConditionGeom2(1) );
1334 Geometry<Node > geom( PointsArray );
1336 std::vector<double> ShapeFunctionsN(2);
1337 std::fill( ShapeFunctionsN.begin(), ShapeFunctionsN.end(), 0.0 );
1338 ShapeFunctionsN[0] = 0.5;
1339 ShapeFunctionsN[1] = 0.5;
1341 MeshDataTransferUtilities DataTransferUtilities;
1342 DataTransferUtilities.Interpolate( geom, ShapeFunctionsN, variables_list, pNode0);
1346 pNode0->GetInitialPosition() = Point{pNode0->Coordinates() - pNode0->FastGetSolutionStepValue(DISPLACEMENT)};
1349 if(node_shared_conditions[pNode0->Id()][0]->Id() == pNode0->Id()){
1356 Geometry<Node >& rConditionGeom0 = node_shared_conditions[pNode0->Id()][
i]->GetGeometry();
1357 Node::Pointer pNodeA = rConditionGeom0(0);
1360 if(node_shared_conditions[pNode2->Id()][0]->Id() == pNode2->Id()){
1369 Condition::Pointer NewCond = node_shared_conditions[pNode2->Id()][
i];
1370 NewCond->Set(TO_ERASE);
1371 Geometry<Node >& rConditionGeom3 = NewCond->GetGeometry();
1372 Node::Pointer pNodeB = rConditionGeom3(1);
1374 pNodeA->Set(MODIFIED);
1375 pNodeB->Set(MODIFIED);
1376 pNode0->Set(MODIFIED);
1382 face.push_back(rConditionGeom1(0));
1383 face.push_back(rConditionGeom3(1));
1385 new_id = initial_cond_size + id;
1387 Condition::Pointer pcond = NewCond->Clone(new_id, face);
1390 pcond->Set(NEW_ENTITY);
1393 std::cout<<
" Condition INSERTED (Id: "<<new_id<<
") ["<<rConditionGeom1[0].Id()<<
", "<<rConditionGeom3[1].Id()<<
"] "<<std::endl;
1396 rConditionGeom1[0].Set(TO_ERASE,
false);
1397 rConditionGeom3[1].Set(TO_ERASE,
false);
1400 pcond->SetValue(NORMAL, NewCond->GetValue(NORMAL) );
1401 pcond->SetValue(MASTER_NODES, NewCond->GetValue(MASTER_NODES) );
1403 MeshDataTransferUtilities TransferUtilities;
1404 TransferUtilities.TransferBoundaryData(pcond, NewCond, *(
mrRemesh.
Transfer) );
1422 RemovedConditions = rModelPart.
Conditions().size() - RemovedConditions;
1425 std::cout<<
" [ CONDITIONS ( removed : "<<RemovedConditions<<
" ) ]"<<std::endl;
1426 std::cout<<
" [ NODES ( removed : "<<RemovedNodes<<
" ) ]"<<std::endl;
1428 std::cout<<
" Ending Conditions : "<<rModelPart.
Conditions().size()<<
" (Removed nodes: "<< RemovedNodes<<
" ) "<<std::endl;
1429 std::cout<<
" REMOVE NON CONVEX BOUNDARY ]; "<<std::endl;
1484 rOStream << std::endl;
Short class definition.
Definition: bucket.h:57
Base class for all Conditions.
Definition: condition.h:59
Geometry< NodeType >::PointsArrayType NodesArrayType
definition of nodes container type, redefined from GeometryType
Definition: condition.h:86
Flags AsFalse() const
Definition: flags.h:241
bool Is(Flags const &rOther) const
Definition: flags.h:274
bool IsNot(Flags const &rOther) const
Definition: flags.h:291
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
IndexType const & Id() const
Id of this Geometry.
Definition: geometry.h:964
PointerVector< TPointType > PointsArrayType
Definition: geometry.h:118
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
size_type size() const
Definition: global_pointers_vector.h:307
Short class definition.
Definition: mesh_data_transfer_utilities.hpp:46
void TransferBoundaryData(Condition::Pointer rCurrentCondition, Condition::Pointer rReferenceCondition, const TransferParameters &rTransferVariables)
Definition: mesh_data_transfer_utilities.cpp:194
Short class definition.
Definition: mesh_error_calculation_utilities.hpp:50
void NodalErrorCalculation(ModelPart &rModelPart, std::vector< double > &rNodalError, std::vector< int > &rIds, const Variable< double > &rVariable)
Definition: mesh_error_calculation_utilities.hpp:82
virtual void SetEchoLevel(int Level)
Definition: mesh_error_calculation_utilities.hpp:284
The base class for processes passed to the solution scheme.
Definition: mesher_process.hpp:37
Short class definition.
Definition: mesher_utilities.hpp:49
void SetFlagsToNodes(ModelPart &rModelPart, const std::vector< Flags > rControlFlags, const std::vector< Flags > rAssignFlags)
Definition: mesher_utilities.cpp:174
static unsigned int GetMaxNodeId(ModelPart &rModelPart)
Definition: mesher_utilities.hpp:1408
static double CalculateElementRadius(Geometry< Node > &rGeometry)
Definition: mesher_utilities.hpp:1142
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
bool IsSubModelPart() const
Definition: model_part.h:1893
std::string & Name()
Definition: model_part.h:1811
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
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
SizeType NumberOfNodes(IndexType ThisIndex=0) const
Definition: model_part.h:341
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
ModelPart & GetParentModelPart()
Definition: model_part.cpp:2124
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
VariablesList & GetNodalSolutionStepVariablesList()
Definition: model_part.h:549
ConditionIterator ConditionsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1371
This class defines the node.
Definition: node.h:65
double Y() const
Definition: point.h:187
double Z() const
Definition: point.h:193
double X() const
Definition: point.h:181
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
void reserve(size_type dim)
Definition: pointer_vector.h:319
void push_back(const TPointerType &x)
Definition: pointer_vector.h:270
Properties encapsulates data shared by different Elements or Conditions. It can store any type of dat...
Definition: properties.h:69
Remove Mesh Nodes Process for 2D and 3D cases.
Definition: remove_nodes_mesher_process.hpp:63
MesherUtilities mMesherUtilities
Definition: remove_nodes_mesher_process.hpp:303
GlobalPointersVector< Element > ElementWeakPtrVectorType
Definition: remove_nodes_mesher_process.hpp:79
MesherUtilities::MeshingParameters & mrRemesh
Definition: remove_nodes_mesher_process.hpp:301
GlobalPointersVector< Node > NodeWeakPtrVectorType
Definition: remove_nodes_mesher_process.hpp:78
virtual bool RemoveNodesOnDistance(ModelPart &rModelPart, unsigned int &inside_nodes_removed, unsigned int &boundary_nodes_removed, bool &any_condition_removed)
Definition: remove_nodes_mesher_process.hpp:354
KRATOS_CLASS_POINTER_DEFINITION(RemoveNodesMesherProcess)
Pointer definition of Process.
GlobalPointersVector< Condition > ConditionWeakPtrVectorType
Definition: remove_nodes_mesher_process.hpp:80
ModelPart & mrModelPart
Definition: remove_nodes_mesher_process.hpp:299
void operator()()
This operator is provided to call the process as a function and simply calls the Execute method.
Definition: remove_nodes_mesher_process.hpp:105
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: remove_nodes_mesher_process.hpp:280
virtual bool RemoveNodesOnError(ModelPart &rModelPart, unsigned int &error_removed_nodes)
Definition: remove_nodes_mesher_process.hpp:561
bool RebuildBoundary(ModelPart &rModelPart)
Definition: remove_nodes_mesher_process.hpp:900
ModelPart::MeshType::GeometryType::PointsArrayType PointsArrayType
Definition: remove_nodes_mesher_process.hpp:76
virtual ~RemoveNodesMesherProcess()
Destructor.
Definition: remove_nodes_mesher_process.hpp:97
RemoveNodesMesherProcess(ModelPart &rModelPart, MesherUtilities::MeshingParameters &rRemeshingParameters, int EchoLevel)
Default constructor.
Definition: remove_nodes_mesher_process.hpp:86
Tree< KDTreePartition< BucketType > > KdtreeType
Definition: remove_nodes_mesher_process.hpp:75
ConditionType::GeometryType GeometryType
Definition: remove_nodes_mesher_process.hpp:73
std::string Info() const override
Turn back information as a string.
Definition: remove_nodes_mesher_process.hpp:268
void CleanRemovedNodes(ModelPart &rModelPart)
Definition: remove_nodes_mesher_process.hpp:318
int mEchoLevel
Definition: remove_nodes_mesher_process.hpp:305
Bucket< 3, Node, std::vector< Node::Pointer >, Node::Pointer, std::vector< Node::Pointer >::iterator, std::vector< double >::iterator > BucketType
Definition: remove_nodes_mesher_process.hpp:74
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: remove_nodes_mesher_process.hpp:274
virtual bool CheckEngagedNode(Node &rNode, std::vector< Node::Pointer > &rNeighbours, std::vector< double > &rNeighbourDistances, unsigned int &rn_points_in_radius)
Definition: remove_nodes_mesher_process.hpp:506
ModelPart::PropertiesType PropertiesType
Definition: remove_nodes_mesher_process.hpp:72
ModelPart::ConditionType ConditionType
Definition: remove_nodes_mesher_process.hpp:71
virtual bool RemoveNodesOnContact(ModelPart &rModelPart, unsigned int &inside_nodes_removed, unsigned int &boundary_nodes_removed, bool &any_condition_removed)
Definition: remove_nodes_mesher_process.hpp:633
void Execute() override
Execute method is used to execute the Process algorithms.
Definition: remove_nodes_mesher_process.hpp:117
A generic tree data structure for spatial partitioning.
Definition: tree.h:190
SizeType SearchInRadius(PointType const &ThisPoint, CoordinateType Radius, IteratorType Results, DistanceIteratorType ResultsDistances, SizeType MaxNumberOfResults)
Search for points within a given radius of a point.
Definition: tree.h:434
#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
static double max(double a, double b)
Definition: GeometryFunctions.h:79
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
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
float radius
Definition: mesh_to_mdpa_converter.py:18
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
int counter
Definition: script_THERMAL_CORRECT.py:218
integer i
Definition: TensorModule.f:17
Definition: mesher_utilities.hpp:631
MeshingInfoParameters::Pointer Info
Definition: mesher_utilities.hpp:681
RefiningParameters::Pointer Refine
Definition: mesher_utilities.hpp:684
TransferParametersType::Pointer Transfer
Definition: mesher_utilities.hpp:690
bool InputInitializedFlag
Definition: mesher_utilities.hpp:661
std::string SubModelPartName
Definition: mesher_utilities.hpp:642
unsigned int NodeMaxId
Definition: mesher_utilities.hpp:666