OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::BlockDynamicsMap< T, DESCRIPTOR, PLATFORM > Class Template Reference

Map between cell indices and concrete dynamics. More...

#include <blockDynamicsMap.h>

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

Public Member Functions

 BlockDynamicsMap (ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > &lattice)
 Constructor for a BlockDynamicsMap.
 
Dynamics< T, DESCRIPTOR > * get (DynamicsPromise< T, DESCRIPTOR > &&promise)
 Returns a pointer to dynamics matching the promise.
 
const Dynamics< T, DESCRIPTOR > * get (std::size_t iCell) const
 
Dynamics< T, DESCRIPTOR > * get (std::size_t iCell)
 
void set (std::size_t iCell, DynamicsPromise< T, DESCRIPTOR > &&promise)
 Assigns promised dynamics to cell index and updates block masks.
 
void collide (CollisionDispatchStrategy strategy)
 Executes local collision step for entire non-overlap area of lattice.
 
std::size_t getWeight (const DynamicsPromise< T, DESCRIPTOR > &promise) const
 Returns number of cells assigned to promised dynamics.
 
std::set< DynamicsPromise< T, DESCRIPTOR > > getAll () const
 Returns set of all dynamics maintained this map.
 

Detailed Description

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

Map between cell indices and concrete dynamics.

Central class for managing and applying dynamics of / to a block lattice.

Maintains both a map of cell indices to dynamics and of dynamics to a mask of all assigned cell indices.

Automatically determines the dominant dynamics and applies the collision step to all cells via the dominant dynamics' ConcreteBlockCollisionO.

Definition at line 265 of file blockDynamicsMap.h.

Constructor & Destructor Documentation

◆ BlockDynamicsMap()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
olb::BlockDynamicsMap< T, DESCRIPTOR, PLATFORM >::BlockDynamicsMap ( ConcreteBlockLattice< T, DESCRIPTOR, PLATFORM > & lattice)
inline

Constructor for a BlockDynamicsMap.

Definition at line 306 of file blockDynamicsMap.h.

306 :
307 _lattice(lattice),
308 _dynamicsOfCells(new Dynamics<T,DESCRIPTOR>* [_lattice.getNcells()] { nullptr }),
309 _operatorOfCells(new BlockCollisionO<T,DESCRIPTOR,PLATFORM>*[_lattice.getNcells()] { nullptr }),
310 _coreMask(lattice.template getData<CollisionSubdomainMask>()),
311 _dominantCollisionO(nullptr)
312 {
313 _lattice.forCoreSpatialLocations([&](LatticeR<DESCRIPTOR::d> lattice) {
314 _coreMask.set(_lattice.getCellId(lattice), true);
315 });
316 }
Vector< std::int32_t, D > LatticeR
Type for spatial block-local lattice coordinates.

Member Function Documentation

◆ collide()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::BlockDynamicsMap< T, DESCRIPTOR, PLATFORM >::collide ( CollisionDispatchStrategy strategy)
inline

Executes local collision step for entire non-overlap area of lattice.

When using the default CollisionDispatchStrategy::Dominant, the most frequently assigned dynamics resp. collision operator is applied and responsible for also colliding cells excluded by its masks using their respective dynamics.

Correspondingly, the alternative CollisionDispatchStrategy::Individual applies all dynamics separately using a list-based approach.

Definition at line 361 of file blockDynamicsMap.h.

362 {
363 switch (strategy) {
365 if (!_dominantCollisionO) {
366 _dominantCollisionO = std::get<1>(std::max_element(
367 _map.begin(),
368 _map.end(),
369 [](const auto& lhs, const auto& rhs) -> bool {
370 return std::get<1>(lhs.second)->weight()
371 < std::get<1>(rhs.second)->weight();
372 })->second).get();
373 }
374 _dominantCollisionO->apply(_lattice, _coreMask, strategy);
375 break;
376
378 for (auto& [id, value] : _map) {
379 auto& [promise, collisionO] = value;
380 if (collisionO->weight() > 0) {
381 collisionO->apply(_lattice, _coreMask, strategy);
382 }
383 }
384 break;
385
386 default:
387 throw std::runtime_error("Invalid collision dispatch strategy");
388 break;
389 }
390 }
typename std::integral_constant< TYPE, VALUE >::type value
Identity type to wrap non-type template arguments.
Definition meta.h:96
@ Individual
Apply all dynamics individually (async for Platform::GPU_CUDA)
@ Dominant
Apply dominant dynamics using mask and fallback to virtual dispatch for others.

