OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::particles::ParticleSystem< T, PARTICLETYPE > Class Template Reference

#include <particleSystem.h>

+ Collaboration diagram for olb::particles::ParticleSystem< T, PARTICLETYPE >:

Public Member Functions

 ParticleSystem ()
 Default constructor.
 
 ParticleSystem (std::size_t count)
 Constructor with initial particle size.
 
 ParticleSystem (std::size_t count, typename associatedTypes::template decompose_into< std::tuple > associatedData)
 Constructor with initial particle size and associated Data.
 
Iterator begin ()
 
Iterator end ()
 
template<typename PCONDITION = conditions::all_particles>
constexpr std::size_t size ()
 Size of ParticleSystem.
 
template<typename PCONDITION = conditions::all_particles>
constexpr std::size_t size (int globiC)
 Size of ParticleSystem (enables passing of globiC, if used in SuperParticleSystem)
 
template<bool boundsCheck = false>
dynamics::ParticleDynamics< T, PARTICLETYPE > * getDynamics (unsigned iDyn=0)
 Get specific dynamics (optional boundsCheck via .at())
 
void addDynamics (std::shared_ptr< dynamics::ParticleDynamics< T, PARTICLETYPE > > &dynamicsSPtr)
 Add dynamics (from shared_pointer of dynamics)
 
template<typename DYNAMICS , typename ... Args>
void defineDynamics (Args &&...args)
 Define dynamics (factory method)
 
void extend ()
 Extend particle system by one particle.
 
void swapParticles (std::size_t iP, std::size_t jP)
 Swap particles by index.
 
void process (std::size_t p0, std::size_t p1, T timeStepSize, unsigned iDyn=0)
 Upate/process particle quantities on a subset (mostly local equivalent to collide)
 
void process (T timeStepSize, unsigned iDyn=0)
 Upate/process particle quantities on all particles.
 
void update ()
 Update particles (equivalent to stream())
 
auto & get ()
 Expose container.
 
std::vector< std::shared_ptr< dynamics::ParticleDynamics< T, PARTICLETYPE > > > & getDynamicsVector ()
 Expose dynamics vector.
 
template<bool boundsCheck = false>
Particle< T, PARTICLETYPE > get (std::size_t iParticle)
 Create and return particle (analogous to cell TODO: make same baseclass) (optional boundsCheck)
 
Particle< T, PARTICLETYPE > operator[] (std::size_t iParticle)
 Create and return particle with operator[].
 
template<typename GROUP , typename FIELD >
auto & getFieldD ()
 Get whole Field by GROUP (or base of GROUP) and FIELD.
 
template<typename GROUP , typename FIELD >
auto getFieldPointer (std::size_t iParticle)
 Get FieldPointer by GROUP (or base of GROUP) and FIELD for specific iParticle.
 
template<typename TYPE >
auto & getAssociatedData ()
 Get associated data by specifying data type.
 
std::size_t getSerialSize () const
 Get serial size of dynamic fields group.
 
void print ()
 Print relevant infos.
 
void checkForErrors ()
 Check for erroes.
 

Detailed Description

template<typename T, typename PARTICLETYPE>
class olb::particles::ParticleSystem< T, PARTICLETYPE >

Definition at line 35 of file particleSystem.h.

Constructor & Destructor Documentation

◆ ParticleSystem() [1/3]

template<typename T , typename PARTICLETYPE >
olb::particles::ParticleSystem< T, PARTICLETYPE >::ParticleSystem ( )

Default constructor.

Definition at line 34 of file particleSystem.hh.

35 : _fieldGroupsContainer( Container<T,PARTICLETYPE,DATA>(0) ),
36 _serialSize(DATA(0).getSerializableSize())
37{}

◆ ParticleSystem() [2/3]

template<typename T , typename PARTICLETYPE >
olb::particles::ParticleSystem< T, PARTICLETYPE >::ParticleSystem ( std::size_t count)

Constructor with initial particle size.

Definition at line 40 of file particleSystem.hh.

