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

BlockReduction2D2D interpolates the data of a SuperF2D functor in a given resolution. More...

#include <blockReduction2D2D.h>

+ Inheritance diagram for olb::BlockReduction2D2D< T >:
+ Collaboration diagram for olb::BlockReduction2D2D< T >:

Public Member Functions

 BlockReduction2D2D (FunctorPtr< SuperF2D< T > > &&f, int resolution=600, BlockDataSyncMode mode=BlockDataSyncMode::ReduceAndBcast)
 
Vector< T, 2 > getPhysR (const int &iX, const int &iY) const
 Transform lattice coordinates to their physical location.
 
HyperplaneLattice3D< T > getPlaneDiscretizationIn3D () const
 Returns embedding of the discretized plane in 3D space.
 
void initialize ()
 Initialize rank-local list of points to be stored in _blockData.
 
void update ()
 Updates and writes the data to _blockData using _rankLocalSubplane.
 
BlockStructureD< 2 > & getBlockStructure () override
 Overload of virtual function from class BlockF2D.
 
- Public Member Functions inherited from olb::BlockDataF2D< T, T >
 BlockDataF2D (BlockData< 2, T, T > &blockData)
 Constructor.
 
 BlockDataF2D (BlockF2D< T > &f)
 to store functor data, constuctor creates _blockData with functor data
 
 ~BlockDataF2D ()
 
BlockData< 2, T, T > & getBlockData ()
 returns _blockData
 
bool operator() (T output[], const int input[]) override
 access to _blockData via its get()
 
- Public Member Functions inherited from olb::BlockF2D< T >
void setBlockStructure (BlockStructureD< 2 > *blockStructure)
 
BlockF2D< T > & operator- (BlockF2D< T > &rhs)
 
BlockF2D< T > & operator+ (BlockF2D< T > &rhs)
 
BlockF2D< T > & operator* (BlockF2D< T > &rhs)
 
BlockF2D< T > & operator/ (BlockF2D< T > &rhs)
 
- Public Member Functions inherited from olb::GenericF< T, int >
virtual ~GenericF ()=default
 
int getSourceDim () const
 read only access to member variable _m
 
int getTargetDim () const
 read only access to member variable _n
 
std::string & getName ()
 read and write access to name
 
std::string const & getName () const
 read only access to name
 
virtual bool operator() (T output[], const int input[])=0
 has to be implemented for 'every' derived class
 
bool operator() (T output[])
 wrapper that call the pure virtual operator() (T output[], const S input[]) from above
 
bool operator() (T output[], int input0)
 
bool operator() (T output[], int input0, int input1)
 
bool operator() (T output[], int input0, int input1, int input2)
 
bool operator() (T output[], int input0, int input1, int input2, int input3)
 

Additional Inherited Members

- Public Types inherited from olb::GenericF< T, int >
using targetType
 
using sourceType
 
- Public Attributes inherited from olb::GenericF< T, int >
std::shared_ptr< GenericF< T, int > > _ptrCalcC
 memory management, frees resouces (calcClass)
 
- Protected Member Functions inherited from olb::BlockDataF2D< T, T >
 BlockDataF2D (int nx, int ny, int size=1)
 
- Protected Member Functions inherited from olb::BlockF2D< T >
 BlockF2D (BlockStructureD< 2 > &blockStructure, int targetDim)
 
 BlockF2D (int targetDim)
 
- Protected Member Functions inherited from olb::GenericF< T, int >
 GenericF (int targetDim, int sourceDim)
 
- Protected Attributes inherited from olb::BlockDataF2D< T, T >
BlockData< 2, T, T > * _blockData
 
bool _owning
 
- Protected Attributes inherited from olb::BlockF2D< T >
BlockStructureD< 2 > * _blockStructure
 

Detailed Description

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

BlockReduction2D2D interpolates the data of a SuperF2D functor in a given resolution.

This is primarily used for exporting GIF images via BlockGifWriter.

Definition at line 47 of file blockReduction2D2D.h.