References olb::BlockCollisionO< T, DESCRIPTOR, PLATFORM >::apply(), olb::Dominant, and olb::Individual.

+ Here is the call graph for this function:

◆ get() [1/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
Dynamics< T, DESCRIPTOR > * olb::BlockDynamicsMap< T, DESCRIPTOR, PLATFORM >::get ( DynamicsPromise< T, DESCRIPTOR > && promise)
inline

Returns a pointer to dynamics matching the promise.

Promise is only realized if dynamics were not previously constructed

Definition at line 322 of file blockDynamicsMap.h.

323 {
324 return resolve(std::forward<decltype(promise)>(promise)).getDynamics();
325 }
+ Here is the caller graph for this function:

◆ get() [2/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
Dynamics< T, DESCRIPTOR > * olb::BlockDynamicsMap< T, DESCRIPTOR, PLATFORM >::get ( std::size_t iCell)
inline

Definition at line 332 of file blockDynamicsMap.h.

333 {
334 return _dynamicsOfCells[iCell];
335 }

◆ get() [3/3]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
const Dynamics< T, DESCRIPTOR > * olb::BlockDynamicsMap< T, DESCRIPTOR, PLATFORM >::get ( std::size_t iCell) const
inline

Definition at line 327 of file blockDynamicsMap.h.

328 {
329 return _dynamicsOfCells[iCell];
330 }

◆ getAll()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
std::set< DynamicsPromise< T, DESCRIPTOR > > olb::BlockDynamicsMap< T, DESCRIPTOR, PLATFORM >::getAll ( ) const
inline

Returns set of all dynamics maintained this map.

Definition at line 407 of file blockDynamicsMap.h.

407 {
408 std::set<DynamicsPromise<T,DESCRIPTOR>> dynamics;
409 for (auto& [id, value] : _map) {
410 const auto& [promise, collisionO] = value;
411 dynamics.emplace(promise);
412 }
413 return dynamics;
414 }

◆ getWeight()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
std::size_t olb::BlockDynamicsMap< T, DESCRIPTOR, PLATFORM >::getWeight ( const DynamicsPromise< T, DESCRIPTOR > & promise) const
inline

Returns number of cells assigned to promised dynamics.

Doesn't allocate, intended for introspection

Definition at line 396 of file blockDynamicsMap.h.

396 {
397 auto iter = _map.find(promise.id());
398 if (iter != _map.end()) {
399 const auto& [_, collisionO] = std::get<1>(*iter);
400 return collisionO->weight();
401 } else {
402 return 0;
403 }
404 }

References olb::DynamicsPromise< T, DESCRIPTOR >::id().

+ Here is the call graph for this function:

◆ set()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::BlockDynamicsMap< T, DESCRIPTOR, PLATFORM >::set ( std::size_t iCell,
DynamicsPromise< T, DESCRIPTOR > && promise )
inline

Assigns promised dynamics to cell index and updates block masks.

Definition at line 338 of file blockDynamicsMap.h.

339 {
340 auto& collisionO = resolve(std::forward<decltype(promise)>(promise));
341 if (_operatorOfCells[iCell] != nullptr) {
342 _operatorOfCells[iCell]->set(iCell, false, !_coreMask[iCell]);
343 }
344 collisionO.set(iCell, true, !_coreMask[iCell]);
345 _operatorOfCells[iCell] = &collisionO;
346 if (Dynamics<T,DESCRIPTOR>* dynamics = collisionO.getDynamics()) {
347 _dynamicsOfCells[iCell] = dynamics;
348 }
349 _dominantCollisionO = nullptr;
350 }
+ Here is the caller graph for this function:

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