13 #if !defined(KRATOS_PARTICLES_UTILITIES_INCLUDED )
14 #define KRATOS_PARTICLES_UTILITIES_INCLUDED
16 #define PRESSURE_ON_EULERIAN_MESH
17 #define USE_FEW_PARTICLES
32 #include "utilities/geometry_utilities.h"
40 #include <boost/timer.hpp>
50 template<
class T, std::
size_t dim >
58 for (std::size_t
i = 0;
i <
dim;
i++)
60 double tmp = p1[
i] - p2[
i];
98 double h = sqrt(2.00*
dummy);
101 ms_vel_gauss[0] =
v[0];
102 ms_vel_gauss[1] =
v[1];
105 for (
unsigned int i=1;
i<3;
i++)
108 ms_vel_gauss[0] += vi[0];
109 ms_vel_gauss[1] += vi[1];
111 ms_vel_gauss *=0.3333;
113 double norm_u = ms_vel_gauss[0]*ms_vel_gauss[0] + ms_vel_gauss[1]*ms_vel_gauss[1];
114 norm_u = sqrt(norm_u);
116 double courant= norm_u * max_dt /
h;
118 double&
counter =
im->GetValue(POISSON_RATIO);
130 rCompleteModelPart.
Nodes() = rEulerianModelPart.
Nodes();
133 if(rEulerianModelPart.
Nodes().size()!= 0)
134 id = (rEulerianModelPart.
Nodes().end() - 1)->Id() + 1;
139 int tot_nodes = rEulerianModelPart.
Nodes().size() + rLagrangianModelPart.
Nodes().size();
140 rCompleteModelPart.
Nodes().reserve( tot_nodes );
143 for (ModelPart::NodesContainerType::iterator node_it = rLagrangianModelPart.
NodesBegin();
144 node_it != rLagrangianModelPart.
NodesEnd(); node_it++)
146 node_it->SetId(
id++);
147 rCompleteModelPart.
AddNode(*(node_it.base()));
160 typedef std::vector<PointType::Pointer>
PointVector;
161 typedef std::vector<PointType::Pointer>::iterator
PointIterator;
175 boost::timer kdtree_construction;
177 for (ModelPart::NodesContainerType::iterator node_it = rLagrangianModelPart.
NodesBegin();
178 node_it != rLagrangianModelPart.
NodesEnd(); ++node_it)
183 list_of_nodes.push_back(pnode);
186 std::cout <<
"kdt constructin time " << kdtree_construction.elapsed() << std::endl;
189 unsigned int bucket_size = 20;
190 tree nodes_tree(list_of_nodes.begin(), list_of_nodes.end(), bucket_size);
193 Node work_point(0, 0.0, 0.0, 0.0);
194 unsigned int MaximumNumberOfResults = 10000;
199 if (rEulerianModelPart.
NodesBegin()->SolutionStepsDataHas(NODAL_H) ==
false)
200 KRATOS_ERROR<<
"Add ----NODAL_H---- variable!!!!!! ERROR";
203 if constexpr (TDim == 2)
204 sigma = 10.0 / (7.0 * 3.1415926);
206 sigma = 1.0 / 3.1415926;
208 for (ModelPart::NodesContainerType::iterator node_it = rEulerianModelPart.
NodesBegin(); node_it != rEulerianModelPart.
NodesEnd(); node_it++)
210 if( (node_it)->FastGetSolutionStepValue(IS_FREE_SURFACE)==
true || (node_it)->FastGetSolutionStepValue(IS_WATER)==1 )
212 work_point.
X() = node_it->X();
213 work_point.
Y() = node_it->Y();
214 work_point.
Z() = node_it->Z();
216 double radius = 1.5 * node_it->FastGetSolutionStepValue(NODAL_H);
219 int number_of_points_in_radius;
222 number_of_points_in_radius = nodes_tree.SearchInRadius(work_point,
radius, Results.begin(), SquaredResultsDistances.begin(), MaximumNumberOfResults);
224 if (number_of_points_in_radius > 0)
227 double&
temperature = (node_it)->FastGetSolutionStepValue(FACE_HEAT_FLUX);
230 double temperature_aux = 0.0;
232 double tot_weight = 0.0;
234 for (
int k = 0;
k < number_of_points_in_radius;
k++)
236 double distance = sqrt(*(SquaredResultsDistances.begin() +
k));
237 double weight = SPHCubicKernel(
sigma, distance,
radius);
241 if((*it_found)->FastGetSolutionStepValue(IS_INTERFACE)==1)
243 temperature_aux += weight * (*it_found)->FastGetSolutionStepValue(INCIDENT_RADIATION_FUNCTION);
244 tot_weight += weight;
249 temperature_aux /= tot_weight;
267 typedef std::vector<PointType::Pointer>
PointVector;
268 typedef std::vector<PointType::Pointer>::iterator
PointIterator;
281 boost::timer kdtree_construction;
283 for (ModelPart::NodesContainerType::iterator node_it = rLagrangianModelPart.
NodesBegin();
284 node_it != rLagrangianModelPart.
NodesEnd(); ++node_it)
289 list_of_nodes.push_back(pnode);
292 std::cout <<
"kdt constructin time " << kdtree_construction.elapsed() << std::endl;
295 unsigned int bucket_size = 20;
296 tree nodes_tree(list_of_nodes.begin(), list_of_nodes.end(), bucket_size);
299 Node work_point(0, 0.0, 0.0, 0.0);
300 unsigned int MaximumNumberOfResults = 10000;
304 if (rEulerianModelPart.
NodesBegin()->SolutionStepsDataHas(NODAL_H) ==
false)
305 KRATOS_ERROR<<
"Add ----NODAL_H---- variable!!!!!! ERROR";
308 if constexpr (TDim == 2)
309 sigma = 10.0 / (7.0 * 3.1415926);
311 sigma = 1.0 / 3.1415926;
313 for (ModelPart::NodesContainerType::iterator node_it = rEulerianModelPart.
NodesBegin(); node_it != rEulerianModelPart.
NodesEnd(); node_it++)
315 if((node_it)->FastGetSolutionStepValue(IS_INTERFACE)==1)
317 work_point.
X() = node_it->X();
318 work_point.
Y() = node_it->Y();
319 work_point.
Z() = node_it->Z();
321 double radius = 2.0 * node_it->FastGetSolutionStepValue(NODAL_H);
324 int number_of_points_in_radius;
327 number_of_points_in_radius = nodes_tree.SearchInRadius(work_point,
radius, Results.begin(), SquaredResultsDistances.begin(), MaximumNumberOfResults);
329 if (number_of_points_in_radius > 0)
332 double temperature_aux = 0.0;
333 double tot_weight = 0.0;
334 for (
int k = 0;
k < number_of_points_in_radius;
k++)
336 double distance = sqrt(*(SquaredResultsDistances.begin() +
k));
337 double weight = SPHCubicKernel(
sigma, distance,
radius);
340 if((*it_found)->FastGetSolutionStepValue(IS_FREE_SURFACE) ==1 || (*it_found)->FastGetSolutionStepValue(IS_WATER) ==1 )
343 tempp=(*it_found)->FastGetSolutionStepValue(YCH4);
345 if(tempp<298.0) tempp=298.0;
347 temperature_aux += weight * tempp;
348 tot_weight += weight;
354 temperature_aux /= tot_weight;
355 (node_it)->FastGetSolutionStepValue(FUEL)=temperature_aux;
362 if((node_it)->FastGetSolutionStepValue(TEMPERATURE)<298.0) (node_it)->FastGetSolutionStepValue(FUEL)=298.0;
363 else (node_it)->FastGetSolutionStepValue(FUEL)=(node_it)->FastGetSolutionStepValue(TEMPERATURE);
380 const int max_results = 1000;
382 const int nparticles = rLagrangianModelPart.
Nodes().size();
384 #pragma omp parallel for firstprivate(results,N)
385 for (
int i = 0;
i < nparticles;
i++)
387 ModelPart::NodesContainerType::iterator iparticle = rLagrangianModelPart.
NodesBegin() +
i;
389 Node ::Pointer pparticle = *(iparticle.base());
392 Element::Pointer pelement;
394 bool is_found = node_locator.FindPointOnMesh(pparticle->Coordinates(),
N, pelement, result_begin, max_results);
396 if (is_found ==
true)
409 if(geom[0].FastGetSolutionStepValue(IS_INTERFACE)>0.5) s0=1;
410 if(geom[1].FastGetSolutionStepValue(IS_INTERFACE)>0.5) s1=1;
411 if(geom[2].FastGetSolutionStepValue(IS_INTERFACE)>0.5) s2=1;
417 for (
unsigned int jj = 0; jj < 2; jj++)
419 for (
unsigned int kk = 0; kk < 3; kk++)
421 qrad[jj] += msDN_DX(kk, jj) * geom[kk].FastGetSolutionStepValue(TEMPERATURE);
422 qrad_P1[jj] += msDN_DX(kk, jj) * geom[kk].FastGetSolutionStepValue(INCIDENT_RADIATION_FUNCTION);
426 double faceheatflux=0.0;
430 if((geom[1].FastGetSolutionStepValue(IS_INTERFACE)>0.5 && geom[0].FastGetSolutionStepValue(IS_INTERFACE)>0.5))
434 interface_segment[0] = (geom[0].X()-geom[1].X());
435 interface_segment[1] = (geom[0].Y()-geom[1].Y());
436 norm = sqrt( pow((interface_segment[0]),2) + pow((interface_segment[1]),2));
438 normaledge1(0)= -interface_segment[1]/norm;
439 normaledge1(1)= interface_segment[0]/norm;
440 faceheatflux += abs(1.0*(qrad[0]*normaledge1(0)+qrad[1]*normaledge1(1))*0.0131);
443 if((geom[1].FastGetSolutionStepValue(IS_INTERFACE)>0.5 && geom[2].FastGetSolutionStepValue(IS_INTERFACE)>0.5))
446 interface_segment[0] = (geom[1].X()-geom[2].X());
447 interface_segment[1] = (geom[1].Y()-geom[2].Y());
448 norm = sqrt( pow((interface_segment[0]),2) + pow((interface_segment[1]),2));
450 normaledge1(0)= -interface_segment[1]/norm;
451 normaledge1(1)= interface_segment[0]/norm;
452 faceheatflux += abs(1.0*(qrad[0]*normaledge1(0)+qrad[1]*normaledge1(1))*0.0131);
454 if((geom[2].FastGetSolutionStepValue(IS_INTERFACE)>0.5 && geom[0].FastGetSolutionStepValue(IS_INTERFACE)>0.5))
457 interface_segment[0] = (geom[2].X()-geom[0].X());
458 interface_segment[1] = (geom[2].Y()-geom[0].Y());
459 norm = sqrt( pow((interface_segment[0]),2) + pow((interface_segment[1]),2));
460 normaledge1(0)= -interface_segment[1]/norm;
461 normaledge1(1)= interface_segment[0]/norm;
462 faceheatflux += abs(1.0*(qrad[0]*normaledge1(0)+qrad[1]*normaledge1(1))*0.0131);
467 if((geom[1].FastGetSolutionStepValue(IS_INTERFACE)<0.5 && geom[0].FastGetSolutionStepValue(IS_INTERFACE)<0.5))
470 interface_segment[0] = (geom[0].X()-geom[1].X());
471 interface_segment[1] = (geom[0].Y()-geom[1].Y());
472 norm = sqrt( pow((interface_segment[0]),2) + pow((interface_segment[1]),2));
473 normaledge1(0)= -interface_segment[1]/norm;
474 normaledge1(1)= interface_segment[0]/norm;
475 faceheatflux += abs(1.0*(qrad[0]*normaledge1(0)+qrad[1]*normaledge1(1))*0.0131);
477 if((geom[1].FastGetSolutionStepValue(IS_INTERFACE)<0.5 && geom[2].FastGetSolutionStepValue(IS_INTERFACE)<0.5))
480 interface_segment[0] = (geom[1].X()-geom[2].X());
481 interface_segment[1] = (geom[1].Y()-geom[2].Y());
482 norm = sqrt( pow((interface_segment[0]),2) + pow((interface_segment[1]),2));
483 normaledge1(0)= -interface_segment[1]/norm;
484 normaledge1(1)= interface_segment[0]/norm;
485 faceheatflux += abs(1.0*(qrad[0]*normaledge1(0)+qrad[1]*normaledge1(1))*0.0131);
487 if((geom[2].FastGetSolutionStepValue(IS_INTERFACE)<0.5 && geom[0].FastGetSolutionStepValue(IS_INTERFACE)<0.5))
490 interface_segment[0] = (geom[2].X()-geom[0].X());
491 interface_segment[1] = (geom[2].Y()-geom[0].Y());
492 norm = sqrt( pow((interface_segment[0]),2) + pow((interface_segment[1]),2));
493 normaledge1(0)= -interface_segment[1]/norm;
494 normaledge1(1)= interface_segment[0]/norm;
495 faceheatflux += abs(1.0*(qrad[0]*normaledge1(0)+qrad[1]*normaledge1(1))*0.0131);
499 (iparticle)->FastGetSolutionStepValue(FACE_HEAT_FLUX)+=(faceheatflux );
512 for(ModelPart::NodesContainerType::const_iterator in = full_model_part.
NodesBegin(); in!=full_model_part.
NodesEnd(); in++)
514 in->FastGetSolutionStepValue(NORMAL) =
zero;
523 for(ModelPart::ElementsContainerType::iterator iii = full_model_part.
ElementsBegin(); iii != full_model_part.
ElementsEnd(); iii++)
525 if( iii->GetGeometry()[1].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0 && iii->GetGeometry()[2].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0 && iii->GetGeometry()[3].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0)
527 v1[0] = iii->GetGeometry()[1].X() -iii->GetGeometry()[3].X();
528 v1[1] = iii->GetGeometry()[1].Y() - iii->GetGeometry()[3].Y();
529 v1[2] = iii->GetGeometry()[1].Z() - iii->GetGeometry()[3].Z();
531 v2[0] = iii->GetGeometry()[2].X() - iii->GetGeometry()[3].X();
532 v2[1] = iii->GetGeometry()[2].Y() - iii->GetGeometry()[3].Y();
533 v2[2] = iii->GetGeometry()[2].Z() - iii->GetGeometry()[3].Z();
539 double c0 = abs(area_normal[0]);
540 double c1 = abs(area_normal[1]);
541 double c2 = abs(area_normal[2]);
547 double norm_u = msAuxVec[0]*msAuxVec[0] + msAuxVec[1]*msAuxVec[1] + msAuxVec[2]*msAuxVec[2];
548 double norm_c =sqrt(norm_u);
550 iii->GetGeometry()[1].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
551 iii->GetGeometry()[2].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
552 iii->GetGeometry()[3].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
555 if( iii->GetGeometry()[0].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0 && iii->GetGeometry()[3].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0 && iii->GetGeometry()[2].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0)
557 v1[0] = iii->GetGeometry()[0].X() -iii->GetGeometry()[2].X();
558 v1[1] = iii->GetGeometry()[0].Y() - iii->GetGeometry()[2].Y();
559 v1[2] = iii->GetGeometry()[0].Z() - iii->GetGeometry()[2].Z();
561 v2[0] = iii->GetGeometry()[3].X() - iii->GetGeometry()[2].X();
562 v2[1] = iii->GetGeometry()[3].Y() - iii->GetGeometry()[2].Y();
563 v2[2] = iii->GetGeometry()[3].Z() - iii->GetGeometry()[2].Z();
567 double c0 = abs(area_normal[0]);
568 double c1 = abs(area_normal[1]);
569 double c2 = abs(area_normal[2]);
575 double norm_u = msAuxVec[0]*msAuxVec[0] + msAuxVec[1]*msAuxVec[1] + msAuxVec[2]*msAuxVec[2];
576 double norm_c =sqrt(norm_u);
578 iii->GetGeometry()[0].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
579 iii->GetGeometry()[3].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
580 iii->GetGeometry()[2].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
583 if( iii->GetGeometry()[0].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0 && iii->GetGeometry()[1].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0 && iii->GetGeometry()[3].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0)
585 v1[0] = iii->GetGeometry()[0].X() -iii->GetGeometry()[3].X();
586 v1[1] = iii->GetGeometry()[0].Y() - iii->GetGeometry()[3].Y();
587 v1[2] = iii->GetGeometry()[0].Z() - iii->GetGeometry()[3].Z();
589 v2[0] = iii->GetGeometry()[1].X() - iii->GetGeometry()[3].X();
590 v2[1] = iii->GetGeometry()[1].Y() - iii->GetGeometry()[3].Y();
591 v2[2] = iii->GetGeometry()[1].Z() - iii->GetGeometry()[3].Z();
596 double c0 = abs(area_normal[0]);
597 double c1 = abs(area_normal[1]);
598 double c2 = abs(area_normal[2]);
603 double norm_u = msAuxVec[0]*msAuxVec[0] + msAuxVec[1]*msAuxVec[1] + msAuxVec[2]*msAuxVec[2];
604 double norm_c =sqrt(norm_u);
606 iii->GetGeometry()[0].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
607 iii->GetGeometry()[1].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
608 iii->GetGeometry()[3].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
610 if( iii->GetGeometry()[0].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0 && iii->GetGeometry()[2].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0 && iii->GetGeometry()[1].FastGetSolutionStepValue(IS_BOUNDARY) == 1.0)
612 v1[0] = iii->GetGeometry()[0].X() -iii->GetGeometry()[1].X();
613 v1[1] = iii->GetGeometry()[0].Y() - iii->GetGeometry()[1].Y();
614 v1[2] = iii->GetGeometry()[0].Z() - iii->GetGeometry()[1].Z();
616 v2[0] = iii->GetGeometry()[2].X() - iii->GetGeometry()[1].X();
617 v2[1] = iii->GetGeometry()[2].Y() - iii->GetGeometry()[1].Y();
618 v2[2] = iii->GetGeometry()[2].Z() - iii->GetGeometry()[1].Z();
623 double c0 = abs(area_normal[0]);
624 double c1 = abs(area_normal[1]);
625 double c2 = abs(area_normal[2]);
631 double norm_u = msAuxVec[0]*msAuxVec[0] + msAuxVec[1]*msAuxVec[1] + msAuxVec[2]*msAuxVec[2];
632 double norm_c =sqrt(norm_u);
634 iii->GetGeometry()[0].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
635 iii->GetGeometry()[2].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
636 iii->GetGeometry()[1].FastGetSolutionStepValue(NORMAL) += area_normal/ norm_c;
640 for(ModelPart::NodesContainerType::iterator iii = full_model_part.
NodesBegin(); iii != full_model_part.
NodesEnd(); iii++)
643 if(iii->FastGetSolutionStepValue(IS_BOUNDARY)==1.0){
645 double norm_y1 =
norm_2(value_y1);
646 value_y1 /=(norm_y1 + 1
e-9);
659 const int max_results = 1000;
661 const int nparticles = rLagrangianModelPart.
Nodes().size();
662 #pragma omp parallel for firstprivate(results,N)
663 for (
int i = 0;
i < nparticles;
i++)
665 ModelPart::NodesContainerType::iterator iparticle = rLagrangianModelPart.
NodesBegin() +
i;
666 Node ::Pointer pparticle = *(iparticle.base());
668 Element::Pointer pelement;
669 bool is_found = node_locator.FindPointOnMesh(pparticle->Coordinates(),
N, pelement, result_begin, max_results);
670 if (is_found ==
true)
679 for (
unsigned int jj = 0; jj < 3; jj++)
681 for (
unsigned int kk = 0; kk < 4; kk++)
683 temmp=geom[kk].FastGetSolutionStepValue(TEMPERATURE);
684 if(temmp<298.0) temmp=298.0;
685 qrad[jj] += msDN_DX(kk, jj) * temmp;
689 (iparticle)->FastGetSolutionStepValue(NORMAL) *=(-1.0);
690 (iparticle)->FastGetSolutionStepValue(FACE_HEAT_FLUX) += abs( (iparticle)->FastGetSolutionStepValue(NORMAL_X) * qrad[0] + (iparticle)->FastGetSolutionStepValue(NORMAL_Y) * qrad[1] + (iparticle)->FastGetSolutionStepValue(NORMAL_Z) * qrad[2]) *0.0131;
705 for (ModelPart::NodesContainerType::iterator node_it = rModelPart.
NodesBegin();node_it != rModelPart.
NodesEnd(); node_it++)
710 coords[0] = node_it->X0() + old_disp[0];
711 coords[1] = node_it->Y0() + old_disp[1];
712 coords[2] = node_it->Z0() + old_disp[2];
732 const int max_results = 10000;
735 const int nparticles = rModelPart.
Nodes().size();
737 #pragma omp parallel for firstprivate(results,N,veulerian,acc_particle)
738 for (
int i = 0;
i < nparticles;
i++)
741 int subdivisions = 5;
743 ModelPart::NodesContainerType::iterator iparticle = rModelPart.
NodesBegin() +
i;
744 Node ::Pointer pparticle = *(iparticle.base());
748 bool first_time=
false;
749 iparticle->FastGetSolutionStepValue(DISTANCE)=0.0;
751 iparticle->FastGetSolutionStepValue(EMBEDDED_VELOCITY) = iparticle->FastGetSolutionStepValue(VELOCITY,1);
753 if(iparticle->Is(SLIP)) do_move =
false;
756 if( do_move ==
true )
760 noalias(iparticle->GetInitialPosition()) = old_position;
761 iparticle->FastGetSolutionStepValue(DISPLACEMENT,1) =
ZeroVector(3);
764 const double small_dt =
dt / subdivisions;
766 for (
int substep = 0; substep < subdivisions; substep++)
769 Element::Pointer pelement;
770 bool is_found =
SearchStructure.FindPointOnMesh(current_position,
N, pelement, result_begin, max_results);
771 iparticle->
Set(TO_ERASE,
true);
774 if (is_found ==
true)
780 for (
unsigned int k = 0;
k < geom.
size();
k++)
782 noalias(veulerian) +=
N[
k] * geom[
k].FastGetSolutionStepValue(VELOCITY,1);
790 noalias(current_position) += small_dt*veulerian;
791 pparticle->Set(TO_ERASE,
false);
792 iparticle->FastGetSolutionStepValue(DISTANCE) += small_dt;
793 iparticle->FastGetSolutionStepValue(EMBEDDED_VELOCITY)=veulerian;
797 double time1=iparticle->FastGetSolutionStepValue(DISTANCE);
802 if( first_time ==
false )
804 noalias(current_position) += small_dt *iparticle->FastGetSolutionStepValue(EMBEDDED_VELOCITY);
806 pparticle->Set(TO_ERASE,
false);
812 noalias(current_position) += small_dt *iparticle->FastGetSolutionStepValue(EMBEDDED_VELOCITY);
814 pparticle->Set(TO_ERASE,
false);
821 iparticle->FastGetSolutionStepValue(DISPLACEMENT) = current_position - iparticle->GetInitialPosition();
826 for(ModelPart::NodesContainerType::iterator it = rModelPart.
NodesBegin(); it!=rModelPart.
NodesEnd(); it++)
830 noalias(it->Coordinates()) = it->GetInitialPosition();
831 noalias(it->Coordinates()) += dn1;
845 (
i)->Is(SLIP) ==
false &&
846 (
i)->
GetValue(NEIGHBOUR_ELEMENTS).size() == 0 &&
847 ((
i)->GetDof(VELOCITY_X).IsFixed() ==
false || (
i)->GetDof(VELOCITY_Y).IsFixed() ==
false || (
i)->GetDof(VELOCITY_Z).IsFixed() ==
false)
852 (
i)->FastGetSolutionStepValue(PRESSURE) = 0;
856 noalias(acc) = (
i)->FastGetSolutionStepValue(BODY_FORCE);
885 for(ModelPart::NodesContainerType::iterator in = rNodes.begin(); in!=rNodes.end(); in++)
887 if(in->FastGetSolutionStepValue(IS_LAGRANGIAN_INLET) ==1)
896 if(
i->FastGetSolutionStepValue(IS_FREE_SURFACE) ==1)
902 if(nf>=2) {in->FastGetSolutionStepValue(IS_WATER)= 1;
923 const int max_results = 1000;
925 const int nparticles = rLagrangianModelPart.
Nodes().size();
927 #pragma omp parallel for firstprivate(results,N)
928 for (
int i = 0;
i < nparticles;
i++)
930 ModelPart::NodesContainerType::iterator iparticle = rLagrangianModelPart.
NodesBegin() +
i;
932 Node ::Pointer pparticle = *(iparticle.base());
935 Element::Pointer pelement;
937 bool is_found = node_locator.FindPointOnMesh(pparticle->Coordinates(),
N, pelement, result_begin, max_results);
939 if (is_found ==
true)
954 for (
unsigned int jj = 0; jj < 3; jj++)
956 temmp=geom[jj].FastGetSolutionStepValue(VELOCITY);
961 (iparticle)->FastGetSolutionStepValue(ANGULAR_VELOCITY) =
velocity;
976 for (ModelPart::NodesContainerType::iterator node_it = rLagrangianModelPart.
NodesBegin(); node_it != rLagrangianModelPart.
NodesEnd(); node_it++)
978 if( node_it->GetValue(NEIGHBOUR_ELEMENTS).size() != 0) (node_it)->FastGetSolutionStepValue(K0) = 0.0;
982 for (ModelPart::ElementsContainerType::iterator el_it = rLagrangianModelPart.
ElementsBegin();el_it != rLagrangianModelPart.
ElementsEnd(); el_it++)
986 double x0 = geom[0].X();
987 double y0 = geom[0].Y();
988 double z0 = geom[0].Z();
989 double x1 = geom[1].X();
990 double y1 = geom[1].Y();
991 double z1 = geom[1].Z();
992 double x2 = geom[2].X();
993 double y2 = geom[2].Y();
994 double z2 = geom[2].Z();
995 double x3 = geom[3].X();
996 double y3 = geom[3].Y();
997 double z3 = geom[3].Z();
1000 area=CalculateVol(x0, y0, z0,
x1, y1, z1,
x2, y2, z2, x3, y3, z3);
1002 geom[0].FastGetSolutionStepValue(K0) += area * 0.25;
1003 geom[1].FastGetSolutionStepValue(K0) += area * 0.25;
1004 geom[2].FastGetSolutionStepValue(K0) += area * 0.25;
1005 geom[3].FastGetSolutionStepValue(K0) += area * 0.25;
1011 for (ModelPart::NodesContainerType::iterator node_it = rLagrangianModelPart.
NodesBegin(); node_it != rLagrangianModelPart.
NodesEnd(); node_it++)
1014 sum +=(node_it)->FastGetSolutionStepValue(K0) ;
1024 int mnumber_of_oil_clusters=0;
1025 for (ModelPart::NodesContainerType::iterator inode = mp_local_model_part.
NodesBegin(); inode != mp_local_model_part.
NodesEnd(); inode++)
1027 inode->FastGetSolutionStepValue(DIAMETER) = -1;
1030 for (ModelPart::ElementsContainerType::iterator ielem = mp_local_model_part.
ElementsBegin();ielem != mp_local_model_part.
ElementsEnd(); ielem++)
1042 for (ModelPart::NodesContainerType::iterator inode = mp_local_model_part.
NodesBegin(); inode != mp_local_model_part.
NodesEnd(); inode++)
1044 if(inode->IsFixed(POROSITY) && inode->FastGetSolutionStepValue(DIAMETER)!=0)
1051 for (ModelPart::NodesContainerType::iterator inode = mp_local_model_part.
NodesBegin(); inode != mp_local_model_part.
NodesEnd(); inode++)
1053 if(inode->FastGetSolutionStepValue(DIAMETER) < 0 )
1060 for (ModelPart::ElementsContainerType::iterator ielem = mp_local_model_part.
ElementsBegin(); ielem != mp_local_model_part.
ElementsEnd(); ielem++)
1063 if(geom.
size()>1 && ielem->GetValue(DIAMETER) < 0 )
1066 ielem->GetValue(DIAMETER) =
color;
1071 for (ModelPart::NodesContainerType::iterator inode = mp_local_model_part.
NodesBegin(); inode != mp_local_model_part.
NodesEnd(); inode++)
1073 if(inode->FastGetSolutionStepValue(DIAMETER) == 0)
1074 inode->FastGetSolutionStepValue(POROSITY)=1.0;
1077 mnumber_of_oil_clusters =
color;
1086 int zz= mnumber_of_oil_clusters + 1;
1087 for(
int jj=0; jj< zz; jj++ )
1098 for (ModelPart::NodesContainerType::iterator inode = mp_local_model_part.
NodesBegin(); inode != mp_local_model_part.
NodesEnd(); inode++)
1100 int colour_p = (inode)->FastGetSolutionStepValue(DIAMETER);
1103 area += (inode)->FastGetSolutionStepValue(K0);
1104 velocity_a += (inode)->FastGetSolutionStepValue(ANGULAR_VELOCITY);
1105 velocity_p += (inode)->FastGetSolutionStepValue(VELOCITY);
1109 velocity_a *=(1.0/nn);
1110 velocity_p *=(1.0/nn);
1115 for (ModelPart::NodesContainerType::iterator inode = mp_local_model_part.
NodesBegin(); inode != mp_local_model_part.
NodesEnd(); inode++)
1117 int colour_p = (inode)->FastGetSolutionStepValue(DIAMETER);
1120 inode->FastGetSolutionStepValue(DRAG_FORCE_X)=drag_coefficient(0);
1121 inode->FastGetSolutionStepValue(DRAG_FORCE_Y)=drag_coefficient(1);
1122 inode->FastGetSolutionStepValue(DRAG_FORCE_Z)=drag_coefficient(2);
1136 double drag_coeff=0.0;
1142 double aux=nodal_mass * 3.0/(3.0*3.1416);
1143 double Radius= pow(aux, 0.3333333);
1144 double area=4.0 * 3.1416 * Radius * Radius;
1145 noalias(vrelative)=velocity_air-velocity_polymer;
1146 double norm_u =
norm_2(vrelative);
1147 double reynolds = 2 * Radius * norm_u / 0.00001;
1148 if (reynolds < 0.01)
1153 noalias(drag_coefficient) = 0.5 * 1.0 * area * drag_coeff * norm_u* vrelative * (1.0 / nodal_mass);
1167 if (reynolds > 1000){
1171 drag_coeff = 24.0 / reynolds * (1.0 + 0.15 * pow(reynolds, 0.687));
1181 if(iNode->GetSolutionStepValue(DIAMETER) < 0 )
1182 iNode->GetSolutionStepValue(DIAMETER)=
color;
1188 if(i_neighbour_element->GetValue(DIAMETER) < 0 )
1190 i_neighbour_element->SetValue(DIAMETER,
color);
1194 for(
unsigned int i = 0;
i < p_geometry.
size();
i++)
1198 p_geometry[
i].GetSolutionStepValue(DIAMETER) =
color;
1199 front_nodes.push_back(p_geometry(
i));
1204 while(!front_nodes.empty())
1207 for(ModelPart::NodesContainerType::iterator i_node = front_nodes.begin() ; i_node != front_nodes.end() ; i_node++)
1212 if(i_neighbour_element->GetValue(DIAMETER) < 0 )
1214 i_neighbour_element->SetValue(DIAMETER,
color);
1218 for(
unsigned int i = 0;
i < p_geometry.
size();
i++)
1222 p_geometry[
i].GetSolutionStepValue(DIAMETER) =
color;
1223 new_front_nodes.push_back(p_geometry(
i));
1229 front_nodes.clear();
1230 for( ModelPart::NodesContainerType::iterator i_node = new_front_nodes.begin() ; i_node != new_front_nodes.end() ; i_node++)
1231 front_nodes.push_back(*(i_node.base()));
1244 const int max_results = 1000;
1247 const int nparticles = rLagrangianModelPart.
Nodes().size();
1249 #pragma omp parallel for firstprivate(results,N,veulerian,temperature)
1250 for (
int i = 0;
i < nparticles;
i++)
1252 ModelPart::NodesContainerType::iterator iparticle = rLagrangianModelPart.
NodesBegin() +
i;
1254 int subdivisions=5.0;
1255 const double small_dt =
dt / subdivisions;
1256 for (
unsigned int substep = 0; substep < subdivisions; substep++)
1258 Node ::Pointer pparticle = *(iparticle.base());
1260 Element::Pointer pelement;
1261 bool is_found = node_locator.FindPointOnMesh(pparticle->Coordinates(),
N, pelement, result_begin, max_results);
1262 if (is_found ==
true)
1267 noalias(veulerian) =
N[0] * geom[0].FastGetSolutionStepValue(VELOCITY, 1);
1268 temperature =
N[0] * geom[0].FastGetSolutionStepValue(YCH4);
1269 for (
unsigned int k = 1;
k < geom.
size();
k++)
1271 noalias(veulerian) +=
N[
k] * geom[
k].FastGetSolutionStepValue(VELOCITY, 1);
1275 double &
temp = (iparticle)->FastGetSolutionStepValue(YCH4);
1280 noalias(disp) += small_dt*veulerian;
1281 noalias(iparticle->Coordinates()) = iparticle->GetInitialPosition();
1282 noalias(iparticle->Coordinates()) += iparticle->FastGetSolutionStepValue(DISPLACEMENT);
1297 typedef std::vector<PointType::Pointer>
PointVector;
1298 typedef std::vector<PointType::Pointer>::iterator
PointIterator;
1313 boost::timer kdtree_construction;
1315 for (ModelPart::NodesContainerType::iterator node_it = rLagrangianModelPart.
NodesBegin();
1316 node_it != rLagrangianModelPart.
NodesEnd(); ++node_it)
1321 list_of_nodes.push_back(pnode);
1324 std::cout <<
"kdt constructin time " << kdtree_construction.elapsed() << std::endl;
1327 unsigned int bucket_size = 20;
1328 tree nodes_tree(list_of_nodes.begin(), list_of_nodes.end(), bucket_size);
1331 Node work_point(0, 0.0, 0.0, 0.0);
1332 unsigned int MaximumNumberOfResults = 10000;
1337 if (rEulerianModelPart.
NodesBegin()->SolutionStepsDataHas(NODAL_H) ==
false)
1338 KRATOS_ERROR<<
"Add ----NODAL_H---- variable!!!!!! ERROR";
1342 if constexpr (TDim == 2)
1343 sigma = 10.0 / (7.0 * 3.1415926);
1345 sigma = 1.0 / 3.1415926;
1347 for (ModelPart::NodesContainerType::iterator node_it = rEulerianModelPart.
NodesBegin(); node_it != rEulerianModelPart.
NodesEnd(); node_it++)
1349 if((node_it)->Y()< -0.15102 )
1351 work_point.
X() = node_it->X();
1352 work_point.
Y() = node_it->Y();
1353 work_point.
Z() = node_it->Z();
1355 double radius = 2.0 * node_it->FastGetSolutionStepValue(NODAL_H);
1358 int number_of_points_in_radius;
1361 number_of_points_in_radius = nodes_tree.SearchInRadius(work_point,
radius, Results.begin(), SquaredResultsDistances.begin(), MaximumNumberOfResults);
1363 if (number_of_points_in_radius > 0)
1366 double temperature_aux = 0.0;
1367 double tot_weight = 0.0;
1369 double E_over_R = 24067.0;
1371 for (
int k = 0;
k < number_of_points_in_radius;
k++)
1373 double distance = sqrt(*(SquaredResultsDistances.begin() +
k));
1374 double weight = SPHCubicKernel(
sigma, distance,
radius);
1377 if( (*it_found)->FastGetSolutionStepValue(DIAMETER) >0 && (*it_found)->FastGetSolutionStepValue(YN2) ==0.0)
1380 tempp=(*it_found)->FastGetSolutionStepValue(YCH4);
1384 temperature_aux += weight * 27400.0 * 1.0 *
C * exp(-E_over_R / tempp ) * 905.0 ;
1385 tot_weight += weight;
1396 temperature_aux /= (tot_weight );
1398 if(temperature_aux>1e9) (node_it)->FastGetSolutionStepValue(HEAT_FLUX) += 1e9;
1399 else (node_it)->FastGetSolutionStepValue(HEAT_FLUX) += temperature_aux;
1411 for (ModelPart::NodesContainerType::iterator node_it = rEulerianModelPart.
NodesBegin(); node_it != rEulerianModelPart.
NodesEnd(); node_it++)
1413 (node_it)->
GetValue(POISSON_RATIO) = 0.0;
1414 (node_it)->
GetValue(YOUNG_MODULUS) = 0.0;
1415 (node_it)->
GetValue(NODAL_MASS) = 0.0;
1416 (node_it)->
GetValue(HEAT_FLUX) = 0.0;
1419 for (ModelPart::ElementsContainerType::iterator el_it = rEulerianModelPart.
ElementsBegin();el_it != rEulerianModelPart.
ElementsEnd(); el_it++)
1421 el_it->
SetValue(YOUNG_MODULUS,0.0);
1424 const int max_results = 1000;
1426 const int nparticles = rLagrangianModelPart.
Nodes().size();
1429 double E_over_R = 24067.0;
1432 #pragma omp parallel for firstprivate(results,N)
1433 for (
int i = 0;
i < nparticles;
i++)
1435 ModelPart::NodesContainerType::iterator iparticle = rLagrangianModelPart.
NodesBegin() +
i;
1437 Node ::Pointer pparticle = *(iparticle.base());
1440 Element::Pointer pelement;
1442 bool is_found = node_locator.FindPointOnMesh(pparticle->Coordinates(),
N, pelement, result_begin, max_results);
1444 if (is_found ==
true)
1448 double density_particle = (iparticle)->FastGetSolutionStepValue(DENSITY);
1449 double Tp=(iparticle)->FastGetSolutionStepValue(YCH4);
1450 if(Tp>1000.0) Tp=1000.0;
1455 if( (iparticle)->FastGetSolutionStepValue(DIAMETER)>0)
1457 (iparticle)->FastGetSolutionStepValue(YN2)=1.0;
1460 KRATOS_WATCH((iparticle)->FastGetSolutionStepValue(DIAMETER));
1461 for (
unsigned int k = 0;
k < geom.
size();
k++)
1466 geom[
k].
GetValue(YOUNG_MODULUS) +=
N[
k] * 27400.0 * 1.0 *
C * exp(-E_over_R/(Tp)) *905.0 * (iparticle)->FastGetSolutionStepValue(K0);
1469 KRATOS_WATCH((iparticle)->FastGetSolutionStepValue(K0));
1473 geom[
k].UnSetLock();
1479 for (ModelPart::ElementsContainerType::iterator el_it = rEulerianModelPart.
ElementsBegin();el_it != rEulerianModelPart.
ElementsEnd(); el_it++)
1483 double x0 = geom[0].X();
1484 double y0 = geom[0].Y();
1485 double z0 = geom[0].Z();
1486 double x1 = geom[1].X();
1487 double y1 = geom[1].Y();
1488 double z1 = geom[1].Z();
1489 double x2 = geom[2].X();
1490 double y2 = geom[2].Y();
1491 double z2 = geom[2].Z();
1492 double x3 = geom[3].X();
1493 double y3 = geom[3].Y();
1494 double z3 = geom[3].Z();
1498 area=CalculateVol(x0, y0, z0,
x1, y1, z1,
x2, y2, z2, x3, y3, z3);
1500 geom[0].FastGetSolutionStepValue(NODAL_MASS) += area * 0.25;
1501 geom[1].FastGetSolutionStepValue(NODAL_MASS) += area * 0.25;
1502 geom[2].FastGetSolutionStepValue(NODAL_MASS) += area * 0.25;
1503 geom[3].FastGetSolutionStepValue(NODAL_MASS) += area * 0.25;
1508 for (ModelPart::NodesContainerType::iterator node_it = rEulerianModelPart.
NodesBegin(); node_it != rEulerianModelPart.
NodesEnd(); node_it++)
1510 const double NN = (node_it)->
GetValue(POISSON_RATIO);
1511 const double tt = (node_it)->
GetValue(YOUNG_MODULUS);
1517 double nodal_mass = node_it->FastGetSolutionStepValue(NODAL_MASS);
1518 double& heat = node_it->FastGetSolutionStepValue(HEAT_FLUX);
1519 double heat_value=tt/NN * (1.0/nodal_mass);
1520 if (heat_value>1e9 ) heat_value = 1e9 ;
1536 inline double SPHCubicKernel(
const double sigma,
const double r,
const double hmax)
1538 double h_half = 0.5 * hmax;
1539 const double s = r / h_half;
1540 const double coeff =
sigma / pow(h_half,
static_cast<int>(TDim));
1543 return coeff * (1.0 - 1.5 * s * s + 0.75 * s * s * s);
1545 return 0.25 *
coeff * pow(2.0 - s, 3);
1550 inline void CalculateCenterAndSearchRadius(Geometry<Node >&geom,
double&
xc,
double&
yc,
double& zc,
double&
R, array_1d<double, 3 > &
N )
1552 double x0 = geom[0].X();
1553 double y0 = geom[0].Y();
1554 double x1 = geom[1].X();
1555 double y1 = geom[1].Y();
1556 double x2 = geom[2].X();
1557 double y2 = geom[2].Y();
1559 xc = 0.3333333333333333333 * (x0 +
x1 +
x2);
1560 yc = 0.3333333333333333333 * (y0 + y1 + y2);
1563 double R1 = (
xc - x0)*(
xc - x0) + (
yc - y0)*(
yc - y0);
1574 inline void CalculateCenterAndSearchRadius(Geometry<Node >&geom,
double&
xc,
double&
yc,
double& zc,
double&
R, array_1d<double, 4 > &
N )
1576 double x0 = geom[0].X();
1577 double y0 = geom[0].Y();
1578 double z0 = geom[0].Z();
1579 double x1 = geom[1].X();
1580 double y1 = geom[1].Y();
1581 double z1 = geom[1].Z();
1582 double x2 = geom[2].X();
1583 double y2 = geom[2].Y();
1584 double z2 = geom[2].Z();
1585 double x3 = geom[3].X();
1586 double y3 = geom[3].Y();
1587 double z3 = geom[3].Z();
1590 xc = 0.25 * (x0 +
x1 +
x2 + x3);
1591 yc = 0.25 * (y0 + y1 + y2 + y3);
1592 zc = 0.25 * (z0 + z1 + z2 + z3);
1594 double R1 = (
xc - x0)*(
xc - x0) + (
yc - y0)*(
yc - y0) + (zc - z0)*(zc - z0);
1595 double R2 = (
xc -
x1)*(
xc -
x1) + (
yc - y1)*(
yc - y1) + (zc - z1)*(zc - z1);
1596 double R3 = (
xc -
x2)*(
xc -
x2) + (
yc - y2)*(
yc - y2) + (zc - z2)*(zc - z2);
1597 double R4 = (
xc - x3)*(
xc - x3) + (
yc - y3)*(
yc - y3) + (zc - z3)*(zc - z3);
1608 inline bool CalculatePosition(Geometry<Node >&geom,
const double xc,
const double yc,
const double zc, array_1d<double, 4 > &
N )
1611 double x0 = geom[0].X();
1612 double y0 = geom[0].Y();
1613 double z0 = geom[0].Z();
1614 double x1 = geom[1].X();
1615 double y1 = geom[1].Y();
1616 double z1 = geom[1].Z();
1617 double x2 = geom[2].X();
1618 double y2 = geom[2].Y();
1619 double z2 = geom[2].Z();
1620 double x3 = geom[3].X();
1621 double y3 = geom[3].Y();
1622 double z3 = geom[3].Z();
1624 double vol = CalculateVol(x0, y0, z0,
x1, y1, z1,
x2, y2, z2, x3, y3, z3);
1626 double inv_vol = 0.0;
1627 if (vol < 0.0000000000001)
1633 inv_vol = 1.0 / vol;
1636 N[0] = CalculateVol(
x1, y1, z1, x3, y3, z3,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
1637 N[1] = CalculateVol(x0, y0, z0,
x1, y1, z1,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
1638 N[2] = CalculateVol(x3, y3, z3,
x1, y1, z1, x0, y0, z0,
xc,
yc, zc) * inv_vol;
1639 N[3] = CalculateVol(x3, y3, z3, x0, y0, z0,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
1642 if (
N[0] >= 0.0 &&
N[1] >= 0.0 &&
N[2] >= 0.0 &&
N[3] >= 0.0 &&
1643 N[0] <= 1.0 &&
N[1] <= 1.0 &&
N[2] <= 1.0 &&
N[3] <= 1.0)
1650 inline double CalculateVol(
const double x0,
const double y0,
1651 const double x1,
const double y1,
1652 const double x2,
const double y2
1655 return 0.5 * ((
x1 - x0)*(y2 - y0)- (y1 - y0)*(
x2 - x0));
1659 inline double CalculateVol(
const double x0,
const double y0,
const double z0,
const double x1,
const double y1,
const double z1,
const double x2,
const double y2,
const double z2,
const double x3,
const double y3,
const double z3 )
1661 double x10 =
x1 - x0;
1662 double y10 = y1 - y0;
1663 double z10 = z1 - z0;
1665 double x20 =
x2 - x0;
1666 double y20 = y2 - y0;
1667 double z20 = z2 - z0;
1669 double x30 = x3 - x0;
1670 double y30 = y3 - y0;
1671 double z30 = z3 - z0;
1673 double detJ = x10 * y20 * z30 - x10 * y30 * z20 + y10 * z20 * x30 - y10 * x20 * z30 + z10 * x20 * y30 - z10 * y20 * x30;
1674 return detJ * 0.1666666666666666666667;
1677 void ComputeGaussPointPositions(Geometry< Node >& geom, BoundedMatrix<double, 4, 3 > & pos, BoundedMatrix<double, 4, 3 > &
N)
1679 double one_third = 1.0 / 3.0;
1680 double one_sixt = 1.0 / 6.0;
1681 double two_third = 2.0 * one_third;
1685 N(0, 2) = two_third;
1686 N(1, 0) = two_third;
1690 N(2, 1) = two_third;
1692 N(3, 0) = one_third;
1693 N(3, 1) = one_third;
1694 N(3, 2) = one_third;
1698 pos(0, 0) = one_sixt * geom[0].X() + one_sixt * geom[1].X() + two_third * geom[2].X();
1699 pos(0, 1) = one_sixt * geom[0].Y() + one_sixt * geom[1].Y() + two_third * geom[2].Y();
1700 pos(0, 2) = one_sixt * geom[0].Z() + one_sixt * geom[1].Z() + two_third * geom[2].Z();
1703 pos(1, 0) = two_third * geom[0].X() + one_sixt * geom[1].X() + one_sixt * geom[2].X();
1704 pos(1, 1) = two_third * geom[0].Y() + one_sixt * geom[1].Y() + one_sixt * geom[2].Y();
1705 pos(1, 2) = two_third * geom[0].Z() + one_sixt * geom[1].Z() + one_sixt * geom[2].Z();
1708 pos(2, 0) = one_sixt * geom[0].X() + two_third * geom[1].X() + one_sixt * geom[2].X();
1709 pos(2, 1) = one_sixt * geom[0].Y() + two_third * geom[1].Y() + one_sixt * geom[2].Y();
1710 pos(2, 2) = one_sixt * geom[0].Z() + two_third * geom[1].Z() + one_sixt * geom[2].Z();
1713 pos(3, 0) = one_third * geom[0].X() + one_third * geom[1].X() + one_third * geom[2].X();
1714 pos(3, 1) = one_third * geom[0].Y() + one_third * geom[1].Y() + one_third * geom[2].Y();
1715 pos(3, 2) = one_third * geom[0].Z() + one_third * geom[1].Z() + one_third * geom[2].Z();
1719 void ComputeGaussPointPositions(Geometry< Node >& geom, BoundedMatrix<double, 16, 3 > & pos, BoundedMatrix<double, 16, 3 > &
N)
1722 double ypos = 1.0 / 12.0;
1723 int pos_counter = 0;
1724 for (
unsigned int i = 0;
i < 4;
i++)
1726 double xpos = 1.0 / 12.0;
1727 for (
unsigned int j = 0;
j < 4 -
i;
j++)
1731 double N3 = 1.0 - xpos - ypos;
1733 pos(pos_counter, 0) = N1 * geom[0].X() + N2 * geom[1].X() + N3 * geom[2].X();
1734 pos(pos_counter, 1) = N1 * geom[0].Y() + N2 * geom[1].Y() + N3 * geom[2].Y();
1735 pos(pos_counter, 2) = N1 * geom[0].Z() + N2 * geom[1].Z() + N3 * geom[2].Z();
1737 N(pos_counter, 0) = N1;
1738 N(pos_counter, 1) = N2;
1739 N(pos_counter, 2) = N3;
1751 for (
unsigned int i = 0;
i < 3;
i++)
1753 double xpos = 2.0 / 12.0;
1754 for (
unsigned int j = 0;
j < 4 -
i;
j++)
1758 double N3 = 1.0 - xpos - ypos;
1760 pos(pos_counter, 0) = N1 * geom[0].X() + N2 * geom[1].X() + N3 * geom[2].X();
1761 pos(pos_counter, 1) = N1 * geom[0].Y() + N2 * geom[1].Y() + N3 * geom[2].Y();
1762 pos(pos_counter, 2) = N1 * geom[0].Z() + N2 * geom[1].Z() + N3 * geom[2].Z();
1764 N(pos_counter, 0) = N1;
1765 N(pos_counter, 1) = N2;
1766 N(pos_counter, 2) = N3;
1776 void ConsistentMassMatrix(
const double A, BoundedMatrix<double, 3, 3 > & M)
1778 double c1 =
A / 12.0;
1779 double c2 = 2.0 * c1;
1791 void CalculateInterfaceNormal(BoundedMatrix<double, 3, 2 >& rPoints, array_1d<double,3>& rDistances, array_1d<double,2>& normal,
double & interface_area, array_1d<double,3>& Ninterface, BoundedMatrix<double, 2, 2 >& rInterfacePoints)
1793 double sign_correction=1.0;
1797 BoundedMatrix<double, 2, 2 > InterfacePoints;
1799 array_1d<bool,3> cut_edges;
1801 array_1d<double,2> interface_segment=
ZeroVector(2);
1803 if ((rDistances(0)*rDistances(1))<0.0) cut_edges[0]=
true;
1805 else cut_edges[0]=
false;
1809 if ((rDistances(1)*rDistances(2))<0.0) cut_edges[1]=
true;
1811 else cut_edges[1]=
false;
1815 if ((rDistances(2)*rDistances(0))<0.0) cut_edges[2]=
true;
1817 else cut_edges[2]=
false;
1827 if (rDistances(0)>0.0) sign_correction=1.0;
1829 else sign_correction=-1.0;
1833 const double relative_position = abs(rDistances(1)/(rDistances(1)-rDistances(0) ) );
1835 InterfacePoints(0,0) = relative_position*rPoints(0,0) + (1.0-relative_position)*rPoints(1,0);
1837 InterfacePoints(0,1) = relative_position*rPoints(0,1) + (1.0-relative_position)*rPoints(1,1);
1845 const double relative_position2 = abs(rDistances(2)/(rDistances(1)-rDistances(2) ) );
1847 InterfacePoints(1,0) = relative_position2*rPoints(1,0) + (1.0-relative_position2)*rPoints(2,0);
1849 InterfacePoints(1,1) = relative_position2*rPoints(1,1) + (1.0-relative_position2)*rPoints(2,1);
1857 const double relative_position2 = abs(rDistances(0)/(rDistances(2)-rDistances(0) ) );
1859 InterfacePoints(1,0) = relative_position2*rPoints(2,0) + (1.0-relative_position2)*rPoints(0,0);
1861 InterfacePoints(1,1) = relative_position2*rPoints(2,1) + (1.0-relative_position2)*rPoints(0,1);
1871 if (rDistances(1)>0.0) sign_correction=1.0;
1873 else sign_correction=-1.0;
1877 const double relative_position = abs(rDistances(2)/(rDistances(2)-rDistances(1) ) );
1879 InterfacePoints(0,0) = relative_position*rPoints(1,0) + (1.0-relative_position)*rPoints(2,0);
1881 InterfacePoints(0,1) = relative_position*rPoints(1,1) + (1.0-relative_position)*rPoints(2,1);
1885 const double relative_position2 = abs(rDistances(0)/(rDistances(2)-rDistances(0) ) );
1887 InterfacePoints(1,0) = relative_position2*rPoints(2,0) + (1.0-relative_position2)*rPoints(0,0);
1889 InterfacePoints(1,1) = relative_position2*rPoints(2,1) + (1.0-relative_position2)*rPoints(0,1);
1893 interface_segment[0] = (InterfacePoints(1,0)-InterfacePoints(0,0));
1895 interface_segment[1] = (InterfacePoints(1,1)-InterfacePoints(0,1));
1898 const double norm = sqrt( pow((interface_segment[0]),2) + pow((interface_segment[1]),2));
1902 normal(0)= -interface_segment[1]*sign_correction/norm;
1904 normal(1)= interface_segment[0]*sign_correction/norm;
1910 interface_area=norm;
1912 rInterfacePoints(0,0)=InterfacePoints(0,0);
1913 rInterfacePoints(0,1)=InterfacePoints(0,1);
1914 rInterfacePoints(1,0)=InterfacePoints(1,0);
1915 rInterfacePoints(1,1)=InterfacePoints(1,1);
1917 const double x_interface = 0.5*(InterfacePoints(0,0)+InterfacePoints(1,0));
1919 const double y_interface = 0.5*(InterfacePoints(0,1)+InterfacePoints(1,1));
1924 double x0 = rPoints(0,0);
1925 double y0 = rPoints(0,1);
1926 double x1 = rPoints(1,0);
1927 double y1 = rPoints(1,1);
1928 double x2 = rPoints(2,0);
1929 double y2 = rPoints(2,1);
1930 double area = CalculateVol(x0, y0,
x1, y1,
x2, y2);
1931 double inv_area = 0.0;
1938 inv_area = 1.0 / area;
1941 Ninterface[0]= CalculateVol(
x1, y1,
x2, y2, x_interface, y_interface) * inv_area;
1942 Ninterface[1] = CalculateVol(
x2, y2, x0, y0, x_interface, y_interface) * inv_area;
1943 Ninterface[2] = CalculateVol(x0, y0,
x1, y1, x_interface, y_interface) * inv_area;
1947 bool CalculatePosition(Geometry<Node >&geom,
const double xc,
const double yc,
const double zc,array_1d<double, 3 > &
N )
1949 double x0 = geom[0].X();
1950 double y0 = geom[0].Y();
1951 double x1 = geom[1].X();
1952 double y1 = geom[1].Y();
1953 double x2 = geom[2].X();
1954 double y2 = geom[2].Y();
1956 double area = CalculateVol(x0, y0,
x1, y1,
x2, y2);
1957 double inv_area = 0.0;
1964 inv_area = 1.0 / area;
1968 N[0] = CalculateVol(
x1, y1,
x2, y2,
xc,
yc) * inv_area;
1969 N[1] = CalculateVol(
x2, y2, x0, y0,
xc,
yc) * inv_area;
1970 N[2] = CalculateVol(x0, y0,
x1, y1,
xc,
yc) * inv_area;
1973 if (
N[0] >= 0.0 &&
N[1] >= 0.0 &&
N[2] >= 0.0 &&
N[0] <= 1.0 &&
N[1] <= 1.0 &&
N[2] <= 1.0)
1980 bool InvertMatrix(
const T&
input, T& inverse)
1983 typedef permutation_matrix<std::size_t> pmatrix;
1991 pmatrix pm(
A.size1());
1995 int res = lu_factorize(
A, pm);
2003 inverse.assign(identity_matrix<double> (
A.size1()));
2007 lu_substitute(
A, pm, inverse);
This class is designed to allow the fast location of MANY points on the top of a 3D mesh.
Definition: binbased_fast_point_locator.h:68
ConfigureType::ResultIteratorType ResultIteratorType
Definition: binbased_fast_point_locator.h:82
ConfigureType::ResultContainerType ResultContainerType
Definition: binbased_fast_point_locator.h:81
Short class definition.
Definition: bucket.h:57
Definition: particle_utilities.h:52
double operator()(T const &p1, T const &p2)
Definition: particle_utilities.h:55
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
TVariableType::Type & GetValue(const TVariableType &rThisVariable)
Definition: geometry.h:627
static void CalculateGeometryData(const GeometryType &rGeometry, BoundedMatrix< double, 4, 3 > &rDN_DX, array_1d< double, 4 > &rN, double &rVolume)
This function is designed to compute the shape function derivatives, shape functions and volume in 3D...
Definition: geometry_utilities.h:176
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: global_pointers_vector.h:79
iterator begin()
Definition: global_pointers_vector.h:221
iterator end()
Definition: global_pointers_vector.h:229
Definition: amatrix_interface.h:41
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
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
void AddNode(NodeType::Pointer pNewNode, IndexType ThisIndex=0)
Definition: model_part.cpp:211
void OverwriteSolutionStepData(IndexType SourceSolutionStepIndex, IndexType DestinationSourceSolutionStepIndex)
Definition: model_part.cpp:180
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodeIterator NodeIterator
Definition: model_part.h:134
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
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
This class defines the node.
Definition: node.h:65
void SetValue(const std::string &rEntry, const Parameters &rOtherValue)
This method sets an existing parameter with a given parameter.
Definition: kratos_parameters.cpp:443
Definition: particle_utilities.h:69
void DetectAllOilClusters(ModelPart &mp_local_model_part)
Definition: particle_utilities.h:1022
void TransferToEulerianMesh(ModelPart &rEulerianModelPart, ModelPart &rLagrangianModelPart)
Definition: particle_utilities.h:260
void EstimateTime(ModelPart &rEulerianModelPart, const double max_dt)
Definition: particle_utilities.h:74
void TransferToEulerianMeshShapeBased_aux(ModelPart &rEulerianModelPart, ModelPart &rLagrangianModelPart, BinBasedFastPointLocator< TDim > &node_locator)
Definition: particle_utilities.h:375
void TransferToEulerianMeshShapeBased(ModelPart &rEulerianModelPart, ModelPart &rLagrangianModelPart, BinBasedFastPointLocator< TDim > &node_locator)
Definition: particle_utilities.h:1407
void TransferToParticlesAirVelocity(ModelPart &rEulerianModelPart, ModelPart &rLagrangianModelPart, BinBasedFastPointLocator< TDim > &node_locator)
Definition: particle_utilities.h:913
void MarkExcessivelyCloseNodes(ModelPart::NodesContainerType &rNodes)
Definition: particle_utilities.h:879
void ColorOilClusters(ModelPart::NodesContainerType::iterator iNode, const int color)
Definition: particle_utilities.h:1179
void VisualizationModelPart(ModelPart &rCompleteModelPart, ModelPart &rEulerianModelPart, ModelPart &rLagrangianModelPart)
Definition: particle_utilities.h:125
void movethermocouples(ModelPart &rEulerianModelPart, ModelPart &rLagrangianModelPart, BinBasedFastPointLocator< TDim > &node_locator)
Definition: particle_utilities.h:1237
void MoveLonelyNodes(ModelPart &ThisModelPart)
Definition: particle_utilities.h:835
void MoveMesh_Streamlines_freesurfaceflows(ModelPart &rModelPart, unsigned int substeps)
Definition: particle_utilities.h:720
void TransferToEulerianMesh_Face_Heat_Flux(ModelPart &rEulerianModelPart, ModelPart &rLagrangianModelPart)
Definition: particle_utilities.h:154
void TransferToEulerianMesh_2(ModelPart &rEulerianModelPart, ModelPart &rLagrangianModelPart)
Definition: particle_utilities.h:1290
void TransferToEulerianMeshShapeBased_aux_3D(ModelPart &rEulerianModelPart, ModelPart &rLagrangianModelPart, BinBasedFastPointLocator< TDim > &node_locator)
Definition: particle_utilities.h:653
KRATOS_CLASS_POINTER_DEFINITION(ParticleUtils< TDim >)
double Calculate_Vol(ModelPart &rLagrangianModelPart)
Definition: particle_utilities.h:967
void CalculateNewtonianDragCoefficient(const double reynolds, double &drag_coeff)
Definition: particle_utilities.h:1159
void CalculateNormal(ModelPart &full_model_part)
3D
Definition: particle_utilities.h:505
void ComputedDragCoefficient(double nodal_mass, array_1d< double, 3 > velocity_air, array_1d< double, 3 > velocity_polymer, array_1d< double, 3 > &drag_coefficient)
Definition: particle_utilities.h:1132
void RestartStep(ModelPart &rModelPart)
Definition: particle_utilities.h:697
double Y() const
Definition: point.h:187
double Z() const
Definition: point.h:193
double X() const
Definition: point.h:181
Definition: search_structure.h:309
void Set(IndexVector const &IndexCell, SizeVector const &_MaxSize, IteratorIteratorType const &IteratorBegin)
Definition: search_structure.h:363
A generic tree data structure for spatial partitioning.
Definition: tree.h:190
#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
dt
Definition: DEM_benchmarks.py:173
im
Definition: GenerateCN.py:100
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
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
TExpressionType::data_type norm_2(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:625
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
TExpressionType::data_type sum(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression)
Definition: amatrix_interface.h:675
DistanceVector::iterator DistanceIterator
Definition: internal_variables_interpolation_process.h:56
std::vector< PointTypePointer > PointVector
Definition: internal_variables_interpolation_process.h:53
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
PointType::Pointer PointTypePointer
Definition: internal_variables_interpolation_process.h:52
PointVector::iterator PointIterator
Definition: internal_variables_interpolation_process.h:54
std::vector< double > DistanceVector
Definition: internal_variables_interpolation_process.h:55
Point PointType
Geometric definitions.
Definition: mortar_classes.h:36
float velocity
Definition: PecletTest.py:54
color
Definition: all_t_win_vs_m_fixed_error.py:230
list coeff
Definition: bombardelli_test.py:41
def GetSolutionStepValue(entity, variable, solution_step_index)
Definition: coupling_interface_data.py:253
float dist
Definition: edgebased_PureConvection.py:89
float temperature
Definition: face_heat.py:58
Dt
Definition: face_heat.py:78
res
Definition: generate_convection_diffusion_explicit_element.py:211
v
Definition: generate_convection_diffusion_explicit_element.py:114
h
Definition: generate_droplet_dynamics.py:91
input
Definition: generate_frictional_mortar_condition.py:435
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
int C
Definition: generate_hyper_elastic_simo_taylor_neo_hookean.py:27
tuple tmp
Definition: generate_total_lagrangian_mixed_volumetric_strain_element.py:98
R
Definition: isotropic_damage_automatic_differentiation.py:172
float radius
Definition: mesh_to_mdpa_converter.py:18
vel
Definition: pure_conduction.py:76
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
float sigma
Definition: rotating_cone.py:79
float temp
Definition: rotating_cone.py:85
float xc
Definition: rotating_cone.py:77
float yc
Definition: rotating_cone.py:78
int counter
Definition: script_THERMAL_CORRECT.py:218
dummy
Definition: script.py:194
A
Definition: sensitivityMatrix.py:70
N
Definition: sensitivityMatrix.py:29
int dim
Definition: sensitivityMatrix.py:25
integer i
Definition: TensorModule.f:17
zero
Definition: test_pureconvectionsolver_benchmarking.py:94
e
Definition: run_cpp_mpi_tests.py:31