12 #if !defined(KRATOS_TRILINOS_LOCAL_REFINE_SIMPLEX_MESH)
13 #define KRATOS_TRILINOS_LOCAL_REFINE_SIMPLEX_MESH
26 #include "Epetra_Vector.h"
27 #include "Epetra_Map.h"
28 #include "Epetra_SerialDenseMatrix.h"
29 #include "Epetra_MpiComm.h"
30 #include "Epetra_FECrsGraph.h"
31 #include "Epetra_FECrsMatrix.h"
32 #include "Epetra_Import.h"
33 #include "Epetra_MpiComm.h"
96 if (refine_on_reference ==
true)
98 KRATOS_ERROR <<
"DISPLACEMENT Variable is not in the model part -- needed if refine_on_reference = true" << std::endl;
101 KRATOS_ERROR <<
"PARTITION_INDEX Variable is not in the model part -- mpi not possible" << std::endl;
105 vector<int> List_New_Nodes;
106 vector<int> partition_new_nodes;
107 vector<array_1d<int, 2 > > father_node_ids;
108 vector< array_1d<double, 3 > > Coordinate_New_Node;
112 if (refine_on_reference ==
true)
122 if (
mrComm.MyPID() == 0) std::cout <<
"beginning the refinement" << std::endl;
125 if (
mrComm.MyPID() == 0) std::cout <<
"index matrix constructed" << std::endl;
128 if (
mrComm.MyPID() == 0) std::cout <<
"Search_Edge_To_Be_Refined completed" << std::endl;
131 if (
mrComm.MyPID() == 0) std::cout <<
"Create_List_Of_New_Nodes completed" << std::endl;
134 if (
mrComm.MyPID() == 0) std::cout <<
"Calculate_Coordinate_And_Insert_New_Nodes completed" << std::endl;
147 if (
mrComm.MyPID() == 0) std::cout <<
"Erase_Old_Element_And_Create_New completed" << std::endl;
152 if (
mrComm.MyPID() == 0) std::cout <<
"Renumbering completed" << std::endl;
159 if (refine_on_reference ==
true)
164 it->X() = it->X0() + disp[0];
165 it->Y() = it->Y0() + disp[1];
166 it->Z() = it->Z0() + disp[2];
172 if (
mrComm.MyPID() == 0) std::cout <<
"recalculation of communication plan completed" << std::endl;
189 std::cout <<
"proc = " <<
mrComm.MyPID() <<
"ghost mesh nodes" << std::endl;
193 std::cout << it->Id() <<
" " << it->Coordinates() << std::endl;
233 int *local_ids =
new int[nlocal_nodes];
237 local_ids[
k++] = it->Id() - 1;
247 int *ids =
new int[
nnodes];
249 for (ModelPart::NodesContainerType::iterator it = this_model_part.
NodesBegin(); it != this_model_part.
NodesEnd(); it++)
251 ids[
k++] = it->Id() - 1;
259 int guess_row_size = 20;
265 for (ModelPart::ElementsContainerType::iterator it = this_model_part.
ElementsBegin(); it != this_model_part.
ElementsEnd(); it++)
268 for (
unsigned int i = 0;
i < geom.
size();
i++)
269 aux_ids[
i] = geom[
i].Id() - 1;
272 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
277 for (
unsigned int i = 0;
i < geom.
size();
i++)
278 aux_ids[
i] = geom[
i].Id() - 1;
313 p_nonoverlapping_partitions->PutScalar(-1.0);
319 ElementsArrayType::iterator it_begin = rElements.ptr_begin();
320 ElementsArrayType::iterator it_end = rElements.ptr_end();
321 for (ElementsArrayType::iterator it = it_begin; it != it_end; ++it)
324 if (it->GetValue(SPLIT_ELEMENT) ==
true)
327 for (
unsigned int i = 0;
i < geom.
size();
i++)
329 int index_i = geom[
i].
Id() - 1;
330 for (
unsigned int j = 0;
j < geom.
size();
j++)
332 int index_j = geom[
j].
Id() - 1;
334 if (index_j > index_i)
336 int ierr = p_edge_ids->SumIntoGlobalValues(1, &index_i, 1, &index_j, &value);
338 ierr = p_nonoverlapping_partitions->ReplaceGlobalValues(1, &index_i, 1, &index_j, &this_partition_index);
347 ierr = p_edge_ids->GlobalAssemble(
true, Add);
348 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
350 ierr = p_nonoverlapping_partitions->GlobalAssemble(
true, Insert);
351 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
354 int MaxNumEntries = p_edge_ids->MaxNumEntries() + 5;
360 ierr = pAoverlap->Import(*p_edge_ids, importer, Insert);
361 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
362 ierr = pAoverlap->FillComplete();
363 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
365 ierr = paux->Import(*p_nonoverlapping_partitions, importer, Insert);
366 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
367 ierr = paux->FillComplete();
368 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
371 pAoverlap.swap(p_edge_ids);
372 paux.swap(p_partition_ids);
389 vector<int> &List_New_Nodes,
390 vector<int> &partition_new_nodes,
395 int NumMyRows = p_edge_ids->NumMyRows();
398 int MaxNumEntries = p_edge_ids->MaxNumEntries();
399 double * id_values =
new double[MaxNumEntries];
400 double * partition_values =
new double[MaxNumEntries];
401 int * Indices =
new int[MaxNumEntries];
405 int n_owned_nonzeros = 0;
406 int n_new_nonzeros = 0;
407 double this_partition_index =
mrComm.MyPID();
409 for (Row = 0; Row < NumMyRows; ++Row)
411 GlobalRow = p_edge_ids->GRID(Row);
412 int ierr = p_edge_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, NumEntries, id_values, Indices);
415 ierr = p_partition_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, NumEntries, partition_values, Indices);
418 for (Col = 0; Col != NumEntries; Col++)
420 if (Indices[Col] > Row)
423 n_new_nonzeros = n_new_nonzeros + 1;
424 if (partition_values[Col] == this_partition_index)
425 n_owned_nonzeros = n_owned_nonzeros + 1;
431 int nodes_before = -1;
432 mrComm.ScanSum(&n_owned_nonzeros, &nodes_before, 1);
433 nodes_before = nodes_before - n_owned_nonzeros;
434 if (nodes_before < 0)
435 KRATOS_THROW_ERROR(std::logic_error,
"problem with scan sum ... giving a negative number of nodes before",
"")
439 int total_number_of_nodes = -1;
440 mrComm.SumAll(&number_of_local_nodes, &total_number_of_nodes, 1);
460 int start_id = total_number_of_nodes + nodes_before + 1;
461 int end_id = start_id + n_owned_nonzeros;
465 plocal_ids->PutScalar(-1);
469 for (Row = 0; Row < NumMyRows; ++Row)
471 GlobalRow = p_edge_ids->GRID(Row);
473 int ierr = p_edge_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, NumEntries, id_values, Indices);
474 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
476 ierr = p_partition_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, NumEntries, partition_values, Indices);
477 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
479 for (Col = 0; Col < NumEntries; ++Col)
481 if (Indices[Col] > Row)
482 if (id_values[Col] < -1.5 &&
483 partition_values[Col] == this_partition_index &&
487 plocal_ids->ReplaceGlobalValues(1, &GlobalRow, 1, &(Indices[Col]), &did);
492 plocal_ids->GlobalAssemble(
true, Insert);
494 KRATOS_ERROR_IF(
id != end_id) <<
"the own node count is not verified...some error occurred" << std::endl;
498 int ierr = p_edge_ids->Import(*plocal_ids, importer, Insert);
499 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
500 p_edge_ids->FillComplete();
504 List_New_Nodes.resize(n_new_nonzeros);
505 partition_new_nodes.resize(n_new_nonzeros);
506 father_node_ids.resize(n_new_nonzeros);
511 for (Row = 0; Row < NumMyRows; ++Row)
513 GlobalRow = p_edge_ids->GRID(Row);
514 int num_id_entries = -1;
515 int ierr = p_edge_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, num_id_entries, id_values, Indices);
516 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
518 ierr = p_partition_ids->ExtractGlobalRowCopy(GlobalRow, MaxNumEntries, NumEntries, partition_values, Indices);
519 KRATOS_ERROR_IF(ierr < 0) <<
"epetra failure in line" << __LINE__ << std::endl;
521 KRATOS_ERROR_IF(NumEntries != num_id_entries) <<
"we should have the same number of new_ids and of partition_values" << std::endl;
522 for (Col = 0; Col < NumEntries; ++Col)
524 if (Indices[Col] > Row)
533 List_New_Nodes[
k] = id_values[Col];
534 partition_new_nodes[
k] = partition_values[Col];
536 father_node_ids[
k][0] = GlobalRow + 1;
537 father_node_ids[
k][1] = Indices[Col] + 1;
541 if (id_values[Col] < -1.5)
542 KRATOS_ERROR <<
"edge to be refined without id assigned" << std::endl;
546 KRATOS_ERROR_IF(
k !=
int(n_new_nonzeros)) <<
"number of new nodes check failed" << std::endl;
551 delete [] partition_values;
563 const vector<int> &List_New_Nodes,
564 const vector<int> &partition_new_nodes)
569 vector< array_1d<double, 3 > > Coordinate_New_Node;
570 Coordinate_New_Node.
resize(father_node_ids.size());
575 for (ModelPart::NodesContainerType::iterator it = this_model_part.
NodesBegin(); it != this_model_part.
NodesEnd(); it++)
576 if ((it->GetDofs()).size() != reference_dofs.size())
578 std::cout <<
"reference_dof_list" << *(this_model_part.
NodesBegin()) << std::endl;
579 std::cout <<
"inconsistent dof list found" << *it << std::endl;
580 KRATOS_THROW_ERROR(std::logic_error,
"list of dofs is not the same on all of the nodes!",
"")
585 for (
unsigned int i = 0;
i < father_node_ids.size();
i++)
590 const int& node_i = father_node_ids[
i][0];
591 const int& node_j = father_node_ids[
i][1];
592 ModelPart::NodesContainerType::iterator it_node1 = this_model_part.
Nodes().find(node_i);
593 if (it_node1 == this_model_part.
NodesEnd())
595 std::cout <<
"- father node 1 - looking for Id " << node_i <<
" " << node_j << std::endl;
598 std::size_t pos1 = it_node1 - this_model_part.
NodesBegin();
599 noalias(Coord_Node_1) = it_node1->Coordinates();
602 ModelPart::NodesContainerType::iterator it_node2 = this_model_part.
Nodes().find(node_j);
603 if (it_node2 == this_model_part.
NodesEnd())
605 std::cout <<
"- father node 2 - looking for Id " << node_i <<
" " << node_j << std::endl;
608 std::size_t pos2 = it_node2 - this_model_part.
NodesBegin();
609 noalias(Coord_Node_2) = it_node2->Coordinates();
612 noalias(Coordinate_New_Node[
i]) = 0.50 * (Coord_Node_1 + Coord_Node_2);
625 Node ::Pointer pnode =
AuxCreateNewNode(this_model_part, List_New_Nodes[
i], Coordinate_New_Node[
i][0], Coordinate_New_Node[
i][1], Coordinate_New_Node[
i][2]);
630 it_node1 = this_model_part.
NodesBegin() + pos1;
631 it_node2 = this_model_part.
NodesBegin() + pos2;
633 pnode->GetValue(FATHER_NODES).resize(0);
634 pnode->GetValue(FATHER_NODES).push_back(Node ::WeakPointer(*it_node1.base()));
635 pnode->GetValue(FATHER_NODES).push_back(Node ::WeakPointer(*it_node2.base()));
637 pnode->X0() = 0.5 * (it_node1->X0() + it_node2->X0());
638 pnode->Y0() = 0.5 * (it_node1->Y0() + it_node2->Y0());
639 pnode->Z0() = 0.5 * (it_node1->Z0() + it_node2->Z0());
642 for (Node ::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); iii++)
645 Node ::DofType::Pointer p_new_dof = pnode->pAddDof(rDof);
646 if (it_node1->IsFixed(rDof.GetVariable()) ==
true && it_node2->IsFixed(rDof.GetVariable()) ==
true)
647 (p_new_dof)->FixDof();
650 (p_new_dof)->FreeDof();
656 unsigned int buffer_size = pnode->GetBufferSize();
659 double* new_step_data = pnode->SolutionStepData().Data(
step);
660 double* step_data1 = it_node1->SolutionStepData().Data(
step);
661 double* step_data2 = it_node2->SolutionStepData().Data(
step);
663 for (
unsigned int j = 0;
j < step_data_size;
j++)
665 new_step_data[
j] = 0.5 * (step_data1[
j] + step_data2[
j]);
669 pnode->FastGetSolutionStepValue(PARTITION_INDEX) = partition_new_nodes[
i];
694 unsigned int current_size = this_model_part.
Nodes().size();
696 this_model_part.
Nodes().Unique();
698 KRATOS_ERROR_IF(current_size != this_model_part.
Nodes().size()) <<
"some node was duplicated! error" << std::endl;
712 bool interpolate_internal_variables
718 int total_existing_elements = -1;
719 int local_existing_elements = this_model_part.
Elements().size();
720 mrComm.SumAll(&local_existing_elements, &total_existing_elements, 1);
722 Element const rReferenceElement;
723 unsigned int to_be_deleted = 0;
724 unsigned int large_id = total_existing_elements * 15;
725 bool create_element =
false;
729 int splitted_edges = 0;
737 for (ModelPart::ElementsContainerType::iterator it = this_model_part.
Elements().begin();
738 it != this_model_part.
Elements().end(); ++it)
740 for (
unsigned int i = 0;
i < 12;
i++)
751 if (create_element ==
true)
754 for (
int i = 0;
i < nel;
i++)
760 this_model_part.
Nodes()(i0),
761 this_model_part.
Nodes()(i1),
762 this_model_part.
Nodes()(i2)
766 Element::Pointer p_element;
767 p_element = it->Create(
current_id, geom, it->pGetProperties());
768 p_element->SetFlags(*it);
769 p_element->Initialize(rCurrentProcessInfo);
770 p_element->InitializeSolutionStep(rCurrentProcessInfo);
771 p_element->FinalizeSolutionStep(rCurrentProcessInfo);
774 if (interpolate_internal_variables ==
true)
778 p_element->GetData() = it->GetData();
780 p_element->GetValue(SPLIT_ELEMENT) =
false;
795 this_model_part.
Elements().push_back(*(it_new.base()));
802 this_model_part.
Elements().erase(this_model_part.
Elements().end() - to_be_deleted, this_model_part.
Elements().end());
804 int number_of_elements_before = -1;
805 int number_of_own_elements = this_model_part.
Elements().size();
806 mrComm.ScanSum(&number_of_own_elements, &number_of_elements_before, 1);
807 number_of_elements_before = number_of_elements_before - number_of_own_elements;
808 if (number_of_elements_before < 0)
809 KRATOS_THROW_ERROR(std::logic_error,
"problem with scan sum ... giving a negative number of nodes before",
"");
811 int start_elem_id = number_of_elements_before + 1;
814 int id_counter = start_elem_id;
815 for (ModelPart::ElementsContainerType::iterator it = this_model_part.
Elements().begin();
816 it != this_model_part.
Elements().end(); ++it)
818 it->SetId(id_counter++);
840 int index_0 = geom[0].
Id() - 1;
841 int index_1 = geom[1].
Id() - 1;
842 int index_2 = geom[2].
Id() - 1;
844 aux[0] = geom[0].
Id();
845 aux[1] = geom[1].
Id();
846 aux[2] = geom[2].
Id();
849 int MaxNumEntries = p_edge_ids->MaxNumEntries();
850 double * id_values =
new double[MaxNumEntries];
851 int * Indices =
new int[MaxNumEntries];
875 int nel = this_model_part.
Elements().size();
877 mrComm.ScanSum(&nel, &el_before, 1);
879 int el_start_id = el_before - nel + 1;
880 if (el_start_id < 0)
KRATOS_THROW_ERROR(std::logic_error,
"wrong id in renumbering of the elements",
"")
882 unsigned int id_elem = el_start_id;
883 for (ModelPart::ElementsContainerType::iterator it = this_model_part.
ElementsBegin();
886 if (it->Id() != id_elem)
898 mrComm.MaxAll(&local_max_id, &max_id, 1);
899 mrComm.SumAll(&local_number_of_nodes, &tot_nnodes, 1);
900 if (max_id != tot_nnodes)
906 mrComm.MaxAll(&local_max_elem_id, &max_id, 1);
907 mrComm.SumAll(&local_number_of_elem, &tot_elements, 1);
908 if (max_id != tot_elements)
927 int nel = this_model_part.
Conditions().size();
930 mrComm.ScanSum(&nel, &el_before, 1);
932 int el_start_id = el_before - nel + 1;
933 if (el_start_id <= 0)
KRATOS_THROW_ERROR(std::logic_error,
"wrong id in renumbering of the Conditions",
"")
935 unsigned int id_elem = el_start_id;
936 for (ModelPart::ConditionsContainerType::iterator it = this_model_part.
ConditionsBegin();
939 if (it->Id() != id_elem)
951 mrComm.MaxAll(&local_max_id, &max_id, 1);
952 mrComm.SumAll(&local_number_of_nodes, &tot_nnodes, 1);
953 if (max_id != tot_nnodes)
958 int local_max_elem_id = 0;
962 mrComm.MaxAll(&local_max_elem_id, &max_id, 1);
963 mrComm.SumAll(&local_number_of_elem, &tot_Conditions, 1);
964 KRATOS_ERROR_IF (max_id != tot_Conditions) <<
"Condition ids are not consecutive" << std::endl;
986 const Element::Pointer father_elem,
987 Element::Pointer child_elem,
990 std::vector<Vector>
values;
991 father_elem->CalculateOnIntegrationPoints(INTERNAL_VARIABLES,
values, rCurrentProcessInfo);
999 child_elem->SetValuesOnIntegrationPoints(INTERNAL_VARIABLES,
values, rCurrentProcessInfo);
1005 for (
int i = 0;
i < row_size;
i++)
1007 if (indices[
i] ==
j)
1019 if (index_0 > index_1)
1021 p_edge_ids->ExtractGlobalRowCopy(index_1, MaxNumEntries, NumEntries,
values, Indices);
1026 p_edge_ids->ExtractGlobalRowCopy(index_0, MaxNumEntries, NumEntries,
values, Indices);
1037 bool interpolate_internal_variables
1040 if (this_model_part.
Elements().size() > 0)
1043 unsigned int to_be_deleted = 0;
1045 int total_existing_elements = -1;
1046 int local_existing_elements = this_model_part.
Elements().size();
1047 mrComm.SumAll(&local_existing_elements, &total_existing_elements, 1);
1049 unsigned int large_id = total_existing_elements * 15;
1050 unsigned int current_id = local_existing_elements + 1;
1051 bool create_element =
false;
1056 for (
unsigned int i = 0;
i < 56;
i++)
1061 int splitted_edges = 0;
1062 int internal_node = 0;
1066 for (ModelPart::ElementsContainerType::iterator it = this_model_part.
ElementsBegin(); it != this_model_part.
ElementsEnd(); ++it)
1071 int index_0 = geom[0].
Id() - 1;
1072 int index_1 = geom[1].
Id() - 1;
1073 int index_2 = geom[2].
Id() - 1;
1074 int index_3 = geom[3].
Id() - 1;
1078 aux[0] = geom[0].
Id();
1079 aux[1] = geom[1].
Id();
1080 aux[2] = geom[2].
Id();
1081 aux[3] = geom[3].
Id();
1084 int MaxNumEntries = p_edge_ids->MaxNumEntries();
1085 double * id_values =
new double[MaxNumEntries];
1086 int * Indices =
new int[MaxNumEntries];
1102 if (create_element ==
true)
1104 if (internal_node == 1)
1111 for (
int i = 0;
i < nel;
i++)
1114 unsigned int base =
i * 4;
1115 unsigned int i0 = aux[
t[base]];
1116 unsigned int i1 = aux[
t[base + 1]];
1117 unsigned int i2 = aux[
t[base + 2]];
1118 unsigned int i3 = aux[
t[base + 3]];
1127 this_model_part.
Nodes()(i0),
1128 this_model_part.
Nodes()(i1),
1129 this_model_part.
Nodes()(i2),
1130 this_model_part.
Nodes()(i3)
1134 Element::Pointer p_element = it->Create(
current_id, geom, it->pGetProperties());
1135 p_element->Initialize(rCurrentProcessInfo);
1136 p_element->InitializeSolutionStep(rCurrentProcessInfo);
1137 p_element->FinalizeSolutionStep(rCurrentProcessInfo);
1141 if (interpolate_internal_variables ==
true)
1145 p_element->GetData() = it->GetData();
1146 p_element->GetValue(SPLIT_ELEMENT) =
false;
1151 it->SetId(large_id);
1161 this_model_part.
Nodes().Sort();
1167 this_model_part.
Elements().erase(this_model_part.
Elements().end() - to_be_deleted, this_model_part.
Elements().end());
1169 unsigned int total_size = this_model_part.
Elements().size() + New_Elements.
size();
1170 this_model_part.
Elements().reserve(total_size);
1176 this_model_part.
Elements().push_back(*(it_new.base()));
1179 int number_of_elements_before = -1;
1180 int number_of_own_elements = this_model_part.
Elements().size();
1181 mrComm.ScanSum(&number_of_own_elements, &number_of_elements_before, 1);
1182 number_of_elements_before = number_of_elements_before - number_of_own_elements;
1183 if (number_of_elements_before < 0)
1184 KRATOS_THROW_ERROR(std::logic_error,
"problem with scan sum ... giving a negative number of nodes before",
"");
1186 int start_elem_id = number_of_elements_before + 1;
1188 int id_counter = start_elem_id;
1189 for (ModelPart::ElementsContainerType::iterator it = this_model_part.
Elements().begin();
1190 it != this_model_part.
Elements().end(); ++it)
1192 it->SetId(id_counter++);
1210 unsigned int new_id = (
model_part.NodesEnd() - 1)->Id() + 1;
1217 double X = (geom[0].X() + geom[1].X() + geom[2].X() + geom[3].X()) / 4.0;
1218 double Y = (geom[0].Y() + geom[1].Y() + geom[2].Y() + geom[3].Y()) / 4.0;
1219 double Z = (geom[0].Z() + geom[1].Z() + geom[2].Z() + geom[3].Z()) / 4.0;
1221 double X0 = (geom[0].X0() + geom[1].X0() + geom[2].X0() + geom[3].X0()) / 4.0;
1222 double Y0 = (geom[0].Y0() + geom[1].Y0() + geom[2].Y0() + geom[3].Y0()) / 4.0;
1223 double Z0 = (geom[0].Z0() + geom[1].Z0() + geom[2].Z0() + geom[3].Z0()) / 4.0;
1234 unsigned int step_data_size =
model_part.GetNodalSolutionStepDataSize();
1236 for (Node ::DofsContainerType::iterator iii = reference_dofs.begin(); iii != reference_dofs.end(); iii++)
1239 Node ::DofType::Pointer p_new_dof = pnode->pAddDof(rDof);
1242 (p_new_dof)->FreeDof();
1252 unsigned int buffer_size =
model_part.NodesBegin()->GetBufferSize();
1254 for (
unsigned int step = 0;
step < buffer_size;
step++)
1256 double* new_step_data = pnode->SolutionStepData().Data(
step);
1257 double* step_data1 = geom[0].SolutionStepData().Data(
step);
1258 double* step_data2 = geom[1].SolutionStepData().Data(
step);
1259 double* step_data3 = geom[2].SolutionStepData().Data(
step);
1260 double* step_data4 = geom[3].SolutionStepData().Data(
step);
1262 for (
unsigned int j = 0;
j < step_data_size;
j++)
1264 new_step_data[
j] = 0.25 * (step_data1[
j] + step_data2[
j] + step_data3[
j] + step_data4[
j]);
1268 pnode->FastGetSolutionStepValue(PARTITION_INDEX) =
mrComm.MyPID();
1270 center_nodes.push_back(pnode);
1277 int total_number_of_nodes_nocenter = 1;
1278 int local_number_of_center_nodes = center_nodes.size();
1280 int rank =
mrComm.MyPID();
1282 int number_of_nodes_before = -1;
1283 mrComm.ScanSum(&local_number_of_center_nodes, &number_of_nodes_before, 1);
1284 number_of_nodes_before = number_of_nodes_before - local_number_of_center_nodes;
1285 if (number_of_nodes_before < 0)
1286 KRATOS_THROW_ERROR(std::logic_error,
"problem with scan sum ... giving a negative number of nodes before",
"");
1289 int number_of_own_nodes_nocenter = 0;
1291 if (it->FastGetSolutionStepValue(PARTITION_INDEX) == rank)
1292 number_of_own_nodes_nocenter++;
1293 number_of_own_nodes_nocenter -= local_number_of_center_nodes;
1294 mrComm.SumAll(&number_of_own_nodes_nocenter, &total_number_of_nodes_nocenter, 1);
1296 int counter = total_number_of_nodes_nocenter + number_of_nodes_before + 1;
1297 for (ModelPart::NodesContainerType::iterator it = center_nodes.begin(); it != center_nodes.end(); it++)
1311 bool interpolate_internal_variables
1318 int total_existing_Conditions = -1;
1319 int local_existing_Conditions = this_model_part.
Conditions().size();
1320 mrComm.SumAll(&local_existing_Conditions, &total_existing_Conditions, 1);
1322 if (this_model_part.
Conditions().size() != 0)
1324 unsigned int to_be_deleted = 0;
1325 unsigned int large_id = total_existing_Conditions * 4;
1326 bool create_Condition =
false;
1330 int splitted_edges = 0;
1338 for (ModelPart::ConditionsContainerType::iterator it = this_model_part.
Conditions().begin();
1339 it != this_model_part.
Conditions().end(); ++it)
1341 for (
unsigned int i = 0;
i < 12;
i++)
1352 if (create_Condition ==
true)
1355 for (
int i = 0;
i < nel;
i++)
1363 this_model_part.
Nodes()(i0),
1364 this_model_part.
Nodes()(i1),
1365 this_model_part.
Nodes()(i2)
1369 Condition::Pointer p_Condition;
1370 p_Condition = it->Create(
current_id, geom, it->pGetProperties());
1371 p_Condition->SetFlags(*it);
1372 p_Condition->Initialize(rCurrentProcessInfo);
1373 p_Condition->InitializeSolutionStep(rCurrentProcessInfo);
1374 p_Condition->FinalizeSolutionStep(rCurrentProcessInfo);
1381 p_Condition->GetData() = it->GetData();
1387 it->SetId(large_id);
1405 this_model_part.
Conditions().push_back(*(it_new.base()));
1409 int number_of_Conditions_before = -1;
1410 int number_of_own_Conditions = this_model_part.
Conditions().size();
1411 mrComm.ScanSum(&number_of_own_Conditions, &number_of_Conditions_before, 1);
1412 number_of_Conditions_before = number_of_Conditions_before - number_of_own_Conditions;
1413 if (number_of_Conditions_before < 0)
1414 KRATOS_THROW_ERROR(std::logic_error,
"problem with scan sum ... giving a negative number of nodes before",
"");
1416 if (this_model_part.
Conditions().size() != 0)
1418 int start_elem_id = number_of_Conditions_before + 1;
1421 int id_counter = start_elem_id;
1422 for (ModelPart::ConditionsContainerType::iterator it = this_model_part.
Conditions().begin();
1423 it != this_model_part.
Conditions().end(); ++it)
1425 it->SetId(id_counter++);
1441 Node::Pointer p_new_node = Node::Pointer(
new Node(Id,
x,
y,
z));
1446 p_new_node->SetBufferSize(r_model_part.
NodesBegin()->GetBufferSize());
MeshType & GhostMesh()
Returns the reference to the mesh storing all ghost entities.
Definition: communicator.cpp:251
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 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
NodesContainerType & Nodes()
Definition: mesh.h:346
NodeIterator NodesEnd()
Definition: mesh.h:336
NodeIterator NodesBegin()
Definition: mesh.h:326
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
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
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
Dof< double > DofType
Dof type.
Definition: node.h:83
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
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
Definition: pointer_vector.h:255
iterator end()
Definition: pointer_vector.h:177
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector.h:89
iterator begin()
Definition: pointer_vector.h:169
void push_back(const TPointerType &x)
Definition: pointer_vector.h:270
size_type size() const
Returns the number of elements in the container.
Definition: pointer_vector_set.h:502
void push_back(TPointerType x)
Adds a pointer to the end of the set.
Definition: pointer_vector_set.h:544
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
A four node tetrahedra geometry with linear shape functions.
Definition: tetrahedra_3d_4.h:59
static int Split_Tetrahedra(const int edges[6], int t[56], int *nel, int *splitted_edges, int *nint)
Function to split a tetrahedron For a given edges splitting pattern, this function computes the inter...
Definition: split_tetrahedra.h:177
static void TetrahedraSplitMode(int aux_ids[11], int edge_ids[6])
Returns the edges vector filled with the splitting pattern. Provided the array of nodal ids,...
Definition: split_tetrahedra.h:91
A three node 2D triangle geometry with linear shape functions.
Definition: triangle_2d_3.h:74
A three node 3D triangle geometry with linear shape functions.
Definition: triangle_3d_3.h:77
static void TriangleSplitMode(const int aux_ids[6], int edge_ids[3])
Definition: split_triangle.h:64
static int Split_Triangle(const int edges[3], int t[12], int *nel, int *splitted_edges, int *nint)
Utility to split triangles.
Definition: split_triangle.h:117
static void TriangleGetNewConnectivityGID(const int triangle_index, const int t[12], const int aux_ids[6], int *id0, int *id1, int *id2)
Definition: split_triangle.h:96
Definition: trilinos_refine_mesh.h:44
void CSR_Row_Matrix(ModelPart &this_model_part, Kratos::shared_ptr< Epetra_FECrsMatrix > &p_edge_ids)
Definition: trilinos_refine_mesh.h:225
Node PointType
Definition: trilinos_refine_mesh.h:53
ModelPart::NodesContainerType NodesArrayType
Definition: trilinos_refine_mesh.h:47
Kratos::shared_ptr< Epetra_CrsGraph > mp_overlapping_graph
Definition: trilinos_refine_mesh.h:979
ModelPart & mr_model_part
Definition: trilinos_refine_mesh.h:972
void Local_Refine_Mesh(bool refine_on_reference, bool interpolate_internal_variables, int domain_size)
Definition: trilinos_refine_mesh.h:92
ModelPart::ElementsContainerType ElementsArrayType
Definition: trilinos_refine_mesh.h:48
Kratos::shared_ptr< Epetra_Map > mp_overlapping_map
Definition: trilinos_refine_mesh.h:974
void Clear()
This function frees all of the memory used.
Definition: trilinos_refine_mesh.h:200
Node ::Pointer PointPointerType
Definition: trilinos_refine_mesh.h:54
Kratos::shared_ptr< Epetra_Map > mp_non_overlapping_map
Definition: trilinos_refine_mesh.h:975
void Erase_Old_Element_And_Create_New_Triangle_Element(ModelPart &this_model_part, const Kratos::shared_ptr< Epetra_FECrsMatrix > p_edge_ids, PointerVector< Element > &New_Elements, bool interpolate_internal_variables)
Definition: trilinos_refine_mesh.h:708
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: trilinos_refine_mesh.h:49
Kratos::shared_ptr< Epetra_FECrsGraph > mp_non_overlapping_graph
Definition: trilinos_refine_mesh.h:978
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_refine_mesh.h:1016
Epetra_MpiComm & mrComm
Definition: trilinos_refine_mesh.h:973
~TrilinosRefineMesh()
Definition: trilinos_refine_mesh.h:67
void Erase_Old_Element_And_Create_New_Tetra_Element(ModelPart &this_model_part, const Kratos::shared_ptr< Epetra_FECrsMatrix > p_edge_ids, PointerVector< Element > &New_Elements, bool interpolate_internal_variables)
Definition: trilinos_refine_mesh.h:1033
unsigned int CreateCenterNode(Geometry< Node > &geom, ModelPart &model_part, ModelPart::NodesContainerType ¢er_nodes)
Definition: trilinos_refine_mesh.h:1207
int mtotal_number_of_existing_nodes
Definition: trilinos_refine_mesh.h:976
Node::Pointer AuxCreateNewNode(ModelPart &r_model_part, int Id, double x, double y, double z)
Definition: trilinos_refine_mesh.h:1438
void PrintDebugInfo()
Definition: trilinos_refine_mesh.h:184
PointVector::iterator PointIterator
Definition: trilinos_refine_mesh.h:56
TrilinosRefineMesh(ModelPart &model_part, Epetra_MpiComm &Comm)
Definition: trilinos_refine_mesh.h:63
void AssignIdToCenterNode(ModelPart::NodesContainerType ¢er_nodes)
Definition: trilinos_refine_mesh.h:1275
void Erase_Old_Condition_And_Create_New_Triangle_Conditions(ModelPart &this_model_part, const Kratos::shared_ptr< Epetra_FECrsMatrix > p_edge_ids, PointerVector< Condition > &New_Conditions, bool interpolate_internal_variables)
Definition: trilinos_refine_mesh.h:1307
double GetValueFromRow(int row, int j, int row_size, int *indices, double *values)
Definition: trilinos_refine_mesh.h:1003
void Calculate_Coordinate_And_Insert_New_Nodes(ModelPart &this_model_part, const vector< array_1d< int, 2 > > &father_node_ids, const vector< int > &List_New_Nodes, const vector< int > &partition_new_nodes)
Definition: trilinos_refine_mesh.h:561
void Create_List_Of_New_Nodes(ModelPart &this_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)
Definition: trilinos_refine_mesh.h:386
void Renumbering_Conditions(ModelPart &this_model_part, PointerVector< Condition > &New_Conditions)
Definition: trilinos_refine_mesh.h:919
vector< Vector > Vector_Order_Tensor
Definition: trilinos_refine_mesh.h:51
void Search_Edge_To_Be_Refined(ModelPart &this_model_part, Kratos::shared_ptr< Epetra_FECrsMatrix > &p_edge_ids, Kratos::shared_ptr< Epetra_FECrsMatrix > &p_partition_ids)
Definition: trilinos_refine_mesh.h:303
void InterpolateInternalVariables(const int &nel, const Element::Pointer father_elem, Element::Pointer child_elem, const ProcessInfo &rCurrentProcessInfo)
Definition: trilinos_refine_mesh.h:985
vector< Vector_Order_Tensor > Node_Vector_Order_Tensor
Definition: trilinos_refine_mesh.h:52
void Calculate_Triangle_Edges(Element::GeometryType &geom, const Kratos::shared_ptr< Epetra_FECrsMatrix > p_edge_ids, int *edge_ids, int aux[6])
Definition: trilinos_refine_mesh.h:833
void Renumbering_Elements(ModelPart &this_model_part, PointerVector< Element > &New_Elements)
Definition: trilinos_refine_mesh.h:869
vector< Matrix > Matrix_Order_Tensor
Definition: trilinos_refine_mesh.h:50
std::vector< PointType::Pointer > PointVector
Definition: trilinos_refine_mesh.h:55
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_TRY
Definition: define.h:109
#define KRATOS_ERROR
Definition: exception.h:161
#define KRATOS_ERROR_IF(conditional)
Definition: exception.h:162
z
Definition: GenerateWind.py:163
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
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
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 domain_size
Definition: face_heat.py:4
int step
Definition: face_heat.py:88
model_part
Definition: face_heat.py:14
y
Other simbols definition.
Definition: generate_axisymmetric_navier_stokes_element.py:54
int t
Definition: ode_solve.py:392
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
int counter
Definition: script_THERMAL_CORRECT.py:218
int current_id
Output settings end ####.
Definition: script.py:194
x
Definition: sensitivityMatrix.py:49
int nnodes
Definition: sensitivityMatrix.py:24
integer i
Definition: TensorModule.f:17