41 : _fieldGroupsContainer( Container<T,PARTICLETYPE,DATA>(count) ),
42 _serialSize(DATA(0).getSerializableSize())
43{}

◆ ParticleSystem() [3/3]

template<typename T , typename PARTICLETYPE >
olb::particles::ParticleSystem< T, PARTICLETYPE >::ParticleSystem ( std::size_t count,
typename associatedTypes::template decompose_into< std::tuple > associatedData )

Constructor with initial particle size and associated Data.

Definition at line 46 of file particleSystem.hh.

48 : _associatedData( associatedData ),
49 _fieldGroupsContainer( Container<T,PARTICLETYPE,DATA>(count) ),
50 _serialSize(DATA(0).getSerializableSize())
51{}

Member Function Documentation

◆ addDynamics()

template<typename T , typename PARTICLETYPE >
void olb::particles::ParticleSystem< T, PARTICLETYPE >::addDynamics ( std::shared_ptr< dynamics::ParticleDynamics< T, PARTICLETYPE > > & dynamicsSPtr)

Add dynamics (from shared_pointer of dynamics)

Definition at line 104 of file particleSystem.hh.

106{
107 _dynamicsVector.push_back( dynamicsSPtr );
108}

◆ begin()

template<typename T , typename PARTICLETYPE >
Iterator olb::particles::ParticleSystem< T, PARTICLETYPE >::begin ( )
inline

Definition at line 87 of file particleSystem.h.

87{ return Iterator(this,0); }

◆ checkForErrors()

template<typename T , typename PARTICLETYPE >
void olb::particles::ParticleSystem< T, PARTICLETYPE >::checkForErrors ( )

Check for erroes.

Definition at line 228 of file particleSystem.hh.

229{
230 //Check, whether at least one ParticleDynamics present
231 if ( _dynamicsVector.size()==0 ){
232 throw std::logic_error("No ParticleDynamics set!");
233 }
234}

◆ defineDynamics()

template<typename T , typename PARTICLETYPE >
template<typename DYNAMICS , typename ... Args>
void olb::particles::ParticleSystem< T, PARTICLETYPE >::defineDynamics ( Args &&... args)

Define dynamics (factory method)

Definition at line 112 of file particleSystem.hh.

112 {
113 _dynamicsVector.push_back( std::make_shared<DYNAMICS>(std::forward<Args>(args)...) );
114}

◆ end()

template<typename T , typename PARTICLETYPE >
Iterator olb::particles::ParticleSystem< T, PARTICLETYPE >::end ( )
inline

Definition at line 88 of file particleSystem.h.

88{ return Iterator(this,size()); }
constexpr std::size_t size()
Size of ParticleSystem.

References olb::particles::ParticleSystem< T, PARTICLETYPE >::size().

+ Here is the call graph for this function:

◆ extend()

template<typename T , typename PARTICLETYPE >
void olb::particles::ParticleSystem< T, PARTICLETYPE >::extend ( )

Extend particle system by one particle.

Definition at line 117 of file particleSystem.hh.

118{
119 _fieldGroupsContainer.push_back();
120// _dynamicsMapContainer.push_back();
121}
+ Here is the caller graph for this function:

◆ get() [1/2]

template<typename T , typename PARTICLETYPE >
auto & olb::particles::ParticleSystem< T, PARTICLETYPE >::get ( )

Expose container.

Definition at line 149 of file particleSystem.hh.

150{
151 return _fieldGroupsContainer;
152}
+ Here is the caller graph for this function:

◆ get() [2/2]

template<typename T , typename PARTICLETYPE >
template<bool boundsCheck>
Particle< T, PARTICLETYPE > olb::particles::ParticleSystem< T, PARTICLETYPE >::get ( std::size_t iParticle)

Create and return particle (analogous to cell TODO: make same baseclass) (optional boundsCheck)

Definition at line 162 of file particleSystem.hh.

