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

BlockReduction3D1D reduces the data of a SuperF3D functor to the intersection between a given 3D line3D and the super geometry. More...

#include <blockReduction3D1D.h>

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

Public Member Functions

 BlockReduction3D1D (FunctorPtr< SuperF3D< T > > &&f, const LineLattice3D< T > &lattice, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast, BlockDataReductionMode reductionMode=BlockDataReductionMode::Analytical)
 Construction using functor and line3D lattice.
 
 BlockReduction3D1D (FunctorPtr< SuperF3D< T > > &&f, const Line3D< T > &line3D, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast, BlockDataReductionMode reductionMode=BlockDataReductionMode::Analytical)
 Construction using functor and line3D.
 
 BlockReduction3D1D (FunctorPtr< SuperF3D< T > > &&f, const Line3D< T > &line3D, int resolution=600, BlockDataSyncMode mode=BlockDataSyncMode::ReduceAndBcast)
 Construction using functor, line3D and resolution.
 
 BlockReduction3D1D (FunctorPtr< SuperF3D< T > > &&f, const Vector< T, 3 > &origin, const Vector< T, 3 > &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::LineLattice3D< T >
 LineLattice3D (CuboidDecomposition< T, 3 > &geometry, Line3D< T > line3D)
 Constructor for automatic discretization.
 
 LineLattice3D (CuboidDecomposition< T, 3 > &geometry, Line3D< T > line3D, int resolution)
 Constructor for discretization of a given resolution.
 
 LineLattice3D (CuboidDecomposition< T, 3 > &geometry, Line3D< T > line3D, T h)
 Constructor for discretization of a given grid width.
 
 LineLattice3D (const LineLattice3D &)=default
 
const Line3D< T > & getLine3D () const
 
Vector< T, 3 > getPhysR (const int &n) const
 Transform 1d lattice coordinates to their physical 3d location.
 
int getN () const
 
getPhysSpacing () const
 
Vector< T, 3 > getPhysOrigin () const
 
Vector< T, 3 > 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::LineLattice3D< T >
const Line3D< T > _line3D
 
Vector< T, 3 > _origin
 Origin vector of the lattice.
 
Vector< T, 3 > _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::BlockReduction3D1D< T >

BlockReduction3D1D reduces the data of a SuperF3D functor to the intersection between a given 3D line3D 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 line3D is parametrized by a origin and a single direction vector u. Definition of line3D using e.g. origin and normal vectors is supported via the line3D interface.

Definition at line 54 of file blockReduction3D1D.h.

Constructor & Destructor Documentation

◆ BlockReduction3D1D() [1/4]

template<typename T >
olb::BlockReduction3D1D< T >::BlockReduction3D1D ( FunctorPtr< SuperF3D< T > > && f,
const LineLattice3D< T > & lattice,
BlockDataSyncMode syncMode = BlockDataSyncMode::ReduceAndBcast,
BlockDataReductionMode reductionMode = BlockDataReductionMode::Analytical )

Construction using functor and line3D lattice.

Parameters
fFunctor to be reduced as a (non-)owning pointer or reference to SuperF3D<T>.
latticeLine3D 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 line3D definition and discretization.

Definition at line 84 of file blockReduction3D1D.hh.

89 : LineLattice3D<T>(lattice),
90 BlockDataF2D<T,T>(lattice.getN(), 1, f->getTargetDim()),
91 _f(std::move(f)),
92 _syncMode(syncMode),
93 _reductionMode(reductionMode)
94{
95 this->getName() = "lineReduction(" + _f->getName() + ")";
96 OstreamManager clout ("BlockReduction3D1D");
97 if ( _reductionMode == BlockDataReductionMode::Discrete ) {
98 const auto& geometry = _f->getSuperStructure().getCuboidDecomposition();
99 const Line3D<T>& line = this->getLine3D();
100 const bool spansAxisPlane = line.isParallelToX() ||
101 line.isParallelToY()||line.isParallelToZ();
102 // verify axes alignment and spacing of hyperplane parametrization
103 if ( !spansAxisPlane ||
104 lattice.getPhysSpacing() != geometry.getDeltaR() ) {
105 // hyperplane lattice doesn't describe a trivially discretizable plane
106 OstreamManager clerr(std::cerr, "BlockReduction3D1D");
107 clerr << "Given hyperplane is not trivially discretizable. "
108 << "Use BlockDataReductionMode::Analytical instead."
109 << std::endl;
110 exit(-1);
111 }
112 }
113
114 // intialize list of relevant rank local points making up the reduced line
115 initialize();
116 // first update of data
117 update();
118}
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
LineLattice3D(CuboidDecomposition< T, 3 > &geometry, Line3D< T > line3D)
Constructor for automatic discretization.
const Line3D< T > & getLine3D() const
T line(Vector< T, D > p, Vector< T, D > a, Vector< T, D > b, T r) any_platform
Definition sdf.h:136
void exit(int exitcode)
Definition singleton.h:177
@ Discrete
Read block data from discrete lattice locations.

References olb::Discrete, olb::LineLattice3D< T >::getLine3D(), olb::GenericF< T, int >::getName(), olb::LineLattice3D< T >::getPhysSpacing(), olb::BlockReduction3D1D< T >::initialize(), and olb::BlockReduction3D1D< T >::update().

+ Here is the call graph for this function:

◆ BlockReduction3D1D() [2/4]

template<typename T >
olb::BlockReduction3D1D< T >::BlockReduction3D1D ( FunctorPtr< SuperF3D< T > > && f,
const Line3D< T > & line3D,
BlockDataSyncMode syncMode = BlockDataSyncMode::ReduceAndBcast,
BlockDataReductionMode reductionMode = BlockDataReductionMode::Analytical )

Construction using functor and line3D.

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

Definition at line 121 of file blockReduction3D1D.hh.

127 std::forward<decltype(f)>(f),
128 LineLattice3D<T>(f->getSuperStructure().getCuboidDecomposition(),
129 line3D),syncMode,reductionMode)
130{ }
BlockReduction3D1D(FunctorPtr< SuperF3D< T > > &&f, const LineLattice3D< T > &lattice, BlockDataSyncMode syncMode=BlockDataSyncMode::ReduceAndBcast, BlockDataReductionMode reductionMode=BlockDataReductionMode::Analytical)
Construction using functor and line3D lattice.

