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

BlockReduction2D1D reduces the data of a SuperF2D functor to the intersection between a given 2D hyperplane and the super geometry. More...

#include <blockReduction2D1D.h>

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

Public Member Functions

 BlockReduction2D1D (FunctorPtr< SuperF2D< T > > &&f, const HyperplaneLattice2D< T > &lattice, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast, BlockDataReductionMode reductionMode=BlockDataReductionMode::Analytical)
 Construction using functor and hyperplane lattice.
 
 BlockReduction2D1D (FunctorPtr< SuperF2D< T > > &&f, const Hyperplane2D< T > &hyperplane, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast, BlockDataReductionMode reductionMode=BlockDataReductionMode::Analytical)
 Construction using functor and hyperplane.
 
 BlockReduction2D1D (FunctorPtr< SuperF2D< T > > &&f, const Hyperplane2D< T > &hyperplane, int resolution=600, BlockDataSyncMode mode=BlockDataSyncMode::ReduceAndBcast)
 Construction using functor, hyperplane and resolution.
 
 BlockReduction2D1D (FunctorPtr< SuperF2D< T > > &&f, const Vector< T, 2 > &origin, const Vector< T, 2 > &direction, int resolution=600, BlockDataSyncMode mode=BlockDataSyncMode::ReduceAndBcast)
 Construction using functor, origin, direction and resolution.
 
bool operator() (T output[], int i)
 Custom operator for easier access to 1-dimensional block data.
 
void initialize ()
 Initialize rank-local list of plane 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.
 
const std::vector< std::tuple< int, int > > & getRankLocalSubplane () const
 
- Public Member Functions inherited from olb::HyperplaneLattice2D< T >
 HyperplaneLattice2D (CuboidGeometry2D< T > &geometry, Hyperplane2D< T > hyperplane)
 Constructor for automatic discretization.
 
 HyperplaneLattice2D (CuboidGeometry2D< T > &geometry, Hyperplane2D< T > hyperplane, int resolution)
 Constructor for discretization of a given resolution.
 
 HyperplaneLattice2D (CuboidGeometry2D< T > &geometry, Hyperplane2D< T > hyperplane, T h)
 Constructor for discretization of a given grid width.
 
 HyperplaneLattice2D (const HyperplaneLattice2D &)=default
 
const Hyperplane2D< T > & getHyperplane () const
 
Vector< T, 2 > getPhysR (const int &n) const
 Transform 1d lattice coordinates to their physical 2d location.
 
int getN () const
 
getPhysSpacing () const
 
Vector< T, 2 > getPhysOrigin () const
 
Vector< T, 2 > getVectorU () const
 
- 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::HyperplaneLattice2D< T >
const Hyperplane2D< T > _hyperplane
 
Vector< T, 2 > _origin
 Origin vector of the lattice.
 
Vector< T, 2 > _u
 Direction vector of the lattice, normalized to grid width _h.
 
_h
 Distance between discrete lattice points.
 
int _n
 Number of lattice points in the direction of _u.
 
- 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::BlockReduction2D1D< T >

BlockReduction2D1D reduces the data of a SuperF2D functor to the intersection between a given 2D hyperplane and the super geometry.

This intersection is interpolated at a set of discrete points according to the given resolution and exposed as a 1-dimensional BlockDataF2D functor.

The hyperplane is parametrized by a origin and a single directionb vector u. Definition of hyperplanes using e.g. origin and normal vectors is supported via the Hyperplane2D interface.

Definition at line 54 of file blockReduction2D1D.h.

Constructor & Destructor Documentation

◆ BlockReduction2D1D() [1/4]

template<typename T >
olb::BlockReduction2D1D< T >::BlockReduction2D1D ( FunctorPtr< SuperF2D< T > > && f,
const HyperplaneLattice2D< T > & lattice,
BlockDataSyncMode syncMode = BlockDataSyncMode::ReduceAndBcast,
BlockDataReductionMode reductionMode = BlockDataReductionMode::Analytical )

Construction using functor and hyperplane lattice.

Parameters
fFunctor to be reduced as a (non-)owning pointer or reference to SuperF2D<T>.
latticeHyperplane lattice parametrization
syncModeDefines MPI synchronization strategy of the interpolated block data.
reductionModeDefines whether data is interpolated or read from discrete lattice locations. Note: BlockDataReductionMode::Analytical imposes restrictions on hyperplane definition and discretization.

Definition at line 93 of file blockReduction2D1D.hh.

98 : HyperplaneLattice2D<T>(lattice),
99 BlockDataF2D<T,T>(lattice.getN(), 1, f->getTargetDim()),
100 _f(std::move(f)),
101 _syncMode(syncMode),
102 _reductionMode(reductionMode)
103{
104 this->getName() = "lineReduction(" + _f->getName() + ")";
105
106 if ( _reductionMode == BlockDataReductionMode::Discrete ) {
107 const CuboidGeometry2D<T>& geometry = _f->getSuperStructure().getCuboidGeometry();
108 const Hyperplane2D<T>& hyperplane = this->getHyperplane();
109 const bool spansAxisPlane = hyperplane.isParallelToX() ||
110 hyperplane.isParallelToY();
111 // verify axes alignment and spacing of hyperplane parametrization
112 if ( !spansAxisPlane ||
113 lattice.getPhysSpacing() != geometry.getMinDeltaR() ) {
114 // hyperplane lattice doesn't describe a trivially discretizable plane
115 OstreamManager clerr(std::cerr, "BlockReduction2D1D");
116 clerr << "Given hyperplane is not trivially discretizable. "
117 << "Use BlockDataReductionMode::Analytical instead."
118 << std::endl;
119 exit(-1);
120 }
121 }
122
123 // intialize list of relevant rank local points making up the reduced line
124 initialize();
125 // first update of data
126 update();
127}
void update()
Updates and writes the data to _blockData using _rankLocalSubplane.
void initialize()
Initialize rank-local list of plane points to be stored in _blockData.
std::string & getName()
read and write access to name
Definition genericF.hh:51
const Hyperplane2D< T > & getHyperplane() const
void exit(int exitcode)
Definition singleton.h:165
@ Discrete
Read block data from discrete lattice locations.

References olb::Discrete, olb::HyperplaneLattice2D< T >::getHyperplane(), olb::CuboidGeometry2D< T >::getMinDeltaR(), olb::GenericF< T, int >::getName(), olb::HyperplaneLattice2D< T >::getPhysSpacing(), olb::BlockReduction2D1D< T >::initialize(), olb::Hyperplane2D< T >::isParallelToX(), olb::Hyperplane2D< T >::isParallelToY(), and olb::BlockReduction2D1D< T >::update().

+ Here is the call graph for this function:

◆ BlockReduction2D1D() [2/4]

template<typename T >
olb::BlockReduction2D1D< T >::BlockReduction2D1D ( FunctorPtr< SuperF2D< T > > && f,
const Hyperplane2D< T > & hyperplane,
BlockDataSyncMode syncMode = BlockDataSyncMode::ReduceAndBcast,
BlockDataReductionMode reductionMode = BlockDataReductionMode::Analytical )

Construction using functor and hyperplane.

Parameters
fFunctor to be reduced as a (non-)owning pointer or reference to SuperF2D<T>.
hyperplaneHyperplane parametrization
syncModeDefines MPI synchronization strategy of the interpolated block data.
reductionModeDefines whether data is interpolated or read from discrete lattice locations.

Definition at line 130 of file blockReduction2D1D.hh.

136 std::forward<decltype(f)>(f),
137 HyperplaneLattice2D<T>(f->getSuperStructure().getCuboidGeometry(),
138 hyperplane),
139 syncMode,
140 reductionMode)
141{ }
BlockReduction2D1D(FunctorPtr< SuperF2D< T > > &&f, const HyperplaneLattice2D< T > &lattice, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast, BlockDataReductionMode reductionMode=BlockDataReductionMode::Analytical)
Construction using functor and hyperplane lattice.

◆ BlockReduction2D1D() [3/4]

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

Construction using functor, hyperplane and resolution.

Parameters
fFunctor to be reduced as a (non-)owning pointer or reference to SuperF2D<T>.
hyperplaneHyperplane parametrization
resolutionDefines the number of voxel of the longest side. If it equals zero, _h is set to the cuboid geometry's minDeltaR.
modeDefines MPI synchronization strategy of the interpolated block data.

Definition at line 144 of file blockReduction2D1D.hh.

149 std::forward<decltype(f)>(f),
150 HyperplaneLattice2D<T>(f->getSuperStructure().getCuboidGeometry(),
151 hyperplane, resolution),
152 mode)
153{ }

◆ BlockReduction2D1D() [4/4]

