OpenLB 1.7
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
olb::DynamicsPromise< T, DESCRIPTOR > Class Template Reference

Factory for instances of a specific Dynamics type. More...

#include <blockDynamicsMap.h>

+ Collaboration diagram for olb::DynamicsPromise< T, DESCRIPTOR >:

Public Member Functions

template<typename DYNAMICS >
 DynamicsPromise (meta::id< DYNAMICS > id=meta::id< DYNAMICS >{})
 
std::type_index id () const
 Returns type index of the promised DYNAMICS.
 
Dynamics< T, DESCRIPTOR > * realize ()
 Returns new instance of the promised DYNAMICS.
 
template<Platform PLATFORM>
BlockCollisionO< T, DESCRIPTOR, PLATFORM > * realize ()
 Returns new instance of the collision operator for promised DYNAMICS.
 

Protected Attributes

std::type_index _id
 
std::function< Dynamics< T, DESCRIPTOR > *()> _dynamicsConstructor
 
std::function< AbstractCollisionO< T, DESCRIPTOR > *(Platform)> _operatorConstructor
 

Detailed Description

template<typename T, typename DESCRIPTOR>
class olb::DynamicsPromise< T, DESCRIPTOR >

Factory for instances of a specific Dynamics type.

Factory callables for DYNAMICS and ConcreteBlockCollisionO<DYNAMICS> are constructed at DynamicsPromise construction time. Recipients accepting such promised dynamics are not obligated to actually realize this promise.

This structure is needed to bridge the gap between high level virtual interfaces and efficient platform-specific implementations with full type knowledge. i.e. DynamicsPromise can carry full dynamics type information through the virtual layer surrounding concrete platform-specialized block lattices (needed as virtual template methods are not supported by C++).

Definition at line 278 of file blockDynamicsMap.h.

Constructor & Destructor Documentation

◆ DynamicsPromise()

template<typename T , typename DESCRIPTOR >
template<typename DYNAMICS >
olb::DynamicsPromise< T, DESCRIPTOR >::DynamicsPromise ( meta::id< DYNAMICS > id = meta::id<DYNAMICS>{})
inline

Definition at line 286 of file blockDynamicsMap.h.

286 {}):
287 _id(typeid(DYNAMICS)),
288 _dynamicsConstructor([]() -> Dynamics<T,DESCRIPTOR>* {
289 return new DYNAMICS();
290 }),
291 _operatorConstructor([](Platform platform) -> AbstractCollisionO<T,DESCRIPTOR>* {
292 static_assert(dynamics::is_generic_v<T,DESCRIPTOR,DYNAMICS>,
293 "Promised DYNAMICS must be generic");
294 switch (platform) {
295 #ifdef PLATFORM_CPU_SISD
297 return new ConcreteBlockCollisionO<T,DESCRIPTOR,Platform::CPU_SISD,DYNAMICS>();
298 #endif
299 #ifdef PLATFORM_CPU_SIMD
301 return new ConcreteBlockCollisionO<T,DESCRIPTOR,Platform::CPU_SIMD,DYNAMICS>();
302 #endif
303 #ifdef PLATFORM_GPU_CUDA
305 return new ConcreteBlockCollisionO<T,DESCRIPTOR,Platform::GPU_CUDA,DYNAMICS>();
306 #endif
307 default:
308 throw std::invalid_argument("Invalid PLATFORM");
309 }
310 })
311 { }
std::function< Dynamics< T, DESCRIPTOR > *()> _dynamicsConstructor
std::function< AbstractCollisionO< T, DESCRIPTOR > *(Platform)> _operatorConstructor
Platform
OpenLB execution targets.
Definition platform.h:36
@ CPU_SIMD
Basic scalar CPU.
@ GPU_CUDA
Vector CPU (AVX2 / AVX-512 collision)

Member Function Documentation

◆ id()

template<typename T , typename DESCRIPTOR >
std::type_index olb::DynamicsPromise< T, DESCRIPTOR >::id ( ) const
inline

Returns type index of the promised DYNAMICS.

Definition at line 314 of file blockDynamicsMap.h.

314 {
315 return _id;
316 }

References olb::DynamicsPromise< T, DESCRIPTOR >::_id.

◆ realize() [1/2]

template<typename T , typename DESCRIPTOR >
Dynamics< T, DESCRIPTOR > * olb::DynamicsPromise< T, DESCRIPTOR >::realize ( )
inline

Returns new instance of the promised DYNAMICS.

Definition at line 319 of file blockDynamicsMap.h.

319 {
320 return _dynamicsConstructor();
321 };

References olb::DynamicsPromise< T, DESCRIPTOR >::_dynamicsConstructor.

◆ realize() [2/2]

template<typename T , typename DESCRIPTOR >
template<Platform PLATFORM>
BlockCollisionO< T, DESCRIPTOR, PLATFORM > * olb::DynamicsPromise< T, DESCRIPTOR >::realize ( )
inline

Returns new instance of the collision operator for promised DYNAMICS.

Definition at line 325 of file blockDynamicsMap.h.

325 {
326 return static_cast<BlockCollisionO<T,DESCRIPTOR,PLATFORM>*>(
327 _operatorConstructor(PLATFORM));
328 };

References olb::DynamicsPromise< T, DESCRIPTOR >::_operatorConstructor.

Member Data Documentation

◆ _dynamicsConstructor

template<typename T , typename DESCRIPTOR >
std::function<Dynamics<T,DESCRIPTOR>*()> olb::DynamicsPromise< T, DESCRIPTOR >::_dynamicsConstructor
protected

Definition at line 281 of file blockDynamicsMap.h.

◆ _id

template<typename T , typename DESCRIPTOR >
std::type_index olb::DynamicsPromise< T, DESCRIPTOR >::_id
protected

Definition at line 280 of file blockDynamicsMap.h.

◆ _operatorConstructor

template<typename T , typename DESCRIPTOR >
std::function<AbstractCollisionO<T,DESCRIPTOR>*(Platform)> olb::DynamicsPromise< T, DESCRIPTOR >::_operatorConstructor
protected

Definition at line 282 of file blockDynamicsMap.h.


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