OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::BlockReduction3D2D< T > Class Template Referencefinal

BlockReduction3D2D reduces the data of a SuperF3D functor to the intersection between a given hyperplane and the super geometry. More...

#include <blockReduction3D2D.h>

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

Public Member Functions

 BlockReduction3D2D (FunctorPtr< SuperF3D< T > > &&f, const HyperplaneLattice3D< T > &lattice, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast, BlockDataReductionMode reductionMode=BlockDataReductionMode::Analytical)
 Construction using functor and hyperplane lattice.
 
 BlockReduction3D2D (FunctorPtr< SuperF3D< T > > &&f, const Hyperplane3D< T > &hyperplane, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast, BlockDataReductionMode reductionMode=BlockDataReductionMode::Analytical)
 Construction using functor and hyperplane.
 
 BlockReduction3D2D (FunctorPtr< SuperF3D< T > > &&f, const Hyperplane3D< T > &hyperplane, int resolution=600, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast)
 Construction using functor, hyperplane and resolution.
 
 BlockReduction3D2D (FunctorPtr< SuperF3D< T > > &&f, const Vector< T, 3 > &origin, const Vector< T, 3 > &u, const Vector< T, 3 > &v, int resolution=600, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast)
 Construction using functor, origin and span vectors as well as resolution.
 
 BlockReduction3D2D (FunctorPtr< SuperF3D< T > > &&f, const Vector< T, 3 > &origin, const Vector< T, 3 > &normal, int resolution=600, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast)
 Construction using functor, origin, normal and resolution.
 
 BlockReduction3D2D (FunctorPtr< SuperF3D< T > > &&f, const Vector< T, 3 > &normal, int resolution=600, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast)
 Construction using functor, normal vector and resolution.
 
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, int > > & getRankLocalSubplane () const
 
- Public Member Functions inherited from olb::HyperplaneLattice3D< T >
 HyperplaneLattice3D (CuboidDecomposition< T, 3 > &geometry, Hyperplane3D< T > hyperplane)
 Constructor for automatic discretization.
 
 HyperplaneLattice3D (CuboidDecomposition< T, 3 > &geometry, Hyperplane3D< T > hyperplane, int resolution)
 Constructor for discretization of a given resolution.
 
 HyperplaneLattice3D (CuboidDecomposition< T, 3 > &geometry, Hyperplane3D< T > hyperplane, T h)
 Constructor for discretization of a given grid width.
 
 HyperplaneLattice3D (Hyperplane3D< T > hyperplane, T h, int nx, int ny)
 Constructor for manual discretization.
 
 HyperplaneLattice3D (const HyperplaneLattice3D &)=default
 
const Hyperplane3D< T > & getHyperplane () const
 
Vector< T, 3 > getPhysR (const int &planeX, const int &planeY) const
 Transform 2d lattice coordinates to their physical 3d location.
 
int getNx () const
 
int getNy () const
 
getPhysSpacing () const
 
Vector< T, 3 > getPhysOrigin () const
 
Vector< T, 3 > getVectorU () const
 
Vector< T, 3 > getVectorV () 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::HyperplaneLattice3D< T >
const Hyperplane3D< T > _hyperplane
 
Vector< T, 3 > _origin
 Origin vector of the lattice.
 
Vector< T, 3 > _u
 Span vector of the lattice, normalized to grid width _h.
 
Vector< T, 3 > _v
 Span vector of the lattice, normalized to grid width _h.
 
_h
 Distance between discrete lattice points.
 
int _nx
 Number of lattice points in the direction of _u.
 
int _ny
 Number of lattice points in the direction of _v.
 
- 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::BlockReduction3D2D< T >

BlockReduction3D2D reduces the data of a SuperF3D functor to the intersection between a given hyperplane and the super geometry.

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

The hyperplane is parametrized by a origin and two span vector u and v. Definition of hyperplanes using e.g. origin and normal vectors is supported via the Hyperplane3D interface.

Definition at line 54 of file blockReduction3D2D.h.

Constructor & Destructor Documentation

◆ BlockReduction3D2D() [1/6]