template<typename T >
olb::BlockReduction2D1D< T >::BlockReduction2D1D ( FunctorPtr< SuperF2D< T > > && f,
const Vector< T, 2 > & origin,
const Vector< T, 2 > & direction,
int resolution = 600,
BlockDataSyncMode mode = BlockDataSyncMode::ReduceAndBcast )

Construction using functor, origin, direction and resolution.

Parameters
fFunctor to be reduced as a (non-)owning pointer or reference to SuperF2D<T>.
directionDirection vector
originOrigin vector
resolutionDefines the number of voxel of the longest side. If it equals zero, _h is set to the cuboid geometry's minDeltaR.
modeDefines MPI synchronization strategy of the interpolated block data.

Definition at line 156 of file blockReduction2D1D.hh.

161 std::forward<decltype(f)>(f),
162 Hyperplane2D<T>().originAt(origin).parallelTo(direction),
163 resolution, mode) { }

Member Function Documentation

◆ getBlockStructure()

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

Overload of virtual function from class BlockF2D.

Reimplemented from olb::BlockF2D< T >.

Definition at line 242 of file blockReduction2D1D.hh.

243{
244 return *this->_blockData;
245}
BlockData< 2, T, T > * _blockData

◆ getRankLocalSubplane()

template<typename T >
const std::vector< std::tuple< int, int > > & olb::BlockReduction2D1D< T >::getRankLocalSubplane ( ) const
Returns
reference to the rank local list of discrete line points, cuboid ids

Definition at line 248 of file blockReduction2D1D.hh.

249{
250 return this->_rankLocalSubplane;
251}

◆ initialize()

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

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

Definition at line 173 of file blockReduction2D1D.hh.

174{
175 const CuboidGeometry2D<T>& geometry = _f->getSuperStructure().getCuboidGeometry();
176 LoadBalancer<T>& load = _f->getSuperStructure().getLoadBalancer();
177
178 _rankLocalSubplane.clear();
179
180 for ( int i = 0; i < this->getN(); ++i ) {
181 const Vector<T,2> physR = this->getPhysR(i);
182
183 // Schedule line point for storage if its physical position intersects the
184 // mother cuboid and the cuboid of the nearest lattice position is local to
185 // the current rank:
186 int iC;
187 if ( geometry.getC(physR, iC) ) {
188 if ( load.isLocal(iC) ) {
189 _rankLocalSubplane.emplace_back(i, iC);
190 }
191 }
192 }
193}
Vector< T, 2 > getPhysR(const int &n) const
Transform 1d lattice coordinates to their physical 2d 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:

◆ operator()()

template<typename T >
bool olb::BlockReduction2D1D< T >::operator() ( T output[],
int i )

Custom operator for easier access to 1-dimensional block data.

Definition at line 166 of file blockReduction2D1D.hh.

167{
168 const int input[2] = { i, 0 };
169 return static_cast<BlockDataF2D<T,T>*>(this)->operator()(output, input);
170}

◆ update()

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

Updates and writes the data to _blockData using _rankLocalSubplane.

Definition at line 196 of file blockReduction2D1D.hh.

197{
198 _f->getSuperStructure().communicate();
199
200#ifdef PARALLEL_MODE_MPI
201 std::unique_ptr<BlockData<2,T,T>> localBlockData(
202 new BlockData<2,T,T>({{this->getN(), 1}, 0}, _f->getTargetDim()));
203
204 switch ( _reductionMode ) {
206 updateBlockAnalytical(*localBlockData);
207 break;
209 updateBlockDiscrete(*localBlockData);
210 break;
211 }
212
213 switch ( _syncMode ) {
215 singleton::mpi().reduce(*localBlockData, this->getBlockData(), MPI_SUM);
217 break;
219 singleton::mpi().reduce(*localBlockData, this->getBlockData(), MPI_SUM);
220 break;
222 if (this->_owning) {
223 delete this->_blockData;
224 }
225 this->_blockData = localBlockData.release();
226 this->_owning = true;
227 break;
228 }
229#else
230 switch ( _reductionMode ) {
232 updateBlockAnalytical(this->getBlockData());
233 break;
235 updateBlockDiscrete(this->getBlockData());
236 break;
237 }
238#endif
239}
BlockData< 2, T, T > & getBlockData()
returns _blockData
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()
@ Analytical
Interpolate block data at exact physical locations.
@ 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::Analytical, olb::singleton::MpiManager::bCast(), olb::Discrete, 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: