8 #if !defined(KRATOS_TRILINOS_LOCAL_CUTTING_APP)
9 #define KRATOS_TRILINOS_LOCAL_CUTTING_APP
20 #include "Epetra_Vector.h"
21 #include "Epetra_Map.h"
22 #include "Epetra_SerialDenseMatrix.h"
23 #include "Epetra_MpiComm.h"
24 #include "Epetra_FECrsGraph.h"
25 #include "Epetra_FECrsMatrix.h"
27 #include "Epetra_FEVector.h"
29 #include "Epetra_Import.h"
30 #include "Epetra_MpiComm.h"
88 ModelPart& this_model_part = mr_model_part;
90 ElementsArrayType::iterator it_begin = rElements.ptr_begin();
91 ElementsArrayType::iterator it_end = rElements.ptr_end();
92 double dist_node_neigh;
95 double local_smallest_edge = 1000000000000000000000000000.0;
97 for (ElementsArrayType::iterator it = it_begin; it != it_end; ++it)
100 for(
unsigned int i = 0;
i < it->GetGeometry().size() ;
i++)
102 node_coord[0] = geom[
i].X();
103 node_coord[1] = geom[
i].Y();
104 node_coord[2] = geom[
i].Z();
105 for(
unsigned int j = 0;
j < it->GetGeometry().size() ;
j++)
107 neigh_coord[0] = geom[
j].X();
108 neigh_coord[1] = geom[
j].Y();
109 neigh_coord[2] = geom[
j].Z();
110 dist_node_neigh = sqrt( pow((node_coord[0]- neigh_coord[0]),2) + pow((node_coord[1]- neigh_coord[1]),2) + pow((node_coord[2]- neigh_coord[2]),2) ) ;
111 if ((dist_node_neigh<local_smallest_edge) && (
i!=
j)) local_smallest_edge=dist_node_neigh;
140 ModelPart& this_model_part = mr_model_part;
141 ModelPart& new_model_part = mr_new_model_part;
151 std::cout <<
"Adding Skin Conditions to the new model part, added in layer:"<<std::endl;
158 NodesArrayType::iterator it_begin_node_old = rNodes_old.ptr_begin();
164 int *local_ids =
new int[nlocal_nodes];
168 local_ids[
k] = it->Id() - 1;
176 int *ids =
new int[
nnodes];
178 for (ModelPart::NodesContainerType::iterator it = this_model_part.
NodesBegin(); it != this_model_part.
NodesEnd(); it++)
180 ids[
k] = it->Id() - 1;
191 aux_non_overlapping_graph->PutScalar(-1.0);
197 bool* used_nodes =
new bool [
nnodes];
198 for (
int index = 0; index!=
nnodes; ++index) used_nodes[index]=
false;
202 int number_of_local_conditions=0;
209 ++number_of_local_conditions;
210 for (
unsigned int i = 0;
i < geom.
size();
i++)
212 aux_ids = geom[
i].
Id() - 1;
213 int node_position = this_model_part.
Nodes().find(geom[
i].Id()) - it_begin_node_old;
214 used_nodes[node_position]=
true;
215 int ierr = aux_non_overlapping_graph->ReplaceGlobalValues( 1 , &aux_ids, &this_partition_index,0);
223 ierr = aux_non_overlapping_graph->GlobalAssemble(Insert,
true);
228 double* local_non_ov =
new double [nlocal_nodes];
229 ierr = aux_non_overlapping_graph->ExtractCopy(local_non_ov,nlocal_nodes);
233 int n_owned_nonzeros = 0;
235 for (
int index=0; index!=nlocal_nodes; ++index)
237 if (local_non_ov[index]>(-0.5))
247 mrComm.ScanSum(&n_owned_nonzeros, &nodes_before, 1);
248 nodes_before -= n_owned_nonzeros;
250 int conditions_before = -1;
251 mrComm.ScanSum(&number_of_local_conditions, &conditions_before, 1);
252 conditions_before -=number_of_local_conditions;
256 int number_of_local_nodes = new_model_part.
Nodes().size();
257 int number_of_old_nodes = -1;
258 mrComm.SumAll(&number_of_local_nodes, &number_of_old_nodes, 1);
259 if (number_of_old_nodes < 0) number_of_old_nodes = 0;
261 int number_of_local_old_conditions = new_model_part.
Conditions().size();
262 int number_of_old_conditions = -1;
263 mrComm.SumAll(&number_of_local_old_conditions, &number_of_old_conditions, 1);
265 if (number_of_old_conditions < 0) number_of_old_conditions = 0;
270 KRATOS_ERROR <<
"The cut model part was not initialized. "
271 "Please call AddVariablesToCutModelPart before AddSkinConditions."
291 int node_id=number_of_old_nodes+nodes_before;
292 for (
int index=0; index!=nlocal_nodes; ++index)
294 if (local_non_ov[index]>(-0.5))
298 ierr = IDs_non_overlapping_graph->ReplaceMyValue ( index , 0 , node_id_double );
304 ierr = IDs_non_overlapping_graph->GlobalAssemble(Insert,
true);
312 Epetra_Import importer(*pmy_ov_map, *pmy_map);
315 ierr = IDs_overlap->Import(*IDs_non_overlapping_graph, importer, Insert);
318 double* local_IDs_ov =
new double [
nnodes];
319 ierr = IDs_overlap->ExtractCopy(local_IDs_ov,
nnodes);
325 ierr = Partition_overlap->Import(*aux_non_overlapping_graph, importer, Insert);
328 double* local_Partition_ov =
new double [
nnodes];
329 ierr = Partition_overlap->ExtractCopy(local_Partition_ov,
nnodes);
334 for (
int index=0; index!=
nnodes; ++index)
337 if (used_nodes[index]==
true)
340 int node_number=
int(local_IDs_ov[index]);
342 ModelPart::NodesContainerType::iterator it_node = this_model_part.
Nodes().begin()+index;
345 Node::Pointer pnode = Node ::Pointer (
new Node(node_number, it_node->X(), it_node->Y(), it_node->Z()));
348 pnode->SetBufferSize(this_model_part.
NodesBegin()->GetBufferSize());
349 pnode->GetValue(FATHER_NODES).resize(0);
350 pnode->GetValue(FATHER_NODES).push_back( Node::WeakPointer( *it_node.base() ) );
351 pnode->GetValue(FATHER_NODES).push_back( Node::WeakPointer( *it_node.base() ) );
352 pnode->
GetValue(WEIGHT_FATHER_NODES) = 1.0;
353 pnode->X0() = it_node->X0();
354 pnode->Y0() = it_node->Y0();
355 pnode->Z0() = it_node->Z0();
357 pnode->FastGetSolutionStepValue(PARTITION_INDEX)= it_node->FastGetSolutionStepValue(PARTITION_INDEX);
358 new_model_part.
Nodes().push_back(pnode);
363 new_model_part.
Nodes().Sort();
365 new_model_part.
Nodes().Unique();
370 int triangle_ID = number_of_old_conditions + conditions_before;
371 vector<int> triangle_nodes(3);
375 for(ModelPart::ConditionsContainerType::iterator i_condition = rConditions.begin() ; i_condition != rConditions.end() ; i_condition++)
380 for(
unsigned int i = 0;
i < i_condition->GetGeometry().size() ;
i++)
382 int position = (geom[
i].
Id()) - 1;
383 int local_position = (*pmy_ov_map).LID(position);
384 triangle_nodes[
i]=local_IDs_ov[local_position] ;
387 new_model_part.
Nodes()(triangle_nodes[0]),
388 new_model_part.
Nodes()(triangle_nodes[1]),
389 new_model_part.
Nodes()(triangle_nodes[2])
392 Condition::Pointer p_condition = rReferenceCondition.
Create(triangle_ID, geometry, properties);
393 new_model_part.
Conditions().push_back(p_condition);
402 if (
mrComm.MyPID() == 0) std::cout <<
"copyng conditions and recalculation plan have been completed" << std::endl;
448 std::cout <<
"Generating Cutting plane with the following data:"<<std::endl;
455 KRATOS_ERROR <<
"The cut model part was not initialized. "
456 "Please call AddVariablesToCutModelPart before GenerateCut."
459 ModelPart& this_model_part = mr_model_part;
462 vector<int> Elems_In_Plane(this_model_part.
Elements().size());
463 int number_of_triangles = 0;
468 vector<int> List_New_Nodes;
469 vector<int> partition_new_nodes;
470 vector<array_1d<int, 2 > > father_node_ids;
471 vector< array_1d<double, 3 > > Coordinate_New_Node;
479 MPI_Barrier(MPI_COMM_WORLD);
482 FirstLoop(mr_model_part, p_edge_ids, p_partition_ids, versor, Xp, number_of_triangles, Elems_In_Plane, tolerance, used_nodes_matrix);
483 MPI_Barrier(MPI_COMM_WORLD);
486 Create_List_Of_New_Nodes(mr_model_part, mr_new_model_part, p_edge_ids, p_partition_ids, List_New_Nodes, partition_new_nodes, father_node_ids, used_nodes_matrix);
487 MPI_Barrier(MPI_COMM_WORLD);
491 MPI_Barrier(MPI_COMM_WORLD);
494 GenerateElements(mr_model_part, mr_new_model_part, Elems_In_Plane, p_edge_ids, versor, plane_number, number_of_triangles);
495 MPI_Barrier(MPI_COMM_WORLD);
502 if (
mrComm.MyPID() == 0) std::cout <<
"recalculation of communication plan completed" << std::endl;
541 int *local_ids =
new int[nlocal_nodes];
545 local_ids[
k++] = it->Id() - 1;
555 int *ids =
new int[
nnodes];
557 for (ModelPart::NodesContainerType::iterator it = this_model_part.
NodesBegin(); it != this_model_part.
NodesEnd(); it++)
559 ids[
k++] = it->Id() - 1;
567 int guess_row_size = 20;
572 for (ModelPart::ElementsContainerType::iterator it = this_model_part.
ElementsBegin(); it != this_model_part.
ElementsEnd(); it++)
575 for (
unsigned int i = 0;
i < geom.
size();
i++)
576 aux_ids[
i] = geom[
i].Id() - 1;
584 for (
unsigned int i = 0;
i < geom.
size();
i++)
585 aux_ids[
i] = geom[
i].Id() - 1;
603 pB.swap(used_nodes_matrix);
613 array_1d<double, 3 > Xp,
int& number_of_triangles, vector<int>& Elems_In_Plane,
double tolerance,
621 p_nonoverlapping_partitions->PutScalar(-1.0);
626 ElementsArrayType::iterator it_begin = rElements.ptr_begin();
627 ElementsArrayType::iterator it_end = rElements.ptr_end();
629 double dist_node_point;
630 double dist_neigh_point;
636 unsigned int exact_nodes = 0;
637 number_of_triangles = 0;
638 int current_element = 0;
639 int number_of_cuts = 0;
641 for (ElementsArrayType::iterator it = it_begin; it != it_end; ++it)
647 for (
unsigned int i = 0;
i < it->GetGeometry().size();
i++)
650 node_coord[0] = geom[
i].X();
651 node_coord[1] = geom[
i].Y();
652 node_coord[2] = geom[
i].Z();
653 noalias(temp_dist) = node_coord;
655 dist_node_point =
inner_prod(temp_dist, versor);
656 for (
unsigned int j = 0;
j < it->GetGeometry().size();
j++)
660 neigh_coord[0] = geom[
j].X();
661 neigh_coord[1] = geom[
j].Y();
662 neigh_coord[2] = geom[
j].Z();
663 noalias(temp_dist) = neigh_coord;
665 dist_neigh_point =
inner_prod(temp_dist, versor);
668 bool isovernode =
false;
670 if (fabs(dist_node_point) < (tolerance))
672 int index_i = geom[
i].
Id() - 1;
674 double true_value = -1.0;
675 int ierr = p_edge_ids->SumIntoGlobalValues(1, &index_i, 1, &index_i, &value);
677 ierr = p_nonoverlapping_partitions->ReplaceGlobalValues(1, &index_i, 1, &index_i, &this_partition_index);
679 ierr = used_nodes_matrix->ReplaceGlobalValues(1, &index_i, 1, &index_i, &true_value);
684 list_matching_nodes[
i] = geom[
i].
Id();
687 if ((dist_node_point * dist_neigh_point) < 0.0 && isovernode ==
false && (fabs(dist_neigh_point)>(tolerance)))
689 int index_i = geom[
i].
Id() - 1;
690 int index_j = geom[
j].
Id() - 1;
692 double true_value = -1.0;
694 if (index_j > index_i)
696 int ierr = p_edge_ids->SumIntoGlobalValues(1, &index_i, 1, &index_j, &value);
698 ierr = p_nonoverlapping_partitions->ReplaceGlobalValues(1, &index_i, 1, &index_j, &this_partition_index);
700 ierr = used_nodes_matrix->ReplaceGlobalValues(1, &index_i, 1, &index_j, &true_value);
711 Elems_In_Plane[current_element - 1] = 0;
712 if (exact_nodes != 3)
714 if (number_of_cuts == 6)
716 number_of_triangles += 1;
717 Elems_In_Plane[current_element - 1] = 1;
719 else if (number_of_cuts == 8)
721 number_of_triangles += 2;
722 Elems_In_Plane[ current_element - 1] = 2;
727 bool found_fourth_node =
true;
728 for (
unsigned int i = 0;
i < it->GetGeometry().size();
i++)
730 found_fourth_node =
true;
731 for (
unsigned int aux_index = 0; aux_index != 4; ++aux_index)
733 if (geom[
i].Id() == list_matching_nodes[aux_index] && list_matching_nodes[aux_index] != 0)
735 found_fourth_node =
false;
739 if (found_fourth_node ==
true)
741 node_coord[0] = geom[
i].X();
742 node_coord[1] = geom[
i].Y();
743 node_coord[2] = geom[
i].Z();
750 noalias(temp_dist) = node_coord;
752 dist_node_point =
inner_prod(temp_dist, versor);
753 if (dist_node_point >= 0.0)
755 if (number_of_cuts == 6)
757 number_of_triangles += 1;
758 Elems_In_Plane[current_element - 1] = 1;
761 else if (number_of_cuts == 8)
763 number_of_triangles += 2;
764 Elems_In_Plane[ current_element - 1] = 2;
773 ierr = p_edge_ids->GlobalAssemble(
true, Add);
776 ierr = p_nonoverlapping_partitions->GlobalAssemble(
true, Insert);
780 int MaxNumEntries = p_edge_ids->MaxNumEntries() + 5;
786 ierr = pAoverlap->Import(*p_edge_ids, importer, Insert);
788 ierr = pAoverlap->FillComplete();
791 ierr = paux->Import(*p_nonoverlapping_partitions, importer, Insert);
793 ierr = paux->FillComplete();
797 pAoverlap.swap(p_edge_ids);
798 paux.swap(p_partition_ids);
815 vector<int> &List_New_Nodes,
816 vector<int> &partition_new_nodes,
822 int NumMyRows = p_edge_ids->NumMyRows();
825 int MaxNumEntries = p_edge_ids->MaxNumEntries();
826 double * id_values =
new double[MaxNumEntries];
827 double * partition_values =
new double[MaxNumEntries];
829 int * Indices =
new int[MaxNumEntries];
834 int * Indices_aux =
new int[MaxNumEntries];
835 double * id_values_aux =
new double[MaxNumEntries];
837 int n_owned_nonzeros = 0;
838 int n_new_nonzeros = 0;
839 double this_partition_index =
mrComm.MyPID();
841 for (Row = 0; Row < NumMyRows; ++Row)
843 GlobalRow = p_edge_ids->GRID(Row);
844 int ierr = p_edge_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, NumEntries, id_values, Indices);
847 ierr = p_partition_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, NumEntries, partition_values, Indices);
850 for (Col = 0; Col != NumEntries; Col++)
852 if (Indices[Col] >= Row)
855 n_new_nonzeros = n_new_nonzeros + 1;
856 if (partition_values[Col] == this_partition_index)
857 n_owned_nonzeros = n_owned_nonzeros + 1;
863 int nodes_before = -1;
864 mrComm.ScanSum(&n_owned_nonzeros, &nodes_before, 1);
865 nodes_before = nodes_before - n_owned_nonzeros;
866 if (nodes_before < 0)
867 KRATOS_THROW_ERROR(std::logic_error,
"problem with scan sum ... giving a negative number of nodes before",
"")
870 int number_of_local_nodes = new_model_part.
Nodes().size();
871 int total_number_of_nodes = -1;
872 mrComm.SumAll(&number_of_local_nodes, &total_number_of_nodes, 1);
874 if (total_number_of_nodes < 0) total_number_of_nodes = 0;
879 int start_id = total_number_of_nodes + nodes_before + 1;
880 int end_id = start_id + n_owned_nonzeros;
884 plocal_ids->PutScalar(-1);
888 for (Row = 0; Row < NumMyRows; ++Row)
890 GlobalRow = p_edge_ids->GRID(Row);
892 int ierr = p_edge_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, NumEntries, id_values, Indices);
895 ierr = p_partition_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, NumEntries, partition_values, Indices);
898 for (Col = 0; Col < NumEntries; ++Col)
900 if (Indices[Col] >= Row)
901 if (id_values[Col] < -1.5 &&
902 partition_values[Col] == this_partition_index &&
906 plocal_ids->ReplaceGlobalValues(1, &GlobalRow, 1, &(Indices[Col]), &did);
911 plocal_ids->GlobalAssemble(
true, Insert);
913 if (
id != end_id)
KRATOS_THROW_ERROR(std::logic_error,
"the own node count is not verified...some error occurred",
"");
918 int ierr = p_edge_ids->Import(*plocal_ids, importer, Insert);
920 p_edge_ids->FillComplete();
925 List_New_Nodes.resize(n_new_nonzeros);
926 partition_new_nodes.resize(n_new_nonzeros);
927 father_node_ids.resize(n_new_nonzeros);
931 for (Row = 0; Row < NumMyRows; ++Row)
933 GlobalRow = p_edge_ids->GRID(Row);
934 int num_id_entries = -1;
935 int ierr = p_edge_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, num_id_entries, id_values, Indices);
938 ierr = p_partition_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, NumEntries, partition_values, Indices);
941 if (NumEntries != num_id_entries)
KRATOS_THROW_ERROR(std::logic_error,
"we should have the same number of new_ids and of partition_values",
"");
942 for (Col = 0; Col < NumEntries; ++Col)
944 if (Indices[Col] >= Row)
949 List_New_Nodes[
k] = id_values[Col];
950 partition_new_nodes[
k] = partition_values[Col];
952 father_node_ids[
k][0] = GlobalRow + 1;
953 father_node_ids[
k][1] = Indices[Col] + 1;
954 int IsNeeded =
GetUpperTriangularMatrixValue(used_nodes_matrix, GlobalRow , (Indices[Col]), MaxNumEntries, NumEntries_aux, Indices_aux, id_values_aux);
957 father_node_ids[
k][0] = -1;
958 father_node_ids[
k][1] = -1;
962 if (id_values[Col] < -1.5)
967 if (
k !=
int(n_new_nonzeros))
KRATOS_THROW_ERROR(std::logic_error,
"number of new nodes check failed",
"")
972 delete [] partition_values;
985 const vector<int> &List_New_Nodes,
986 const vector<int> &partition_new_nodes,
996 double dist_node_point;
998 double dist_node_intersect;
1000 vector< array_1d<double, 3 > > Coordinate_New_Node;
1001 Coordinate_New_Node.
resize(father_node_ids.size());
1005 MPI_Barrier(MPI_COMM_WORLD);
1006 if ((father_node_ids.size())!=0)
1008 for (
unsigned int i = 0;
i < father_node_ids.size();
i++)
1013 const int& node_i = father_node_ids[
i][0];
1014 const int& node_j = father_node_ids[
i][1];
1017 ModelPart::NodesContainerType::iterator it_node1 = this_model_part.
Nodes().find(node_i);
1018 if (it_node1 == this_model_part.
NodesEnd())
1020 std::cout <<
"- father node 1 - looking for Id " << node_i <<
" " << node_j << std::endl;
1023 noalias(Coord_Node_1) = it_node1->Coordinates();
1026 ModelPart::NodesContainerType::iterator it_node2 = this_model_part.
Nodes().find(node_j);
1027 if (it_node2 == this_model_part.
NodesEnd())
1029 std::cout <<
"- father node 2 - looking for Id " << node_i <<
" " << node_j << std::endl;
1032 noalias(Coord_Node_2) = it_node2->Coordinates();
1034 noalias(temp_dist) = Coord_Node_1;
1036 dist_node_point =
inner_prod(temp_dist, versor);
1037 dist_node_point = fabs(dist_node_point);
1039 Xp_1 = Xp - Coord_Node_1;
1040 Xp_2 = Coord_Node_2 - Coord_Node_1;
1043 if (dist_node_point <= (tolerance)) dist_node_intersect = 0.0;
1044 weight = (1.0 - dist_node_intersect);
1046 if (weight > 1.05)
KRATOS_WATCH(
"**** something's wrong! weight higher than 1! ****");
1048 for (
unsigned int index = 0; index != 3; ++index)
1049 if (father_node_ids[
i][0] != father_node_ids[
i][1])
1050 Coordinate_New_Node[
i][index] = Coord_Node_1[index] + (dist_node_intersect) * (Coord_Node_2[index] - Coord_Node_1[index]);
1052 Coordinate_New_Node[
i][index] = Coord_Node_1[index];
1055 Node::Pointer pnode = Node ::Pointer (
new Node(List_New_Nodes[
i], Coordinate_New_Node[
i][0], Coordinate_New_Node[
i][1], Coordinate_New_Node[
i][2]));
1057 pnode->SetBufferSize(this_model_part.
NodesBegin()->GetBufferSize());
1058 pnode->GetValue(FATHER_NODES).resize(0);
1059 pnode->GetValue(FATHER_NODES).push_back(Node ::WeakPointer(*it_node1.base()));
1060 pnode->GetValue(FATHER_NODES).push_back(Node ::WeakPointer(*it_node2.base()));
1061 pnode->
GetValue(WEIGHT_FATHER_NODES) = weight;
1063 pnode->X0() = weight * (it_node1->X0()) + (1.0 - weight) * it_node2->X0();
1064 pnode->Y0() = weight * (it_node1->Y0()) + (1.0 - weight) * it_node2->Y0();
1065 pnode->Z0() = weight * (it_node1->Z0()) + (1.0 - weight) * it_node2->Z0();
1066 pnode->FastGetSolutionStepValue(PARTITION_INDEX) = partition_new_nodes[
i];
1067 new_model_part.
Nodes().push_back(pnode);
1071 new_model_part.
Nodes().Sort();
1072 unsigned int current_size = new_model_part.
Nodes().size();
1073 new_model_part.
Nodes().Unique();
1075 if(current_size != new_model_part.
Nodes().size())
1109 unsigned int temp_int;
1113 int total_existing_elements = -1;
1114 int local_existing_elements = new_model_part.
Conditions().size();
1115 mrComm.SumAll(&local_existing_elements, &total_existing_elements, 1);
1117 if (total_existing_elements < 0) total_existing_elements = 0;
1119 Element const rReferenceElement;
1122 int MaxNumEntries = p_edge_ids->MaxNumEntries();
1123 double * id_values =
new double[MaxNumEntries];
1124 int * Indices =
new int[MaxNumEntries];
1128 ElementsArrayType::iterator it_begin_old = rElements_old.ptr_begin();
1129 ElementsArrayType::iterator it_end_old = rElements_old.ptr_end();
1134 int triangle_id_int = 0;
1135 int current_element = 0;
1136 unsigned int triangle_nodes = 0;
1137 bool new_node =
false;
1140 for (
unsigned int k = 0;
k != 4; ++
k)
1142 TriangleNodesArray[
k] = -1;
1145 int elements_before = -1;
1146 mrComm.ScanSum(&number_of_triangles, &elements_before, 1);
1147 if (elements_before < 0) elements_before = 0;
1148 else elements_before-=number_of_triangles;
1151 for (ElementsArrayType::iterator it = it_begin_old; it != it_end_old; ++it)
1156 if (Elems_In_Plane[current_element - 1] == 1)
1159 for (
unsigned int i = 0;
i < it->GetGeometry().size();
i++)
1162 for (
unsigned int j = 0;
j < it->GetGeometry().size();
j++)
1165 int index_i = geom[
i].
Id() - 1;
1166 int index_j = geom[
j].
Id() - 1;
1169 for (
unsigned int l = 0;
l != 3; ++
l)
1171 if (TriangleNodesArray[
l] == NodeId
1176 if (new_node && index_i <= index_j)
1178 TriangleNodesArray[triangle_nodes] = NodeId;
1181 if (triangle_nodes == 3)
break;
1183 if (triangle_nodes == 3)
break;
1186 ModelPart::NodesContainerType::iterator it_node1 = new_model_part.
Nodes().find(TriangleNodesArray[0]);
1187 noalias(temp_vector1) = it_node1->Coordinates();
1189 it_node1 = new_model_part.
Nodes().find(TriangleNodesArray[1]);
1190 noalias(temp_vector2) = it_node1->Coordinates();
1192 it_node1 = new_model_part.
Nodes().find(TriangleNodesArray[2]);
1193 noalias(temp_vector3) = it_node1->Coordinates();
1195 temp_vector3 -= temp_vector1;
1196 temp_vector2 -= temp_vector1;
1203 temp_int = TriangleNodesArray[2];
1204 TriangleNodesArray[2] = TriangleNodesArray[1];
1205 TriangleNodesArray[1] = temp_int;
1210 new_model_part.
Nodes()(TriangleNodesArray[0]),
1211 new_model_part.
Nodes()(TriangleNodesArray[1]),
1212 new_model_part.
Nodes()(TriangleNodesArray[2])
1215 Condition::Pointer p_condition = rReferenceCondition.
Create(triangle_id_int + 1 + elements_before + total_existing_elements, geom, properties);
1216 new_model_part.
Conditions().push_back(p_condition);
1224 if (Elems_In_Plane[current_element - 1] == 2)
1229 for (
unsigned int i = 0;
i < it->GetGeometry().size();
i++)
1232 for (
unsigned int j = 0;
j < it->GetGeometry().size();
j++)
1235 int index_i = geom[
i].
Id() - 1;
1236 int index_j = geom[
j].
Id() - 1;
1239 for (
unsigned int l = 0;
l != 3; ++
l)
1241 if (TriangleNodesArray[
l] == NodeId
1247 if (new_node && index_i < index_j)
1249 TriangleNodesArray[triangle_nodes] = NodeId;
1252 if (triangle_nodes == 4)
break;
1254 if (triangle_nodes == 4)
break;
1263 ModelPart::NodesContainerType::iterator it_node1 = new_model_part.
Nodes().find(TriangleNodesArray[0]);
1264 noalias(temp_vector1) = it_node1->Coordinates();
1268 for (
int iii = 1; iii != 4; ++iii)
1270 it_node1 = new_model_part.
Nodes().find(TriangleNodesArray[iii]);
1271 noalias(temp_vector2) = it_node1->Coordinates();
1272 noalias(temp_vector3) = temp_vector2 - temp_vector1;
1293 it_node1 = new_model_part.
Nodes().find(TriangleNodesArray[jjj]);
1294 noalias(temp_vector2) = it_node1->Coordinates();
1296 it_node1 = new_model_part.
Nodes().find(TriangleNodesArray[kkk]);
1297 noalias(temp_vector3) = it_node1->Coordinates();
1299 noalias(temp_vector2) -= temp_vector1;
1300 noalias(temp_vector3) -= temp_vector1;
1302 dist2 =
inner_prod(temp_vector2, temp_vector4);
1303 dist3 =
inner_prod(temp_vector3, temp_vector4);
1308 nodes_for_2triang[0] = TriangleNodesArray[0];
1309 nodes_for_2triang[1] = TriangleNodesArray[jjj];
1310 nodes_for_2triang[2] = TriangleNodesArray[iii];
1311 nodes_for_2triang[3] = TriangleNodesArray[iii];
1312 nodes_for_2triang[4] = TriangleNodesArray[kkk];
1313 nodes_for_2triang[5] = TriangleNodesArray[0];
1323 for (
int index = 0; index != 2; ++index)
1326 it_node1 = new_model_part.
Nodes().find(nodes_for_2triang[index * 3 + 0]);
1327 noalias(temp_vector1) = it_node1->Coordinates();
1329 it_node1 = new_model_part.
Nodes().find(nodes_for_2triang[index * 3 + 1]);
1330 noalias(temp_vector2) = it_node1->Coordinates();
1332 it_node1 = new_model_part.
Nodes().find(nodes_for_2triang[index * 3 + 2]);
1333 noalias(temp_vector3) = it_node1->Coordinates();
1335 temp_vector3 -= temp_vector1;
1336 temp_vector2 -= temp_vector1;
1341 temp_int = nodes_for_2triang[index * 3 + 2];
1342 nodes_for_2triang[index * 3 + 2] = nodes_for_2triang[index * 3 + 1];
1343 nodes_for_2triang[index * 3 + 1] = temp_int;
1347 new_model_part.
Nodes()(nodes_for_2triang[index * 3 + 0]),
1348 new_model_part.
Nodes()(nodes_for_2triang[index * 3 + 1]),
1349 new_model_part.
Nodes()(nodes_for_2triang[index * 3 + 2])
1352 Condition::Pointer p_condition = rReferenceCondition.
Create(triangle_id_int + 1 + elements_before + total_existing_elements, geom, properties);
1354 new_model_part.
Conditions().push_back(p_condition);
1375 if (
mrComm.MyPID() == 0) std::cout <<
"Updating cut data:"<<std::endl;
1379 for (ModelPart::NodesContainerType::iterator it = new_model_part.
NodesBegin(); it != new_model_part.
NodesEnd(); it++)
1381 double* node0_data = it->GetValue(FATHER_NODES)[0].SolutionStepData().Data(0);
1382 double* node1_data = it->GetValue(FATHER_NODES)[1].SolutionStepData().Data(0);
1383 double weight = it->GetValue(WEIGHT_FATHER_NODES);
1384 double* step_data = (it)->SolutionStepData().Data(0);
1385 int partition_index= it->FastGetSolutionStepValue(PARTITION_INDEX);
1388 for (
int j = 0;
j < step_data_size;
j++)
1390 step_data[
j] = weight * node0_data[
j] + (1.0 - weight) * node1_data[
j];
1392 it->FastGetSolutionStepValue(PARTITION_INDEX)=partition_index;
1420 for (
int i = 0;
i < row_size;
i++)
1422 if (indices[
i] ==
j)
1434 if (index_0 > index_1)
1436 p_edge_ids->ExtractGlobalRowCopy(index_1, MaxNumEntries, NumEntries,
values, Indices);
1441 p_edge_ids->ExtractGlobalRowCopy(index_0, MaxNumEntries, NumEntries,
values, Indices);
virtual const DataCommunicator & GetDataCommunicator() const
Definition: communicator.cpp:340
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
Base class for all Conditions.
Definition: condition.h:59
virtual Pointer Create(IndexType NewId, NodesArrayType const &ThisNodes, PropertiesType::Pointer pProperties) const
It creates a new condition pointer.
Definition: condition.h:205
Base class for all Elements.
Definition: element.h:60
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
Definition: amatrix_interface.h:41
static const TComponentType & Get(const std::string &rName)
Retrieves a component with the specified name.
Definition: kratos_components.h:114
static T CrossProduct(const T &a, const T &b)
Performs the vector product of the two input vectors a,b.
Definition: math_utils.h:762
NodesContainerType & Nodes()
Definition: mesh.h:346
NodeIterator NodesEnd()
Definition: mesh.h:336
NodeIterator NodesBegin()
Definition: mesh.h:326
PropertiesType::Pointer pGetProperties(IndexType PropertiesId)
Definition: mesh.h:394
static void SetMPICommunicator(ModelPart &rThisModelPart, const DataCommunicator &rDataCommunicator)
Create and assign an MPICommunicator for a ModelPart instance.
Definition: model_part_communicator_utilities.h:64
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementIterator ElementsBegin(IndexType ThisIndex=0)
Definition: model_part.h:1169
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
SizeType GetNodalSolutionStepDataSize()
Definition: model_part.h:571
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
Communicator & GetCommunicator()
Definition: model_part.h:1821
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ConditionsContainerType & Conditions(IndexType ThisIndex=0)
Definition: model_part.h:1381
void AddNodalSolutionStepVariable(VariableData const &ThisVariable)
Definition: model_part.h:532
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
NodeIterator NodesEnd(IndexType ThisIndex=0)
Definition: model_part.h:497
MeshType & GetMesh(IndexType ThisIndex=0)
Definition: model_part.h:1791
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
This function recomputes the communication plan for MPI.
Definition: parallel_fill_communicator.h:56
void Execute() override
Execute the communicator fill.
Definition: parallel_fill_communicator.cpp:39
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
A three node 3D triangle geometry with linear shape functions.
Definition: triangle_3d_3.h:77
TRILINOS CUTTING APPLICATION.
Definition: trilinos_cutting_app.h:46
void UpdateCutData(ModelPart &new_model_part, ModelPart &old_model_part)
Definition: trilinos_cutting_app.h:1373
void AddVariablesToCutModelPart(const ModelPart &rModelPart, ModelPart &rNewModelPart) const
Initialize the solution step data container for the cut model part.
Definition: trilinos_cutting_app.h:412
void Clear()
Definition: trilinos_cutting_app.h:512
Kratos::shared_ptr< Epetra_Map > mp_overlapping_map
Definition: trilinos_cutting_app.h:1406
double GetValueFromRow(int row, int j, int row_size, int *indices, double *values)
Definition: trilinos_cutting_app.h:1418
Kratos::shared_ptr< Epetra_Map > mp_non_overlapping_map
Definition: trilinos_cutting_app.h:1407
double smallest_edge
Definition: trilinos_cutting_app.h:1402
ModelPart::NodesContainerType NodesArrayType
Definition: trilinos_cutting_app.h:49
Kratos::shared_ptr< Epetra_FECrsGraph > mp_non_overlapping_graph
Definition: trilinos_cutting_app.h:1410
void CSR_Row_Matrix(ModelPart &this_model_part, Kratos::shared_ptr< Epetra_FECrsMatrix > &p_edge_ids, Kratos::shared_ptr< Epetra_FECrsMatrix > &used_nodes_matrix)
Definition: trilinos_cutting_app.h:532
TrilinosCuttingApplication(Epetra_MpiComm &Comm)
Definition: trilinos_cutting_app.h:65
void FindSmallestEdge(ModelPart &mr_model_part)
This function Creates cutting planes by creating nodes and conditions (to define the conectivities) i...
Definition: trilinos_cutting_app.h:86
int mtotal_number_of_existing_nodes
Definition: trilinos_cutting_app.h:1408
void Calculate_Coordinate_And_Insert_New_Nodes(ModelPart &this_model_part, ModelPart &new_model_part, const vector< array_1d< int, 2 > > &father_node_ids, const vector< int > &List_New_Nodes, const vector< int > &partition_new_nodes, array_1d< double, 3 > versor, array_1d< double, 3 > Xp, double tolerance)
Definition: trilinos_cutting_app.h:983
void AddSkinConditions(ModelPart &mr_model_part, ModelPart &mr_new_model_part, int plane_number)
ADDSKINCONDITIONS: THIS FUNCTION ADDS TO THE NEW MODEL PART THE DATA OF THE CONDITIONS BELONGING TO T...
Definition: trilinos_cutting_app.h:138
Node ::Pointer PointPointerType
Definition: trilinos_cutting_app.h:56
void Create_List_Of_New_Nodes(ModelPart &this_model_part, ModelPart &new_model_part, Kratos::shared_ptr< Epetra_FECrsMatrix > &p_edge_ids, Kratos::shared_ptr< Epetra_FECrsMatrix > &p_partition_ids, vector< int > &List_New_Nodes, vector< int > &partition_new_nodes, vector< array_1d< int, 2 > > &father_node_ids, Kratos::shared_ptr< Epetra_FECrsMatrix > &used_nodes_matrix)
Definition: trilinos_cutting_app.h:812
PointVector::iterator PointIterator
Definition: trilinos_cutting_app.h:58
Kratos::shared_ptr< Epetra_CrsGraph > mp_overlapping_graph
Definition: trilinos_cutting_app.h:1411
vector< Vector_Order_Tensor > Node_Vector_Order_Tensor
Definition: trilinos_cutting_app.h:54
double GetUpperTriangularMatrixValue(const Kratos::shared_ptr< Epetra_FECrsMatrix > &p_edge_ids, int index_0, int index_1, int &MaxNumEntries, int &NumEntries, int *Indices, double *values)
Definition: trilinos_cutting_app.h:1431
Node PointType
Definition: trilinos_cutting_app.h:55
void FirstLoop(ModelPart &this_model_part, Kratos::shared_ptr< Epetra_FECrsMatrix > &p_edge_ids, Kratos::shared_ptr< Epetra_FECrsMatrix > &p_partition_ids, array_1d< double, 3 > versor, array_1d< double, 3 > Xp, int &number_of_triangles, vector< int > &Elems_In_Plane, double tolerance, Kratos::shared_ptr< Epetra_FECrsMatrix > &used_nodes_matrix)
Definition: trilinos_cutting_app.h:611
ModelPart::ElementsContainerType ElementsArrayType
Definition: trilinos_cutting_app.h:50
Epetra_MpiComm & mrComm
Definition: trilinos_cutting_app.h:1405
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: trilinos_cutting_app.h:51
void GenerateElements(ModelPart &this_model_part, ModelPart &new_model_part, vector< int > Elems_In_Plane, const Kratos::shared_ptr< Epetra_FECrsMatrix > p_edge_ids, array_1d< double, 3 > versor, int plane_number, int &number_of_triangles)
Definition: trilinos_cutting_app.h:1090
void GenerateCut(ModelPart &mr_model_part, ModelPart &mr_new_model_part, const array_1d< double, 3 > &versor, const array_1d< double, 3 > &Xp, int plane_number, double tolerance_factor)
This function Creates cutting planes by creating nodes and conditions (to define the conectivities) i...
Definition: trilinos_cutting_app.h:436
~TrilinosCuttingApplication()
Definition: trilinos_cutting_app.h:71
bool mMPICommSetup_is_defined
Definition: trilinos_cutting_app.h:1403
std::vector< PointType::Pointer > PointVector
Definition: trilinos_cutting_app.h:57
vector< Matrix > Matrix_Order_Tensor
Definition: trilinos_cutting_app.h:52
vector< Vector > Vector_Order_Tensor
Definition: trilinos_cutting_app.h:53
bool Has(const VariableData &rThisVariable) const
Definition: variables_list.h:372
BOOST_UBLAS_INLINE void resize(size_type array_size, bool preserve=true)
Definition: array_1d.h:242
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
Parameters GetValue(Parameters &rParameters, const std::string &rEntry)
Definition: add_kratos_parameters_to_python.cpp:53
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
std::shared_ptr< T > shared_ptr
Definition: smart_pointers.h:27
TExpression1Type::data_type inner_prod(AMatrix::MatrixExpression< TExpression1Type, TCategory1 > const &First, AMatrix::MatrixExpression< TExpression2Type, TCategory2 > const &Second)
Definition: amatrix_interface.h:592
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
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
list values
Definition: bombardelli_test.py:42
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
int node_id
Definition: read_stl.py:12
int counter
Definition: script_THERMAL_CORRECT.py:218
int nnodes
Definition: sensitivityMatrix.py:24
integer i
Definition: TensorModule.f:17
integer l
Definition: TensorModule.f:17