Constructor & Destructor Documentation

◆ BlockReduction2D2D()

template<typename T >
olb::BlockReduction2D2D< T >::BlockReduction2D2D ( FunctorPtr< SuperF2D< T > > && f,
int resolution = 600,
BlockDataSyncMode mode = BlockDataSyncMode::ReduceAndBcast )

Definition at line 68 of file blockReduction2D2D.hh.

70 : BlockDataF2D<T,T>(f->getSuperStructure().getCuboidGeometry().getMotherCuboid().getNx(),
71 f->getSuperStructure().getCuboidGeometry().getMotherCuboid().getNy(),
72 f->getTargetDim()),
73 _f(std::move(f)),
74 _origin(_f->getSuperStructure().getCuboidGeometry().getMotherCuboid().getOrigin()),
75 _h(_f->getSuperStructure().getCuboidGeometry().getMinDeltaR()),
76 _nx(_f->getSuperStructure().getCuboidGeometry().getMotherCuboid().getNx()),
77 _ny(_f->getSuperStructure().getCuboidGeometry().getMotherCuboid().getNy()),
78 _syncMode(mode)
79{
80 this->getName() = "planeReduction(" + _f->getName() + ")";
81
82 _origin[0] -= 10*std::numeric_limits<T>::epsilon();
83 _origin[1] -= 10*std::numeric_limits<T>::epsilon();
84
85 // changes _h, _nx, _ny to match resolution
86 updateToWantedResolution(resolution);
87 // intialize list of relevant rank local points
88 initialize();
89 // first update of data
90 update();
91}
void initialize()
Initialize rank-local list of points to be stored in _blockData.
void update()
Updates and writes the data to _blockData using _rankLocalSubplane.
std::string & getName()
read and write access to name
Definition genericF.hh:51

References olb::GenericF< T, int >::getName(), olb::BlockReduction2D2D< T >::initialize(), and olb::BlockReduction2D2D< T >::update().

+ Here is the call graph for this function:

Member Function Documentation

◆ getBlockStructure()

template<typename T >
BlockStructureD< 2 > & olb::BlockReduction2D2D< T >::getBlockStructure ( )
overridevirtual

Overload of virtual function from class BlockF2D.

Reimplemented from olb::BlockF2D< T >.

Definition at line 193 of file blockReduction2D2D.hh.

194{
195 return *this->_blockData;
196}
BlockData< 2, T, T > * _blockData

◆ getPhysR()

template<typename T >
Vector< T, 2 > olb::BlockReduction2D2D< T >::getPhysR ( const int & iX,
const int & iY ) const

Transform lattice coordinates to their physical location.

Definition at line 94 of file blockReduction2D2D.hh.

95{
96 return Vector<T,2> {
97 _origin[0] + T(iX) * _h,
98 _origin[1] + T(iY) * _h
99 };
100}

◆ getPlaneDiscretizationIn3D()

template<typename T >
HyperplaneLattice3D< T > olb::BlockReduction2D2D< T >::getPlaneDiscretizationIn3D ( ) const

Returns embedding of the discretized plane in 3D space.

i.e. span vectors are X, Y unit vectors. Origin, spacing and resolution is exposed.

Required for dimension agnostic implementation of GnuplotHeatMap<T>

Definition at line 103 of file blockReduction2D2D.hh.

104{
105 return HyperplaneLattice3D<T>(
106 Hyperplane3D<T>()
107 .originAt({_origin[0], _origin[1], 0})
108 .spannedBy({1,0,0}, {0,1,0}),
109 _h, _nx, _ny);
110}
+ Here is the caller graph for this function:

◆ initialize()

template<typename T >
void olb::BlockReduction2D2D< T >::initialize ( )

Initialize rank-local list of points to be stored in _blockData.

Definition at line 113 of file blockReduction2D2D.hh.

