12 #if !defined(KRATOS_MOVE_PARTICLE_UTILITY_FLUID_PFEM2_TRANSPORT_INCLUDED)
13 #define KRATOS_MOVE_PARTICLE_UTILITY_FLUID_PFEM2_TRANSPORT_INCLUDED
35 #include "utilities/geometry_utilities.h"
63 template<
unsigned int TDim>
88 : mr_model_part(
model_part) , mmaximum_number_of_particles(maximum_number_of_particles) ,
94 std::cout <<
"initializing moveparticle utility for scalar transport" << std::endl;
100 ModelPart::ElementsContainerType::iterator ielembegin = mr_model_part.
ElementsBegin();
101 for(
unsigned int ii=0; ii<mr_model_part.
Elements().size(); ii++)
103 ModelPart::ElementsContainerType::iterator ielem = ielembegin+ii;
106 mlast_elem_id= (mr_model_part.
ElementsEnd()-1)->Id();
109 ModelPart::NodesContainerType::iterator inodebegin = mr_model_part.
NodesBegin();
110 vector<unsigned int> node_partition;
112 int number_of_threads = omp_get_max_threads();
114 int number_of_threads = 1;
116 OpenMPUtils::CreatePartition(number_of_threads, mr_model_part.
Nodes().size(), node_partition);
118 #pragma omp parallel for
119 for(
int kkk=0; kkk<number_of_threads; kkk++)
121 for(
unsigned int ii=node_partition[kkk]; ii<node_partition[kkk+1]; ii++)
123 ModelPart::NodesContainerType::iterator pnode = inodebegin+ii;
126 position_node = pnode->Coordinates();
129 const double number_of_neighbours =
double(rneigh.
size());
133 position_difference = inode->Coordinates() - position_node;
134 double current_distance= sqrt(pow(position_difference[0],2)+pow(position_difference[1],2)+pow(position_difference[2],2));
137 distance += current_distance / number_of_neighbours;
140 pnode->FastGetSolutionStepValue(MEAN_SIZE)=distance;
149 vector<unsigned int> element_partition;
150 OpenMPUtils::CreatePartition(number_of_threads, mr_model_part.
Elements().size(), element_partition);
153 #pragma omp parallel for
154 for(
int kkk=0; kkk<number_of_threads; kkk++)
156 for(
unsigned int ii=element_partition[kkk]; ii<element_partition[kkk+1]; ii++)
158 ModelPart::ElementsContainerType::iterator ielem = ielembegin+ii;
162 Edge = ielem->GetGeometry()[1].Coordinates() - ielem->GetGeometry()[0].Coordinates();
163 mElemSize = Edge[0]*Edge[0];
164 for (
unsigned int d = 1;
d < TDim;
d++)
165 mElemSize += Edge[
d]*Edge[
d];
167 for (
unsigned int i = 2;
i < (TDim+1);
i++)
168 for(
unsigned int j = 0;
j <
i;
j++)
170 Edge = ielem->GetGeometry()[
i].Coordinates() - ielem->GetGeometry()[
j].Coordinates();
171 double Length = Edge[0]*Edge[0];
172 for (
unsigned int d = 1;
d < TDim;
d++)
173 Length += Edge[
d]*Edge[
d];
174 if (Length < mElemSize) mElemSize = Length;
176 mElemSize = sqrt(mElemSize);
177 ielem->GetValue(MEAN_SIZE) = mElemSize;
187 mnelems = mr_model_part.
Elements().size();
189 std::cout <<
"about to resize vectors" << std::endl;
194 mparticles_vector.resize(mnelems*mmaximum_number_of_particles);
197 mnumber_of_particles_in_elems.resize(mnelems);
198 mnumber_of_particles_in_elems=
ZeroVector(mnelems);
201 mnumber_of_particles_in_elems_aux.resize(mnelems);
205 mvector_of_particle_pointers_vectors.resize(mnelems);
209 std::cout <<
"about to create particles" << std::endl;
215 for(
unsigned int ii=0; ii<mr_model_part.
Elements().size(); ii++)
217 ModelPart::ElementsContainerType::iterator ielem = ielembegin+ii;
228 int & number_of_particles = mnumber_of_particles_in_elems[ii];
229 number_of_particles=0;
234 ComputeGaussPointPositions_initial(geom, pos,
N);
236 for (
unsigned int j = 0;
j < pos.size1();
j++)
241 pparticle.
X()=pos(
j,0);
242 pparticle.
Y()=pos(
j,1);
243 pparticle.
Z()=pos(
j,2);
250 for (
unsigned int k = 0;
k < (TDim+1);
k++)
252 scalar1 +=
N(
j,
k) * geom[
k].FastGetSolutionStepValue(mUnknownVar);
256 particle_pointers(
j) = &pparticle;
257 number_of_particles++ ;
263 m_nparticles=particle_id;
266 mparticle_printing_tool_initialized=
false;
286 paux.swap(mpBinsObjectDynamic);
289 std::cout <<
"finished mounting Bins" << std::endl;
304 paux.swap(mpBinsObjectDynamic);
306 KRATOS_INFO(
"MoveParticleUtilityScalarTransport") <<
"Finished mounting Bins with cell size: " << CellSize << std::endl;
317 const double nodal_weight = 1.0/ (1.0 +
double (TDim) );
319 ModelPart::ElementsContainerType::iterator ielembegin = mr_model_part.
ElementsBegin();
320 vector<unsigned int> element_partition;
322 int number_of_threads = omp_get_max_threads();
324 int number_of_threads = 1;
326 OpenMPUtils::CreatePartition(number_of_threads, mr_model_part.
Elements().size(), element_partition);
328 #pragma omp parallel for
329 for(
int kkk=0; kkk<number_of_threads; kkk++)
331 for(
unsigned int ii=element_partition[kkk]; ii<element_partition[kkk+1]; ii++)
333 ModelPart::ElementsContainerType::iterator ielem = ielembegin+ii;
338 for (
unsigned int i=0;
i != (TDim+1) ;
i++)
339 vector_mean_velocity += geom[
i].FastGetSolutionStepValue(mVelocityVar);
340 vector_mean_velocity *= nodal_weight;
342 const double mean_velocity = sqrt ( pow(vector_mean_velocity[0],2) + pow(vector_mean_velocity[1],2) + pow(vector_mean_velocity[2],2) );
343 ielem->GetValue(MEAN_VEL_OVER_ELEM_SIZE) = mean_velocity / (ielem->GetValue(MEAN_SIZE));
356 ModelPart::NodesContainerType::iterator inodebegin = mr_model_part.
NodesBegin();
357 vector<unsigned int> node_partition;
359 int number_of_threads = omp_get_max_threads();
361 int number_of_threads = 1;
363 OpenMPUtils::CreatePartition(number_of_threads, mr_model_part.
Nodes().size(), node_partition);
365 #pragma omp parallel for
366 for(
int kkk=0; kkk<number_of_threads; kkk++)
368 for(
unsigned int ii=node_partition[kkk]; ii<node_partition[kkk+1]; ii++)
370 ModelPart::NodesContainerType::iterator inode = inodebegin+ii;
372 if (inode->IsFixed(mUnknownVar))
374 inode->FastGetSolutionStepValue(mUnknownVar)=inode->GetSolutionStepValue(mUnknownVar,1);
385 ModelPart::NodesContainerType::iterator inodebegin = mr_model_part.
NodesBegin();
386 vector<unsigned int> node_partition;
388 int number_of_threads = omp_get_max_threads();
390 int number_of_threads = 1;
392 OpenMPUtils::CreatePartition(number_of_threads, mr_model_part.
Nodes().size(), node_partition);
394 #pragma omp parallel for
395 for(
int kkk=0; kkk<number_of_threads; kkk++)
397 for(
unsigned int ii=node_partition[kkk]; ii<node_partition[kkk+1]; ii++)
399 ModelPart::NodesContainerType::iterator inode = inodebegin+ii;
400 inode->FastGetSolutionStepValue(DELTA_SCALAR1) = inode->FastGetSolutionStepValue(mUnknownVar) - inode->FastGetSolutionStepValue(mProjectionVar) ;
412 ModelPart::NodesContainerType::iterator inodebegin = rNodes.begin();
413 vector<unsigned int> node_partition;
415 int number_of_threads = omp_get_max_threads();
417 int number_of_threads = 1;
419 OpenMPUtils::CreatePartition(number_of_threads, rNodes.size(), node_partition);
421 #pragma omp parallel for
422 for(
int kkk=0; kkk<number_of_threads; kkk++)
424 for(
unsigned int ii=node_partition[kkk]; ii<node_partition[kkk+1]; ii++)
426 ModelPart::NodesContainerType::iterator inode = inodebegin+ii;
427 inode->GetSolutionStepValue(OriginVariable,1) = inode->FastGetSolutionStepValue(OriginVariable);
442 const int offset = moffset;
448 if (offset!=0) even_timestep=
false;
449 else even_timestep=
true;
451 const int post_offset = mmaximum_number_of_particles*
int(even_timestep);
455 double delta_t = CurrentProcessInfo[DELTA_TIME];
458 const unsigned int max_results = 10000;
465 vector<unsigned int> element_partition;
467 int number_of_threads = omp_get_max_threads();
469 int number_of_threads = 1;
471 OpenMPUtils::CreatePartition(number_of_threads, mr_model_part.
Elements().size(), element_partition);
473 ModelPart::ElementsContainerType::iterator ielembegin = mr_model_part.
ElementsBegin();
478 #pragma omp parallel for
479 for(
int kkk=0; kkk<number_of_threads; kkk++)
481 for(
unsigned int ii=element_partition[kkk]; ii<element_partition[kkk+1]; ii++)
485 int & number_of_particles = mnumber_of_particles_in_elems[ii];
487 mnumber_of_particles_in_elems_aux[ii]=number_of_particles;
488 mnumber_of_particles_in_elems[ii]=0;
492 std::cout <<
"convecting particles" << std::endl;
497 #pragma omp parallel for
498 for(
int kkk=0; kkk<number_of_threads; kkk++)
504 elements_in_trajectory.
resize(20);
506 for(
unsigned int ielem=element_partition[kkk]; ielem<element_partition[kkk+1]; ielem++)
511 ModelPart::ElementsContainerType::iterator old_element = ielembegin+ielem;
512 const int old_element_id = old_element->Id();
514 ParticlePointerVector& old_element_particle_pointers = mvector_of_particle_pointers_vectors(old_element_id-1);
516 if ( (results.size()) !=max_results)
517 results.resize(max_results);
519 unsigned int number_of_elements_in_trajectory=0;
521 for(
int ii=0; ii<(mnumber_of_particles_in_elems_aux(ielem)); ii++)
526 Element::Pointer pcurrent_element( *old_element.base() );
529 if (erase_flag==
false){
530 MoveParticle(pparticle,pcurrent_element,elements_in_trajectory,number_of_elements_in_trajectory,result_begin,max_results);
532 const int current_element_id = pcurrent_element->Id();
534 int & number_of_particles_in_current_elem = mnumber_of_particles_in_elems(current_element_id-1);
537 if (number_of_particles_in_current_elem<mmaximum_number_of_particles && erase_flag==
false)
541 ParticlePointerVector& current_element_particle_pointers = mvector_of_particle_pointers_vectors(current_element_id-1);
545 if (number_of_particles_in_current_elem<mmaximum_number_of_particles)
548 current_element_particle_pointers(post_offset+number_of_particles_in_current_elem) = &pparticle;
550 number_of_particles_in_current_elem++ ;
551 if (number_of_particles_in_current_elem>mmaximum_number_of_particles)
586 moffset = post_offset;;
600 std::cout <<
"projecting info to mesh" << std::endl;
603 const int offset = moffset;
614 ModelPart::NodesContainerType::iterator inodebegin = mr_model_part.
NodesBegin();
615 vector<unsigned int> node_partition;
617 int number_of_threads = omp_get_max_threads();
619 int number_of_threads = 1;
621 OpenMPUtils::CreatePartition(number_of_threads, mr_model_part.
Nodes().size(), node_partition);
623 #pragma omp parallel for
624 for(
int kkk=0; kkk<number_of_threads; kkk++)
626 for(
unsigned int ii=node_partition[kkk]; ii<node_partition[kkk+1]; ii++)
628 ModelPart::NodesContainerType::iterator inode = inodebegin+ii;
629 inode->FastGetSolutionStepValue(mProjectionVar)=0.0;
630 inode->FastGetSolutionStepValue(YP)=0.0;
636 vector<unsigned int> element_partition;
637 OpenMPUtils::CreatePartition(number_of_threads, mr_model_part.
Elements().size(), element_partition);
639 ModelPart::ElementsContainerType::iterator ielembegin = mr_model_part.
ElementsBegin();
640 #pragma omp parallel for
641 for(
int kkk=0; kkk<number_of_threads; kkk++)
643 for(
unsigned int ii=element_partition[kkk]; ii<element_partition[kkk+1]; ii++)
645 ModelPart::ElementsContainerType::iterator ielem = ielembegin+ii;
654 for (
int i=0 ;
i!=(TDim+1) ; ++
i)
656 nodes_positions[
i*3+0]=geom[
i].X();
657 nodes_positions[
i*3+1]=geom[
i].Y();
658 nodes_positions[
i*3+2]=geom[
i].Z();
666 int & number_of_particles_in_elem= mnumber_of_particles_in_elems[ii];
670 for (
int iii=0; iii<number_of_particles_in_elem ; iii++ )
672 if (iii==mmaximum_number_of_particles)
682 const float& particle_scalar1 = pparticle.
GetScalar1();
685 bool is_found = CalculatePosition(nodes_positions,position[0],position[1],position[2],
N);
689 for (
int j=0 ;
j!=(TDim+1);
j++)
690 if (
N[
j]<0.0 &&
N[
j]> -1
e-5)
695 for (
int j=0 ;
j!=(TDim+1);
j++)
702 double weight=
N(
j)*
N(
j);
708 nodes_addedweights[
j]+= weight;
711 nodes_added_scalar1[
j] += weight*particle_scalar1;
719 for (
int i=0 ;
i!=(TDim+1) ; ++
i) {
721 geom[
i].FastGetSolutionStepValue(mProjectionVar) +=nodes_added_scalar1[
i];
722 geom[
i].FastGetSolutionStepValue(YP) +=nodes_addedweights[
i];
728 #pragma omp parallel for
729 for(
int kkk=0; kkk<number_of_threads; kkk++)
731 for(
unsigned int ii=node_partition[kkk]; ii<node_partition[kkk+1]; ii++)
733 ModelPart::NodesContainerType::iterator inode = inodebegin+ii;
734 double sum_weights = inode->FastGetSolutionStepValue(YP);
735 if (sum_weights>0.00001)
738 double & height = inode->FastGetSolutionStepValue(mProjectionVar);
739 height /=sum_weights;
744 inode->FastGetSolutionStepValue(mProjectionVar)=inode->FastGetSolutionStepValue(mUnknownVar,1);
761 std::cout <<
"projecting info to mesh (semi implicit)" << std::endl;
764 const int offset = moffset;
775 ModelPart::NodesContainerType::iterator inodebegin = mr_model_part.
NodesBegin();
776 vector<unsigned int> node_partition;
778 int number_of_threads = omp_get_max_threads();
780 int number_of_threads = 1;
782 OpenMPUtils::CreatePartition(number_of_threads, mr_model_part.
Nodes().size(), node_partition);
784 #pragma omp parallel for
785 for(
int kkk=0; kkk<number_of_threads; kkk++)
787 for(
unsigned int ii=node_partition[kkk]; ii<node_partition[kkk+1]; ii++)
789 ModelPart::NodesContainerType::iterator inode = inodebegin+ii;
790 inode->FastGetSolutionStepValue(mProjectionVar)=0.0;
791 inode->FastGetSolutionStepValue(YP)=0.0;
797 vector<unsigned int> element_partition;
798 OpenMPUtils::CreatePartition(number_of_threads, mr_model_part.
Elements().size(), element_partition);
800 ModelPart::ElementsContainerType::iterator ielembegin = mr_model_part.
ElementsBegin();
801 #pragma omp parallel for
802 for(
int kkk=0; kkk<number_of_threads; kkk++)
813 for(
unsigned int ii=element_partition[kkk]; ii<element_partition[kkk+1]; ii++)
815 ModelPart::ElementsContainerType::iterator ielem = ielembegin+ii;
826 const double elem_volume = geom.
Area();
828 for (
int i=0 ;
i!=(TDim+1) ; ++
i)
830 nodes_positions[
i*3+0]=geom[
i].X();
831 nodes_positions[
i*3+1]=geom[
i].Y();
832 nodes_positions[
i*3+2]=geom[
i].Z();
839 int & number_of_particles_in_elem= mnumber_of_particles_in_elems[ii];
842 for (
int iii=0; iii<number_of_particles_in_elem ; iii++ )
844 if (iii==mmaximum_number_of_particles)
854 const float& particle_scalar1 = pparticle.
GetScalar1();
857 bool is_found = CalculatePosition(nodes_positions,position[0],position[1],position[2],
N);
861 for (
int j=0 ;
j!=(TDim+1);
j++)
862 if (
N[
j]<0.0 &&
N[
j]> -1
e-5)
867 for (
int j=0 ;
j!=(TDim+1);
j++)
870 for (
int k=0 ;
k!=(TDim+1);
k++)
871 mass_matrix(
j,
k) += weight*
N(
k);
873 rhs_scalar1[
j] += weight *
double(particle_scalar1);
878 double this_particle_weight = weight*elem_volume/(
double(number_of_particles_in_elem))*0.1;
879 nodes_addedweights[
j]+= this_particle_weight;
880 nodes_added_scalar1[
j] += this_particle_weight*particle_scalar1;
888 if constexpr (TDim==3)
889 InvertMatrix( mass_matrix, inverse_mass_matrix);
891 InvertMatrix3x3( mass_matrix, inverse_mass_matrix);
894 if(number_of_particles_in_elem >
static_cast<int>(TDim)*3)
896 for (
int i=0 ;
i!=(TDim+1);
i++)
898 for (
int j=0 ;
j!=(TDim+1);
j++)
900 nodes_added_scalar1[
i] += inverse_mass_matrix(
i,
j)*rhs_scalar1[
j]*elem_volume*(1.0/(
double(1+TDim)));
905 for (
int i=0 ;
i!=(TDim+1);
i++)
906 nodes_addedweights[
i] += elem_volume*(1.0/(
double(1+TDim)));
910 for (
int i=0 ;
i!=(TDim+1) ; ++
i) {
912 geom[
i].FastGetSolutionStepValue(mProjectionVar) +=nodes_added_scalar1[
i];
913 geom[
i].FastGetSolutionStepValue(YP) +=nodes_addedweights[
i];
919 #pragma omp parallel for
920 for(
int kkk=0; kkk<number_of_threads; kkk++)
922 for(
unsigned int ii=node_partition[kkk]; ii<node_partition[kkk+1]; ii++)
924 ModelPart::NodesContainerType::iterator inode = inodebegin+ii;
925 double sum_weights = inode->FastGetSolutionStepValue(YP);
926 if (sum_weights>0.00001)
928 double & scalar1 = inode->FastGetSolutionStepValue(mProjectionVar);
929 scalar1 /=sum_weights;
934 inode->FastGetSolutionStepValue(mProjectionVar)=inode->FastGetSolutionStepValue(mUnknownVar,1);
949 const int offset = moffset;
952 ModelPart::ElementsContainerType::iterator ielembegin = mr_model_part.
ElementsBegin();
955 vector<unsigned int> element_partition;
957 int number_of_threads = omp_get_max_threads();
959 int number_of_threads = 1;
961 OpenMPUtils::CreatePartition(number_of_threads, mr_model_part.
Elements().size(), element_partition);
963 #pragma omp parallel for
964 for(
int kkk=0; kkk<number_of_threads; kkk++)
966 for(
unsigned int ii=element_partition[kkk]; ii<element_partition[kkk+1]; ii++)
969 ModelPart::ElementsContainerType::iterator ielem = ielembegin+ii;
970 Element::Pointer pelement(*ielem.base());
975 int & number_of_particles_in_elem= mnumber_of_particles_in_elems[ii];
979 for (
int iii=0; iii<number_of_particles_in_elem ; iii++ )
982 if (iii>mmaximum_number_of_particles)
989 if (erase_flag==
false)
991 CorrectParticleUsingDeltaVariables(pparticle,pelement,geom);
1010 while (
i != endit && (
i)->Id() != (candidate)->Id())
1016 v.push_back(candidate);
1030 const int offset =moffset;
1031 const int max_results = 1000;
1035 vector<unsigned int> elem_partition;
1036 int number_of_rows=mr_model_part.
Elements().size();
1037 elem_partition.resize(number_of_threads + 1);
1038 int elem_partition_size = number_of_rows / number_of_threads;
1039 elem_partition[0] = 0;
1040 elem_partition[number_of_threads] = number_of_rows;
1042 for (
unsigned int i = 1;
i < number_of_threads;
i++)
1043 elem_partition[
i] = elem_partition[
i - 1] + elem_partition_size;
1044 ModelPart::ElementsContainerType::iterator ielembegin = mr_model_part.
ElementsBegin();
1046 #pragma omp parallel firstprivate(elem_partition)
1057 unsigned int freeparticle=0;
1060 for(
unsigned int ii=elem_partition[
k]; ii<elem_partition[
k+1]; ii++)
1063 ModelPart::ElementsContainerType::iterator ielem = ielembegin+ii;
1064 results.resize(max_results);
1068 int & number_of_particles_in_elem= mnumber_of_particles_in_elems[ii];
1070 if (number_of_particles_in_elem<(minimum_number_of_particles))
1074 ComputeGaussPointPositionsForPreReseed(geom, pos,
N);
1077 for (
unsigned int j = 0;
j < (pos.size1());
j++)
1079 bool keep_looking =
true;
1082 if (mparticles_vector[freeparticle].GetEraseFlag()==
true)
1084 #pragma omp critical
1086 if (mparticles_vector[freeparticle].GetEraseFlag()==
true)
1088 mparticles_vector[freeparticle].GetEraseFlag()=
false;
1092 if (keep_looking==
false)
1106 bool is_found = CalculatePosition(geom,pos(
j,0),pos(
j,1),pos(
j,2),aux2_N);
1107 if (is_found==
false)
1116 Element::Pointer pelement( *ielem.base() );
1117 MoveParticle_inverse_way(pparticle, pelement, result_begin, max_results);
1120 mparticles_vector[freeparticle] = pparticle;
1122 element_particle_pointers(offset+number_of_particles_in_elem) = &mparticles_vector[freeparticle];
1125 number_of_particles_in_elem++;
1149 const int offset = moffset;
1155 vector<unsigned int> elem_partition;
1156 int number_of_rows=mr_model_part.
Elements().size();
1159 elem_partition.resize(number_of_threads + 1);
1160 int elem_partition_size = number_of_rows / number_of_threads;
1161 elem_partition[0] = 0;
1162 elem_partition[number_of_threads] = number_of_rows;
1164 for (
unsigned int i = 1;
i < number_of_threads;
i++)
1165 elem_partition[
i] = elem_partition[
i - 1] + elem_partition_size;
1172 ModelPart::ElementsContainerType::iterator ielembegin = mr_model_part.
ElementsBegin();
1174 #pragma omp parallel firstprivate(elem_partition)
1176 unsigned int reused_particles=0;
1178 unsigned int freeparticle = 0;
1187 double mesh_scalar1;
1191 unsigned int number_of_reseeded_particles;
1196 for(
unsigned int ii=elem_partition[
k]; ii<elem_partition[
k+1]; ii++)
1199 ModelPart::ElementsContainerType::iterator ielem = ielembegin+ii;
1203 int & number_of_particles_in_elem= mnumber_of_particles_in_elems[ii];
1207 if ( (number_of_particles_in_elem<(minimum_number_of_particles)))
1211 number_of_reseeded_particles=0;
1215 number_of_reseeded_particles= 3+2*TDim;
1216 ComputeGaussPointPositionsForPostReseed(geom, pos,
N);
1218 for (
unsigned int j = 0;
j < number_of_reseeded_particles;
j++)
1221 bool keep_looking =
true;
1224 if (mparticles_vector[freeparticle].GetEraseFlag()==
true)
1226 #pragma omp critical
1228 if (mparticles_vector[freeparticle].GetEraseFlag()==
true)
1230 mparticles_vector[freeparticle].GetEraseFlag()=
false;
1234 if (keep_looking==
false)
1249 bool is_found = CalculatePosition(geom,pos(
j,0),pos(
j,1),pos(
j,2),aux_N);
1250 if (is_found==
false)
1259 for (
unsigned int l = 0;
l < (TDim+1);
l++)
1261 mesh_scalar1 +=
N(
j,
l) * geom[
l].FastGetSolutionStepValue(mUnknownVar);
1267 mparticles_vector[freeparticle]=pparticle;
1268 element_particle_pointers(offset+number_of_particles_in_elem) = &mparticles_vector[freeparticle];
1269 number_of_particles_in_elem++;
1274 KRATOS_THROW_ERROR(std::logic_error,
"FINISHED THE LIST AND COULDNT FIND A FREE CELL FOR THE NEW PARTICLE!",
"");
1294 if(mparticle_printing_tool_initialized==
false)
1296 mfilter_factor=input_filter_factor;
1299 KRATOS_THROW_ERROR(std::logic_error,
"AN EMPTY MODEL PART IS REQUIRED FOR THE PRINTING OF PARTICLES",
"");
1304 for (
unsigned int i=0;
i!=((mmaximum_number_of_particles*mnelems)/mfilter_factor)+mfilter_factor;
i++)
1308 pnode->SetBufferSize(1);
1310 mparticle_printing_tool_initialized=
true;
1314 const double inactive_particle_position= -10.0;
1316 inactive_particle_position_vector(0)=inactive_particle_position;
1317 inactive_particle_position_vector(1)=inactive_particle_position;
1318 inactive_particle_position_vector(2)=inactive_particle_position;
1322 ModelPart::NodesContainerType::iterator inode = inodebegin+ii;
1323 inode->FastGetSolutionStepValue(mUnknownVar) = 0.0;
1324 inode->FastGetSolutionStepValue(DISPLACEMENT) = inactive_particle_position_vector;
1330 for (
int i=0;
i!=mmaximum_number_of_particles*mnelems;
i++)
1335 ModelPart::NodesContainerType::iterator inode = inodebegin+
counter;
1336 inode->FastGetSolutionStepValue(mUnknownVar) = pparticle.
GetScalar1();
1337 inode->FastGetSolutionStepValue(DISPLACEMENT) = pparticle.
Coordinates();
1356 Element::Pointer & pelement,
1358 unsigned int & number_of_elements_in_trajectory,
1360 const unsigned int MaxNumberOfResults)
1364 double delta_t = CurrentProcessInfo[DELTA_TIME];
1365 unsigned int nsubsteps;
1369 bool KEEP_INTEGRATING=
false;
1384 is_found = FindNodeOnMesh(position,
N ,pelement,result_begin,MaxNumberOfResults);
1385 if(is_found ==
true)
1387 KEEP_INTEGRATING=
true;
1391 for(
unsigned int j=0;
j<(TDim+1);
j++)
1393 noalias(
vel) += geom[
j].FastGetSolutionStepValue(mVelocityVar)*
N[
j];
1397 nsubsteps = 10.0 * (
delta_t * pelement->GetValue(MEAN_VEL_OVER_ELEM_SIZE));
1402 position +=
vel*substep_dt;
1406 unsigned int check_from_element_number=0;
1409 for(
unsigned int i=0;
i<(nsubsteps-1);
i++)
1411 if (KEEP_INTEGRATING==
true)
1413 is_found = FindNodeOnMesh(position,
N ,pelement,elements_in_trajectory,number_of_elements_in_trajectory,check_from_element_number,result_begin,MaxNumberOfResults);
1414 if(is_found ==
true)
1416 Geometry< Node >& geom = pelement->GetGeometry();
1419 for(
unsigned int j=0;
j<(TDim+1);
j++)
1421 noalias(
vel) += geom[
j].FastGetSolutionStepValue(mVelocityVar)*
N[
j];
1425 position+=
vel*substep_dt;
1430 KEEP_INTEGRATING=
false;
1442 if (KEEP_INTEGRATING==
false) (pparticle.
GetEraseFlag()=
true);
1443 else is_found = FindNodeOnMesh(position,
N ,pelement,result_begin,MaxNumberOfResults);
1451 void CorrectParticleUsingDeltaVariables(
1452 Convection_Particle & pparticle,
1453 Element::Pointer & pelement,
1454 Geometry< Node >& geom)
1456 array_1d<double,TDim+1>
N;
1459 array_1d<double,3> coords = pparticle.Coordinates();
1460 float & particle_scalar1 = pparticle.GetScalar1();
1462 double delta_scalar1 = 0.0;
1464 bool is_found = CalculatePosition(geom,coords[0],coords[1],coords[2],
N);
1465 if(is_found ==
false)
1468 for (
int j=0 ;
j!=(TDim+1);
j++)
1474 for(
unsigned int j=0;
j<(TDim+1);
j++)
1476 delta_scalar1 += geom[
j].FastGetSolutionStepValue(DELTA_SCALAR1)*
N[
j];
1478 particle_scalar1 = particle_scalar1 + delta_scalar1;
1481 void MoveParticle_inverse_way(
1482 Convection_Particle & pparticle,
1483 Element::Pointer & pelement,
1485 const unsigned int MaxNumberOfResults)
1489 double delta_t = CurrentProcessInfo[DELTA_TIME];
1490 unsigned int nsubsteps;
1494 bool KEEP_INTEGRATING=
false;
1497 array_1d<double,3>
vel;
1498 array_1d<double,3> position;
1499 array_1d<double,3> mid_position;
1500 array_1d<double,TDim+1>
N;
1501 double scalar1 = 0.0;
1505 position = pparticle.Coordinates();
1508 is_found = FindNodeOnMesh(position,
N ,pelement,result_begin,MaxNumberOfResults);
1509 if(is_found ==
true)
1511 KEEP_INTEGRATING=
true;
1512 Geometry< Node >& geom = pelement->GetGeometry();
1516 for(
unsigned int j=0;
j<(TDim+1);
j++)
1518 scalar1 += geom[
j].FastGetSolutionStepValue(mUnknownVar)*
N(
j);
1519 noalias(
vel) += geom[
j].FastGetSolutionStepValue(mVelocityVar)*
N[
j];
1522 nsubsteps = 10.0 * (
delta_t * pelement->GetValue(MEAN_VEL_OVER_ELEM_SIZE));
1527 position -=
vel*substep_dt;
1529 for(
unsigned int i=0;
i<(nsubsteps-1);
i++)
1530 {
if (KEEP_INTEGRATING==
true) {
1531 is_found = FindNodeOnMesh(position,
N ,pelement,result_begin,MaxNumberOfResults);
1532 if(is_found ==
true)
1534 Geometry< Node >& geom = pelement->GetGeometry();
1540 for(
unsigned int j=0;
j<(TDim+1);
j++)
1542 noalias(
vel) += geom[
j].FastGetSolutionStepValue(mVelocityVar)*
N[
j] ;
1543 scalar1 += geom[
j].FastGetSolutionStepValue(mUnknownVar)*
N(
j);
1547 position-=
vel*substep_dt;
1549 else KEEP_INTEGRATING=
false;
1555 pparticle.GetScalar1()=scalar1;
1567 bool FindNodeOnMesh( array_1d<double,3>& position,
1568 array_1d<double,TDim+1>&
N,
1569 Element::Pointer & pelement,
1571 const unsigned int MaxNumberOfResults)
1575 const array_1d<double,3>& coords = position;
1576 array_1d<double,TDim+1> aux_N;
1578 Geometry<Node >& geom_default = pelement->GetGeometry();
1579 bool is_found_1 = CalculatePosition(geom_default,coords[0],coords[1],coords[2],
N);
1580 if(is_found_1 ==
true)
1609 for (
unsigned int i=0;
i!=(neighb_elems.
size());
i++)
1611 if(neighb_elems(
i).get()!=
nullptr)
1613 Geometry<Node >& geom = neighb_elems[
i].GetGeometry();
1614 bool is_found_2 = CalculatePosition(geom,coords[0],coords[1],coords[2],
N);
1617 pelement=neighb_elems(
i)->shared_from_this();
1625 SizeType results_found = mpBinsObjectDynamic->SearchObjectsInCell(Point{coords}, result_begin, MaxNumberOfResults );
1627 if(results_found>0){
1631 Geometry<Node >& geom = (*(result_begin+
i))->GetGeometry();
1634 bool is_found = CalculatePosition(geom,coords[0],coords[1],coords[2],
N);
1636 if(is_found ==
true)
1638 pelement=Element::Pointer((*(result_begin+
i)));
1650 bool FindNodeOnMesh( array_1d<double,3>& position,
1651 array_1d<double,TDim+1>&
N,
1652 Element::Pointer & pelement,
1654 unsigned int & number_of_elements_in_trajectory,
1655 unsigned int & check_from_element_number,
1657 const unsigned int MaxNumberOfResults)
1661 const array_1d<double,3>& coords = position;
1662 array_1d<double,TDim+1> aux_N;
1664 Geometry<Node >& geom_default = pelement->GetGeometry();
1665 bool is_found_1 = CalculatePosition(geom_default,coords[0],coords[1],coords[2],
N);
1666 if(is_found_1 ==
true)
1672 for (
unsigned int i=(check_from_element_number);
i!=number_of_elements_in_trajectory;
i++)
1674 Geometry<Node >& geom = elements_in_trajectory[
i].GetGeometry();
1675 bool is_found_2 = CalculatePosition(geom,coords[0],coords[1],coords[2],aux_N);
1678 pelement=elements_in_trajectory(
i)->shared_from_this();
1680 check_from_element_number =
i+1 ;
1687 auto& neighb_elems = pelement->GetValue(NEIGHBOUR_ELEMENTS);
1710 for (
unsigned int i=0;
i!=(neighb_elems.
size());
i++)
1712 if(neighb_elems(
i).get()!=
nullptr)
1714 Geometry<Node >& geom = neighb_elems[
i].GetGeometry();
1715 bool is_found_2 = CalculatePosition(geom,coords[0],coords[1],coords[2],
N);
1718 pelement=neighb_elems(
i)->shared_from_this();
1719 if (number_of_elements_in_trajectory<20)
1721 elements_in_trajectory(number_of_elements_in_trajectory)=pelement;
1722 number_of_elements_in_trajectory++;
1723 check_from_element_number = number_of_elements_in_trajectory;
1733 SizeType results_found = mpBinsObjectDynamic->SearchObjectsInCell(Point{coords}, result_begin, MaxNumberOfResults );
1740 Geometry<Node >& geom = (*(result_begin+
i))->GetGeometry();
1743 bool is_found = CalculatePosition(geom,coords[0],coords[1],coords[2],
N);
1745 if(is_found ==
true)
1747 pelement=Element::Pointer((*(result_begin+
i)));
1748 if (number_of_elements_in_trajectory<20)
1750 elements_in_trajectory(number_of_elements_in_trajectory)=pelement;
1751 number_of_elements_in_trajectory++;
1752 check_from_element_number = number_of_elements_in_trajectory;
1768 inline bool CalculatePosition(Geometry<Node >&geom,
1769 const double xc,
const double yc,
const double zc,
1770 array_1d<double, 3 > &
N
1773 double x0 = geom[0].X();
1774 double y0 = geom[0].Y();
1775 double x1 = geom[1].X();
1776 double y1 = geom[1].Y();
1777 double x2 = geom[2].X();
1778 double y2 = geom[2].Y();
1780 double area = CalculateVol(x0, y0,
x1, y1,
x2, y2);
1781 double inv_area = 0.0;
1787 inv_area = 1.0 / area;
1791 N[0] = CalculateVol(
x1, y1,
x2, y2,
xc,
yc) * inv_area;
1792 N[1] = CalculateVol(
x2, y2, x0, y0,
xc,
yc) * inv_area;
1793 N[2] = CalculateVol(x0, y0,
x1, y1,
xc,
yc) * inv_area;
1796 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)
1803 inline bool CalculatePosition(
const array_1d<
double,3*(TDim+1)>& nodes_positions,
1804 const double xc,
const double yc,
const double zc,
1805 array_1d<double, 3 > &
N
1808 const double& x0 = nodes_positions[0];
1809 const double& y0 = nodes_positions[1];
1810 const double&
x1 = nodes_positions[3];
1811 const double& y1 = nodes_positions[4];
1812 const double&
x2 = nodes_positions[6];
1813 const double& y2 = nodes_positions[7];
1815 double area = CalculateVol(x0, y0,
x1, y1,
x2, y2);
1816 double inv_area = 0.0;
1822 inv_area = 1.0 / area;
1826 N[0] = CalculateVol(
x1, y1,
x2, y2,
xc,
yc) * inv_area;
1827 N[1] = CalculateVol(
x2, y2, x0, y0,
xc,
yc) * inv_area;
1828 N[2] = CalculateVol(x0, y0,
x1, y1,
xc,
yc) * inv_area;
1831 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)
1841 inline bool CalculatePosition(Geometry<Node >&geom,
1842 const double xc,
const double yc,
const double zc,
1843 array_1d<double, 4 > &
N
1847 double x0 = geom[0].X();
1848 double y0 = geom[0].Y();
1849 double z0 = geom[0].Z();
1850 double x1 = geom[1].X();
1851 double y1 = geom[1].Y();
1852 double z1 = geom[1].Z();
1853 double x2 = geom[2].X();
1854 double y2 = geom[2].Y();
1855 double z2 = geom[2].Z();
1856 double x3 = geom[3].X();
1857 double y3 = geom[3].Y();
1858 double z3 = geom[3].Z();
1860 double vol = CalculateVol(x0, y0, z0,
x1, y1, z1,
x2, y2, z2, x3, y3, z3);
1862 double inv_vol = 0.0;
1863 if (vol < 0.000000000000000000000000000001)
1868 inv_vol = 1.0 / vol;
1871 N[0] = CalculateVol(
x1, y1, z1, x3, y3, z3,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
1872 N[1] = CalculateVol(x0, y0, z0,
x1, y1, z1,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
1873 N[2] = CalculateVol(x3, y3, z3,
x1, y1, z1, x0, y0, z0,
xc,
yc, zc) * inv_vol;
1874 N[3] = CalculateVol(x3, y3, z3, x0, y0, z0,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
1877 if (
N[0] >= 0.0 &&
N[1] >= 0.0 &&
N[2] >= 0.0 &&
N[3] >= 0.0 &&
1878 N[0] <= 1.0 &&
N[1] <= 1.0 &&
N[2] <= 1.0 &&
N[3] <= 1.0)
1886 inline bool CalculatePosition(
const array_1d<
double,3*(TDim+1)>& nodes_positions,
1887 const double xc,
const double yc,
const double zc,
1888 array_1d<double, 4 > &
N
1892 const double& x0 = nodes_positions[0];
1893 const double& y0 = nodes_positions[1];
1894 const double& z0 = nodes_positions[2];
1895 const double&
x1 = nodes_positions[3];
1896 const double& y1 = nodes_positions[4];
1897 const double& z1 = nodes_positions[5];
1898 const double&
x2 = nodes_positions[6];
1899 const double& y2 = nodes_positions[7];
1900 const double& z2 = nodes_positions[8];
1901 const double& x3 = nodes_positions[9];
1902 const double& y3 = nodes_positions[10];
1903 const double& z3 = nodes_positions[11];
1905 double vol = CalculateVol(x0, y0, z0,
x1, y1, z1,
x2, y2, z2, x3, y3, z3);
1907 double inv_vol = 0.0;
1908 if (vol < 0.000000000000000000000000000001)
1913 inv_vol = 1.0 / vol;
1916 N[0] = CalculateVol(
x1, y1, z1, x3, y3, z3,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
1917 N[1] = CalculateVol(x0, y0, z0,
x1, y1, z1,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
1918 N[2] = CalculateVol(x3, y3, z3,
x1, y1, z1, x0, y0, z0,
xc,
yc, zc) * inv_vol;
1919 N[3] = CalculateVol(x3, y3, z3, x0, y0, z0,
x2, y2, z2,
xc,
yc, zc) * inv_vol;
1922 if (
N[0] >= 0.0 &&
N[1] >= 0.0 &&
N[2] >= 0.0 &&
N[3] >= 0.0 &&
1923 N[0] <= 1.0 &&
N[1] <= 1.0 &&
N[2] <= 1.0 &&
N[3] <= 1.0)
1930 inline double CalculateVol(
const double x0,
const double y0,
1931 const double x1,
const double y1,
1932 const double x2,
const double y2
1935 return 0.5 * ((
x1 - x0)*(y2 - y0)- (y1 - y0)*(
x2 - x0));
1940 inline double CalculateVol(
const double x0,
const double y0,
const double z0,
1941 const double x1,
const double y1,
const double z1,
1942 const double x2,
const double y2,
const double z2,
1943 const double x3,
const double y3,
const double z3
1946 double x10 =
x1 - x0;
1947 double y10 = y1 - y0;
1948 double z10 = z1 - z0;
1950 double x20 =
x2 - x0;
1951 double y20 = y2 - y0;
1952 double z20 = z2 - z0;
1954 double x30 = x3 - x0;
1955 double y30 = y3 - y0;
1956 double z30 = z3 - z0;
1958 double detJ = x10 * y20 * z30 - x10 * y30 * z20 + y10 * z20 * x30 - y10 * x20 * z30 + z10 * x20 * y30 - z10 * y20 * x30;
1959 return detJ * 0.1666666666666666666667;
1964 void ComputeGaussPointPositions_4(Geometry< Node >& geom, BoundedMatrix<double, 7, 3 > & pos,BoundedMatrix<double, 7, 3 > &
N)
1966 double one_third = 1.0 / 3.0;
1967 double one_sixt = 0.15;
1968 double two_third = 0.7;
1972 N(0, 2) = two_third;
1973 N(1, 0) = two_third;
1977 N(2, 1) = two_third;
1979 N(3, 0) = one_third;
1980 N(3, 1) = one_third;
1981 N(3, 2) = one_third;
1984 pos(0, 0) = one_sixt * geom[0].X() + one_sixt * geom[1].X() + two_third * geom[2].X();
1985 pos(0, 1) = one_sixt * geom[0].Y() + one_sixt * geom[1].Y() + two_third * geom[2].Y();
1986 pos(0, 2) = one_sixt * geom[0].Z() + one_sixt * geom[1].Z() + two_third * geom[2].Z();
1989 pos(1, 0) = two_third * geom[0].X() + one_sixt * geom[1].X() + one_sixt * geom[2].X();
1990 pos(1, 1) = two_third * geom[0].Y() + one_sixt * geom[1].Y() + one_sixt * geom[2].Y();
1991 pos(1, 2) = two_third * geom[0].Z() + one_sixt * geom[1].Z() + one_sixt * geom[2].Z();
1994 pos(2, 0) = one_sixt * geom[0].X() + two_third * geom[1].X() + one_sixt * geom[2].X();
1995 pos(2, 1) = one_sixt * geom[0].Y() + two_third * geom[1].Y() + one_sixt * geom[2].Y();
1996 pos(2, 2) = one_sixt * geom[0].Z() + two_third * geom[1].Z() + one_sixt * geom[2].Z();
1999 pos(3, 0) = one_third * geom[0].X() + one_third * geom[1].X() + one_third * geom[2].X();
2000 pos(3, 1) = one_third * geom[0].Y() + one_third * geom[1].Y() + one_third * geom[2].Y();
2001 pos(3, 2) = one_third * geom[0].Z() + one_third * geom[1].Z() + one_third * geom[2].Z();
2006 void ComputeGaussPointPositionsForPostReseed(Geometry< Node >& geom, BoundedMatrix<double, 7, 3 > & pos,BoundedMatrix<double, 7, 3 > &
N)
2008 double one_third = 1.0 / 3.0;
2009 double one_eight = 0.12;
2010 double three_quarters = 0.76;
2012 N(0, 0) = one_eight;
2013 N(0, 1) = one_eight;
2014 N(0, 2) = three_quarters;
2016 N(1, 0) = three_quarters;
2017 N(1, 1) = one_eight;
2018 N(1, 2) = one_eight;
2020 N(2, 0) = one_eight;
2021 N(2, 1) = three_quarters;
2022 N(2, 2) = one_eight;
2024 N(3, 0) = one_third;
2025 N(3, 1) = one_third;
2026 N(3, 2) = one_third;
2028 N(4, 0) = one_eight;
2033 N(5, 1) = one_eight;
2038 N(6, 2) = one_eight;
2042 pos(0, 0) = one_eight * geom[0].X() + one_eight * geom[1].X() + three_quarters * geom[2].X();
2043 pos(0, 1) = one_eight * geom[0].Y() + one_eight * geom[1].Y() + three_quarters * geom[2].Y();
2044 pos(0, 2) = one_eight * geom[0].Z() + one_eight * geom[1].Z() + three_quarters * geom[2].Z();
2047 pos(1, 0) = three_quarters * geom[0].X() + one_eight * geom[1].X() + one_eight * geom[2].X();
2048 pos(1, 1) = three_quarters * geom[0].Y() + one_eight * geom[1].Y() + one_eight * geom[2].Y();
2049 pos(1, 2) = three_quarters * geom[0].Z() + one_eight * geom[1].Z() + one_eight * geom[2].Z();
2052 pos(2, 0) = one_eight * geom[0].X() + three_quarters * geom[1].X() + one_eight * geom[2].X();
2053 pos(2, 1) = one_eight * geom[0].Y() + three_quarters * geom[1].Y() + one_eight * geom[2].Y();
2054 pos(2, 2) = one_eight * geom[0].Z() + three_quarters * geom[1].Z() + one_eight * geom[2].Z();
2057 pos(3, 0) = one_third * geom[0].X() + one_third * geom[1].X() + one_third * geom[2].X();
2058 pos(3, 1) = one_third * geom[0].Y() + one_third * geom[1].Y() + one_third * geom[2].Y();
2059 pos(3, 2) = one_third * geom[0].Z() + one_third * geom[1].Z() + one_third * geom[2].Z();
2062 pos(4, 0) = one_eight * geom[0].X() + 0.44 * geom[1].X() + 0.44 * geom[2].X();
2063 pos(4, 1) = one_eight * geom[0].Y() + 0.44 * geom[1].Y() + 0.44 * geom[2].Y();
2064 pos(4, 2) = one_eight * geom[0].Z() + 0.44 * geom[1].Z() + 0.44 * geom[2].Z();
2067 pos(5, 0) = 0.44 * geom[0].X() + one_eight * geom[1].X() + 0.44 * geom[2].X();
2068 pos(5, 1) = 0.44 * geom[0].Y() + one_eight * geom[1].Y() + 0.44 * geom[2].Y();
2069 pos(5, 2) = 0.44 * geom[0].Z() + one_eight * geom[1].Z() + 0.44 * geom[2].Z();
2072 pos(6, 0) = 0.44 * geom[0].X() + 0.44 * geom[1].X() + one_eight * geom[2].X();
2073 pos(6, 1) = 0.44 * geom[0].Y() + 0.44 * geom[1].Y() + one_eight * geom[2].Y();
2074 pos(6, 2) = 0.44 * geom[0].Z() + 0.44 * geom[1].Z() + one_eight * geom[2].Z();
2081 void ComputeGaussPointPositionsForPostReseed(Geometry< Node >& geom, BoundedMatrix<double, 9, 3 > & pos,BoundedMatrix<double, 9, 4 > &
N)
2083 double one_quarter = 0.25;
2084 double small_fraction = 0.1;
2085 double big_fraction = 0.7;
2086 double mid_fraction = 0.3;
2088 N(0, 0) = big_fraction;
2089 N(0, 1) = small_fraction;
2090 N(0, 2) = small_fraction;
2091 N(0, 3) = small_fraction;
2093 N(1, 0) = small_fraction;
2094 N(1, 1) = big_fraction;
2095 N(1, 2) = small_fraction;
2096 N(1, 3) = small_fraction;
2098 N(2, 0) = small_fraction;
2099 N(2, 1) = small_fraction;
2100 N(2, 2) = big_fraction;
2101 N(2, 3) = small_fraction;
2103 N(3, 0) = small_fraction;
2104 N(3, 1) = small_fraction;
2105 N(3, 2) = small_fraction;
2106 N(3, 3) = big_fraction;
2108 N(4, 0) = one_quarter;
2109 N(4, 1) = one_quarter;
2110 N(4, 2) = one_quarter;
2111 N(4, 3) = one_quarter;
2113 N(5, 0) = small_fraction;
2114 N(5, 1) = mid_fraction;
2115 N(5, 2) = mid_fraction;
2116 N(5, 3) = mid_fraction;
2118 N(6, 0) = mid_fraction;
2119 N(6, 1) = small_fraction;
2120 N(6, 2) = mid_fraction;
2121 N(6, 3) = mid_fraction;
2123 N(7, 0) = mid_fraction;
2124 N(7, 1) = mid_fraction;
2125 N(7, 2) = small_fraction;
2126 N(7, 3) = mid_fraction;
2128 N(8, 0) = mid_fraction;
2129 N(8, 1) = mid_fraction;
2130 N(8, 2) = mid_fraction;
2131 N(8, 3) = small_fraction;
2134 for (
unsigned int i=0;
i!=4;
i++)
2136 array_1d<double, 3 > & coordinates = geom[
i].Coordinates();
2137 for (
unsigned int j=0;
j!=9;
j++)
2139 for (
unsigned int k=0;
k!=3;
k++)
2140 pos(
j,
k) +=
N(
j,
i) * coordinates[
k];
2149 void ComputeGaussPointPositionsForPreReseed(Geometry< Node >& geom, BoundedMatrix<double, 3, 3 > & pos,BoundedMatrix<double, 3, 3 > &
N)
2165 pos(0, 0) = 0.5 * geom[0].X() + 0.25 * geom[1].X() + 0.25 * geom[2].X();
2166 pos(0, 1) = 0.5 * geom[0].Y() + 0.25 * geom[1].Y() + 0.25 * geom[2].Y();
2167 pos(0, 2) = 0.5 * geom[0].Z() + 0.25 * geom[1].Z() + 0.25 * geom[2].Z();
2170 pos(1, 0) = 0.25 * geom[0].X() + 0.5 * geom[1].X() + 0.25 * geom[2].X();
2171 pos(1, 1) = 0.25 * geom[0].Y() + 0.5 * geom[1].Y() + 0.25 * geom[2].Y();
2172 pos(1, 2) = 0.25 * geom[0].Z() + 0.5 * geom[1].Z() + 0.25 * geom[2].Z();
2175 pos(2, 0) = 0.25 * geom[0].X() + 0.25 * geom[1].X() + 0.5 * geom[2].X();
2176 pos(2, 1) = 0.25 * geom[0].Y() + 0.25 * geom[1].Y() + 0.5 * geom[2].Y();
2177 pos(2, 2) = 0.25 * geom[0].Z() + 0.25 * geom[1].Z() + 0.5 * geom[2].Z();
2181 void ComputeGaussPointPositionsForPreReseed(Geometry< Node >& geom, BoundedMatrix<double, 4, 3 > & pos,BoundedMatrix<double, 4, 4 > &
N)
2207 for (
unsigned int i=0;
i!=4;
i++)
2209 array_1d<double, 3 > & coordinates = geom[
i].Coordinates();
2210 for (
unsigned int j=0;
j!=4;
j++)
2212 for (
unsigned int k=0;
k!=3;
k++)
2213 pos(
j,
k) +=
N(
j,
i) * coordinates[
k];
2221 void ComputeGaussPointPositions_45(Geometry< Node >& geom, BoundedMatrix<double, 45, 3 > & pos,BoundedMatrix<double, 45, 3 > &
N)
2225 for (
unsigned int i=0;
i!=9;
i++)
2227 for (
unsigned int j=0;
j!=(9-
i);
j++)
2243 void ComputeGaussPointPositions_initial(Geometry< Node >& geom, BoundedMatrix<double, 15, 3 > & pos,BoundedMatrix<double, 15, 3 > &
N)
2247 for (
unsigned int i=0;
i!=5;
i++)
2249 for (
unsigned int j=0;
j!=(5-
i);
j++)
2265 void ComputeGaussPointPositions_initial(Geometry< Node >& geom, BoundedMatrix<double, 20, 3 > & pos,BoundedMatrix<double, 20, 4 > &
N)
2269 double fraction_increment;
2271 for (
unsigned int i=0;
i!=4;
i++)
2274 for (
unsigned int j=0;
j!=(4-
i);
j++)
2277 for (
unsigned int k=0;
k!=(4-
i-
j);
k++)
2283 fraction_increment = 0.27;
2301 bool InvertMatrix(
const T&
input, T& inverse)
2303 typedef permutation_matrix<std::size_t> pmatrix;
2309 pmatrix pm(
A.size1());
2312 int res = lu_factorize(
A, pm);
2317 inverse.assign(identity_matrix<double> (
A.size1()));
2320 lu_substitute(
A, pm, inverse);
2325 bool InvertMatrix3x3(
const BoundedMatrix<double, TDim+1 , TDim+1 >&
A, BoundedMatrix<double, TDim+1 , TDim+1 >& result)
2327 double determinant = +
A(0,0)*(
A(1,1)*
A(2,2)-
A(2,1)*
A(1,2))
2328 -
A(0,1)*(
A(1,0)*
A(2,2)-
A(1,2)*
A(2,0))
2329 +
A(0,2)*(
A(1,0)*
A(2,1)-
A(1,1)*
A(2,0));
2330 double invdet = 1/determinant;
2331 result(0,0) = (
A(1,1)*
A(2,2)-
A(2,1)*
A(1,2))*invdet;
2332 result(1,0) = -(
A(0,1)*
A(2,2)-
A(0,2)*
A(2,1))*invdet;
2333 result(2,0) = (
A(0,1)*
A(1,2)-
A(0,2)*
A(1,1))*invdet;
2334 result(0,1) = -(
A(1,0)*
A(2,2)-
A(1,2)*
A(2,0))*invdet;
2335 result(1,1) = (
A(0,0)*
A(2,2)-
A(0,2)*
A(2,0))*invdet;
2336 result(2,1) = -(
A(0,0)*
A(1,2)-
A(1,0)*
A(0,2))*invdet;
2337 result(0,2) = (
A(1,0)*
A(2,1)-
A(2,0)*
A(1,1))*invdet;
2338 result(1,2) = -(
A(0,0)*
A(2,1)-
A(2,0)*
A(0,1))*invdet;
2339 result(2,2) = (
A(0,0)*
A(1,1)-
A(1,0)*
A(0,1))*invdet;
2348 if (rCurrentProcessInfo.Has(CONVECTION_DIFFUSION_SETTINGS)==
false)
2349 KRATOS_THROW_ERROR(std::logic_error,
"no CONVECTION_DIFFUSION_SETTINGS in model_part",
"");
2352 ConvectionDiffusionSettings::Pointer my_settings = rCurrentProcessInfo.GetValue(CONVECTION_DIFFUSION_SETTINGS);
2355 if(my_settings->IsDefinedUnknownVariable()==
true)
2357 if (mr_model_part.
NodesBegin()->SolutionStepsDataHas(my_settings->GetUnknownVariable()) ==
false)
2358 KRATOS_THROW_ERROR(std::logic_error,
"ConvDiffSettings: Unknown Variable defined but not contained in the model part",
"");
2361 KRATOS_THROW_ERROR(std::logic_error,
"ConvDiffSettings: Unknown Variable not defined!",
"");
2366 if(my_settings->IsDefinedProjectionVariable()==
true)
2368 if (mr_model_part.
NodesBegin()->SolutionStepsDataHas(my_settings->GetProjectionVariable()) ==
false)
2369 KRATOS_THROW_ERROR(std::logic_error,
"ConvDiffSettings: Projection Variable defined but not contained in the model part",
"");
2372 KRATOS_THROW_ERROR(std::logic_error,
"No Projection variable assigned for ConvDiff!",
"");
2384 if(my_settings->IsDefinedConvectionVariable()==
true)
2385 KRATOS_THROW_ERROR(std::logic_error,
"ConvDiffSettings: ConvectionVariable not used. Use VelocityVariable instead",
"");
2388 if(my_settings->IsDefinedVelocityVariable()==
true)
2390 if (mr_model_part.
NodesBegin()->SolutionStepsDataHas(my_settings->GetVelocityVariable()) ==
false)
2391 KRATOS_THROW_ERROR(std::logic_error,
"ConvDiffSettings: Velocity Variable defined but not contained in the model part",
"");
2394 KRATOS_THROW_ERROR(std::logic_error,
"No Velocity variable assigned for ConvDiff!",
"");
2396 if (mr_model_part.
NodesBegin()->SolutionStepsDataHas(MEAN_SIZE) ==
false)
2399 if (mr_model_part.
NodesBegin()->SolutionStepsDataHas(DELTA_SCALAR1) ==
false)
2400 KRATOS_THROW_ERROR(std::logic_error,
"Add DELTA_SCALAR1 variable to model part!",
"");
2417 double max_substep_dt;
2418 int mmaximum_number_of_particles;
2419 std::vector< Convection_Particle > mparticles_vector;
2422 bool mparticle_printing_tool_initialized;
2423 unsigned int mfilter_factor;
2424 unsigned int mlast_node_id;
2427 vector<int> mnumber_of_particles_in_elems;
2428 vector<int> mnumber_of_particles_in_elems_aux;
2430 vector<ParticlePointerVector> mvector_of_particle_pointers_vectors;
2432 typename BinsObjectDynamic<Configure>::Pointer mpBinsObjectDynamic;
2434 const Variable<double>& mUnknownVar;
2435 const Variable<double>& mProjectionVar;
2436 const Variable<array_1d<double,3> >& mVelocityVar;
2437 const Variable<array_1d<double,3> >& mMeshVelocityVar;
Short class definition.
Definition: bins_dynamic_objects.h:57
PFEM Particle class.
Definition: convection_particle.h:62
bool & GetEraseFlag()
Definition: convection_particle.h:111
float & GetScalar1()
Definition: convection_particle.h:106
Geometry base class.
Definition: geometry.h:71
virtual double Area() const
This method calculate and return area or surface area of this geometry depending to it's dimension.
Definition: geometry.h:1345
This class is a vector which stores global pointers.
Definition: global_pointers_vector.h:61
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: global_pointers_vector.h:79
iterator begin()
Definition: global_pointers_vector.h:221
size_type size() const
Definition: global_pointers_vector.h:307
void resize(size_type new_dim) const
Definition: global_pointers_vector.h:366
iterator end()
Definition: global_pointers_vector.h:229
Definition: amatrix_interface.h:41
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
NodeIterator NodesBegin(IndexType ThisIndex=0)
Definition: model_part.h:487
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
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
ElementsContainerType::ContainerType & ElementsArray(IndexType ThisIndex=0)
Definition: model_part.h:1209
Definition: move_particle_utility.h:65
PointerVector< Convection_Particle, Convection_Particle *, std::vector< Convection_Particle * > > ParticlePointerVector
Definition: move_particle_utility.h:77
void TransferLagrangianToEulerian()
Definition: move_particle_utility.h:591
void CopyScalarVarToPreviousTimeStep(const Variable< double > &OriginVariable, ModelPart::NodesContainerType &rNodes)
Definition: move_particle_utility.h:408
void MountBin(const double CellSize)
Definition: move_particle_utility.h:294
void MoveParticles()
Definition: move_particle_utility.h:435
Configure::ContainerType ContainerType
Definition: move_particle_utility.h:71
void ExecuteParticlesPritingTool(ModelPart &lagrangian_model_part, int input_filter_factor)
Definition: move_particle_utility.h:1289
void CorrectParticlesWithoutMovingUsingDeltaVariables()
Definition: move_particle_utility.h:943
Configure::PointType PointType
Definition: move_particle_utility.h:69
Configure::ResultIteratorType ResultIteratorType
Definition: move_particle_utility.h:76
void CalculateDeltaVariables()
Definition: move_particle_utility.h:382
void TransferLagrangianToEulerianImp()
Definition: move_particle_utility.h:755
void CalculateVelOverElemSize()
Definition: move_particle_utility.h:311
void AddUniqueWeakPointer(GlobalPointersVector< TDataType > &v, const typename TDataType::WeakPointer candidate)
Definition: move_particle_utility.h:1006
void ResetBoundaryConditions()
Definition: move_particle_utility.h:352
void PreReseed(int minimum_number_of_particles)
Definition: move_particle_utility.h:1024
Configure::IteratorType IteratorType
Definition: move_particle_utility.h:73
SpatialContainersConfigure< TDim > Configure
Definition: move_particle_utility.h:68
KRATOS_CLASS_POINTER_DEFINITION(MoveParticleUtilityScalarTransport)
MoveParticleUtilityScalarTransport(ModelPart &model_part, int maximum_number_of_particles)
Definition: move_particle_utility.h:87
void MountBin()
Definition: move_particle_utility.h:274
virtual ~MoveParticleUtilityScalarTransport()
Definition: move_particle_utility.h:271
void PostReseed(int minimum_number_of_particles)
Definition: move_particle_utility.h:1144
Configure::ResultContainerType ResultContainerType
Definition: move_particle_utility.h:74
static int ThisThread()
Wrapper for omp_get_thread_num().
Definition: openmp_utils.h:108
static int GetNumThreads()
Returns the current number of threads.
Definition: parallel_utilities.cpp:34
Point class.
Definition: point.h:59
CoordinatesArrayType const & Coordinates() const
Definition: point.h:215
double Y() const
Definition: point.h:187
double Z() const
Definition: point.h:193
double X() const
Definition: point.h:181
PointerVector is a container like stl vector but using a vector to store pointers to its data.
Definition: pointer_vector.h:72
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_INFO(label)
Definition: logger.h:250
Kratos::ModelPart ModelPart
Definition: kratos_wrapper.h:31
ProcessInfo & GetProcessInfo(ModelPart &rModelPart)
Definition: add_model_part_to_python.cpp:54
const Variable< double > & GetVelocityVariable()
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
KratosZeroMatrix< double > ZeroMatrix
Definition: amatrix_interface.h:559
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
TABLE_NUMBER_ANGULAR_VELOCITY TABLE_NUMBER_MOMENT I33 BEAM_INERTIA_ROT_UNIT_LENGHT_Y KRATOS_DEFINE_APPLICATION_VARIABLE(DEM_APPLICATION, double, BEAM_INERTIA_ROT_UNIT_LENGHT_Z) typedef std double
Definition: DEM_application_variables.h:182
ProcessInfo
Definition: edgebased_PureConvection.py:116
model_part
Definition: face_heat.py:14
res
Definition: generate_convection_diffusion_explicit_element.py:211
v
Definition: generate_convection_diffusion_explicit_element.py:114
input
Definition: generate_frictional_mortar_condition.py:435
x2
Definition: generate_frictional_mortar_condition.py:122
x1
Definition: generate_frictional_mortar_condition.py:121
threshold
Definition: isotropic_damage_automatic_differentiation.py:135
lagrangian_model_part
Definition: lagrangian_droplet_test.py:45
int d
Definition: ode_solve.py:397
vel
Definition: pure_conduction.py:76
int k
Definition: quadrature.py:595
int j
Definition: quadrature.py:648
int node_id
Definition: read_stl.py:12
float xc
Definition: rotating_cone.py:77
float yc
Definition: rotating_cone.py:78
float delta_t
Definition: rotatingcone_PureConvectionBenchmarking.py:129
int counter
Definition: script_THERMAL_CORRECT.py:218
A
Definition: sensitivityMatrix.py:70
N
Definition: sensitivityMatrix.py:29
integer i
Definition: TensorModule.f:17
integer l
Definition: TensorModule.f:17
e
Definition: run_cpp_mpi_tests.py:31
Configure::ResultIteratorType ResultIteratorType
Definition: transfer_utility.h:252