14 #if !defined(KRATOS_CONVECT_PARTICLES_UTILITIES_INCLUDED )
15 #define KRATOS_CONVECT_PARTICLES_UTILITIES_INCLUDED
17 #define PRESSURE_ON_EULERIAN_MESH
18 #define USE_FEW_PARTICLES
34 #include "utilities/geometry_utilities.h"
51 : mpSearchStructure(pSearchStructure)
71 const double small_dt =
dt/
static_cast<double>(subdivisions);
77 const int max_results = rModelPart.
Nodes().size();
81 const int nparticles = rModelPart.
Nodes().size();
83 #pragma omp parallel for firstprivate(results,N,veulerian,acc_particle)
84 for (
int i = 0;
i < nparticles;
i++)
86 unsigned int substep = 0;
89 Node ::Pointer pparticle = *(iparticle.base());
91 array_1d<double,3> current_position = iparticle->GetInitialPosition() + iparticle->FastGetSolutionStepValue(DISPLACEMENT,1);
93 Element::Pointer pelement;
94 bool is_found =
false;
98 while(substep++ < subdivisions)
109 is_found = geom.
IsInside(current_position, aux_point_local_coordinates, 1.0e-5);
112 if(is_found ==
false)
113 is_found = mpSearchStructure->FindPointOnMesh(current_position,
N, pelement, result_begin, max_results);
117 is_found = mpSearchStructure->FindPointOnMesh(current_position,
N, pelement, result_begin, max_results);
120 (iparticle)->Set(TO_ERASE,
true);
122 if (is_found ==
true)
126 const double new_step_factor =
static_cast<double>(substep)/subdivisions;
127 const double old_step_factor = 1.0 - new_step_factor;
129 noalias(veulerian) =
N[0] * ( new_step_factor*geom[0].FastGetSolutionStepValue(VELOCITY) + old_step_factor*geom[0].FastGetSolutionStepValue(VELOCITY,1));
130 for (
unsigned int k = 1;
k < geom.
size();
k++)
131 noalias(veulerian) +=
N[
k] * ( new_step_factor*geom[
k].FastGetSolutionStepValue(VELOCITY) + old_step_factor*geom[
k].FastGetSolutionStepValue(VELOCITY,1) );
132 noalias(current_position) += small_dt*veulerian;
134 (iparticle)->Set(TO_ERASE,
false);
143 if (is_found ==
true)
147 iparticle->FastGetSolutionStepValue(DISPLACEMENT) = current_position - iparticle->GetInitialPosition();
148 noalias(pparticle->Coordinates()) = current_position;
169 const int max_results = 10000;
172 const int nparticles = rModelPart.
Nodes().size();
174 #pragma omp parallel for firstprivate(results,N,v1,v2,v3,v4,vtot,x)
175 for (
int i = 0;
i < nparticles;
i++)
180 Node ::Pointer pparticle = *(iparticle.base());
182 array_1d<double,3> initial_position = iparticle->GetInitialPosition() + iparticle->FastGetSolutionStepValue(DISPLACEMENT,1);
184 Element::Pointer pelement;
185 bool is_found =
false;
188 is_found = mpSearchStructure->FindPointOnMesh(initial_position,
N, pelement, result_begin, max_results);
189 if( is_found ==
false)
goto end_of_particle;
191 noalias(v1) =
N[0] * ( geom[0].FastGetSolutionStepValue(VELOCITY,1));
192 for (
unsigned int k = 1;
k < geom.
size();
k++)
193 noalias(v1) +=
N[
k] * ( geom[
k].FastGetSolutionStepValue(VELOCITY,1) );
200 is_found = mpSearchStructure->FindPointOnMesh(
x,
N, pelement, result_begin, max_results);
201 if( is_found ==
false)
goto end_of_particle;
203 const double new_step_factor = 0.5;
204 const double old_step_factor = 0.5;
206 noalias(v2) =
N[0] * ( new_step_factor*geom[0].FastGetSolutionStepValue(VELOCITY) + old_step_factor*geom[0].FastGetSolutionStepValue(VELOCITY,1));
207 for (
unsigned int k = 1;
k < geom.
size();
k++)
208 noalias(v2) +=
N[
k] * ( new_step_factor*geom[
k].FastGetSolutionStepValue(VELOCITY) + old_step_factor*geom[
k].FastGetSolutionStepValue(VELOCITY,1) );
215 is_found = mpSearchStructure->FindPointOnMesh(
x,
N, pelement, result_begin, max_results);
216 if( is_found ==
false)
goto end_of_particle;
218 const double new_step_factor = 0.5;
219 const double old_step_factor = 0.5;
221 noalias(v3) =
N[0] * ( new_step_factor*geom[0].FastGetSolutionStepValue(VELOCITY) + old_step_factor*geom[0].FastGetSolutionStepValue(VELOCITY,1));
222 for (
unsigned int k = 1;
k < geom.
size();
k++)
223 noalias(v3) +=
N[
k] * ( new_step_factor*geom[
k].FastGetSolutionStepValue(VELOCITY) + old_step_factor*geom[
k].FastGetSolutionStepValue(VELOCITY,1) );
230 is_found = mpSearchStructure->FindPointOnMesh(
x,
N, pelement, result_begin, max_results);
231 if( is_found ==
false)
goto end_of_particle;
233 noalias(v4) =
N[0] * ( geom[0].FastGetSolutionStepValue(VELOCITY));
234 for (
unsigned int k = 1;
k < geom.
size();
k++)
235 noalias(v4) +=
N[
k] * ( geom[
k].FastGetSolutionStepValue(VELOCITY) );
239 (iparticle)->Set(TO_ERASE,
false);
242 noalias(
x) += 0.16666666666666666666667*
dt*v1;
243 noalias(
x) += 0.33333333333333333333333*
dt*v2;
244 noalias(
x) += 0.33333333333333333333333*
dt*v3;
245 noalias(
x) += 0.16666666666666666666667*
dt*v4;
247 iparticle->FastGetSolutionStepValue(DISPLACEMENT) =
x - iparticle->GetInitialPosition();
248 noalias(pparticle->Coordinates()) =
x;
250 end_of_particle: (iparticle)->Set(TO_ERASE,
true);
270 for(
unsigned int i=0;
i<geom.
size();
i++)
272 if(geom[
i].Is(TO_ERASE))
274 it->Set(TO_ERASE,
true);
284 temp_elems_container.
reserve(rModelPart.
Elements().size() - nerased_el);
290 if( it->IsNot(TO_ERASE) )
291 (rModelPart.
Elements()).push_back(*(it.base()));
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
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
const Matrix & ShapeFunctionsValues() const
Definition: geometry.h:3393
virtual bool IsInside(const CoordinatesArrayType &rPointGlobalCoordinates, CoordinatesArrayType &rResult, const double Tolerance=std::numeric_limits< double >::epsilon()) const
Checks if given point in global space coordinates is inside the geometry boundaries....
Definition: geometry.h:1918
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
ElementIterator ElementsEnd(IndexType ThisIndex=0)
Definition: model_part.h:1179
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
Definition: convect_particles_utilities.h:46
~ParticleConvectUtily()
Definition: convect_particles_utilities.h:55
KRATOS_CLASS_POINTER_DEFINITION(ParticleConvectUtily< TDim >)
void MoveParticles_RK4(ModelPart &rModelPart)
Definition: convect_particles_utilities.h:161
void MoveParticles_Substepping(ModelPart &rModelPart, unsigned int subdivisions)
Definition: convect_particles_utilities.h:67
void EraseOuterElements(ModelPart &rModelPart)
Definition: convect_particles_utilities.h:261
ParticleConvectUtily(typename BinBasedFastPointLocator< TDim >::Pointer pSearchStructure)
Definition: convect_particles_utilities.h:50
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data...
Definition: pointer_vector_set.h:72
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector_set.h:95
void swap(PointerVectorSet &rOther)
Swaps the contents of this PointerVectorSet with another.
Definition: pointer_vector_set.h:532
iterator begin()
Returns an iterator pointing to the beginning of the container.
Definition: pointer_vector_set.h:278
void reserve(int reservedsize)
Reserves memory for a specified number of elements.
Definition: pointer_vector_set.h:733
iterator end()
Returns an iterator pointing to the end of the container.
Definition: pointer_vector_set.h:314
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
dt
Definition: DEM_benchmarks.py:173
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
int k
Definition: quadrature.py:595
N
Definition: sensitivityMatrix.py:29
x
Definition: sensitivityMatrix.py:49
integer i
Definition: TensorModule.f:17