163{
164 if constexpr(boundsCheck){
165 if (iParticle>_fieldGroupsContainer.size()){
166 throw std::out_of_range("Particle does not exist in Particlesystem!");
167 }
168 return Particle<T,PARTICLETYPE>( _fieldGroupsContainer.data(),
169 _dynamicsVector, iParticle );
170 } else {
171 return Particle<T,PARTICLETYPE>( _fieldGroupsContainer.data(),
172 _dynamicsVector, iParticle );
173 }
174}

◆ getAssociatedData()

template<typename T , typename PARTICLETYPE >
template<typename TYPE >
auto & olb::particles::ParticleSystem< T, PARTICLETYPE >::getAssociatedData ( )

Get associated data by specifying data type.

Definition at line 205 of file particleSystem.hh.

206{
207 const std::size_t idx = associatedTypes::template index<TYPE>();
208 return std::get<idx>(_associatedData);
209}

◆ getDynamics()

template<typename T , typename PARTICLETYPE >
template<bool boundsCheck>
dynamics::ParticleDynamics< T, PARTICLETYPE > * olb::particles::ParticleSystem< T, PARTICLETYPE >::getDynamics ( unsigned iDyn = 0)

Get specific dynamics (optional boundsCheck via .at())

Definition at line 93 of file particleSystem.hh.

95{
96 if constexpr(boundsCheck){
97 return _dynamicsVector.at(iDyn).get();
98 } else {
99 return _dynamicsVector[iDyn].get();
100 }
101}

◆ getDynamicsVector()

template<typename T , typename PARTICLETYPE >
std::vector< std::shared_ptr< dynamics::ParticleDynamics< T, PARTICLETYPE > > > & olb::particles::ParticleSystem< T, PARTICLETYPE >::getDynamicsVector ( )

Expose dynamics vector.

Definition at line 155 of file particleSystem.hh.

156{
157 return _dynamicsVector;
158}

◆ getFieldD()

template<typename T , typename PARTICLETYPE >
template<typename GROUP , typename FIELD >
auto & olb::particles::ParticleSystem< T, PARTICLETYPE >::getFieldD ( )

Get whole Field by GROUP (or base of GROUP) and FIELD.

Definition at line 184 of file particleSystem.hh.

185{
186 using GROUP_EVAL = typename PARTICLETYPE::template derivedField<GROUP>;
187 using FIELD_EVAL = typename GROUP_EVAL::template derivedField<FIELD>;
188 return _fieldGroupsContainer.data().template get<GROUP_EVAL>()
189 .template get<FIELD_EVAL>();
190}

◆ getFieldPointer()

template<typename T , typename PARTICLETYPE >
template<typename GROUP , typename FIELD >
auto olb::particles::ParticleSystem< T, PARTICLETYPE >::getFieldPointer ( std::size_t iParticle)

Get FieldPointer by GROUP (or base of GROUP) and FIELD for specific iParticle.

Definition at line 194 of file particleSystem.hh.

195{
196 using GROUP_EVAL = typename PARTICLETYPE::template derivedField<GROUP>;
197 using FIELD_EVAL = typename GROUP_EVAL::template derivedField<FIELD>;
198 return _fieldGroupsContainer.data().template get<GROUP_EVAL>()
199 .template get<FIELD_EVAL>()
200 .getRowPointer( iParticle );
201}

◆ getSerialSize()

template<typename T , typename PARTICLETYPE >
std::size_t olb::particles::ParticleSystem< T, PARTICLETYPE >::getSerialSize ( ) const

Get serial size of dynamic fields group.

Definition at line 213 of file particleSystem.hh.

214{
215 return _serialSize;
216}

◆ operator[]()

template<typename T , typename PARTICLETYPE >
Particle< T, PARTICLETYPE > olb::particles::ParticleSystem< T, PARTICLETYPE >::operator[] ( std::size_t iParticle)

Create and return particle with operator[].

Definition at line 177 of file particleSystem.hh.

178{
179 return get(iParticle);
180}
auto & get()
Expose container.

◆ print()

template<typename T , typename PARTICLETYPE >
void olb::particles::ParticleSystem< T, PARTICLETYPE >::print ( )

Print relevant infos.

