diff --git a/doc/sphinx/src/using-eos.rst b/doc/sphinx/src/using-eos.rst index 2559cf65bc7..98679558709 100644 --- a/doc/sphinx/src/using-eos.rst +++ b/doc/sphinx/src/using-eos.rst @@ -275,16 +275,13 @@ is summed using the ``Kokkos::parallel_reduce`` functionality in the // PORTABLE_INLINE_FUNCTION // decorator here. void operator()(const T &eos) const { - Real *P = P_; // gets around warnings regarding capture of "this" pointer - Real *rho = rho_; - Real *sie = sie_; // reduction target Real tot_diff; // reduction op Kokkos::parallel_reduce( "MyCheckPofRE", N_, KOKKOS_LAMBDA(const int i, Real &diff) { - diff += std::abs(P[i] - eos.PressureFromDensityInternalEnergy(rho[i], sie[i])); + diff += std::abs(P_[i] - eos.PressureFromDensityInternalEnergy(rho_[i], sie_[i])); }, tot_diff); std::cout << "Total difference = " << tot_diff << std::endl; diff --git a/test/test_eos_unit.cpp b/test/test_eos_unit.cpp index 84fe7de4c69..be732ba21ee 100644 --- a/test/test_eos_unit.cpp +++ b/test/test_eos_unit.cpp @@ -514,23 +514,20 @@ class CheckPofRE { public: CheckPofRE(Real *P, Real *rho, Real *sie, int N) : P_(P), rho_(rho), sie_(sie), N_(N) {} template - void operator()(const T &eos) const { - Real *P = P_; // gets around capture of this pointer - Real *rho = rho_; - Real *sie = sie_; - // must be initialized to zero because portableReduce is a simple for loop on host - int nwrong = 0; + void operator()(const T &eos) { portableReduce( "MyCheckPofRE", 0, N_, PORTABLE_LAMBDA(const int i, int &nw) { - nw += !(isClose(P[i], - eos.PressureFromDensityInternalEnergy(rho[i], sie[i], nullptr), + nw += !(isClose(P_[i], + eos.PressureFromDensityInternalEnergy(rho_[i], sie_[i], nullptr), 1e-15)); }, nwrong); - REQUIRE(nwrong == 0); } + // must be initialized to zero because portableReduce is a simple for loop on host + int nwrong = 0; + private: int N_; Real *P_; @@ -564,8 +561,9 @@ SCENARIO("Ideal gas vector Evaluate call", "[IdealGas][Evaluate]") { P[i] = eos_device.PressureFromDensityInternalEnergy(rho[i], sie[i]); }); THEN("The vector Evaluate API can be used to compare") { - CheckPofRE myOp(P, rho, sie, N); - eos_device.Evaluate(myOp); + CheckPofRE my_op(P, rho, sie, N); + eos_device.Evaluate(my_op); + REQUIRE(my_op.nwrong == 0); } }