diff --git a/Examples/Fluid_Kerr/PerfectFluidLevel.hpp b/Examples/Fluid_Kerr/PerfectFluidLevel.hpp index ebd466b42..a35b4a239 100644 --- a/Examples/Fluid_Kerr/PerfectFluidLevel.hpp +++ b/Examples/Fluid_Kerr/PerfectFluidLevel.hpp @@ -31,23 +31,23 @@ class PerfectFluidLevel : public GRAMRLevel typedef PerfectFluid PerfectFluidEoS; //! Things to do at the end of the advance step, after RK4 calculation - virtual void specificAdvance(); + virtual void specificAdvance() override; //! Initialize data for the field and metric variables - virtual void initialData(); + virtual void initialData() override; #ifdef CH_USE_HDF5 //! routines to do before outputting plot file - virtual void prePlotLevel(); + virtual void prePlotLevel() override; #endif //! RHS routines used at each RK4 step virtual void specificEvalRHS(GRLevelData &a_soln, GRLevelData &a_rhs, - const double a_time); + const double a_time) override; //! Things to do in UpdateODE step, after soln + rhs update virtual void specificUpdateODE(GRLevelData &a_soln, - const GRLevelData &a_rhs, Real a_dt); + const GRLevelData &a_rhs, Real a_dt) override; /// Things to do before tagging cells (i.e. filling ghosts) virtual void preTagCells() override; diff --git a/Examples/Fluid_Kerr/PositiveDensity.hpp b/Examples/Fluid_Kerr/PositiveDensity.hpp index 480c800e1..fef8137b0 100644 --- a/Examples/Fluid_Kerr/PositiveDensity.hpp +++ b/Examples/Fluid_Kerr/PositiveDensity.hpp @@ -35,9 +35,9 @@ class PositiveDensity vi[2] = current_cell.load_vars(c_vi3); auto make_zero = simd_compare_lt(D, m_min_D); - D = simd_conditional(make_zero, D, m_min_D); + D = simd_conditional(make_zero, m_min_D, D); // tau = simd_conditional(make_zero, tau, 1e-4); - FOR(i) vi[i] = simd_conditional(make_zero, vi[i], m_min_v); + FOR(i) vi[i] = simd_conditional(make_zero, m_min_v, vi[i]); // current_cell.store_vars(D, c_D); // current_cell.store_vars(rho, c_rho); diff --git a/Examples/Fluid_Kerr/PrimitiveRecovery.hpp b/Examples/Fluid_Kerr/PrimitiveRecovery.hpp index 599156277..159eeb3d0 100644 --- a/Examples/Fluid_Kerr/PrimitiveRecovery.hpp +++ b/Examples/Fluid_Kerr/PrimitiveRecovery.hpp @@ -10,9 +10,11 @@ #include "CCZ4Geometry.hpp" #include "Cell.hpp" #include "DefaultEoS.hpp" +#include "simd.hpp" #include "Tensor.hpp" #include "TensorAlgebra.hpp" #include "UserVariables.hpp" +#include "UsingNamespace.H" #include "VarsTools.hpp" // template @@ -58,12 +60,10 @@ class PrimitiveRecovery int i = 0; - auto cond = simd_all_false(simd_compare_lt(diff, tolerance)); - //while (simd_all_false(simd_compare_lt(diff, tolerance))) - while (i<20) - // while (simd_compare_lt(tolerance, diff)) + data_t empty; + while (!simd_all_false(simd_compare_lt(tolerance, diff), empty)) { - i++; + i++; Wa = sqrt(pow(xa, 2.) / (pow(xa, 2.) - r)); vars.rho = pow(vars.chi, 1.5) * vars.D / Wa; @@ -74,7 +74,7 @@ class PrimitiveRecovery xn = Wa * (1. + vars.eps + P_over_rho); diff = abs(xn - xa); xa = xn; - if (i >= 20) + if (i >= 100) break; } } diff --git a/Source/simd/arm/neon.hpp b/Source/simd/arm/neon.hpp index b80de2304..d6a7f59cf 100644 --- a/Source/simd/arm/neon.hpp +++ b/Source/simd/arm/neon.hpp @@ -95,7 +95,7 @@ template <> struct simd : public simd_base return vmaxq_f64(a, b); } - friend ALWAYS_INLINE bool simd_all_false(const mask_t cond) + friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b) { uint64x2_t high_bits = vshrq_n_u64(input, 63); //Lanes are indexed like bits (big-endian) @@ -178,7 +178,7 @@ template <> struct simd : public simd_base return vmaxq_f32(a, b); } - friend ALWAYS_INLINE bool simd_all_false(const mask_t cond) + friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b) { uint32x4_t high_bits = vshrq_n_u32(input, 31); //Lanes are indexed like bits (big-endian) diff --git a/Source/simd/arm/sve.hpp b/Source/simd/arm/sve.hpp index c4a368ab0..65d31923c 100644 --- a/Source/simd/arm/sve.hpp +++ b/Source/simd/arm/sve.hpp @@ -122,7 +122,7 @@ template <> struct simd : public simd_base return svmax_f64_z(svptrue_b64(), a, b); } - friend ALWAYS_INLINE bool simd_all_false(const mask_t cond) + friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b) { //Would be nice to implement a movemask here, for extensions to lane-specific info return !svptest_any(svptrue_b64(), cond); @@ -212,7 +212,7 @@ template <> struct simd : public simd_base return svmax_f32_z(svptrue_b32(), a, b); } - friend ALWAYS_INLINE bool simd_all_false(const mask_t cond) + friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b) { //Would be nice to implement a movemask here, for extensions to lane-specific info return !svptest_any(svptrue_b32(), cond); diff --git a/Source/simd/simd.hpp b/Source/simd/simd.hpp index 940152fee..1cb5aee50 100644 --- a/Source/simd/simd.hpp +++ b/Source/simd/simd.hpp @@ -175,7 +175,8 @@ template ALWAYS_INLINE t simd_max(const t &a, const t &b) return (a > b) ? a : b; } -template ALWAYS_INLINE bool simd_all_false(const bool cond) +// Here, t is some simd variable +template ALWAYS_INLINE bool simd_all_false(const bool cond, const t &b) { return !cond; } diff --git a/Source/simd/x64/avx.hpp b/Source/simd/x64/avx.hpp index 5681e12e2..113d3f7f6 100644 --- a/Source/simd/x64/avx.hpp +++ b/Source/simd/x64/avx.hpp @@ -109,7 +109,7 @@ template <> struct simd : public simd_base return _mm256_max_pd(a, b); } - friend ALWAYS_INLINE bool simd_all_false(const mask_t cond) + friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b) { int mask = _mm256_movemask_pd(cond); return mask == 0 ? true : false; @@ -199,7 +199,7 @@ template <> struct simd : public simd_base return _mm256_max_ps(a, b); } - friend ALWAYS_INLINE bool simd_all_false(const mask_t cond) + friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b) { int mask = _mm256_movemask_ps(cond); return mask == 0 ? true : false; diff --git a/Source/simd/x64/avx512.hpp b/Source/simd/x64/avx512.hpp index 3ba08a44b..c9f1b99d8 100644 --- a/Source/simd/x64/avx512.hpp +++ b/Source/simd/x64/avx512.hpp @@ -103,7 +103,7 @@ template <> struct simd : public simd_base return _mm512_max_pd(a, b); } - friend ALWAYS_INLINE bool simd_all_false(const mask_t cond) + friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b) { int mask = static_cast(cond); return mask == 0 ? true : false; @@ -204,7 +204,7 @@ template <> struct simd : public simd_base return _mm512_max_ps(a, b); } - friend ALWAYS_INLINE bool simd_all_false(const mask_t cond) + friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b) { int mask = static_cast(cond); return mask == 0 ? true : false; diff --git a/Source/simd/x64/sse.hpp b/Source/simd/x64/sse.hpp index e6a548c61..52d44704e 100644 --- a/Source/simd/x64/sse.hpp +++ b/Source/simd/x64/sse.hpp @@ -121,7 +121,7 @@ template <> struct simd : public simd_base return _mm_max_pd(a, b); } - friend ALWAYS_INLINE bool simd_all_false(const mask_t cond) + friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b) { int mask = _mm_movemask_pd(cond); return mask == 0 ? true : false; @@ -221,7 +221,7 @@ template <> struct simd : public simd_base return _mm_max_ps(a, b); } - friend ALWAYS_INLINE bool simd_all_false(const mask_t cond) + friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b) { int mask = _mm_movemask_ps(cond); return mask == 0 ? true : false;