Definition at line 219 of file particleSystem.hh.

220{
221 OstreamManager clout(std::cout, "ParticleSystem");
222 clout << "-----ParticleSystem------" << std::endl;
223 clout << "nop=" << size() << std::endl;
224 clout << "-------------------------" << std::endl;
225}

◆ process() [1/2]

template<typename T , typename PARTICLETYPE >
void olb::particles::ParticleSystem< T, PARTICLETYPE >::process ( std::size_t p0,
std::size_t p1,
T timeStepSize,
unsigned iDyn = 0 )

Upate/process particle quantities on a subset (mostly local equivalent to collide)

Definition at line 131 of file particleSystem.hh.

133{
134 auto particle = get(iP0);
135 for (std::size_t iP=iP0; iP<iPmax; ++iP) {
136 particle.process(timeStepSize,iDyn);
137 particle.advanceId();
138 }
139}

◆ process() [2/2]

template<typename T , typename PARTICLETYPE >
void olb::particles::ParticleSystem< T, PARTICLETYPE >::process ( T timeStepSize,
unsigned iDyn = 0 )

Upate/process particle quantities on all particles.

Definition at line 142 of file particleSystem.hh.

143{
144 process(0, size(), timeStepSize, iDyn);
145}
void process(std::size_t p0, std::size_t p1, T timeStepSize, unsigned iDyn=0)
Upate/process particle quantities on a subset (mostly local equivalent to collide)

◆ size() [1/2]

template<typename T , typename PARTICLETYPE >
template<typename PCONDITION >
constexpr std::size_t olb::particles::ParticleSystem< T, PARTICLETYPE >::size ( )
constexpr

Size of ParticleSystem.

Definition at line 55 of file particleSystem.hh.

56{
57 //Either directly return size of container
58 if constexpr(std::is_same_v<PCONDITION,conditions::all_particles>){
59 return _fieldGroupsContainer.size();
60 //Or iterate over container evaluating condition
61 } else {
62 std::size_t count=0;
63 for (std::size_t iP=0; iP<_fieldGroupsContainer.size(); ++iP) {
64 auto particle = get(iP);
65 doWhenMeetingCondition<T,PARTICLETYPE,PCONDITION>( particle,
66 [&](Particle<T,PARTICLETYPE> particle){ ++count; });
67 }
68 return count;
69 }
70}
+ Here is the caller graph for this function:

◆ size() [2/2]

template<typename T , typename PARTICLETYPE >
template<typename PCONDITION >
constexpr std::size_t olb::particles::ParticleSystem< T, PARTICLETYPE >::size ( int globiC)
constexpr

Size of ParticleSystem (enables passing of globiC, if used in SuperParticleSystem)

Definition at line 74 of file particleSystem.hh.

75{
76 //Either directly return size of container
77 if constexpr(std::is_same_v<PCONDITION,conditions::all_particles>){
78 return _fieldGroupsContainer.size();
79 //Or iterate over container evaluating condition
80 } else {
81 std::size_t count=0;
82 for (std::size_t iP=0; iP<_fieldGroupsContainer.size(); ++iP) {
83 auto particle = get(iP);
84 doWhenMeetingCondition<T,PARTICLETYPE,PCONDITION>( particle,
85 [&](Particle<T,PARTICLETYPE> particle){ ++count; }, globiC);
86 }
87 return count;
88 }
89}

◆ swapParticles()

template<typename T , typename PARTICLETYPE >
void olb::particles::ParticleSystem< T, PARTICLETYPE >::swapParticles ( std::size_t iP,
std::size_t jP )

Swap particles by index.

Definition at line 124 of file particleSystem.hh.

125{
126 _fieldGroupsContainer.swapElements(iP,jP);
127// _dynamicsMapContainer.swapElements(iP,jP);
128}
+ Here is the caller graph for this function:

◆ update()

template<typename T , typename PARTICLETYPE >
void olb::particles::ParticleSystem< T, PARTICLETYPE >::update ( )

Update particles (equivalent to stream())


The documentation for this class was generated from the following files: