11 #if !defined(KRATOS_MPI_NEIGHBOURS_CALCULATOR )
12 #define KRATOS_MPI_NEIGHBOURS_CALCULATOR
24 #include "custom_utilities/neighbours_calculator.h"
26 #include "../applications/mpi_search_application/custom_utilities/bins_dynamic_objects_mpi.h"
27 #include "../applications/mpi_search_application/custom_utilities/morton_parallel_partitioner.h"
71 typedef BinsObjectDynamicMpi <ConfigureType>
Bins;
72 typedef MortonParallelPartitioner <ConfigureType>
Part;
89 double radius_extend = 0.0;
90 if (extension_option) radius_extend = rCurrentProcessInfo[SEARCH_RADIUS_EXTENSION];
92 static double MaxNodeRadius = 0.0f;
93 if(std::abs(MaxNodeRadius) < std::numeric_limits<double>::epsilon())
94 for (
IteratorType particle_pointer_it = pLocalElements.begin(); particle_pointer_it != pLocalElements.end(); ++particle_pointer_it)
96 double NodeRaidus = (1.0 + radius_extend) * (*particle_pointer_it)->GetGeometry()[0].GetSolutionStepValue(RADIUS);
97 MaxNodeRadius = NodeRaidus > MaxNodeRadius ? NodeRaidus : MaxNodeRadius;
100 static Part partitioner;
101 partitioner.LloydsBasedPartitioner(r_model_part,MaxNodeRadius,CalculateBoundary);
114 int destination = -1;
116 bool IsInGhostMesh =
false;
119 for(
int i = 0;
i < NumberOfRanks;
i++)
120 if((*neighbour_it)->GetGeometry()[0].GetSolutionStepValue(PARTITION_INDEX) == communicator_ranks[
i])
125 for(
IteratorType element_it = pGhostElements.begin(); !IsInGhostMesh && element_it != pGhostElements.end(); ++element_it)
126 if((*element_it)->GetGeometry()[0].Id() == (*neighbour_it)->GetGeometry()[0].Id())
127 IsInGhostMesh =
true;
139 IsInGhostMesh =
false;
145 for(
IteratorType element_it = pMyGhostElements.begin(); !IsInGhostMesh && element_it != pMyGhostElements.end(); ++element_it)
146 if((*element_it)->GetGeometry()[0].Id() == (*neighbour_it)->GetGeometry()[0].Id())
147 IsInGhostMesh =
true;
179 for(
unsigned int i = 0;
i < NumberOfRanks;
i++)
197 for (
unsigned int i = 0;
i < r_model_part.
GetCommunicator().LocalMeshes().size();
i++)
200 for (
unsigned int i = 0;
i < r_model_part.
GetCommunicator().GhostMeshes().size();
i++)
211 int NumberOfElements,
212 int MaximumNumberOfResults,
213 std::vector<std::size_t> &NumberOfResults,
214 std::vector<std::vector<PointerType> > &Results,
215 std::vector<std::vector<double> > &ResultsDistances,
216 std::vector<double> &Radius
219 Bins particle_bin(pIteratorElements.begin(), pIteratorElements.end());
220 particle_bin.SearchObjectsMpi(r_model_part,pIteratorElements.
begin(),NumberOfElements,Radius,Results,ResultsDistances,NumberOfResults,MaximumNumberOfResults,r_model_part.
pGetCommunicator());
228 inline void Clear(ModelPart::NodesContainerType::iterator node_it,
int step_data_size) {
229 unsigned int buffer_size = node_it->GetBufferSize();
230 for (
unsigned int step = 0;
step < buffer_size;
step++) {
232 double* step_data = (node_it)->SolutionStepData().Data(
step);
234 for (
int j = 0;
j < step_data_size;
j++) {
242 inline void ClearVariables(ModelPart::NodesContainerType::iterator node_it, Variable<array_1d<double, 3 > >& rVariable) {
249 inline void ClearVariables(
ParticleIterator particle_it, Variable<double>& rVariable) {
256 Mpi_Neighbours_Calculator & operator=(Mpi_Neighbours_Calculator
const& rOther);
NeighbourIndicesContainerType & NeighbourIndices()
Definition: communicator.cpp:162
MeshType & GhostMesh()
Returns the reference to the mesh storing all ghost entities.
Definition: communicator.cpp:251
SizeType GetNumberOfColors() const
Definition: communicator.cpp:121
MeshType & LocalMesh()
Returns the reference to the mesh storing all local entities.
Definition: communicator.cpp:245
iterator begin()
Iterator pointing to the beginning of the container.
Definition: data_value_container.h:209
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: global_pointers_vector.h:79
typename TContainerType::iterator ptr_iterator
Definition: global_pointers_vector.h:85
Definition: amatrix_interface.h:41
NodesContainerType & Nodes()
Definition: mesh.h:346
ElementsContainerType::ContainerType & ElementsArray()
Definition: mesh.h:588
ElementsContainerType & Elements()
Definition: mesh.h:568
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
Communicator & GetCommunicator()
Definition: model_part.h:1821
Communicator::Pointer pGetCommunicator()
Definition: model_part.h:1831
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
Definition: mpi_neighbours_calculator.h:35
ConfigureType::IteratorContactType IteratorContactType
Definition: mpi_neighbours_calculator.h:57
ConfigureType::ContainerType ContainerType
Definition: mpi_neighbours_calculator.h:49
DistanceVector::iterator DistanceIterator
Definition: mpi_neighbours_calculator.h:66
ConfigureType::ResultContainerType ResultContainerType
Definition: mpi_neighbours_calculator.h:52
ConfigureType::ResultIteratorType ResultIteratorType
Definition: mpi_neighbours_calculator.h:54
virtual void Add_To_Modelpart(ModelPart &r_model_part, ResultIteratorType neighbour_it)
Definition: mpi_neighbours_calculator.h:106
virtual void Clean_Modelpart(ModelPart &r_model_part)
Definition: mpi_neighbours_calculator.h:167
ParticlePointerVector::iterator ParticlePointerIterator
Definition: mpi_neighbours_calculator.h:45
virtual ContainerType & Get_Elements(ModelPart &r_model_part)
Definition: mpi_neighbours_calculator.h:204
ConfigureType::PointerContactType PointerContactType
Definition: mpi_neighbours_calculator.h:58
ConfigureType::PointType PointType
Definition: mpi_neighbours_calculator.h:47
MpiDiscreteParticleConfigure< 3 > ConfigureType
Definition: mpi_neighbours_calculator.h:37
ConfigureType::PointerType PointerType
Definition: mpi_neighbours_calculator.h:50
MortonParallelPartitioner< ConfigureType > Part
Definition: mpi_neighbours_calculator.h:72
ConfigureType::IteratorType IteratorType
Definition: mpi_neighbours_calculator.h:51
ConfigureType::ResultPointerType ResultPointerType
Definition: mpi_neighbours_calculator.h:53
ConfigureType::PointerTypeIterator PointerTypeIterator
Definition: mpi_neighbours_calculator.h:59
ConfigureType::ContainerContactType ContainerContactType
Definition: mpi_neighbours_calculator.h:56
ModelPart::ElementsContainerType ParticlePointerVector
Definition: mpi_neighbours_calculator.h:44
ModelPart::ElementsContainerType::ContainerType ParticleVector
Definition: mpi_neighbours_calculator.h:41
virtual void Sort_Modelpart(ModelPart &r_model_part)
Definition: mpi_neighbours_calculator.h:195
GlobalPointersVector< Element > ParticleWeakVector
Definition: mpi_neighbours_calculator.h:61
std::vector< array_1d< double, 3 > > TangDisplacementsVectorType
Definition: mpi_neighbours_calculator.h:68
BinsObjectDynamicMpi< ConfigureType > Bins
Definition: mpi_neighbours_calculator.h:71
ConfigureType::ContactPairType ContactPairType
Definition: mpi_neighbours_calculator.h:55
TParticle Particle
Definition: mpi_neighbours_calculator.h:39
virtual void SearchNeighbours(ModelPart &r_model_part, ContainerType &pIteratorElements, int NumberOfElements, int MaximumNumberOfResults, std::vector< std::size_t > &NumberOfResults, std::vector< std::vector< PointerType > > &Results, std::vector< std::vector< double > > &ResultsDistances, std::vector< double > &Radius)
Definition: mpi_neighbours_calculator.h:209
ConfigureType::DistanceIteratorType DistanceIteratorType
Definition: mpi_neighbours_calculator.h:48
Particle::Pointer ParticlePointer
Definition: mpi_neighbours_calculator.h:40
static void Parallel_partitioning(ModelPart &r_model_part, bool extension_option, int CalculateBoundary)
Definition: mpi_neighbours_calculator.h:80
ParticleWeakVector::ptr_iterator ParticleWeakIteratorType_ptr
Definition: mpi_neighbours_calculator.h:63
virtual ~Mpi_Neighbours_Calculator()
Pointer definition of Neighbour_calculator.
Definition: mpi_neighbours_calculator.h:77
ParticleVector::iterator ParticleIterator
Definition: mpi_neighbours_calculator.h:42
ParticleWeakVector::iterator ParticleWeakIterator
Definition: mpi_neighbours_calculator.h:62
TangDisplacementsVectorType::iterator TangDisplacementsIteratorType
Definition: mpi_neighbours_calculator.h:69
std::vector< double > DistanceVector
Definition: mpi_neighbours_calculator.h:65
Definition: mpi_discrete_particle_configure.h:45
ElementsContainerType::ContainerType ResultContainerType
Definition: mpi_discrete_particle_configure.h:60
ContainerType::value_type PointerType
Definition: mpi_discrete_particle_configure.h:57
std::vector< typename Element::Pointer > ContainerType
Definition: mpi_discrete_particle_configure.h:56
ContainerType::iterator IteratorType
Definition: mpi_discrete_particle_configure.h:58
std::vector< double >::iterator DistanceIteratorType
Definition: mpi_discrete_particle_configure.h:55
ResultContainerType::iterator ResultIteratorType
Definition: mpi_discrete_particle_configure.h:62
std::vector< PointerType >::iterator PointerTypeIterator
Definition: mpi_discrete_particle_configure.h:65
ResultContainerType::value_type ResultPointerType
Definition: mpi_discrete_particle_configure.h:61
Point class.
Definition: point.h:59
boost::indirect_iterator< typename TContainerType::iterator > iterator
Definition: pointer_vector.h:89
void Unique()
Remove duplicate elements from the set.
Definition: pointer_vector_set.h:764
void push_back(TPointerType x)
Adds a pointer to the end of the set.
Definition: pointer_vector_set.h:544
ProcessInfo holds the current value of different solution parameters.
Definition: process_info.h:59
#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
int step
Definition: face_heat.py:88
int j
Definition: quadrature.py:648
integer i
Definition: TensorModule.f:17
Configure::ContainerType ContainerType
Definition: transfer_utility.h:247