20 #ifndef GEOS_PHYSICSSOLVERS_KERNELLAUNCHSELECTORS_HPP
21 #define GEOS_PHYSICSSOLVERS_KERNELLAUNCHSELECTORS_HPP
28 template<
typename S,
typename T,
typename LAMBDA >
29 void invokePhaseDispatchLambda ( S val, T numPhases, LAMBDA && lambda )
33 lambda( val, std::integral_constant< T, 1 >());
36 else if( numPhases == 2 )
38 lambda( val, std::integral_constant< T, 2 >());
41 else if( numPhases == 3 )
43 lambda( val, std::integral_constant< T, 3 >());
48 GEOS_ERROR(
"Unsupported state: " << numPhases );
52 template<
typename S,
typename T,
typename LAMBDA >
53 void invokeThermalDispatchLambda ( S val, T isThermal, LAMBDA && lambda )
57 lambda( val, std::integral_constant< T, 1 >());
60 else if( isThermal == 0 )
62 lambda( val, std::integral_constant< T, 0 >());
67 GEOS_ERROR(
"Unsupported state: " << isThermal );
71 template<
typename T,
typename LAMBDA >
72 void kernelLaunchSelectorThermalSwitch( T value, LAMBDA && lambda )
74 static_assert( std::is_integral< T >::value,
"kernelLaunchSelectorThermalSwitch: type should be integral" );
80 lambda( std::integral_constant< T, 0 >() );
85 lambda( std::integral_constant< T, 1 >() );
90 GEOS_ERROR(
"Unsupported thermal state: " << value );
95 template<
typename T,
typename LAMBDA >
96 void kernelLaunchSelectorCompThermSwitch( T value,
bool const isThermal, LAMBDA && lambda )
98 static_assert( std::is_integral< T >::value,
"kernelLaunchSelectorCompSwitch: value type should be integral" );
105 invokeThermalDispatchLambda( std::integral_constant< T, 1 >(), isThermal, lambda );
return;
109 invokeThermalDispatchLambda( std::integral_constant< T, 2 >(), isThermal, lambda );
114 invokeThermalDispatchLambda( std::integral_constant< T, 3 >(), isThermal, lambda );
119 invokeThermalDispatchLambda( std::integral_constant< T, 4 >(), isThermal, lambda );
124 invokeThermalDispatchLambda( std::integral_constant< T, 5 >(), isThermal, lambda );
129 GEOS_ERROR(
"Unsupported number of components: " << value );
134 template<
typename T,
typename LAMBDA >
135 void kernelLaunchSelectorCompPhaseSwitch( T value, T n_phase, LAMBDA && lambda )
137 static_assert( std::is_integral< T >::value,
"kernelLaunchSelectorCompSwitch: value type should be integral" );
142 invokePhaseDispatchLambda( std::integral_constant< T, 1 >(), n_phase, lambda );
147 invokePhaseDispatchLambda( std::integral_constant< T, 2 >(), n_phase, lambda );
152 invokePhaseDispatchLambda( std::integral_constant< T, 3 >(), n_phase, lambda );
157 invokePhaseDispatchLambda( std::integral_constant< T, 4 >(), n_phase, lambda );
162 invokePhaseDispatchLambda( std::integral_constant< T, 5 >(), n_phase, lambda );
166 {
GEOS_ERROR(
"Unsupported number of components: " << value ); }
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.