@@ -63,9 +63,10 @@ class AdiabaticGLMMHDEOS : public EquationOfState {
6363 // int& j, const int& i) \brief Fills an array of primitives given an array of
6464 // conserveds, potentially updating the conserved with floors
6565 template <typename View4D>
66- KOKKOS_INLINE_FUNCTION void ConsToPrim (View4D cons, View4D prim, const int &nhydro,
67- const int &nscalars, const int &k, const int &j,
68- const int &i) const {
66+ KOKKOS_INLINE_FUNCTION int ConsToPrim (View4D cons, View4D prim, const int &nhydro,
67+ const int &nscalars, const int &k, const int &j,
68+ const int &i) const {
69+ int floors_used = 0 ;
6970 auto gam = GetGamma ();
7071 auto gm1 = gam - 1.0 ;
7172 auto density_floor_ = GetDensityFloor ();
@@ -95,13 +96,19 @@ class AdiabaticGLMMHDEOS : public EquationOfState {
9596 Real &w_Bz = prim (IB3, k, j, i);
9697 Real &w_psi = prim (IPS, k, j, i);
9798
99+ PARTHENON_REQUIRE (u_d != 0.0 ,
100+ " Densities should never be exactly 0! This points to working with "
101+ " some default initialized and/or uninitialized data." );
98102 // Let's apply floors explicitly, i.e., by default floor will be disabled (<=0)
99103 // and the code will fail if a negative density is encountered.
100104 PARTHENON_REQUIRE (u_d > 0.0 || density_floor_ > 0.0 ,
101105 " Got negative density. Consider enabling first-order flux "
102106 " correction or setting a reasonble density floor." );
103107 // apply density floor, without changing momentum or energy
104- u_d = (u_d > density_floor_) ? u_d : density_floor_;
108+ if (u_d < density_floor_) {
109+ u_d = density_floor_;
110+ floors_used = floors_used | 1 ; // set density floor flag
111+ }
105112 w_d = u_d;
106113
107114 Real di = 1.0 / u_d;
@@ -146,6 +153,7 @@ class AdiabaticGLMMHDEOS : public EquationOfState {
146153 // apply pressure floor, correct total energy
147154 u_e = (pressure_floor_ / gm1) + e_k + e_B;
148155 w_p = pressure_floor_;
156+ floors_used = floors_used | 2 ; // set pressure floor flag
149157 }
150158
151159 // temperature (internal energy) based pressure floor
@@ -154,6 +162,7 @@ class AdiabaticGLMMHDEOS : public EquationOfState {
154162 // apply temperature floor, correct total energy
155163 u_e = (u_d * e_floor_) + e_k + e_B;
156164 w_p = eff_pressure_floor;
165+ floors_used = floors_used | 4 ; // set temperture floor flag
157166 }
158167
159168 // temperature (internal energy) based pressure ceiling
@@ -168,6 +177,7 @@ class AdiabaticGLMMHDEOS : public EquationOfState {
168177 for (auto n = nhydro; n < nhydro + nscalars; ++n) {
169178 prim (n, k, j, i) = cons (n, k, j, i) * di;
170179 }
180+ return floors_used;
171181 }
172182
173183 private:
0 commit comments