24#ifndef SUPER_PARTICLE_SYSTEM_HH
25#define SUPER_PARTICLE_SYSTEM_HH
31template <
typename T,
typename PARTICLETYPE>
34 : _superStructure(superStructure)
36 , _maximalCircumRadius(maximalCircumRadius)
38 static_assert(access::providesValid<PARTICLETYPE>(),
"Field GENERAL:VALID has to be provided");
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;
181 communication::forSystemsInSuperParticleSystem<T,PARTICLETYPE>(
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& cuboidGeometry = _superStructure.getCuboidGeometry();
219 const T physDeltaX = cuboidGeometry.getMotherCuboid().getDeltaR();
221 _superStructure.getOverlap() );
226template <
typename T,
typename PARTICLETYPE>
227void SuperParticleSystem<T, PARTICLETYPE>::updateCuboidNeighborhood()
229 auto& cuboidGeometry = _superStructure.getCuboidGeometry();
230 unsigned offset = getOffset();
232 std::map<int,std::vector<int>> neighbourhood;
235 constexpr bool correctFaultyNeighbourhood =
true;
238 for (
const auto& cuboidNeighbourPair: neighbourhood){
239 const int globiC = cuboidNeighbourPair.first;
241 _cuboidNeighborhood[globiC] =
242 std::unordered_set<int>(cuboidNeighbourPair.second.begin(),
243 cuboidNeighbourPair.second.end());
247 _neighbourRanks = communication::getNeighbourRanksFromCuboidNeighbourhood<T, PARTICLETYPE::d, false>(
248 _superStructure, _cuboidNeighborhood);
250 _extendedNeighbourRanks = _neighbourRanks;
251 for(
int rank : _neighbourRanks) {
253 T, PARTICLETYPE::d,
false>(_superStructure, rank, _cuboidNeighborhood);
254 _extendedNeighbourRanks.insert(neighborRanks.begin(), neighborRanks.end());
class for marking output with some text
Representation of a statistic for a parallel 2D geometry.
CuboidGeometry< T, D > & getCuboidGeometry()
Read and write access to cuboid geometry.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
SuperParticleSystem(SuperStructure< T, PARTICLETYPE::d > &superStructure, T maximalCircumRadius=T{0.})
SuperStructure< T, PARTICLETYPE::d > & getSuperStructure()
Particle< T, PARTICLETYPE > get(std::size_t globalParticleID)
constexpr std::size_t size()
const std::unordered_set< int > & getNeighbourRanks()
void addDynamics(std::shared_ptr< dynamics::ParticleDynamics< T, PARTICLETYPE > > &dynamicsSPtr)
const std::vector< std::unordered_set< int > > & getCuboidNeighborhood()
void defineDynamics(Args &&...args)
void updateOffsetFromCircumRadius(T circumRadius)
std::vector< ParticleSystem< T, PARTICLETYPE > * > & getBlockParticleSystems()
const std::unordered_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.
std::unordered_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)
cpu::simd::Pack< T > max(cpu::simd::Pack< T > rhs, cpu::simd::Pack< T > lhs)
Top level namespace for all of OpenLB.
void evaluateCuboidGeometryNeighbourhood(CuboidGeometry2D< T > &cuboidGeometry, std::map< int, std::vector< int > > &neighbourhood, int offset=0)
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.