◆ BlockReduction3D1D() [3/4]

template<typename T >
olb::BlockReduction3D1D< T >::BlockReduction3D1D ( FunctorPtr< SuperF3D< T > > && f,
const Line3D< T > & line3D,
int resolution = 600,
BlockDataSyncMode mode = BlockDataSyncMode::ReduceAndBcast )

Construction using functor, line3D and resolution.

Parameters
fFunctor to be reduced as a (non-)owning pointer or reference to SuperF3D<T>.
line3DLine3D 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 133 of file blockReduction3D1D.hh.

138 std::forward<decltype(f)>(f),
139 LineLattice3D<T>(f->getSuperStructure().getCuboidDecomposition(),
140 line3D, resolution),mode)
141{ }

◆ BlockReduction3D1D() [4/4]

template<typename T >
olb::BlockReduction3D1D< T >::BlockReduction3D1D ( FunctorPtr< SuperF3D< T > > && f,
const Vector< T, 3 > & origin,
const Vector< T, 3 > & 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 SuperF3D<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 144 of file blockReduction3D1D.hh.

149 std::forward<decltype(f)>(f),
150 Line3D<T>().originAt(origin).parallelTo(direction),
151 resolution, mode) { }

Member Function Documentation

◆ getBlockStructure()

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

Overload of virtual function from class BlockF2D.

Reimplemented from olb::BlockF2D< T >.

Definition at line 229 of file blockReduction3D1D.hh.

230{
231 return *this->_blockData;
232}
BlockData< 2, T, T > * _blockData

◆ getRankLocalSubplane()

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

Definition at line 235 of file blockReduction3D1D.hh.

236{
237 return this->_rankLocalSubplane;
238}

◆ initialize()

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

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

Definition at line 161 of file blockReduction3D1D.hh.

162{
163 const auto& geometry = _f->getSuperStructure().getCuboidDecomposition();
164 LoadBalancer<T>& load = _f->getSuperStructure().getLoadBalancer();
165
166 _rankLocalSubplane.clear();
167
168 for ( int i = 0; i < this->getN(); ++i ) {
169 const Vector<T,3> physR = this->getPhysR(i);
170
171 // Schedule line point for storage if its physical position intersects the
172 // mother cuboid and the cuboid of the nearest lattice position is local to
173 // the current rank:
174 if (auto iC = geometry.getC(physR)) {
175 if (load.isLocal(*iC)) {
176 _rankLocalSubplane.emplace_back(i, *iC);
177 }
178 }
179 }
180}
Vector< T, 3 > getPhysR(const int &n) const
Transform 1d 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:

◆ operator()()

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

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

Definition at line 154 of file blockReduction3D1D.hh.

155{
156 const int input[2] = { i, 0 };
157 return static_cast<BlockDataF2D<T,T>*>(this)->operator()(output, input);
158}

◆ update()

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

Updates and writes the data to _blockData using _rankLocalSubplane.

Definition at line 183 of file blockReduction3D1D.hh.

184{
185 _f->getSuperStructure().communicate();
186
187#ifdef PARALLEL_MODE_MPI
188 std::unique_ptr<BlockData<2,T,T>> localBlockData(
189 new BlockData<2,T,T>({{this->getN(), 1}, 0}, _f->getTargetDim()));
190
191 switch ( _reductionMode ) {
193 updateBlockAnalytical(*localBlockData);
194 break;
196 updateBlockDiscrete(*localBlockData);
197 break;
198 }
199
200 switch ( _syncMode ) {
202 singleton::mpi().reduce(*localBlockData, this->getBlockData(), MPI_SUM);
204 break;
206 singleton::mpi().reduce(*localBlockData, this->getBlockData(), MPI_SUM);
207 break;
209 if (this->_owning) {
210 delete this->_blockData;
211 }
212 this->_blockData = localBlockData.release();
213 this->_owning = true;
214 break;
215 }
216#else
217 switch ( _reductionMode ) {
219 updateBlockAnalytical(this->getBlockData());
220 break;
222 updateBlockDiscrete(this->getBlockData());
223 break;
224 }
225#endif
226}
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: