66 const std::size_t NNodesSW =
static_cast<int>(rSWModelPart.
Nodes().size());
67 ModelPart::NodesContainerType::iterator node_beginSW = rSWModelPart.
NodesBegin();
69 const std::size_t NNodesPfem =
static_cast<int>(rPfemModelPart.
Nodes().size());
70 ModelPart::NodesContainerType::iterator node_beginPfem = rPfemModelPart.
NodesBegin();
72 double distance, distance_to_first_neigh_node, distance_to_second_neigh_node;
73 double ratio, ratio1,ratio2;
76 double Tol2 = Tol*Tol;
78 int first_neigh_node, second_neigh_node;
80 double height, vertical_velocity, topography;
83 for(std::size_t
i = 0;
i < NNodesPfem;
i++) {
84 ModelPart::NodesContainerType::iterator it_node = node_beginPfem +
i;
86 distance_to_first_neigh_node = 1e32;
87 distance_to_second_neigh_node = 1e32;
89 for (std::size_t
j = 0;
j < NNodesSW;
j++){
90 ModelPart::NodesContainerType::iterator jt_node = node_beginSW +
j;
92 distance = (it_node->X() - jt_node->X())*(it_node->X() - jt_node->X()) + (it_node->Y() - jt_node->Y())*(it_node->Y() - jt_node->Y());
93 if (distance < distance_to_first_neigh_node){
94 distance_to_first_neigh_node = distance;
99 for (std::size_t
j = 0;
j < NNodesSW;
j++){
100 ModelPart::NodesContainerType::iterator jt_node = node_beginSW +
j;
102 distance = (it_node->X() - jt_node->X())*(it_node->X() - jt_node->X()) + (it_node->Y() - jt_node->Y())*(it_node->Y() - jt_node->Y());
103 if ((distance < distance_to_second_neigh_node) & (distance > distance_to_first_neigh_node)){
104 distance_to_second_neigh_node = distance;
105 second_neigh_node =
j;
109 ModelPart::NodesContainerType::iterator jt_node1 = node_beginSW + first_neigh_node;
110 ModelPart::NodesContainerType::iterator jt_node2 = node_beginSW + second_neigh_node;
112 double dx = std::abs(jt_node1->X() - jt_node2->X());
113 double dy = std::abs(jt_node1->Y() - jt_node2->Y());
115 if (distance_to_first_neigh_node*distance_to_first_neigh_node > Tol2*(dx*dx + dy*dy)){
116 KRATOS_WARNING(
"Interpolate_sw_to_pfem") <<
"PFEM node quite far from SW output interface " << std::endl;
119 if (((dx >
tol) & (dy <
tol)) | ((dx <
tol) & (dy >
tol))){
120 if ((dx >
tol) & (dy <
tol)){
121 ratio = (it_node->X() - jt_node2->X())/(jt_node1->X() - jt_node2->X());
122 }
else if ((dx <
tol) & (dy >
tol)){
123 ratio = (it_node->Y() - jt_node2->Y())/(jt_node1->Y() - jt_node2->Y());
126 velocity = ratio*(jt_node1->GetValue(VELOCITY) - jt_node2->GetValue(VELOCITY)) + jt_node2->GetValue(VELOCITY);
127 height = ratio*(jt_node1->GetValue(HEIGHT) - jt_node2->GetValue(HEIGHT)) + jt_node2->GetValue(HEIGHT);
128 vertical_velocity = ratio*(jt_node1->GetValue(VERTICAL_VELOCITY) - jt_node2->GetValue(VERTICAL_VELOCITY)) + jt_node2->GetValue(VERTICAL_VELOCITY);
129 topography = ratio*(jt_node1->GetValue(TOPOGRAPHY) - jt_node2->GetValue(TOPOGRAPHY)) + jt_node2->GetValue(TOPOGRAPHY);
131 ratio1 = (it_node->X() - jt_node2->X())/(jt_node1->X() - jt_node2->X());
132 ratio2 = (it_node->Y() - jt_node2->Y())/(jt_node1->Y() - jt_node2->Y());
134 velocity = ratio1*(jt_node1->GetValue(VELOCITY) - jt_node2->GetValue(VELOCITY)) + jt_node2->GetValue(VELOCITY);
135 height = ratio1*(jt_node1->GetValue(HEIGHT) - jt_node2->GetValue(HEIGHT)) + jt_node2->GetValue(HEIGHT);
136 vertical_velocity = ratio1*(jt_node1->GetValue(VERTICAL_VELOCITY) - jt_node2->GetValue(VERTICAL_VELOCITY)) + jt_node2->GetValue(VERTICAL_VELOCITY);
137 topography = ratio1*(jt_node1->GetValue(TOPOGRAPHY) - jt_node2->GetValue(TOPOGRAPHY)) + jt_node2->GetValue(TOPOGRAPHY);
139 velocity += ratio2*(jt_node1->GetValue(VELOCITY) - jt_node2->GetValue(VELOCITY)) + jt_node2->GetValue(VELOCITY);
140 height += ratio2*(jt_node1->GetValue(HEIGHT) - jt_node2->GetValue(HEIGHT)) + jt_node2->GetValue(HEIGHT);
141 vertical_velocity += ratio2*(jt_node1->GetValue(VERTICAL_VELOCITY) - jt_node2->GetValue(VERTICAL_VELOCITY)) + jt_node2->GetValue(VERTICAL_VELOCITY);
142 topography += ratio2*(jt_node1->GetValue(TOPOGRAPHY) - jt_node2->GetValue(TOPOGRAPHY)) + jt_node2->GetValue(TOPOGRAPHY);
146 vertical_velocity = 0.5*vertical_velocity;
147 topography = 0.5*topography;
150 it_node->GetValue(HEIGHT) = height;
151 it_node->GetValue(VELOCITY) =
velocity;
152 it_node->GetValue(VERTICAL_VELOCITY) = vertical_velocity;
153 it_node->GetValue(TOPOGRAPHY) = topography;
Definition: interpolate_sw_to_pfem_utility.hpp:36
KRATOS_CLASS_POINTER_DEFINITION(InterpolateSwToPfemUtility)
virtual ~InterpolateSwToPfemUtility()
Destructor.
Definition: interpolate_sw_to_pfem_utility.hpp:59
void InterpolateVariables(ModelPart &rPfemModelPart, ModelPart &rSWModelPart)
Definition: interpolate_sw_to_pfem_utility.hpp:63
InterpolateSwToPfemUtility()
Constructor.
Definition: interpolate_sw_to_pfem_utility.hpp:54
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
#define KRATOS_WARNING(label)
Definition: logger.h:265
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
float velocity
Definition: PecletTest.py:54
int tol
Definition: hinsberg_optimization.py:138
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31
Basic Structs for the utility -----------------------------------------------------------------------...
Definition: interpolate_sw_to_pfem_utility.hpp:43
double ColumnSize
Definition: interpolate_sw_to_pfem_utility.hpp:46
int NRows
Definition: interpolate_sw_to_pfem_utility.hpp:45
int NColumns
Definition: interpolate_sw_to_pfem_utility.hpp:45
double SectionSize
Definition: interpolate_sw_to_pfem_utility.hpp:46
double X_max
Definition: interpolate_sw_to_pfem_utility.hpp:44
double RowSize
Definition: interpolate_sw_to_pfem_utility.hpp:46
double Y_max
Definition: interpolate_sw_to_pfem_utility.hpp:44
double Y_min
Definition: interpolate_sw_to_pfem_utility.hpp:44
double Z_min
Definition: interpolate_sw_to_pfem_utility.hpp:44
double Z_max
Definition: interpolate_sw_to_pfem_utility.hpp:44
int NSections
Definition: interpolate_sw_to_pfem_utility.hpp:45
double X_min
Definition: interpolate_sw_to_pfem_utility.hpp:44