OpenLB 1.7
Loading...
Searching...
No Matches
superParticleSystem.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2022-2023 Nicolas Hafen, Jan E. Marquardt
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef SUPER_PARTICLE_SYSTEM_H
25#define SUPER_PARTICLE_SYSTEM_H
26
27namespace olb {
28
29namespace particles {
30
31template <typename T, typename PARTICLETYPE>
33private:
34 std::vector<ParticleSystem<T, PARTICLETYPE>*> _blockParticleSystems;
37 std::unordered_set<int> _neighbourRanks;
39 std::unordered_set<int> _extendedNeighbourRanks;
41 std::vector<std::unordered_set<int>> _cuboidNeighborhood;
42 std::size_t _currentGlobalID = 0;
43 const std::size_t _serialSize;
44 T _maximalCircumRadius = T{0.};
45
46 unsigned getOffset();
47 void updateCuboidNeighborhood();
48
49public:
50 SuperParticleSystem(SuperStructure<T, PARTICLETYPE::d>& superStructure, T maximalCircumRadius = T{0.});
52 SuperParticleSystem(SuperGeometry<T, PARTICLETYPE::d>& superGeometry, T maximalCircumRadius = T{0.});
53 void print();
54 void addDynamics(std::shared_ptr<dynamics::ParticleDynamics<T,PARTICLETYPE>>& dynamicsSPtr );
55 template <typename DYNAMICS, typename ...Args>
56 void defineDynamics(Args&& ...args);
57 std::vector<ParticleSystem<T, PARTICLETYPE>*>& getBlockParticleSystems();
59 const std::unordered_set<int>& getNeighbourRanks();
60 const std::unordered_set<int>& getExtendedNeighbourRanks();
61 const std::vector<std::unordered_set<int>>& getCuboidNeighborhood();
62 std::size_t getGlobID();
63 std::size_t getSerialSize() const;
64 Particle<T, PARTICLETYPE> get(std::size_t globalParticleID);
65 template<typename PCONDITION=conditions::all_particles>
66 constexpr std::size_t size(); //Returns total number of particles
67 void checkForErrors();
68 void updateOffsetFromCircumRadius(T circumRadius);
69};
70
71//Define type that can be both ParticleSystem and SuperParticleSystem
72//- depending on particle type
73template <typename T, typename PARTICLETYPE>
74using XParticleSystem = std::conditional_t<
75 PARTICLETYPE::template providesNested<descriptors::PARALLELIZATION>(),
77
78
79//Simple stuctur that stores information to avoid an additional particle search
80//-intended to be returnd during particle creation
81//-synchronize(): ensures the same localID on all cores (most likely never necessary,
82// as localID is only valid in the respective cuboid )
84 //Stored quantities
85 int globiC;
86 std::size_t globalID;
87 std::size_t localID;
88 //Constructor
92 ParallelParticleLocator(int globiC_, std::size_t globalID_, std::size_t localID_)
93 : globiC(globiC_), globalID(globalID_), localID(localID_)
94 {}
95
96 //Synchronize
98#ifdef PARALLEL_MODE_MPI
102#endif
103 }
104 //Print
105 void print(){
106 std::cout << "ParallelParticleLocator: ("
107 << "globiC=" << globiC
108 << ", globID=" << globalID
109 << ", locID=" << localID << ")"
110 << std::endl;
111 }
112};
113
114
115} //namespace particles
116
117} //namespace olb
118
119#endif
Representation of a statistic for a parallel 2D geometry.
SuperParticleSystem(SuperStructure< T, PARTICLETYPE::d > &superStructure, T maximalCircumRadius=T{0.})
SuperStructure< T, PARTICLETYPE::d > & getSuperStructure()
Particle< T, PARTICLETYPE > get(std::size_t globalParticleID)
const std::unordered_set< int > & getNeighbourRanks()
void addDynamics(std::shared_ptr< dynamics::ParticleDynamics< T, PARTICLETYPE > > &dynamicsSPtr)
const std::vector< std::unordered_set< int > > & getCuboidNeighborhood()
std::vector< ParticleSystem< T, PARTICLETYPE > * > & getBlockParticleSystems()
const std::unordered_set< int > & getExtendedNeighbourRanks()
void reduceAndBcast(T &reductVal, MPI_Op op, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Reduction operation, followed by a broadcast.
std::conditional_t< PARTICLETYPE::template providesNested< descriptors::PARALLELIZATION >(), SuperParticleSystem< T, PARTICLETYPE >, ParticleSystem< T, PARTICLETYPE > > XParticleSystem
MpiManager & mpi()
Top level namespace for all of OpenLB.
ParallelParticleLocator(int globiC_, std::size_t globalID_, std::size_t localID_)