OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | List of all members
olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM > Class Template Referencefinal

Concrete collision operator for legacy dynamics. More...

#include <blockDynamicsMap.h>

+ Inheritance diagram for olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM >:
+ Collaboration diagram for olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM >:

Public Member Functions

 LegacyBlockCollisionO (std::size_t count, Dynamics< T, DESCRIPTOR > **dynamics)
 
std::type_index id () const override
 
std::size_t weight () const override
 Returns number of assigned cells.
 
void set (CellID iCell, bool state, bool overlap) override
 Set whether iCell is covered by the present collision step.
 
Dynamics< T, DESCRIPTOR > * getDynamics () override
 
void setup (ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > &block) override
 Setup collision on block.
 
void apply (ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > &block, ConcreteBlockMask< T, PLATFORM > &subdomain, CollisionDispatchStrategy strategy) override
 Apply collision on subdomain of block.
 
- Public Member Functions inherited from olb::AbstractBlockO
virtual ~AbstractBlockO ()=default
 

Detailed Description

template<typename T, typename DESCRIPTOR, Platform PLATFORM>
class olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM >

Concrete collision operator for legacy dynamics.

To be removed once both all OpenLB-included dynamics are adapted and legacy support was included in at least one release.

Legacy dynamics are only supported on CPU targets.

Definition at line 133 of file blockDynamicsMap.h.

Constructor & Destructor Documentation

◆ LegacyBlockCollisionO()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM >::LegacyBlockCollisionO ( std::size_t count,
Dynamics< T, DESCRIPTOR > ** dynamics )
inline

Definition at line 159 of file blockDynamicsMap.h.

159 :
160 _mask{count},
161 _legacyDynamics{dynamics}
162 { }
+ Here is the caller graph for this function:

Member Function Documentation

◆ apply()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM >::apply ( ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > & block,
ConcreteBlockMask< T, PLATFORM > & subdomain,
CollisionDispatchStrategy strategy )
inlineoverridevirtual

Apply collision on subdomain of block.

Loop excludes overlap areas of block as collisions are never applied there. This assumes that subdomain is the core mask of BlockDynamicsMap.

Implements olb::BlockCollisionO< T, DESCRIPTOR, PLATFORM >.

Definition at line 202 of file blockDynamicsMap.h.

205 {
206 if (strategy != CollisionDispatchStrategy::Dominant) {
207 throw std::runtime_error("LegacyBlockCollisionO only supports CollisionDispatchStrategy::Dominant");
208 }
209
210 typename LatticeStatistics<T>::Aggregatable statistics{};
211 #ifdef PARALLEL_MODE_OMP
212 #pragma omp declare reduction(+ : typename LatticeStatistics<T>::Aggregatable : omp_out += omp_in) initializer (omp_priv={})
213 #endif
214
215 if constexpr (DESCRIPTOR::d == 3) {
216 #ifdef PARALLEL_MODE_OMP
217 #pragma omp parallel for schedule(dynamic,1) reduction(+ : statistics)
218 #endif
219 for (int iX=0; iX < block.getNx(); ++iX) {
220 auto cell = block.get(iX,0,0);
221 for (int iY=0; iY < block.getNy(); ++iY) {
222 for (int iZ=0; iZ < block.getNz(); ++iZ) {
223 CellID iCell = block.getCellId(iX,iY,iZ);
224 if (_mask[iCell]) {
225 cell.setCellId(iCell);
226 if (auto cellStatistic = _legacyDynamics[iCell]->collide(cell)) {
227 statistics.increment(cellStatistic.rho, cellStatistic.uSqr);
228 }
229 } else {
230 cpu::Cell<T,DESCRIPTOR,PLATFORM> cell(block, iCell);
231 if (auto cellStatistic = _dynamicsOfCells[iCell]->collide(cell)) {
232 statistics.increment(cellStatistic.rho, cellStatistic.uSqr);
233 }
234 }
235 }
236 }
237 }
238 } else {
239 #ifdef PARALLEL_MODE_OMP
240 #pragma omp parallel for schedule(dynamic,1) reduction(+ : statistics)
241 #endif
242 for (int iX=0; iX < block.getNx(); ++iX) {
243 auto cell = block.get(iX,0);
244 for (int iY=0; iY < block.getNy(); ++iY) {
245 CellID iCell = block.getCellId(iX,iY);
246 if (_mask[iCell]) {
247 cell.setCellId(iCell);
248 if (auto cellStatistic = _legacyDynamics[iCell]->collide(cell)) {
249 statistics.increment(cellStatistic.rho, cellStatistic.uSqr);
250 }
251 } else {
252 cpu::Cell<T,DESCRIPTOR,PLATFORM> cell(block, iCell);
253 if (auto cellStatistic = _dynamicsOfCells[iCell]->collide(cell)) {
254 statistics.increment(cellStatistic.rho, cellStatistic.uSqr);
255 }
256 }
257 }
258 }
259 }
260
261 block.getStatistics().incrementStats(statistics);
262 }
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.
LatticeStatistics< T > & getStatistics()
Return a handle to the LatticeStatistics object.
int getNy() const
Read only access to block height.
int getNx() const
Read only access to block width.
CellID getCellId(LatticeR< D > latticeR) const
Get 1D cell ID.
int getNz() const
Read only access to block height.
std::uint32_t CellID
Type for sequential block-local cell indices.
@ Dominant
Apply dominant dynamics using mask and fallback to virtual dispatch for others.

