24#ifndef SUPER_PARTICLE_SYSTEM_HH
25#define SUPER_PARTICLE_SYSTEM_HH
31template <
typename T,
typename PARTICLETYPE>
34 : _superStructure(superStructure)
36 , _maximalCircumRadius(maximalCircumRadius)
43 for (
int iC = 1; iC < loadBalancer.size(); ++iC) {
48 updateCuboidNeighborhood();
51template <
typename T,
typename PARTICLETYPE>
55 static_cast<
SuperStructure<T, PARTICLETYPE::d>&>(superGeometry), maximalCircumRadius)
58template <
typename T,
typename PARTICLETYPE>
62 auto loadBalancer = _superStructure.getLoadBalancer();
64 clout <<
"---SuperParticleSystem---" << std::endl;
65 clout.setMultiOutput(
true);
66#ifdef PARALLEL_MODE_MPI
69 for (
int iC = 0; iC < loadBalancer.size(); ++iC) {
70 int globiC = loadBalancer.glob(iC);
71 auto& bParticleSystem = *_blockParticleSystems[iC];
72 size_t size = bParticleSystem.size();
73 clout <<
"BlockParticleSystem " << globiC <<
" (" << rank <<
"," << iC
75 <<
": nop=" << size << std::endl;
77 clout.setMultiOutput(
false);
78#ifdef PARALLEL_MODE_MPI
81 clout <<
"-------------------------" << std::endl;
84template <
typename T,
typename PARTICLETYPE>
88 auto loadBalancer = _superStructure.getLoadBalancer();
89 for (
int iC = 0; iC < loadBalancer.size(); ++iC) {
90 auto& bParticleSystem = *_blockParticleSystems[iC];
91 bParticleSystem.addDynamics( dynamicsSPtr );
95template<
typename T,
typename PARTICLETYPE>
96template <
typename DYNAMICS,
typename ...Args>
98 auto loadBalancer = _superStructure.getLoadBalancer();
99 for (
int iC = 0; iC < loadBalancer.size(); ++iC) {
100 auto& bParticleSystem = *_blockParticleSystems[iC];
101 bParticleSystem.template defineDynamics<DYNAMICS>( std::forward<Args>(args)... );
105template <
typename T,
typename PARTICLETYPE>
108 return _neighbourRanks;
111template <
typename T,
typename PARTICLETYPE>
114 return _extendedNeighbourRanks;
117template <
typename T,
typename PARTICLETYPE>
120 return _cuboidNeighborhood;
123template <
typename T,
typename PARTICLETYPE>
124std::vector<ParticleSystem<T, PARTICLETYPE>*>&
127 return _blockParticleSystems;
130template <
typename T,
typename PARTICLETYPE>
134 return _superStructure;
137template <
typename T,
typename PARTICLETYPE>
140 return _currentGlobalID++;
143template <
typename T,
typename PARTICLETYPE>
150template <
typename T,
typename PARTICLETYPE>
154 using namespace descriptors;
157 _blockParticleSystems) {
158 for (std::size_t localiP = 0; localiP < blockParticleSystem->size();
160 auto particle = blockParticleSystem->get(localiP);
161 const std::size_t currentGlobalParticleID =
162 particle.template getField<PARALLELIZATION, ID>();
163 if (globalParticleID == currentGlobalParticleID) {
170 <<
" cannot find particle with global id " << globalParticleID
173 return _blockParticleSystems[0]->
get(0);
176template <
typename T,
typename PARTICLETYPE>
177template <
typename PCONDITION>
180 std::size_t size = 0;
184 size += particleSystem.template size<PCONDITION>(globiC);
186#ifdef PARALLEL_MODE_MPI
192template <
typename T,
typename PARTICLETYPE>
196#ifdef PARALLEL_MODE_MPI
199 _blockParticleSystems[0]->checkForErrors();
200#ifdef PARALLEL_MODE_MPI
205template <
typename T,
typename PARTICLETYPE>
209 if(_maximalCircumRadius < circumRadius) {
210 _maximalCircumRadius = circumRadius;
211 updateCuboidNeighborhood();
215template <
typename T,
typename PARTICLETYPE>
218 auto& cuboidDecomposition = _superStructure.getCuboidDecomposition();
219 const T physDeltaX = cuboidDecomposition.getMotherCuboid().getDeltaR();
221 _superStructure.getOverlap() );
226template <
typename T,
typename PARTICLETYPE>
227void SuperParticleSystem<T, PARTICLETYPE>::updateCuboidNeighborhood()
229 auto& cuboidDecomposition = _superStructure.getCuboidDecomposition();
230 int offset = getOffset();
232 std::map<int,std::vector<int>> neighbourhood;
235 constexpr bool correctFaultyNeighbourhood =
true;
238 for (
auto [globiC, neighbors] : neighbourhood) {
239 _cuboidNeighborhood[globiC] = std::set<int>(neighbors.begin(), neighbors.end());
243 _superStructure, _cuboidNeighborhood);
245 _extendedNeighbourRanks = _neighbourRanks;
246 for(
int rank : _neighbourRanks) {
248 T, PARTICLETYPE::d,
false>(_superStructure, rank, _cuboidNeighborhood);
249 _extendedNeighbourRanks.insert(neighborRanks.begin(), neighborRanks.end());
class for marking output with some text
Representation of a statistic for a parallel 2D geometry.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
CuboidDecomposition< T, D > & getCuboidDecomposition()
Read and write access to cuboid geometry.
auto & get()
Expose container.
SuperParticleSystem(SuperStructure< T, PARTICLETYPE::d > &superStructure, T maximalCircumRadius=T{0.})
SuperStructure< T, PARTICLETYPE::d > & getSuperStructure()
const std::set< int > & getNeighbourRanks()
Particle< T, PARTICLETYPE > get(std::size_t globalParticleID)
constexpr std::size_t size()
void addDynamics(std::shared_ptr< dynamics::ParticleDynamics< T, PARTICLETYPE > > &dynamicsSPtr)
void defineDynamics(Args &&...args)
void updateOffsetFromCircumRadius(T circumRadius)
std::vector< ParticleSystem< T, PARTICLETYPE > * > & getBlockParticleSystems()
const std::vector< std::set< int > > & getCuboidNeighborhood()
const std::set< int > & getExtendedNeighbourRanks()
std::size_t getSerialSize() const
void synchronizeIO(unsigned tDelay=100, MPI_Comm comm=MPI_COMM_WORLD)
Synchronizes the processes and wait to ensure correct cout order.
void reduceAndBcast(T &reductVal, MPI_Op op, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Reduction operation, followed by a broadcast.
int getRank() const
Returns the process ID.
constexpr bool providesValid()
Provides field INVALID.
void forSystemsInSuperParticleSystem(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, F f)
std::set< int > getNeighbourRanksFromCuboidNeighbourhood(SuperStructure< T, D > &superStructure, int rank, std::map< int, std::vector< int > > neighbourhood)
Get neighbour ranks.
ADf< T, DIM > ceil(const ADf< T, DIM > &a)
Top level namespace for all of OpenLB.
void evaluateCuboidDecompositionNeighbourhood(CuboidDecomposition< T, D > &cuboidDecomposition, std::map< int, std::vector< int > > &neighbourhood, int offset)
Evaluate complete neighbourhood and store in std::map.
bool checkCuboidNeighbourhoodConsistency(std::map< int, std::vector< int > > &neighbourhood, bool correct=false, bool verbose=false)
Consistency check for neighbour retrieval.