19 #ifndef GEOS_PHYSICSSOLVERS_KERNELLAUNCHSELECTORS_HPP
20 #define GEOS_PHYSICSSOLVERS_KERNELLAUNCHSELECTORS_HPP
27 template<
typename S,
typename T,
typename LAMBDA >
28 void invokePhaseDispatchLambda ( S val, T numPhases, LAMBDA && lambda )
32 lambda( val, std::integral_constant< T, 1 >());
35 else if( numPhases == 2 )
37 lambda( val, std::integral_constant< T, 2 >());
40 else if( numPhases == 3 )
42 lambda( val, std::integral_constant< T, 3 >());
47 GEOS_ERROR(
"Unsupported state: " << numPhases );
51 template<
typename S,
typename T,
typename LAMBDA >
52 void invokeThermalDispatchLambda ( S val, T isThermal, LAMBDA && lambda )
56 lambda( val, std::integral_constant< T, 1 >());
59 else if( isThermal == 0 )
61 lambda( val, std::integral_constant< T, 0 >());
66 GEOS_ERROR(
"Unsupported state: " << isThermal );
70 template<
typename T,
typename LAMBDA >
71 void kernelLaunchSelectorThermalSwitch( T value, LAMBDA && lambda )
73 static_assert( std::is_integral< T >::value,
"kernelLaunchSelectorThermalSwitch: type should be integral" );
79 lambda( std::integral_constant< T, 0 >() );
84 lambda( std::integral_constant< T, 1 >() );
89 GEOS_ERROR(
"Unsupported thermal state: " << value );
94 template<
typename T,
typename LAMBDA >
95 void kernelLaunchSelectorCompThermSwitch( T value,
bool const isThermal, LAMBDA && lambda )
97 static_assert( std::is_integral< T >::value,
"kernelLaunchSelectorCompSwitch: value type should be integral" );
104 invokeThermalDispatchLambda( std::integral_constant< T, 1 >(), isThermal, lambda );
return;
108 invokeThermalDispatchLambda( std::integral_constant< T, 2 >(), isThermal, lambda );
113 invokeThermalDispatchLambda( std::integral_constant< T, 3 >(), isThermal, lambda );
118 invokeThermalDispatchLambda( std::integral_constant< T, 4 >(), isThermal, lambda );
123 invokeThermalDispatchLambda( std::integral_constant< T, 5 >(), isThermal, lambda );
128 GEOS_ERROR(
"Unsupported number of components: " << value );
133 template<
typename T,
typename LAMBDA >
134 void kernelLaunchSelectorCompPhaseSwitch( T value, T n_phase, LAMBDA && lambda )
136 static_assert( std::is_integral< T >::value,
"kernelLaunchSelectorCompSwitch: value type should be integral" );
141 invokePhaseDispatchLambda( std::integral_constant< T, 1 >(), n_phase, lambda );
146 invokePhaseDispatchLambda( std::integral_constant< T, 2 >(), n_phase, lambda );
151 invokePhaseDispatchLambda( std::integral_constant< T, 3 >(), n_phase, lambda );
156 invokePhaseDispatchLambda( std::integral_constant< T, 4 >(), n_phase, lambda );
161 invokePhaseDispatchLambda( std::integral_constant< T, 5 >(), n_phase, lambda );
165 {
GEOS_ERROR(
"Unsupported number of components: " << value ); }
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.