9 #if !defined(KRATOS_DEM_FEM_SEARCH_H_INCLUDED )
10 #define KRATOS_DEM_FEM_SEARCH_H_INCLUDED
123 int MaxNumberOfElements = rConditions.size();
133 std::vector<unsigned int> total_fem_partition_index;
134 OpenMPUtils::CreatePartition(num_of_threads, conditions_bins.size(), total_fem_partition_index);
137 std::vector<GeometricalObjectType::ContainerType> Vector_BinsConditionPointerToGeometricalObjecPointerTemporalVector(num_of_threads);
139 std::vector<array_1d<double, 3> > Vector_DEM_BB_LowPoint(num_of_threads); std::vector <array_1d<double, 3 > > Vector_DEM_BB_HighPoint(num_of_threads);
140 std::vector<array_1d<double, 3> > Vector_GLOBAL_BB_LowPoint(num_of_threads); std::vector <array_1d<double, 3 > > Vector_GLOBAL_BB_HighPoint(num_of_threads);
142 std::vector<double> Vector_Ref_Radius(num_of_threads);
143 std::vector<RadiusArrayType> Vector_Radius_out(num_of_threads);
145 double Global_Ref_Radius = 0.0;
146 double inf = std::numeric_limits<double>::infinity();
148 for (std::size_t
i = 0;
i < 3;
i++) {
149 DEM_BB_LowPoint[
i] = inf;
150 DEM_BB_HighPoint[
i] = -inf;
152 mGlobal_BB_LowPoint[
i] = inf;
153 mGlobal_BB_HighPoint[
i] = -inf;
156 typedef ElementsContainerType::ContainerType::iterator Elem_iter;
157 typedef ConditionsContainerType::ContainerType::iterator Cond_iter;
166 for(std::size_t
i = 0;
i < 3;
i++) {
167 Vector_DEM_BB_LowPoint[
k][
i] = inf;
168 Vector_DEM_BB_HighPoint[
k][
i] = -inf;
172 for (
int p = 0;
p <(
int) elements_sear.size();
p++) {
174 Elem_iter it = elements_sear.begin() +
p;
181 Vector_Ref_Radius[
k] = (Vector_Ref_Radius[
k] <
radius) ?
radius : Vector_Ref_Radius[
k] ;
183 for(std::size_t
i = 0;
i < 3;
i++) {
184 Vector_DEM_BB_LowPoint[
k][
i] = (Vector_DEM_BB_LowPoint[
k][
i] > aux_coor[
i]) ? aux_coor[
i] : Vector_DEM_BB_LowPoint[
k][
i];
185 Vector_DEM_BB_HighPoint[
k][
i] = (Vector_DEM_BB_HighPoint[
k][
i] < aux_coor[
i]) ? aux_coor[
i] : Vector_DEM_BB_HighPoint[
k][
i];
192 for(
int k = 0;
k < num_of_threads;
k++) {
193 for(std::size_t
i = 0;
i < 3;
i++) {
194 DEM_BB_LowPoint[
i] = (DEM_BB_LowPoint[
i] > Vector_DEM_BB_LowPoint[
k][
i]) ? Vector_DEM_BB_LowPoint[
k][
i] : DEM_BB_LowPoint[
i];
195 DEM_BB_HighPoint[
i] = (DEM_BB_HighPoint[
i] < Vector_DEM_BB_HighPoint[
k][
i]) ? Vector_DEM_BB_HighPoint[
k][
i] : DEM_BB_HighPoint[
i];
198 Global_Ref_Radius = (Global_Ref_Radius < Vector_Ref_Radius[
k]) ? Vector_Ref_Radius[
k] : Global_Ref_Radius;
201 for(std::size_t
i = 0;
i < 3;
i++) {
202 DEM_BB_LowPoint[
i] -= 1.00f * Global_Ref_Radius;
203 DEM_BB_HighPoint[
i] += 1.00f * Global_Ref_Radius;
212 Vector_BinsConditionPointerToGeometricalObjecPointerTemporalVector[
k].reserve(total_fem_partition_index[
k+1]);
214 for(std::size_t
i = 0;
i < 3;
i++) {
215 Vector_GLOBAL_BB_LowPoint[
k][
i] = inf;
216 Vector_GLOBAL_BB_HighPoint[
k][
i] = -inf;
222 #pragma omp for private(rHighPoint,rLowPoint)
223 for (
int c = 0;
c < (
int)conditions_bins.size();
c++) {
225 Cond_iter it = conditions_bins.
begin() +
c;
228 noalias(rLowPoint) = pGeometry[0];
229 noalias(rHighPoint) = pGeometry[0];
231 for(
unsigned int point = 1; point < pGeometry.
size(); point++ ) {
232 for(
unsigned int i = 0;
i < 3;
i++ ) {
233 rHighPoint[
i] = ( rHighPoint[
i] < pGeometry[point][
i] ) ? pGeometry[point][
i] : rHighPoint[
i];
234 rLowPoint[
i] = ( rLowPoint[
i] > pGeometry[point][
i] ) ? pGeometry[point][
i] : rLowPoint[
i];
240 for(
unsigned int i = 0;
i < 3;
i++) {
241 if(( rHighPoint[
i] < DEM_BB_LowPoint[
i] ) || ( rLowPoint[
i] > DEM_BB_HighPoint[
i] )) {
248 for(
unsigned int i = 0;
i < 3;
i++ ) {
249 Vector_GLOBAL_BB_LowPoint[
k][
i] = (Vector_GLOBAL_BB_LowPoint[
k][
i] > rLowPoint[
i]) ? rLowPoint[
i] : Vector_GLOBAL_BB_LowPoint[
k][
i];
250 Vector_GLOBAL_BB_HighPoint[
k][
i] = (Vector_GLOBAL_BB_HighPoint[
k][
i] < rHighPoint[
i]) ? rHighPoint[
i] : Vector_GLOBAL_BB_HighPoint[
k][
i];
252 Vector_BinsConditionPointerToGeometricalObjecPointerTemporalVector[
k].push_back(*it);
259 int fem_total_size = 0;
260 for(
int k = 0;
k < num_of_threads;
k++) {
261 fem_total_size += Vector_BinsConditionPointerToGeometricalObjecPointerTemporalVector[
k].
size();
264 BinsConditionPointerToGeometricalObjecPointerTemporalVector.reserve(fem_total_size);
266 for(
int k = 0;
k < num_of_threads;
k++) {
267 BinsConditionPointerToGeometricalObjecPointerTemporalVector.insert(
268 BinsConditionPointerToGeometricalObjecPointerTemporalVector.end(),
269 Vector_BinsConditionPointerToGeometricalObjecPointerTemporalVector[
k].begin(),
270 Vector_BinsConditionPointerToGeometricalObjecPointerTemporalVector[
k].end()
273 for(std::size_t
i = 0;
i < 3;
i++) {
274 mGlobal_BB_LowPoint[
i] = (mGlobal_BB_LowPoint[
i] > Vector_GLOBAL_BB_LowPoint[
k][
i]) ? Vector_GLOBAL_BB_LowPoint[
k][
i] : mGlobal_BB_LowPoint[
i];
275 mGlobal_BB_HighPoint[
i] = (mGlobal_BB_HighPoint[
i] < Vector_GLOBAL_BB_HighPoint[
k][
i]) ? Vector_GLOBAL_BB_HighPoint[
k][
i] : mGlobal_BB_HighPoint[
i];
279 if(BinsConditionPointerToGeometricalObjecPointerTemporalVector.size() >0 ) {
285 mBins =
new GeometricalBinsType(BinsConditionPointerToGeometricalObjecPointerTemporalVector.begin(), BinsConditionPointerToGeometricalObjecPointerTemporalVector.end());
292 DistanceType localResultsDistances(MaxNumberOfElements);
293 std::size_t NumberOfResults = 0;
295 #pragma omp for schedule(dynamic, 100)
296 for (
int p = 0;
p < (
int)elements_sear.size();
p++) {
298 Elem_iter it = elements_sear.begin() +
p;
300 GeometricalObject::Pointer go_it(*it);
301 bool search_particle =
true;
308 for(
unsigned int i = 0;
i < 3;
i++ ) {
309 search_particle &= !(aux_coor[
i] < (mGlobal_BB_LowPoint[
i] - Rad) ) || (aux_coor[
i] > (mGlobal_BB_HighPoint[
i] + Rad) );
312 if(search_particle) {
314 auto ResultsPointer = localResults.begin();
315 DistanceType::iterator ResultsDistancesPointer = localResultsDistances.begin();
317 NumberOfResults = (*mBins).SearchObjectsInRadiusExclusive(go_it,Rad,ResultsPointer,ResultsDistancesPointer,MaxNumberOfElements);
319 rResults[
p].reserve(NumberOfResults);
321 for(
auto c_it = localResults.begin(); c_it != localResults.begin() + NumberOfResults; c_it++) {
322 auto presult = *c_it;
323 Condition::Pointer condition = dynamic_pointer_cast<Condition>(presult);
325 rResults[
p].push_back(condition);
328 rResultsDistance[
p].insert(rResultsDistance[
p].begin(),localResultsDistances.begin(),localResultsDistances.begin()+NumberOfResults);
342 return (mGlobal_BB_HighPoint);
345 return (mGlobal_BB_LowPoint);
349 virtual std::string
Info()
const override
351 std::stringstream buffer;
352 buffer <<
"DEM_FEM_Search" ;
358 virtual void PrintInfo(std::ostream& rOStream)
const override {rOStream <<
"DEM_FEM_Search";}
361 virtual void PrintData(std::ostream& rOStream)
const override {}
415 GeometricalBinsType* mBins;
460 DEM_FEM_Search(DEM_FEM_Search
const& rOther)
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Short class definition.
Definition: bins_dynamic_objects.h:57
Short class definition.
Definition: dem_fem_search.h:55
double * DistanceIterator
Definition: dem_fem_search.h:68
PointType * PtrPointType
Definition: dem_fem_search.h:63
std::vector< PtrPointType > * PointVector
Definition: dem_fem_search.h:64
BinsObjectDynamic< RigidFaceGeometricalConfigureType > GeometricalBinsType
Definition: dem_fem_search.h:78
~DEM_FEM_Search()
Destructor.
Definition: dem_fem_search.h:97
DEM_FEM_Search()
Default constructor.
Definition: dem_fem_search.h:90
void SearchRigidFaceForDEMInRadiusExclusiveImplementation(ElementsContainerType const &rElements, ConditionsContainerType const &rConditions, VectorResultConditionsContainerType &rResults, VectorDistanceType &rResultsDistance)
Definition: dem_fem_search.h:101
array_1d< double, 3 > GetBBLowPoint()
Definition: dem_fem_search.h:344
virtual void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: dem_fem_search.h:358
RigidFaceGeometricalObjectConfigure< 3 > RigidFaceGeometricalConfigureType
Definition: dem_fem_search.h:76
double * DistanceVector
Definition: dem_fem_search.h:67
KRATOS_CLASS_POINTER_DEFINITION(DEM_FEM_Search)
Pointer definition of OMP_DEMSearch.
virtual void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: dem_fem_search.h:361
std::vector< PtrPointType >::iterator PointIterator
Definition: dem_fem_search.h:65
array_1d< double, 3 > GetBBHighPoint()
Definition: dem_fem_search.h:341
virtual std::string Info() const override
Turn back information as a string.
Definition: dem_fem_search.h:349
RigidFaceGeometricalConfigureType::ElementsContainerType GeometricalObjectType
Definition: dem_fem_search.h:80
Geometry base class.
Definition: geometry.h:71
SizeType size() const
Definition: geometry.h:518
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
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
TContainerType ContainerType
Definition: pointer_vector_set.h:90
This class is used to search for elements, conditions and nodes in a given model part.
Definition: spatial_search.h:50
std::vector< ResultConditionsContainerType > VectorResultConditionsContainerType
Definition: spatial_search.h:92
std::vector< double > RadiusArrayType
Input/output types.
Definition: spatial_search.h:95
std::vector< DistanceType > VectorDistanceType
Definition: spatial_search.h:97
ModelPart::ElementsContainerType ElementsContainerType
Elements classes.
Definition: spatial_search.h:85
ModelPart::ConditionsContainerType ConditionsContainerType
Conditions classes.
Definition: spatial_search.h:90
std::vector< double > DistanceType
Definition: spatial_search.h:96
Definition: spheric_particle.h:31
virtual double GetSearchRadius()
Definition: spheric_particle.cpp:2201
BOOST_UBLAS_INLINE size_type size() const
Definition: array_1d.h:370
BOOST_UBLAS_INLINE const_iterator begin() const
Definition: array_1d.h:606
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
T & noalias(T &TheMatrix)
Definition: amatrix_interface.h:484
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
c
Definition: generate_weakly_compressible_navier_stokes_element.py:108
float radius
Definition: mesh_to_mdpa_converter.py:18
int k
Definition: quadrature.py:595
p
Definition: sensitivityMatrix.py:52
integer i
Definition: TensorModule.f:17
Configure::ContainerType ContainerType
Definition: transfer_utility.h:247