114{
115 const CuboidGeometry2D<T>& geometry = _f->getSuperStructure().getCuboidGeometry();
116 LoadBalancer<T>& load = _f->getSuperStructure().getLoadBalancer();
117
118 _rankLocalSubplane.clear();
119
120 for ( int iX = 0; iX < _nx; ++iX ) {
121 for ( int iY = 0; iY < _ny; ++iY ) {
122 const Vector<T,2> physR = getPhysR(iX, iY);
123
124 // Schedule plane point for storage if its physical position intersects the
125 // mother cuboid and the cuboid of the nearest lattice position is local to
126 // the current rank:
127 int iC;
128 if ( geometry.getC(physR, iC) ) {
129 if ( load.isLocal(iC) ) {
130 _rankLocalSubplane.emplace_back(iX, iY, iC);
131 }
132 }
133 }
134 }
135}
Vector< T, 2 > getPhysR(const int &iX, const int &iY) const
Transform lattice coordinates to their physical location.

References olb::CuboidGeometry2D< T >::getC(), and olb::LoadBalancer< T >::isLocal().

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

◆ update()

template<typename T >
void olb::BlockReduction2D2D< T >::update ( )

Updates and writes the data to _blockData using _rankLocalSubplane.

Definition at line 138 of file blockReduction2D2D.hh.

139{
140 _f->getSuperStructure().communicate();
141
142 AnalyticalFfromSuperF2D<T> analyticalF(*_f);
143
144#ifdef PARALLEL_MODE_MPI
145 std::unique_ptr<BlockData<2,T,T>> localBlockData(
146 new BlockData<2,T,T>({{_nx, _ny}, 0}, this->getTargetDim()));
147#endif
148
149 for ( std::tuple<int,int,int>& pos : _rankLocalSubplane ) {
150 const int& iX = std::get<0>(pos);
151 const int& iY = std::get<1>(pos);
152 const Vector<T,2> physR = getPhysR(iX, iY);
153
154 for ( int iSize = 0; iSize < _f->getTargetDim(); ++iSize ) {
155 this->_blockData->get({iX, iY}, iSize) = T();
156 }
157
158 T output[_f->getTargetDim()];
159 const T input[2] { physR[0], physR[1] };
160
161 if (analyticalF(output, input)) {
162 for ( int iSize = 0; iSize < _f->getTargetDim(); ++iSize ) {
163#ifdef PARALLEL_MODE_MPI
164 localBlockData->get({iX, iY}, iSize) += output[iSize];
165#else
166 this->_blockData->get({iX, iY}, iSize) += output[iSize];
167#endif
168 }
169 }
170 }
171
172#ifdef PARALLEL_MODE_MPI
173 switch ( _syncMode ) {
175 singleton::mpi().reduce(*localBlockData, this->getBlockData(), MPI_SUM);
177 break;
179 singleton::mpi().reduce(*localBlockData, this->getBlockData(), MPI_SUM);
180 break;
182 if (this->_owning) {
183 delete this->_blockData;
184 }
185 this->_blockData = localBlockData.release();
186 this->_owning = true;
187 break;
188 }
189#endif
190}
BlockData< 2, T, T > & getBlockData()
returns _blockData
U & get(std::size_t iCell, int iD=0)
Definition blockData.hh:94
int getTargetDim() const
read only access to member variable _n
Definition genericF.hh:45
void bCast(T *sendBuf, int sendCount, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Broadcast data from one processor to multiple processors.
void reduce(T &sendVal, T &recvVal, MPI_Op op, int root=0, MPI_Comm=MPI_COMM_WORLD)
Reduction operation toward one processor.
MpiManager & mpi()
@ ReduceOnly
optimize for usage in e.g. BlockGifWriter, full data only available on main rank
@ None
optimize for usage in e.g. SuperLatticeFlux3D, only rank-local data available
@ ReduceAndBcast
default behavior, full block data available on all ranks after update

References olb::singleton::MpiManager::bCast(), olb::singleton::mpi(), olb::None, olb::singleton::MpiManager::reduce(), olb::ReduceAndBcast, and olb::ReduceOnly.

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

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