template<typename T >
olb::BlockReduction3D2D< T >::BlockReduction3D2D ( FunctorPtr< SuperF3D< T > > && f,
const HyperplaneLattice3D< 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 SuperF3D<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 92 of file blockReduction3D2D.hh.

97 : HyperplaneLattice3D<T>(lattice),
98 BlockDataF2D<T,T>(lattice.getNx(), lattice.getNy(), f->getTargetDim()),
99 _f(std::move(f)),
100 _syncMode(syncMode),
101 _reductionMode(reductionMode)
102{
103 this->getName() = "planeReduction(" + _f->getName() + ")";
104
105 if ( _reductionMode == BlockDataReductionMode::Discrete ) {
106 const auto& geometry = _f->getSuperStructure().getCuboidDecomposition();
107 const Hyperplane3D<T>& hyperplane = this->getHyperplane();
108 const bool spansAxisPlane = hyperplane.isXYPlane() ||
109 hyperplane.isXZPlane() ||
110 hyperplane.isYZPlane();
111 // verify axes alignment and spacing of hyperplane parametrization
112 if ( !spansAxisPlane ||
113 lattice.getPhysSpacing() != geometry.getDeltaR() ) {
114 // hyperplane lattice doesn't describe a trivially discretizable plane
115 OstreamManager clerr(std::cerr, "BlockReduction3D2D");
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 plane
124 initialize();
125 // first update of data
126 update();
127}
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.
std::string & getName()
Definition genericF.hh:51
HyperplaneLattice3D(CuboidDecomposition< T, 3 > &geometry, Hyperplane3D< T > hyperplane)
Constructor for automatic discretization.
const Hyperplane3D< T > & getHyperplane() const
void exit(int exitcode)
Definition singleton.h:177
@ Discrete
Read block data from discrete lattice locations.

References olb::Discrete, olb::HyperplaneLattice3D< T >::getHyperplane(), olb::GenericF< T, int >::getName(), olb::HyperplaneLattice3D< T >::getPhysSpacing(), olb::BlockReduction3D2D< T >::initialize(), olb::Hyperplane3D< T >::isXYPlane(), olb::Hyperplane3D< T >::isXZPlane(), olb::Hyperplane3D< T >::isYZPlane(), and olb::BlockReduction3D2D< T >::update().

+ Here is the call graph for this function:

◆ BlockReduction3D2D() [2/6]

template<typename T >
olb::BlockReduction3D2D< T >::BlockReduction3D2D ( FunctorPtr< SuperF3D< T > > && f,
const Hyperplane3D< 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 SuperF3D<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 blockReduction3D2D.hh.

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

◆ BlockReduction3D2D() [3/6]

template<typename T >
olb::BlockReduction3D2D< T >::BlockReduction3D2D ( FunctorPtr< SuperF3D< T > > && f,
const Hyperplane3D< T > & hyperplane,
int resolution = 600,
BlockDataSyncMode syncMode = BlockDataSyncMode::ReduceAndBcast )

Construction using functor, hyperplane and resolution.

Parameters
fFunctor to be reduced as a (non-)owning pointer or reference to SuperF3D<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.
syncModeDefines MPI synchronization strategy of the interpolated block data.

Definition at line 144 of file blockReduction3D2D.hh.

150 std::forward<decltype(f)>(f),
151 HyperplaneLattice3D<T>(f->getSuperStructure().getCuboidDecomposition(),
152 hyperplane, resolution),
153 syncMode)
154{ }

◆ BlockReduction3D2D() [4/6]

template<typename T >
olb::BlockReduction3D2D< T >::BlockReduction3D2D ( FunctorPtr< SuperF3D< T > > && f,
const Vector< T, 3 > & origin,
const Vector< T, 3 > & u,
const Vector< T, 3 > & v,
int resolution = 600,
BlockDataSyncMode syncMode = BlockDataSyncMode::ReduceAndBcast )

Construction using functor, origin and span vectors as well as resolution.

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

Definition at line 157 of file blockReduction3D2D.hh.

162 std::forward<decltype(f)>(f),
163 Hyperplane3D<T>().originAt(origin).spannedBy(u, v),
164 resolution, syncMode)
165{ }

◆ BlockReduction3D2D() [5/6]

template<typename T >
olb::BlockReduction3D2D< T >::BlockReduction3D2D ( FunctorPtr< SuperF3D< T > > && f,
const Vector< T, 3 > & origin,
const Vector< T, 3 > & normal,
int resolution = 600,
BlockDataSyncMode syncMode = BlockDataSyncMode::ReduceAndBcast )

Construction using functor, origin, normal and resolution.

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

Definition at line 168 of file blockReduction3D2D.hh.

173 std::forward<decltype(f)>(f),
174 Hyperplane3D<T>().originAt(origin).normalTo(normal),
175 resolution, syncMode)
176{ }

◆ BlockReduction3D2D() [6/6]

template<typename T >
olb::BlockReduction3D2D< T >::BlockReduction3D2D ( FunctorPtr< SuperF3D< T > > && f,
const Vector< T, 3 > & normal,
int resolution = 600,
BlockDataSyncMode syncMode = BlockDataSyncMode::ReduceAndBcast )

Construction using functor, normal vector and resolution.

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

Definition at line 179 of file blockReduction3D2D.hh.

184 std::forward<decltype(f)>(f),
185 Hyperplane3D<T>()
186 .centeredIn(f->getSuperStructure().getCuboidDecomposition().getMotherCuboid())
187 .normalTo(normal),
188 resolution, syncMode)
189{ }

