40template<
unsigned D,
typename T,
typename U>
44 _communicatable(_data)
46 for (
unsigned iD=0; iD <
_size; ++iD) {
51template<
unsigned D,
typename T,
typename U>
55 _communicatable(_data)
57 for (
unsigned iD=0; iD < _size; ++iD) {
58 _data.emplace_back(this->getNcells());
62template<
unsigned D,
typename T,
typename U>
65 _size(blockF.getTargetDim())
67 for (
unsigned iD=0; iD < _size; ++iD) {
68 _data.emplace_back(this->getNcells());
72 this->forCoreSpatialLocations([&](
LatticeR<D> latticeR) {
73 for (
unsigned iD=0; iD < D; ++iD) {
74 input[iD] = latticeR[iD];
76 blockF(output, input);
77 for (
unsigned iD=0; iD < _size; ++iD) {
78 get(latticeR,iD) = output[iD];
83template<
unsigned D,
typename T,
typename U>
86 const std::size_t iCell = this->getCellId(input);
87 for (
unsigned iD=0; iD < _size; ++iD) {
88 output[iD] = _data[iD][iCell];
93template<
unsigned D,
typename T,
typename U>
96 return _data[iD][iCell];
99template<
unsigned D,
typename T,
typename U>
102 return get(this->getCellId(latticeR), iD);
105template<
unsigned D,
typename T,
typename U>
108 return _data[iD][this->getCellId(latticeR)];
111template<
unsigned D,
typename T,
typename U>
117template<
unsigned D,
typename T,
typename U>
123template<
unsigned D,
typename T,
typename U>
126 return _data.
size() * _data[0].getNblock();
129template<
unsigned D,
typename T,
typename U>
132 return _data.size() * _data[0].getSerializableSize();
135template<
unsigned D,
typename T,
typename U>
138 std::size_t currentBlock = 0;
139 bool* dataPtr =
nullptr;
141 for (
unsigned iD=0; iD < _size; ++iD) {
142 registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, _data[iD], loadingMode);
150#ifdef PARALLEL_MODE_MPI
157 for (
unsigned iD=0; iD < sendData.
getSize(); ++iD) {
159 sendData.
getNcells(), MPI_DOUBLE, root, comm);
168 for (
unsigned iD=0; iD < sendData.
getSize(); ++iD) {
170 sendData.
getNcells(), MPI_FLOAT, root, comm);
175void MpiManager::reduce<BlockData<2,double,int> >(
BlockData<2,double,int>& sendVal,
BlockData<2,double,int>& recvVal, MPI_Op op,
int root, MPI_Comm comm)
180 for (
unsigned iD=0; iD < sendVal.getSize(); ++iD) {
181 MPI_Reduce(
static_cast<void*
>(sendVal.getColumn(iD).data()),
182 static_cast<void*
>(recvVal.getColumn(iD).data()),
183 sendVal.getNcells(), MPI_DOUBLE, op, root, comm);
188void MpiManager::reduce<BlockData<2,double,double> >(
BlockData<2,double,double>& sendVal,
BlockData<2,double,double>& recvVal, MPI_Op op,
int root, MPI_Comm comm)
193 for (
unsigned iD=0; iD < sendVal.getSize(); ++iD) {
194 MPI_Reduce(
static_cast<void*
>(sendVal.getColumn(iD).data()),
195 static_cast<void*
>(recvVal.getColumn(iD).data()),
196 sendVal.getNcells(), MPI_DOUBLE, op, root, comm);
201void MpiManager::reduce<BlockData<2,float,float> >(
BlockData<2,float,float>& sendVal,
BlockData<2,float,float>& recvVal, MPI_Op op,
int root, MPI_Comm comm)
206 for (
unsigned iD=0; iD < sendVal.getSize(); ++iD) {
207 MPI_Reduce(
static_cast<void*
>(sendVal.getColumn(iD).data()),
208 static_cast<void*
>(recvVal.getColumn(iD).data()),
209 sendVal.getNcells(), MPI_FLOAT, op, root, comm);
bool operator()(T output[], const int input[])
bool * getBlock(std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
Returns the address of the i-th block and its size.
std::size_t getSerializableSize() const override
Returns the binary size of the data to be saved.
Column< U > & getColumn(unsigned iD)
std::size_t getNblock() const override
Returns the number of blocks.
std::vector< cpu::sisd::Column< U > > _data
BlockData(Cuboid< T, D > &cuboid, int overlap=0, int size=1)
U & get(std::size_t iCell, int iD=0)
std::size_t getNcells() const
Get number of cells.
Plain column for SISD CPU targets (default)
void bCast(T *sendBuf, int sendCount, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Broadcast data from one processor to multiple processors.
The description of a single 2D cuboid – header file.
The description of a single 3D cuboid – header file.
Wrapper functions that simplify the use of MPI.
Top level namespace for all of OpenLB.
std::conditional_t< D==2, BlockF2D< T >, BlockF3D< T > > BlockF
std::conditional_t< D==2, Cuboid2D< T >, Cuboid3D< T > > Cuboid