24#ifndef BLOCK_LATTICE_FIELD_REDUCTION_O_H
25#define BLOCK_LATTICE_FIELD_REDUCTION_O_H
29namespace field::reduction {
40 template <
typename CELL>
46template <
typename TAG_FIELD>
48 template <
typename CELL>
51 return cell.template getField<TAG_FIELD>() == (int) 1;
56 template <
typename FIELDD>
69#ifdef PARALLEL_MODE_MPI
75 template <
typename FIELDD>
79 return lhs > rhs ? lhs : rhs;
85 return std::numeric_limits<T>::lowest();
88#ifdef PARALLEL_MODE_MPI
94 template <
typename FIELDD>
98 return lhs < rhs ? lhs : rhs;
101 template <
typename T>
104 return std::numeric_limits<T>::max();
107#ifdef PARALLEL_MODE_MPI
113 template <
typename FIELDD>
123template <
typename FIELD,
typename REDUCTION_OP,
typename CONDITION>
131 template <
typename BLOCK>
134 void apply(BLOCK& blockLattice) {
throw std::runtime_error(
"BlockLatticeFieldReductionO not implemented"); }
137 template <
typename BLOCK>
143 template <
typename BLOCK>
150template <
typename FIELD,
typename REDUCTION_OP,
typename CONDITION>
151template <
typename T,
typename DESCRIPTOR, Platform PLATFORM>
157 blockLattice.template getData<OperatorParameters<BlockLatticeFieldReductionO>>();
163 OstreamManager clout(std::cout,
"Apply function in BlockLatticeFieldReductionO on CPU");
165 auto&
parameters = blockLattice.template getData<OperatorParameters<BlockLatticeFieldReductionO>>().
parameters;
167 const auto& blockField = blockLattice.template getField<FIELD>();
169 parameters.template get<fields::array_of<FIELD>>();
171 for (
unsigned iD = 0; iD < blockField.d; iD++) {
172 if (elementField[iD] ==
nullptr) {
176 elementField[iD][0] = REDUCTION_OP {}.reset(elementField[iD][0]);
181 const std::size_t iCell = blockLattice.
getCellId(latticeR);
183 if (cell.template getField<field::reduction::TAG_CORE>() == (
int)1) {
184 if (CONDITION {}(cell)) {
186 for (
unsigned iD = 0; iD < blockField.d; iD++) {
187 elementField[iD][0] = REDUCTION_OP {}(elementField[iD][0], blockCellField[iD]);
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.
void forSpatialLocations(F f) const
CellID getCellId(LatticeR< D > latticeR) const
Get 1D cell ID.
Implementation of BlockLattice on a concrete PLATFORM.
Highest-level interface to read-only Cell data.
class for marking output with some text
Top level namespace for all of OpenLB.
constexpr bool isPlatformCPU(Platform platform)
Returns true if platform is equal to Platform::CPU_*.
OperatorScope
Block-wide operator application scopes.
@ PerBlock
Per-block application, i.e. OPERATOR::apply is passed a ConcreteBlockLattice.
void setup(BLOCK &blockLattice)
void apply(BLOCK &blockLattice)
void apply(BLOCK &blockLattice)
static constexpr OperatorScope scope
void setup(BLOCK &blockLattice)
Base of a descriptor field of scalar TYPE.
bool operator()(CELL &cell) any_platform
T reset(T lhs) any_platform
FIELDD operator()(FIELDD lhs, FIELDD rhs) any_platform
FIELDD operator()(FIELDD lhs, FIELDD rhs) any_platform
T reset(T lhs) any_platform
FIELDD operator()(FIELDD lhs) any_platform
FIELDD operator()(FIELDD lhs, FIELDD rhs) any_platform
T reset(T lhs) any_platform
bool operator()(CELL &cell) any_platform