Member Function Documentation

◆ getBlockStructure()

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

Overload of virtual function from class BlockF2D.

Reimplemented from olb::BlockF2D< T >.

Definition at line 262 of file blockReduction3D2D.hh.

263{
264 return *this->_blockData;
265}
BlockData< 2, T, T > * _blockData

◆ getRankLocalSubplane()

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

Definition at line 268 of file blockReduction3D2D.hh.

269{
270 return this->_rankLocalSubplane;
271}

◆ initialize()

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

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

Definition at line 192 of file blockReduction3D2D.hh.

193{
194 const auto& geometry = _f->getSuperStructure().getCuboidDecomposition();
195 LoadBalancer<T>& load = _f->getSuperStructure().getLoadBalancer();
196
197 _rankLocalSubplane.clear();
198
199 for ( int iX = 0; iX < this->getNx(); ++iX ) {
200 for ( int iY = 0; iY < this->getNy(); ++iY ) {
201 const Vector<T,3> physR = this->getPhysR(iX, iY);
202
203 // Schedule plane point for storage if its physical position intersects the
204 // mother cuboid and the cuboid of the nearest lattice position is local to
205 // the current rank:
206 if (auto iC = geometry.getC(physR)) {
207 if ( load.isLocal(*iC) ) {
208 _rankLocalSubplane.emplace_back(iX, iY, *iC);
209 }
210 }
211 }
212 }
213}
Vector< T, 3 > getPhysR(const int &planeX, const int &planeY) const
Transform 2d lattice coordinates to their physical 3d location.

References 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::BlockReduction3D2D< T >::update ( )

Updates and writes the data to _blockData using _rankLocalSubplane.

Definition at line 216 of file blockReduction3D2D.hh.

217{
218 _f->getSuperStructure().communicate();
219
220#ifdef PARALLEL_MODE_MPI
221 std::unique_ptr<BlockData<2,T,T>> localBlockData(
222 new BlockData<2,T,T>({{this->getNx(), this->getNy()}, 0}, _f->getTargetDim()));
223
224 switch ( _reductionMode ) {
226 updateBlockAnalytical(*localBlockData);
227 break;
229 updateBlockDiscrete(*localBlockData);
230 break;
231 }
232
233 switch ( _syncMode ) {
235 singleton::mpi().reduce(*localBlockData, this->getBlockData(), MPI_SUM);
237 break;
239 singleton::mpi().reduce(*localBlockData, this->getBlockData(), MPI_SUM);
240 break;
242 if (this->_owning) {
243 delete this->_blockData;
244 }
245 this->_blockData = localBlockData.release();
246 this->_owning = true;
247 break;
248 }
249#else
250 switch ( _reductionMode ) {
252 updateBlockAnalytical(this->getBlockData());
253 break;
255 updateBlockDiscrete(this->getBlockData());
256 break;
257 }
258#endif
259}
BlockData< 2, T, T > & getBlockData()
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: