@@ -49,9 +49,10 @@ class AdiabaticHydroEOS : public EquationOfState {
4949 // int& j, const int& i) \brief Fills an array of primitives given an array of
5050 // conserveds, potentially updating the conserved with floors
5151 template <typename View4D>
52- KOKKOS_INLINE_FUNCTION void ConsToPrim (View4D cons, View4D prim, const int &nhydro,
53- const int &nscalars, const int &k, const int &j,
54- const int &i) const {
52+ KOKKOS_INLINE_FUNCTION int ConsToPrim (View4D cons, View4D prim, const int &nhydro,
53+ const int &nscalars, const int &k, const int &j,
54+ const int &i) const {
55+ int floors_used = 0 ;
5556 Real gm1 = GetGamma () - 1.0 ;
5657 auto density_floor_ = GetDensityFloor ();
5758 auto pressure_floor_ = GetPressureFloor ();
@@ -72,13 +73,19 @@ class AdiabaticHydroEOS : public EquationOfState {
7273 Real &w_vz = prim (IV3, k, j, i);
7374 Real &w_p = prim (IPR, k, j, i);
7475
76+ PARTHENON_REQUIRE (u_d != 0.0 ,
77+ " Densities should never be exactly 0! This points to working with "
78+ " some default initialized and/or uninitialized data." );
7579 // Let's apply floors explicitly, i.e., by default floor will be disabled (<=0)
7680 // and the code will fail if a negative density is encountered.
7781 PARTHENON_REQUIRE (u_d > 0.0 || density_floor_ > 0.0 ,
7882 " Got negative density. Consider enabling first-order flux "
7983 " correction or setting a reasonble density floor." );
8084 // apply density floor, without changing momentum or energy
81- u_d = (u_d > density_floor_) ? u_d : density_floor_;
85+ if (u_d < density_floor_) {
86+ u_d = density_floor_;
87+ floors_used = floors_used | 1 ; // set density floor flag
88+ }
8289 w_d = u_d;
8390
8491 Real di = 1.0 / u_d;
@@ -117,6 +124,7 @@ class AdiabaticHydroEOS : public EquationOfState {
117124 // apply pressure floor, correct total energy
118125 u_e = (pressure_floor_ / gm1) + e_k;
119126 w_p = pressure_floor_;
127+ floors_used = floors_used | 2 ; // set pressure floor flag
120128 }
121129
122130 // temperature (internal energy) based pressure floor
@@ -125,6 +133,7 @@ class AdiabaticHydroEOS : public EquationOfState {
125133 // apply temperature floor, correct total energy
126134 u_e = (u_d * e_floor_) + e_k;
127135 w_p = eff_pressure_floor;
136+ floors_used = floors_used | 4 ; // set temperture floor flag
128137 }
129138
130139 // temperature (internal energy) based pressure ceiling
@@ -139,6 +148,7 @@ class AdiabaticHydroEOS : public EquationOfState {
139148 for (auto n = nhydro; n < nhydro + nscalars; ++n) {
140149 prim (n, k, j, i) = cons (n, k, j, i) * di;
141150 }
151+ return floors_used;
142152 }
143153
144154 private:
0 commit comments