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

#include <superGeometryStatistics3D.h>

+ Collaboration diagram for olb::SuperGeometryStatistics3D< T >:

Public Member Functions

 SuperGeometryStatistics3D (SuperGeometry< T, 3 > *superGeometry)
 Constructor.
 
 SuperGeometryStatistics3D (SuperGeometryStatistics3D const &rhs)
 Copy constructor.
 
SuperGeometryStatistics3D< T > & operator= (SuperGeometryStatistics3D const &rhs)
 Copy assignment.
 
bool & getStatisticsStatus ()
 Read and write access to a flag, which indicates if an uptate is needed (=true)
 
bool const & getStatisticsStatus () const
 Read only access to a flag, which indicates if an uptate is needed (=true)
 
void update (bool verbose=false)
 Updates the statistics if it is really needed.
 
int getNmaterials ()
 Returns the number of different materials.
 
int getNmaterials () const
 
std::size_t getNvoxel (int material)
 Returns the number of voxels for a given material number.
 
std::size_t getNvoxel (int material) const
 
std::size_t getNvoxel ()
 Returns the number of voxels with material!=0.
 
std::size_t getNvoxel () const
 
olb::Vector< T, 3 > getMinPhysR (int material)
 Returns the min. phys position in each direction corresponding to material number.
 
olb::Vector< T, 3 > getMinPhysR (int material) const
 
olb::Vector< T, 3 > getMinPhysR ()
 Returns the min. phys position in each direction corresponding to all non-zero material numbers.
 
olb::Vector< T, 3 > getMinPhysR () const
 
olb::Vector< T, 3 > getMaxPhysR (int material)
 Returns the max. phys position in each direction corresponding to material number.
 
olb::Vector< T, 3 > getMaxPhysR (int material) const
 
olb::Vector< T, 3 > getMaxPhysR ()
 Returns the max. phys position in each direction corresponding to all non-zero material numbers.
 
olb::Vector< T, 3 > getMaxPhysR () const
 
olb::Vector< T, 3 > getPhysExtend (int material)
 Returns the phys extend as length in each direction.
 
std::vector< T > getPhysExtend (int material) const
 
olb::Vector< T, 3 > getPhysRadius (int material)
 Returns the phys radius as length in each direction.
 
olb::Vector< T, 3 > getPhysRadius (int material) const
 
olb::Vector< T, 3 > getCenterPhysR (int material)
 Returns the center position.
 
olb::Vector< T, 3 > getCenterPhysR (int material) const
 
olb::Vector< int, 3 > getType (int iC, int iX, int iY, int iZ)
 Returns the boundary type which is characterized by a discrte normal (c.f. Zimny)
 
olb::Vector< int, 3 > getType (int iC, int iX, int iY, int iZ) const
 
olb::Vector< T, 3 > computeNormal (int material)
 Returns normal that points into the fluid for paraxial surfaces.
 
olb::Vector< T, 3 > computeNormal (int material) const
 
olb::Vector< int, 3 > computeDiscreteNormal (int material, T maxNorm=1.1)
 Returns discrete normal with norm maxNorm that points into the fluid for paraxial surfaces maxNorm=1.1 implies only normals parallel to the axises.
 
olb::Vector< int, 3 > computeDiscreteNormal (int material, T maxNorm=1.1) const
 
computeMaxPhysDistance (int material) const
 Returns util::sqrt( maxX^2 + maxY^2 + maxZ^2 ) max over a certain material number.
 
computeMaxPhysDistance () const
 Returns util::sqrt( maxX^2 + maxY^2 + maxZ^2 ) max over all material numbers.
 
void print ()
 Prints some statistic information, i.e. the number of voxels and min. max. physical position for each different material.
 
void print () const
 

Detailed Description

template<typename T>
class olb::SuperGeometryStatistics3D< T >

Definition at line 57 of file superGeometryStatistics3D.h.

Constructor & Destructor Documentation

