80 template<
unsigned int TDim,
bool CounterHasHistory=false >
86 const double SearchTolerance=1
e-5
92 if constexpr (CounterHasHistory)
93 rNode.FastGetSolutionStepValue(rCounterVariable) = 0.0;
95 rNode.SetValue(rCounterVariable,0.0);
99 unsigned int max_results = 10000;
103 block_for_each(rParticlesModelPart.
Nodes(), TLS, [&rLocator, &rCounterVariable, SearchTolerance](
const auto& rNode,
auto& rTLS)
106 Vector shape_functions;
107 Element::Pointer p_element;
108 const bool is_found = rLocator.FindPointOnMesh(rNode.Coordinates(), shape_functions, p_element, rTLS.begin(), rTLS.size(), SearchTolerance);
113 auto& r_geom = p_element->GetGeometry();
114 for(unsigned int i=0; i<r_geom.size(); ++i)
116 if constexpr (CounterHasHistory)
118 auto& rcounter = r_geom[i].FastGetSolutionStepValue(rCounterVariable);
119 AtomicAdd(rcounter, 1.0);
123 auto& rcounter = r_geom[i].GetValue(rCounterVariable);
124 AtomicAdd(rcounter, 1.0);
143 template<
unsigned int TDim,
class TScalarType,
bool ParticleTypeVariableHasHistory=false>
148 const int NumberOfTypes,
151 const double SearchTolerance=1
e-5
157 rElement.SetValue(rClassificationVectorVariable,zero);
161 unsigned int max_results = 10000;
168 [&rLocator, &rParticleTypeVariable, &rClassificationVectorVariable, &NumberOfTypes, SearchTolerance]
169 (
const auto& rNode,
auto& rTLS)
171 auto& results = rTLS.first;
172 Vector& shape_functions = rTLS.second;
173 Element::Pointer p_element;
174 const bool is_found = rLocator.FindPointOnMesh(rNode.Coordinates(), shape_functions, p_element, results.begin(), results.size(), SearchTolerance);
179 if constexpr (ParticleTypeVariableHasHistory)
180 particle_type = static_cast<int>(rNode.FastGetSolutionStepValue(rParticleTypeVariable));
182 particle_type = static_cast<int>(rNode.GetValue(rParticleTypeVariable));
184 if(particle_type>=0 && particle_type<NumberOfTypes)
186 auto& rclassification = p_element->GetValue(rClassificationVectorVariable);
187 AtomicAdd(rclassification[particle_type], 1.0);
201 template<
unsigned int TDim,
class TDataType,
bool VariableHasHistory >
206 const TDataType& OutsiderValue,
207 const double SearchTolerance=1
e-5
210 unsigned int max_results = 10000;
214 block_for_each(rParticlesModelPart.
Nodes(), TLS, [&rLocator, &rVariable, &OutsiderValue, SearchTolerance](
auto& rNode,
auto& rTLS)
217 Vector shape_functions;
218 Element::Pointer p_element;
219 const bool is_found = rLocator.FindPointOnMesh(rNode.Coordinates(), shape_functions, p_element, rTLS.begin(), rTLS.size(), SearchTolerance);
223 if constexpr (VariableHasHistory)
224 rNode.FastGetSolutionStepValue(rVariable) = OutsiderValue;
226 rNode.SetValue(rVariable, OutsiderValue);
242 template<
unsigned int TDim,
class TDataType,
bool InterpolationVariableHasHistory>
245 const Matrix& rCoordinates,
247 const double SearchTolerance
250 unsigned int max_results = 10000;
253 auto interpolations = std::make_pair(
DenseVector<bool>(rCoordinates.size1()), std::vector<TDataType>(rCoordinates.size1()));
256 const auto zero = rInterpolationVariable.
Zero();
257 IndexPartition(rCoordinates.size1()).
for_each(TLS, [&rLocator, &rCoordinates, &interpolations, &rInterpolationVariable, &
zero, SearchTolerance](
const auto&
i,
auto& rTLS)
260 Element::Pointer p_element;
261 const bool is_found = rLocator.FindPointOnMesh(
row(rCoordinates,
i), shape_functions, p_element, rTLS.
begin(), rTLS.size(), SearchTolerance);
263 (interpolations.first)[
i] = is_found;
266 auto& r_geom = p_element->GetGeometry();
267 (interpolations.second)[i] = zero;
268 for(unsigned int k=0; k<r_geom.size(); ++k)
270 if constexpr (InterpolationVariableHasHistory)
271 (interpolations.second)[i] += shape_functions[k]*r_geom[k].FastGetSolutionStepValue(rInterpolationVariable);
273 (interpolations.second)[i] += shape_functions[k]*r_geom[k].GetValue(rInterpolationVariable);
279 return interpolations;
305 return std::string(
"ParticlesUtilities");
378 rOStream << std::endl;
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
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::ResultContainerType ResultContainerType
Definition: binbased_fast_point_locator.h:81
This class is useful for index iteration over containers.
Definition: parallel_utilities.h:451
void for_each(TUnaryFunction &&f)
Definition: parallel_utilities.h:514
iterator begin()
Definition: amatrix_interface.h:241
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
ElementsContainerType & Elements(IndexType ThisIndex=0)
Definition: model_part.h:1189
NodesContainerType & Nodes(IndexType ThisIndex=0)
Definition: model_part.h:507
Collection of utilities to compute statistic of particles.
Definition: particles_utilities.h:57
void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: particles_utilities.h:309
static void MarkOutsiderParticles(BinBasedFastPointLocator< TDim > &rLocator, ModelPart &rParticlesModelPart, const Variable< TDataType > &rVariable, const TDataType &OutsiderValue, const double SearchTolerance=1e-5)
: this function looks if particle is found in the locator. If it is not, "rVariable" is marked with t...
Definition: particles_utilities.h:202
static void ClassifyParticlesInElements(BinBasedFastPointLocator< TDim > &rLocator, ModelPart &rVolumeModelPart, const ModelPart &rParticlesModelPart, const int NumberOfTypes, const Variable< TScalarType > &rParticleTypeVariable=AUX_INDEX, const Variable< Vector > &rClassificationVectorVariable=MARKER_LABELS, const double SearchTolerance=1e-5)
: this function takes all the nodes in rParticlesModelPart and finds in which element they fall withi...
Definition: particles_utilities.h:144
KRATOS_CLASS_POINTER_DEFINITION(ParticlesUtilities)
Pointer definition of ParticlesUtilities.
static std::pair< DenseVector< bool >, std::vector< TDataType > > InterpolateValuesAtCoordinates(BinBasedFastPointLocator< TDim > &rLocator, const Matrix &rCoordinates, const Variable< TDataType > &rInterpolationVariable, const double SearchTolerance)
This function takes a matrix of coordinates and gives the intrpolated value of the variable rInterpol...
Definition: particles_utilities.h:243
ParticlesUtilities()=delete
Default constructor.
void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: particles_utilities.h:312
static void CountParticlesInNodes(BinBasedFastPointLocator< TDim > &rLocator, ModelPart &rVolumeModelPart, const ModelPart &rParticlesModelPart, const Variable< double > &rCounterVariable, const double SearchTolerance=1e-5)
: this function takes all the nodes in rParticlesModelPart and finds in which element they fall withi...
Definition: particles_utilities.h:81
std::string Info() const
Turn back information as a string.
Definition: particles_utilities.h:303
const TDataType & Zero() const
This method returns the zero value of the variable type.
Definition: variable.h:346
std::ostream & operator<<(std::ostream &rOStream, const ParticlesUtilities &rThis)
output stream function
Definition: particles_utilities.h:374
std::istream & operator>>(std::istream &rIStream, ParticlesUtilities &rThis)
input stream function
Definition: particles_utilities.h:367
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
KratosZeroVector< double > ZeroVector
Definition: amatrix_interface.h:561
Internals::Matrix< double, AMatrix::dynamic, 1 > Vector
Definition: amatrix_interface.h:472
void block_for_each(TIterator itBegin, TIterator itEnd, TFunction &&rFunction)
Execute a functor on all items of a range in parallel.
Definition: parallel_utilities.h:299
AMatrix::MatrixRow< const TExpressionType > row(AMatrix::MatrixExpression< TExpressionType, TCategory > const &TheExpression, std::size_t RowIndex)
Definition: amatrix_interface.h:649
integer i
Definition: TensorModule.f:17
zero
Definition: test_pureconvectionsolver_benchmarking.py:94
e
Definition: run_cpp_mpi_tests.py:31