24#ifndef BLOCK_REDUCTION_2D2D_HH
25#define BLOCK_REDUCTION_2D2D_HH
44void BlockReduction2D2D<T>::updateToWantedResolution(
int resolution)
48 T newH = _nx*_h/(T)resolution;
50 _ny = (int)(_ny*_h/newH) + 1;
54 T newH = _ny*_h/(T)resolution;
56 _nx = (int)(_nx*_h/newH) + 1;
60 delete this->_blockData;
62 this->_blockData =
new BlockData<2,T,T>({{_nx, _ny}, 0}, _f->getTargetDim());
70 :
BlockDataF2D<T,T>(f->getSuperStructure().getCuboidGeometry().getMotherCuboid().getNx(),
71 f->getSuperStructure().getCuboidGeometry().getMotherCuboid().getNy(),
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()),
80 this->
getName() =
"planeReduction(" + _f->getName() +
")";
82 _origin[0] -= 10*std::numeric_limits<T>::epsilon();
83 _origin[1] -= 10*std::numeric_limits<T>::epsilon();
86 updateToWantedResolution(resolution);
97 _origin[0] + T(iX) * _h,
98 _origin[1] + T(iY) * _h
107 .originAt({_origin[0], _origin[1], 0})
108 .spannedBy({1,0,0}, {0,1,0}),
118 _rankLocalSubplane.clear();
120 for (
int iX = 0; iX < _nx; ++iX ) {
121 for (
int iY = 0; iY < _ny; ++iY ) {
128 if ( geometry.
getC(physR, iC) ) {
130 _rankLocalSubplane.emplace_back(iX, iY, iC);
140 _f->getSuperStructure().communicate();
144#ifdef PARALLEL_MODE_MPI
145 std::unique_ptr<BlockData<2,T,T>> localBlockData(
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);
154 for (
int iSize = 0; iSize < _f->getTargetDim(); ++iSize ) {
155 this->_blockData->get({iX, iY}, iSize) = T();
158 T output[_f->getTargetDim()];
159 const T input[2] { physR[0], physR[1] };
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];
166 this->_blockData->get({iX, iY}, iSize) += output[iSize];
172#ifdef PARALLEL_MODE_MPI
173 switch ( _syncMode ) {
183 delete this->_blockData;
185 this->_blockData = localBlockData.release();
186 this->_owning =
true;
195 return *this->_blockData;
Converts super functions to analytical functions.
BlockDataF2D can store data of any BlockFunctor2D.
void initialize()
Initialize rank-local list of points to be stored in _blockData.
HyperplaneLattice3D< T > getPlaneDiscretizationIn3D() const
Returns embedding of the discretized plane in 3D space.
void update()
Updates and writes the data to _blockData using _rankLocalSubplane.
Vector< T, 2 > getPhysR(const int &iX, const int &iY) const
Transform lattice coordinates to their physical location.
BlockReduction2D2D(FunctorPtr< SuperF2D< T > > &&f, int resolution=600, BlockDataSyncMode mode=BlockDataSyncMode::ReduceAndBcast)
BlockStructureD< 2 > & getBlockStructure() override
Overload of virtual function from class BlockF2D.
A cuboid structure represents the grid of a considered domain.
bool getC(std::vector< T > physR, int &iC) const
Returns true and the cuboid number of the nearest lattice position to the given physical position if ...
Smart pointer for managing the various ways of passing functors around.
std::string & getName()
read and write access to name
Parametrization of a hyperplane lattice.
Base class for all LoadBalancer.
bool isLocal(const int &glob)
returns whether glob is on this process
represents all functors that operate on a SuperStructure<T,2> in general
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.
Wrapper functions that simplify the use of MPI.
Top level namespace for all of OpenLB.
BlockDataSyncMode
Mode of synchronizing functor block data between processes.
@ 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
Definition of a analytical 2D plane embedded in 3D space.