◆ SuperGeometryStatistics3D() [1/2]

template<typename T >
olb::SuperGeometryStatistics3D< T >::SuperGeometryStatistics3D ( SuperGeometry< T, 3 > * superGeometry)

Constructor.

Definition at line 42 of file superGeometryStatistics3D.hh.

43 : _superGeometry(superGeometry), _statisticsUpdateNeeded(true),
44 _nMaterials(0), _minOverMaterial(0), _maxOverMaterial(0),
45 clout(std::cout,"SuperGeometryStatistics3D")
46{
47}

◆ SuperGeometryStatistics3D() [2/2]

template<typename T >
olb::SuperGeometryStatistics3D< T >::SuperGeometryStatistics3D ( SuperGeometryStatistics3D< T > const & rhs)

Copy constructor.

Definition at line 50 of file superGeometryStatistics3D.hh.

51 : _superGeometry(rhs._superGeometry), _statisticsUpdateNeeded(true),
52 _nMaterials(rhs._nMaterials),
53 _minOverMaterial(rhs._minOverMaterial), _maxOverMaterial(rhs._maxOverMaterial),
54 clout(std::cout,"SuperGeometryStatistics3D")
55{
56}

Member Function Documentation

◆ computeDiscreteNormal() [1/2]

template<typename T >
olb::Vector< int, 3 > olb::SuperGeometryStatistics3D< T >::computeDiscreteNormal ( int material,
T maxNorm = 1.1 )

Returns discrete normal with norm maxNorm that points into the fluid for paraxial surfaces maxNorm=1.1 implies only normals parallel to the axises.

Definition at line 509 of file superGeometryStatistics3D.hh.

510{
511 update();
512 return const_this->computeDiscreteNormal(material, maxNorm);
513}
void update(bool verbose=false)
Updates the statistics if it is really needed.

◆ computeDiscreteNormal() [2/2]

template<typename T >
olb::Vector< int, 3 > olb::SuperGeometryStatistics3D< T >::computeDiscreteNormal ( int material,
T maxNorm = 1.1 ) const

Definition at line 516 of file superGeometryStatistics3D.hh.

517{
518 olb::Vector<T,3> normal = computeNormal(material);
519 olb::Vector<int, 3> discreteNormal(0);
520
521 T smallestAngle = T(0);
522 for (int iX = -1; iX<=1; iX++) {
523 for (int iY = -1; iY<=1; iY++) {
524 for (int iZ = -1; iZ<=1; iZ++) {
525 T norm = util::sqrt(iX*iX+iY*iY+iZ*iZ);
526 if (norm>0.&& norm<maxNorm) {
527 T angle = (iX*normal[0] + iY*normal[1] + iZ*normal[2])/norm;
528 if (angle>=smallestAngle) {
529 smallestAngle=angle;
530 discreteNormal[0] = iX;
531 discreteNormal[1] = iY;
532 discreteNormal[2] = iZ;
533 }
534 }
535 }
536 }
537 }
538 return discreteNormal;
539}
olb::Vector< T, 3 > computeNormal(int material)
Returns normal that points into the fluid for paraxial surfaces.
Plain old scalar vector.
Definition vector.h:47
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Definition pack.h:100
constexpr T norm(const ScalarVector< T, D, IMPL > &a)
Euclidean vector norm.

References olb::norm(), and olb::util::sqrt().

+ Here is the call graph for this function:

◆ computeMaxPhysDistance() [1/2]

template<typename T >
T olb::SuperGeometryStatistics3D< T >::computeMaxPhysDistance ( ) const

Returns util::sqrt( maxX^2 + maxY^2 + maxZ^2 ) max over all material numbers.

Definition at line 549 of file superGeometryStatistics3D.hh.

550{
551 Vector<T,3> vec(getMaxPhysR()[0] -getMinPhysR()[0], getMaxPhysR()[1] -getMinPhysR()[1], getMaxPhysR()[2] -getMinPhysR()[2]);
552 return norm(vec);
553}
olb::Vector< T, 3 > getMinPhysR()
Returns the min. phys position in each direction corresponding to all non-zero material numbers.
olb::Vector< T, 3 > getMaxPhysR()
Returns the max. phys position in each direction corresponding to all non-zero material numbers.

References olb::norm().

+ Here is the call graph for this function:

◆ computeMaxPhysDistance() [2/2]

template<typename T >
T olb::SuperGeometryStatistics3D< T >::computeMaxPhysDistance ( int material) const

Returns util::sqrt( maxX^2 + maxY^2 + maxZ^2 ) max over a certain material number.

Definition at line 542 of file superGeometryStatistics3D.hh.

543{
544 Vector<T,3> vec(getMaxPhysR(material)[0] -getMinPhysR(material)[0], getMaxPhysR(material)[1] -getMinPhysR(material)[1], getMaxPhysR(material)[2] -getMinPhysR(material)[2]);
545 return norm(vec);
546}

References olb::norm().

+ Here is the call graph for this function:

◆ computeNormal() [1/2]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::computeNormal ( int material)

Returns normal that points into the fluid for paraxial surfaces.

Definition at line 466 of file superGeometryStatistics3D.hh.

467{
468 update();
469 return const_this->computeNormal(material);
470}

◆ computeNormal() [2/2]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::computeNormal ( int material) const

Definition at line 473 of file superGeometryStatistics3D.hh.

474{
475 std::vector<T> normal (3,int());
476 for (int iCloc=0; iCloc<_superGeometry->getLoadBalancer().size(); iCloc++) {
477 for (int iDim=0; iDim<3; iDim++) {
478 if (_superGeometry->getBlockGeometry(iCloc).getStatistics().getNvoxel(material)!=0) {
479 normal[iDim] += _superGeometry->getBlockGeometry(iCloc).getStatistics().computeNormal(material)[iDim]*_superGeometry->getBlockGeometry(iCloc).getStatistics().getNvoxel(material);
480 }
481 }
482 }
483
484#ifdef PARALLEL_MODE_MPI
485 for (int iDim=0; iDim<3; iDim++) {
486 singleton::mpi().reduceAndBcast((normal[iDim]), MPI_SUM);
487 }
488#endif
489
490 if (getNvoxel(material) == 0) {
491 std::cerr << "Unkown material number: " << material << std::endl;
492 std::exit(-1);
493 }
494
495 for (int iDim=0; iDim<3; iDim++) {
496 normal[iDim] /= getNvoxel(material);
497 }
498
499 T norm = util::sqrt(normal[0]*normal[0]+normal[1]*normal[1]+normal[2]*normal[2]);
500 if (norm>0.) {
501 normal[0]/=norm;
502 normal[1]/=norm;
503 normal[2]/=norm;
504 }
505 return normal;
506}
std::size_t getNvoxel()
Returns the number of voxels with material!=0.
BlockGeometry< T, D > & getBlockGeometry(int locIC)
Read and write access to a single block geometry.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
void reduceAndBcast(T &reductVal, MPI_Op op, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Reduction operation, followed by a broadcast.
MpiManager & mpi()

References olb::singleton::mpi(), olb::norm(), olb::singleton::MpiManager::reduceAndBcast(), and olb::util::sqrt().

+ Here is the call graph for this function:

◆ getCenterPhysR() [1/2]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getCenterPhysR ( int material)

Returns the center position.

Definition at line 434 of file superGeometryStatistics3D.hh.

435{
436 update();
437 return const_this->getCenterPhysR(material);
438}

◆ getCenterPhysR() [2/2]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getCenterPhysR ( int material) const

Definition at line 441 of file superGeometryStatistics3D.hh.

442{
443 olb::Vector<T, 3> center;
444 for (int iDim=0; iDim<3; iDim++) {
445 center[iDim] = getMinPhysR(material)[iDim] + getPhysRadius(material)[iDim];
446 }
447 return center;
448}
olb::Vector< T, 3 > getPhysRadius(int material)
Returns the phys radius as length in each direction.

◆ getMaxPhysR() [1/4]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getMaxPhysR ( )

Returns the max. phys position in each direction corresponding to all non-zero material numbers.

Definition at line 381 of file superGeometryStatistics3D.hh.

382{
383 update();
384 return const_this->getMaxPhysR();
385}

◆ getMaxPhysR() [2/4]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getMaxPhysR ( ) const

Definition at line 388 of file superGeometryStatistics3D.hh.

389{
390 return _maxOverMaterial;
391}

◆ getMaxPhysR() [3/4]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getMaxPhysR ( int material)

Returns the max. phys position in each direction corresponding to material number.

Definition at line 363 of file superGeometryStatistics3D.hh.

364{
365 update();
366 return const_this->getMaxPhysR(material);
367}

◆ getMaxPhysR() [4/4]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getMaxPhysR ( int material) const

Definition at line 370 of file superGeometryStatistics3D.hh.

371{
372 try {
373 return _material2max.at(material);
374 }
375 catch (std::out_of_range& ex) {
376 return {0, 0, 0};
377 }
378}

◆ getMinPhysR() [1/4]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getMinPhysR ( )

Returns the min. phys position in each direction corresponding to all non-zero material numbers.

Definition at line 350 of file superGeometryStatistics3D.hh.

351{
352 update();
353 return const_this->getMinPhysR();
354}

◆ getMinPhysR() [2/4]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getMinPhysR ( ) const

Definition at line 357 of file superGeometryStatistics3D.hh.

358{
359 return _minOverMaterial;
360}

◆ getMinPhysR() [3/4]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getMinPhysR ( int material)

Returns the min. phys position in each direction corresponding to material number.

Definition at line 331 of file superGeometryStatistics3D.hh.

332{
333 update();
334 return const_this->getMinPhysR(material);
335}

◆ getMinPhysR() [4/4]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getMinPhysR ( int material) const

Definition at line 338 of file superGeometryStatistics3D.hh.

339{
340 try {
341 return _material2min.at(material);
342 }
343 catch (std::out_of_range& ex) {
344 return {0, 0, 0};
345 }
346}

◆ getNmaterials() [1/2]

template<typename T >
int olb::SuperGeometryStatistics3D< T >::getNmaterials ( )

Returns the number of different materials.

Definition at line 281 of file superGeometryStatistics3D.hh.

282{
283 update();
284 return const_this->getNmaterials();
285}

◆ getNmaterials() [2/2]

template<typename T >
int olb::SuperGeometryStatistics3D< T >::getNmaterials ( ) const

Definition at line 288 of file superGeometryStatistics3D.hh.

289{
290 return _nMaterials;
291}

◆ getNvoxel() [1/4]

template<typename T >
std::size_t olb::SuperGeometryStatistics3D< T >::getNvoxel ( )

Returns the number of voxels with material!=0.

Definition at line 312 of file superGeometryStatistics3D.hh.

313{
314 update();
315 return const_this->getNvoxel();
316}

◆ getNvoxel() [2/4]

template<typename T >
std::size_t olb::SuperGeometryStatistics3D< T >::getNvoxel ( ) const

Definition at line 319 of file superGeometryStatistics3D.hh.

320{
321 std::size_t total = 0;
322 for (const auto& material : _material2n) {
323 if (material.first!=0) {
324 total += material.second;
325 }
326 }
327 return total;
328}

◆ getNvoxel() [3/4]

template<typename T >
std::size_t olb::SuperGeometryStatistics3D< T >::getNvoxel ( int material)

Returns the number of voxels for a given material number.

Definition at line 294 of file superGeometryStatistics3D.hh.

295{
296 update(true);
297 return const_this->getNvoxel(material);
298}

◆ getNvoxel() [4/4]

template<typename T >
std::size_t olb::SuperGeometryStatistics3D< T >::getNvoxel ( int material) const

Definition at line 301 of file superGeometryStatistics3D.hh.

302{
303 try {
304 return _material2n.at(material);
305 }
306 catch (std::out_of_range& ex) {
307 return 0;
308 }
309}

◆ getPhysExtend() [1/2]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getPhysExtend ( int material)

Returns the phys extend as length in each direction.

Definition at line 394 of file superGeometryStatistics3D.hh.

395{
396 update();
397 return const_this->getPhysExtend(material);
398}

◆ getPhysExtend() [2/2]

template<typename T >
std::vector< T > olb::SuperGeometryStatistics3D< T >::getPhysExtend ( int material) const

Definition at line 401 of file superGeometryStatistics3D.hh.

402{
403 try {
404 std::vector<T> extend;
405 for (int iDim = 0; iDim < 3; iDim++) {
406 extend.push_back(_material2max.at(material)[iDim] - _material2min.at(material)[iDim]);
407 }
408 return extend;
409 }
410 catch (std::out_of_range& ex) {
411 return { 0, 0, 0 };
412 }
413}

◆ getPhysRadius() [1/2]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getPhysRadius ( int material)

Returns the phys radius as length in each direction.

Definition at line 416 of file superGeometryStatistics3D.hh.

417{
418 update();
419 return const_this->getPhysRadius(material);
420}

◆ getPhysRadius() [2/2]

template<typename T >
olb::Vector< T, 3 > olb::SuperGeometryStatistics3D< T >::getPhysRadius ( int material) const

Definition at line 423 of file superGeometryStatistics3D.hh.

424{
425 olb::Vector<T, 3> radius;
426 for (int iDim=0; iDim<3; iDim++) {
427 //radius.push_back((getMaxPhysR(material)[iDim] - getMinPhysR(material)[iDim])/2.);
428 radius[iDim] = (getMaxPhysR(material)[iDim] - getMinPhysR(material)[iDim])/2.;
429 }
430 return radius;
431}

◆ getStatisticsStatus() [1/2]

template<typename T >
bool & olb::SuperGeometryStatistics3D< T >::getStatisticsStatus ( )

Read and write access to a flag, which indicates if an uptate is needed (=true)

Definition at line 71 of file superGeometryStatistics3D.hh.

72{
73 return _statisticsUpdateNeeded;
74}

◆ getStatisticsStatus() [2/2]

template<typename T >
bool const & olb::SuperGeometryStatistics3D< T >::getStatisticsStatus ( ) const

Read only access to a flag, which indicates if an uptate is needed (=true)

Definition at line 77 of file superGeometryStatistics3D.hh.

78{
79 return _statisticsUpdateNeeded;
80}

◆ getType() [1/2]

template<typename T >
olb::Vector< int, 3 > olb::SuperGeometryStatistics3D< T >::getType ( int iC,
int iX,
int iY,
int iZ )

Returns the boundary type which is characterized by a discrte normal (c.f. Zimny)

Definition at line 451 of file superGeometryStatistics3D.hh.

452{
453 update();
454 return const_this->getType(iC, iX, iY, iZ);
455}

◆ getType() [2/2]

template<typename T >
olb::Vector< int, 3 > olb::SuperGeometryStatistics3D< T >::getType ( int iC,
int iX,
int iY,
int iZ ) const

Definition at line 458 of file superGeometryStatistics3D.hh.

459{
460 int iCloc=_superGeometry->getLoadBalancer().loc(iC);
461 olb::Vector<int, 3> discreteNormal = _superGeometry->getBlockGeometry(iCloc).getStatistics().getType(iX, iY, iZ);
462 return discreteNormal;
463}

◆ operator=()

template<typename T >
SuperGeometryStatistics3D< T > & olb::SuperGeometryStatistics3D< T >::operator= ( SuperGeometryStatistics3D< T > const & rhs)

Copy assignment.

Definition at line 59 of file superGeometryStatistics3D.hh.

60{
61 _superGeometry = rhs._superGeometry;
62 _statisticsUpdateNeeded = true;
63 _nMaterials = rhs._nMaterials;
64 _minOverMaterial = rhs._minOverMaterial;
65 _maxOverMaterial = rhs._maxOverMaterial;
66 return *this;
67}

◆ print() [1/2]

template<typename T >
void olb::SuperGeometryStatistics3D< T >::print ( )

Prints some statistic information, i.e. the number of voxels and min. max. physical position for each different material.

Definition at line 556 of file superGeometryStatistics3D.hh.

557{
558 update();
559 return const_this->print();
560}

◆ print() [2/2]

template<typename T >
void olb::SuperGeometryStatistics3D< T >::print ( ) const

Definition at line 563 of file superGeometryStatistics3D.hh.

564{
565 try {
566 std::size_t nCells = 0;
567 for (const auto& material : _material2n) {
568 clout << "materialNumber=" << material.first
569 << "; count=" << material.second
570 << "; minPhysR=(" << _material2min.at(material.first)[0] <<","<< _material2min.at(material.first)[1] <<","<< _material2min.at(material.first)[2] <<")"
571 << "; maxPhysR=(" << _material2max.at(material.first)[0] <<","<< _material2max.at(material.first)[1] <<","<< _material2max.at(material.first)[2] <<")"
572 << std::endl;
573 nCells += material.second;
574 }
575 clout << "countTotal[1e6]=" << nCells / 1.e6 << std::endl;
576 }
577 catch (std::out_of_range& ex) {
578 }
579}

◆ update()

template<typename T >
void olb::SuperGeometryStatistics3D< T >::update ( bool verbose = false)

Updates the statistics if it is really needed.

Definition at line 84 of file superGeometryStatistics3D.hh.

85{
86 const_this = const_cast<const SuperGeometryStatistics3D<T>*>(this);
87
88#ifdef PARALLEL_MODE_MPI
89 // This needs to be done with integers due to undesired behaviour with bool and LOR implicated by the MPI standard
90 int updateReallyNeededGlobal = 0;
91 if (_statisticsUpdateNeeded) {
92 updateReallyNeededGlobal = 1;
93 }
94 singleton::mpi().reduceAndBcast(updateReallyNeededGlobal, MPI_SUM);
95
96 if (updateReallyNeededGlobal>0) {
97 _statisticsUpdateNeeded = true;
98 }
99 //singleton::mpi().reduceAndBcast(_statisticsUpdateNeeded, MPI_LOR);
100#endif
101
102 // check if update is really needed
103 if (_statisticsUpdateNeeded ) {
104 int updateReallyNeeded = 0;
105 for (int iCloc=0; iCloc<_superGeometry->getLoadBalancer().size(); iCloc++) {
106 if (_superGeometry->getBlockGeometry(iCloc).getStatistics().getStatisticsStatus() ) {
107 auto& blockGeometry = const_cast<BlockGeometry<T,3>&>(_superGeometry->getBlockGeometry(iCloc));
108 blockGeometry.getStatistics().update(false);
109 updateReallyNeeded++;
110 }
111 }
112
113
114#ifdef PARALLEL_MODE_MPI
115 singleton::mpi().reduceAndBcast(updateReallyNeeded, MPI_SUM);
116#endif
117
118 if (updateReallyNeeded==0) {
119 _statisticsUpdateNeeded = false;
120 // clout << "almost updated" << std::endl;
121 return;
122 }
123
124
125 // get total number of different materials right
126 _nMaterials = int();
127 {
128 std::set<int> tmpMaterials{};
129 for (int iCloc=0; iCloc<_superGeometry->getLoadBalancer().size(); iCloc++) {
130 const auto& blockMaterial2n = _superGeometry->getBlockGeometry(iCloc).getStatistics().getMaterial2n();
131 for (auto [material, _] : blockMaterial2n) {
132 tmpMaterials.insert(material);
133 }
134 }
135 _nMaterials = tmpMaterials.size();
136 }
137
138 _material2n = std::map<int, std::size_t>();
139
140#ifdef PARALLEL_MODE_MPI
141 singleton::mpi().reduceAndBcast(_nMaterials, MPI_SUM);
142#endif
143
144 // store the number and min., max. possition for each rank
145 for (int iCloc=0; iCloc<_superGeometry->getLoadBalancer().size(); iCloc++) {
146 std::map<int, std::size_t> material2n = _superGeometry->getBlockGeometry(iCloc).getStatistics().getMaterial2n();
147 std::map<int, std::size_t>::iterator iter;
148
149 for (iter = material2n.begin(); iter != material2n.end(); iter++) {
150 if (iter->second!=0) {
151 std::vector<T> minPhysR = _superGeometry->getBlockGeometry(iCloc).getStatistics().getMinPhysR(iter->first);
152 std::vector<T> maxPhysR = _superGeometry->getBlockGeometry(iCloc).getStatistics().getMaxPhysR(iter->first);
153 if (_material2n.count(iter->first) == 0) {
154 _material2n[iter->first] = iter->second;
155 _material2min[iter->first] = minPhysR;
156 _material2max[iter->first] = maxPhysR;
157 }
158 else {
159 _material2n[iter->first] += iter->second;
160 for (int iDim=0; iDim<3; iDim++) {
161 if (_material2min[iter->first][iDim] > minPhysR[iDim]) {
162 _material2min[iter->first][iDim] = minPhysR[iDim];
163 }
164 if (_material2max[iter->first][iDim] < maxPhysR[iDim]) {
165 _material2max[iter->first][iDim] = maxPhysR[iDim];
166 }
167 }
168 }
169 }
170 }
171 }
172
173 // store the number and min., max. possition for all ranks
174#ifdef PARALLEL_MODE_MPI
175 std::ptrdiff_t materials[_nMaterials];
176 std::ptrdiff_t materialsInBuf[_nMaterials];
177 std::ptrdiff_t materialCount[_nMaterials];
178 std::ptrdiff_t materialCountInBuf[_nMaterials];
179 T materialMinR[3*_nMaterials];
180 T materialMaxR[3*_nMaterials];
181 T materialMinRinBuf[3*_nMaterials];
182 T materialMaxRinBuf[3*_nMaterials];
183
184 for (int iM=0; iM<_nMaterials; iM++) {
185 materials[iM]=-1;
186 materialCount[iM]=0;
187 for (int iDim=0; iDim<3; iDim++) {
188 materialMinRinBuf[3*iM + iDim] = T();
189 materialMaxRinBuf[3*iM + iDim] = T();
190 }
191 }
192 std::size_t counter = 0;
193 std::map<int, std::size_t>::iterator iMaterial;
194 for (iMaterial = _material2n.begin(); iMaterial != _material2n.end(); iMaterial++) {
195 materials[counter] = iMaterial->first;
196 materialCount[counter] = iMaterial->second;
197 for (int iDim=0; iDim<3; iDim++) {
198 materialMinR[3*counter + iDim] = _material2min[iMaterial->first][iDim];
199 materialMaxR[3*counter + iDim] = _material2max[iMaterial->first][iDim];
200 }
201 counter++;
202 }
203
204 for (int iRank=1; iRank<singleton::mpi().getSize(); iRank++) {
205 int myRank = singleton::mpi().getRank();
206 singleton::mpi().sendRecv(materials, materialsInBuf, _nMaterials,
207 (myRank+iRank)%singleton::mpi().getSize(),
208 (myRank-iRank+singleton::mpi().getSize())%singleton::mpi().getSize(), 0);
209 singleton::mpi().sendRecv(materialCount, materialCountInBuf, _nMaterials,
210 (myRank+iRank)%singleton::mpi().getSize(),
211 (myRank-iRank+singleton::mpi().getSize())%singleton::mpi().getSize(), 1);
212 singleton::mpi().sendRecv(materialMinR, materialMinRinBuf, 3*_nMaterials,
213 (myRank+iRank)%singleton::mpi().getSize(),
214 (myRank-iRank+singleton::mpi().getSize())%singleton::mpi().getSize(), 2);
215 singleton::mpi().sendRecv(materialMaxR, materialMaxRinBuf, 3*_nMaterials,
216 (myRank+iRank)%singleton::mpi().getSize(),
217 (myRank-iRank+singleton::mpi().getSize())%singleton::mpi().getSize(), 3);
218 for (int iM=0; iM<_nMaterials; iM++) {
219 if (materialsInBuf[iM]!=-1) {
220 std::vector<T> minPhysR(3,T());
221 std::vector<T> maxPhysR(3,T());
222 for (int iDim=0; iDim<3; iDim++) {
223 minPhysR[iDim] = materialMinRinBuf[3*iM + iDim];
224 maxPhysR[iDim] = materialMaxRinBuf[3*iM + iDim];
225 }
226 if (_material2n.count(materialsInBuf[iM]) == 0) {
227 _material2n[materialsInBuf[iM]] = materialCountInBuf[iM];
228 _material2min[materialsInBuf[iM]] = minPhysR;
229 _material2max[materialsInBuf[iM]] = maxPhysR;
230 }
231 else {
232 _material2n[materialsInBuf[iM]] += materialCountInBuf[iM];
233 for (int iDim=0; iDim<3; iDim++) {
234 if (_material2min[materialsInBuf[iM]][iDim] > minPhysR[iDim]) {
235 _material2min[materialsInBuf[iM]][iDim] = minPhysR[iDim];
236 }
237 if (_material2max[materialsInBuf[iM]][iDim] < maxPhysR[iDim]) {
238 _material2max[materialsInBuf[iM]][iDim] = maxPhysR[iDim];
239 }
240 }
241 }
242 }
243 }
244 }
245#endif
246
247 // update _minOverMaterial and _maxOverMaterial
248 typename std::map< int, olb::Vector<T, 3> >::const_iterator iter;
249 // find componentwise minimal extension over all material numbers
250 for ( int iDim = 0; iDim < 3; iDim++ ) {
251 // minimum
252 for ( iter = _material2min.begin(); iter != _material2min.end(); iter++ ) {
253 if ( iter->first != 0 ) { // only relevant material number are considered
254 if ( _minOverMaterial[iDim] > iter->second[iDim] ) {
255 _minOverMaterial[iDim] = iter->second[iDim];
256 }
257 }
258 }
259 // maximum
260 for ( iter = _material2max.begin(); iter != _material2max.end(); iter++ ) {
261 if ( iter->first != 0 ) { // only relevant material number are considered
262 if ( _maxOverMaterial[iDim] < iter->second[iDim] ) {
263 _maxOverMaterial[iDim] = iter->second[iDim];
264 }
265 }
266 }
267 }
268
269 //clout.setMultiOutput(true);
270// print();
271 //clout.setMultiOutput(false);
272
273 if (verbose) {
274 clout << "updated" << std::endl;
275 }
276 _statisticsUpdateNeeded = false;
277 }
278}
int getSize() const
Returns the number of processes.
int getRank() const
Returns the process ID.
void sendRecv(T *sendBuf, T *recvBuf, int count, int dest, int source, int tag=0, MPI_Comm comm=MPI_COMM_WORLD)
Send and receive data between two partners.

References olb::singleton::MpiManager::getRank(), olb::singleton::MpiManager::getSize(), olb::BlockGeometry< T, D >::getStatistics(), olb::singleton::mpi(), olb::singleton::MpiManager::reduceAndBcast(), and olb::singleton::MpiManager::sendRecv().

+ Here is the call graph for this function:

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