References olb::Dominant, olb::BlockLattice< T, DESCRIPTOR >::get(), olb::BlockStructureD< D >::getCellId(), olb::BlockStructureD< D >::getNx(), olb::BlockStructureD< D >::getNy(), olb::BlockStructureD< D >::getNz(), and olb::BlockLattice< T, DESCRIPTOR >::getStatistics().

+ Here is the call graph for this function:

◆ getDynamics()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
Dynamics< T, DESCRIPTOR > * olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM >::getDynamics ( )
inlineoverridevirtual

Implements olb::AbstractCollisionO< T, DESCRIPTOR >.

Definition at line 184 of file blockDynamicsMap.h.

185 {
186 return nullptr;
187 }

◆ id()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
std::type_index olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM >::id ( ) const
inlineoverridevirtual

Implements olb::AbstractBlockO.

Definition at line 164 of file blockDynamicsMap.h.

165 {
166 return typeid(LegacyBlockCollisionO);
167 }
LegacyBlockCollisionO(std::size_t count, Dynamics< T, DESCRIPTOR > **dynamics)

References olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM >::LegacyBlockCollisionO().

+ Here is the call graph for this function:

◆ set()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM >::set ( CellID iCell,
bool state,
bool overlap )
inlineoverridevirtual

Set whether iCell is covered by the present collision step.

Parameters
iCellCell index
state(De)activate for this dynamics / collision
overlapCell index in overlap (set dynamics but do not collide)

Implements olb::AbstractCollisionO< T, DESCRIPTOR >.

Definition at line 174 of file blockDynamicsMap.h.

175 {
176 if (!overlap) {
177 _mask.set(iCell, state);
178 }
179 if (state) {
180 _dynamicsOfCells[iCell] = resolve(iCell);
181 }
182 }

◆ setup()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM >::setup ( ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > & block)
inlineoverridevirtual

Setup collision on block.

Implements olb::BlockCollisionO< T, DESCRIPTOR, PLATFORM >.

Definition at line 189 of file blockDynamicsMap.h.

190 {
191 // Remember block in order to construct LegacyConcreteDynamics
192 _block = &block;
193 // Fetch pointer to concretized dynamic-dispatch field
194 _dynamicsOfCells = block.template getField<cpu::DYNAMICS<T,DESCRIPTOR,PLATFORM>>()[0].data();
195 }

◆ weight()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
std::size_t olb::LegacyBlockCollisionO< T, DESCRIPTOR, PLATFORM >::weight ( ) const
inlineoverridevirtual

Returns number of assigned cells.

Used to determine the dominant dynamics to choose e.g. which collision operator to vectorize or to prefer in GPU kernels.

Implements olb::AbstractCollisionO< T, DESCRIPTOR >.

Definition at line 169 of file blockDynamicsMap.h.

170 {
171 return _mask.weight();
172 }

The documentation for this class was generated from the following file: