OpenLB 1.7
Loading...
Searching...
No Matches
Functions
olb::particles::statistics Namespace Reference

Functions

template<typename T , typename S , typename PARTICLETYPE , typename F >
void evaluateParticleSystemStatistics (SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, std::vector< S > &data, int noSampledQuantities, F f, int root=0)
 Evaluate particle statistics for each cuboid (each ParticleSystem)
 
template<typename T , typename PARTICLETYPE , typename PCONDITION = conditions::valid_particles>
std::vector< std::size_t > gatherActivity (SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem)
 Gather number of active particles and total number for each cuboid.
 
template<typename T , typename PARTICLETYPE >
void printActivityGathered (SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem)
 Print activity gathered a main processor.
 

Function Documentation

◆ evaluateParticleSystemStatistics()

template<typename T , typename S , typename PARTICLETYPE , typename F >
void olb::particles::statistics::evaluateParticleSystemStatistics ( SuperParticleSystem< T, PARTICLETYPE > & sParticleSystem,
std::vector< S > & data,
int noSampledQuantities,
F f,
int root = 0 )

Evaluate particle statistics for each cuboid (each ParticleSystem)

Definition at line 38 of file particleStatistics.h.

40{
41 //Set number of quantities (including globiC at first position)
42 int noQ = noSampledQuantities + 1;
43 //Retrieve load balancer and set up samples vector
44 auto& loadBalancer = sParticleSystem.getSuperStructure().getLoadBalancer();
45 std::vector<S> samples(loadBalancer.size()*noQ);
46 //Iterate over particle systems
47 communication::forSystemsInSuperParticleSystem( sParticleSystem,
48 [&](ParticleSystem<T,PARTICLETYPE>& particleSystem, int iC, int globiC){
49 //Set index for samples array
50 int idx = iC*noQ;
51 samples[idx] = globiC;
52 //Perform requested sampling (assuming globiC at first pos)
53 f ( particleSystem, globiC, idx+1, samples );
54 });
55
56 //Execute gathering
57 const int numTasks = singleton::mpi().getSize();
58 const int recvBufSize = samples.size()*numTasks;
59 data.resize(recvBufSize);
60 int sendCount = samples.size();
61 int recvCounts[numTasks];
62 int displs[numTasks];
63 std::fill(recvCounts,&recvCounts[numTasks],sendCount);
64 std::generate(displs,&displs[numTasks],[&sendCount,n = 0] () mutable { return sendCount*n++; });
65#ifdef PARALLEL_MODE_MPI
66 singleton::mpi().gatherv<S>(samples.data(), sendCount, data.data(),
67 recvCounts, displs, root);
68#endif
69}
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
SuperStructure< T, PARTICLETYPE::d > & getSuperStructure()

References olb::particles::communication::forSystemsInSuperParticleSystem(), olb::singleton::MpiManager::gatherv(), olb::SuperStructure< T, D >::getLoadBalancer(), olb::singleton::MpiManager::getSize(), olb::particles::SuperParticleSystem< T, PARTICLETYPE >::getSuperStructure(), and olb::singleton::mpi().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gatherActivity()

template<typename T , typename PARTICLETYPE , typename PCONDITION = conditions::valid_particles>
std::vector< std::size_t > olb::particles::statistics::gatherActivity ( SuperParticleSystem< T, PARTICLETYPE > & sParticleSystem)

Gather number of active particles and total number for each cuboid.

Definition at line 73 of file particleStatistics.h.

75{
76 //Set sampling properties
77 unsigned noSampledQuantities = 2;
78 std::vector<std::size_t> dataV;
79 //Evaluate particle system statistics
80 evaluateParticleSystemStatistics( sParticleSystem, dataV, noSampledQuantities,
81 [](ParticleSystem<T,PARTICLETYPE>& particleSystem, int globiC, int idx, auto& samples){
82 //Introduce couters for sampled quantities
83 std::size_t noP = 0;
84 std::size_t noActive = 0;
85 //Iterate over particles
86 forParticlesInParticleSystem<T,PARTICLETYPE,PCONDITION>( particleSystem,
87 [&](Particle<T,PARTICLETYPE>& particle){
88 //Evaluate counter increment
89 if ( access::isActive(particle) ){ ++noActive; }
90 ++noP;
91 },globiC); //forParticlesInParticleSystem<T,PARTICLETYPE,PCONDITION>
92 //Update samples vector with counters
93 samples[idx+0] = noActive;
94 samples[idx+1] = noP;
95 });
96 //Return gathered dataV
97 return dataV;
98}
void evaluateParticleSystemStatistics(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem, std::vector< S > &data, int noSampledQuantities, F f, int root=0)
Evaluate particle statistics for each cuboid (each ParticleSystem)

References evaluateParticleSystemStatistics(), and olb::particles::access::isActive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printActivityGathered()

template<typename T , typename PARTICLETYPE >
void olb::particles::statistics::printActivityGathered ( SuperParticleSystem< T, PARTICLETYPE > & sParticleSystem)

Print activity gathered a main processor.

Definition at line 103 of file particleStatistics.h.

103 {
104 OstreamManager clout ( std::cout, "Activity" );
105 auto activityStatistics = gatherActivity( sParticleSystem );
106 unsigned noQ = 3;
107 for (int idx=0; idx<activityStatistics.size(); idx+=noQ ){
108 clout << "ParticleSystem " << activityStatistics[idx] << ":"
109 << " active=" << activityStatistics[idx+1]
110 << "/" << activityStatistics[idx+2]
111 << std::endl;
112 }
113}
class for marking output with some text
std::vector< std::size_t > gatherActivity(SuperParticleSystem< T, PARTICLETYPE > &sParticleSystem)
Gather number of active particles and total number for each cuboid.

References gatherActivity().

+ Here is the call graph for this function: