Skip to content
Merged
8 changes: 5 additions & 3 deletions pgens/accretion/pgen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ namespace user {
TWO * metric.spin() * g_00);
}

Inline auto bx1(const coord_t<D>& x_Ph) const -> real_t { // at ( i , j + HALF )
Inline auto bx1(const coord_t<D>& x_Ph) const
-> real_t { // at ( i , j + HALF )
coord_t<D> xi { ZERO }, x0m { ZERO }, x0p { ZERO };
metric.template convert<Crd::Ph, Crd::Cd>(x_Ph, xi);

Expand All @@ -61,7 +62,8 @@ namespace user {
}
}

Inline auto bx2(const coord_t<D>& x_Ph) const -> real_t { // at ( i + HALF , j )
Inline auto bx2(const coord_t<D>& x_Ph) const
-> real_t { // at ( i + HALF , j )
coord_t<D> xi { ZERO }, x0m { ZERO }, x0p { ZERO };
metric.template convert<Crd::Ph, Crd::Cd>(x_Ph, xi);

Expand Down Expand Up @@ -174,7 +176,7 @@ namespace user {
return false;
}

Inline auto operator()(const coord_t<M::Dim>& x_Ph) const -> real_t override {
Inline auto operator()(const coord_t<M::Dim>& x_Ph) const -> real_t {
auto fill = true;
for (auto d = 0u; d < M::Dim; ++d) {
fill &= x_Ph[d] > x_min[d] and x_Ph[d] < x_max[d] and sigma_crit(x_Ph);
Expand Down
2 changes: 1 addition & 1 deletion pgens/reconnection/pgen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace user {
, center_x { center_x }
, cs_y { cs_y } {}

Inline auto operator()(const coord_t<M::Dim>& x_Ph) const -> real_t override {
Inline auto operator()(const coord_t<M::Dim>& x_Ph) const -> real_t {
return ONE / SQR(math::cosh((x_Ph[1] - cs_y) / cs_width)) *
(ONE - math::exp(-SQR((x_Ph[0] - center_x) / cs_width)));
}
Expand Down
22 changes: 6 additions & 16 deletions src/archetypes/energy_dist.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ namespace arch {

EnergyDistribution(const M& metric) : metric { metric } {}

// Takes the physical coordinate of the particle and returns
// the velocity in tetrad basis
// last argument -- is the species index (1, ..., nspec)
Inline virtual void operator()(const coord_t<D>&,
vec_t<Dim::_3D>& v,
spidx_t = 0) const {
v[0] = ZERO;
v[1] = ZERO;
v[2] = ZERO;
}

protected:
const M metric;
};
Expand All @@ -61,7 +50,8 @@ namespace arch {

Inline void operator()(const coord_t<M::Dim>&,
vec_t<Dim::_3D>& v,
spidx_t = 0) const override {
spidx_t = 0) const {

v[0] = ZERO;
v[1] = ZERO;
v[2] = ZERO;
Expand All @@ -85,7 +75,7 @@ namespace arch {

Inline void operator()(const coord_t<M::Dim>&,
vec_t<Dim::_3D>& v,
spidx_t = 0) const override {
spidx_t = 0) const {
auto rand_gen = pool.get_state();
auto rand_X1 = Random<real_t>(rand_gen);
auto rand_gam = ONE;
Expand Down Expand Up @@ -241,7 +231,7 @@ namespace arch {

Inline void operator()(const coord_t<M::Dim>&,
vec_t<Dim::_3D>& v,
spidx_t sp = 0) const override {
spidx_t sp = 0) const {
SampleFromMaxwellian<S, M::CoordType == Coord::Cart>(v,
pool,
temperature,
Expand Down Expand Up @@ -293,7 +283,7 @@ namespace arch {

Inline void operator()(const coord_t<M::Dim>&,
vec_t<Dim::_3D>& v,
spidx_t sp = 0) const override {
spidx_t sp = 0) const {
SampleFromMaxwellian<S, M::CoordType == Coord::Cart>(
v,
pool,
Expand Down Expand Up @@ -367,7 +357,7 @@ namespace arch {

Inline void operator()(const coord_t<M::Dim>& x_Code,
vec_t<Dim::_3D>& v,
spidx_t = 0) const override {
spidx_t = 0) const {
if (cmp::AlmostZero(temperature)) {
v[0] = ZERO;
v[1] = ZERO;
Expand Down
8 changes: 2 additions & 6 deletions src/archetypes/spatial_dist.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ namespace arch {

SpatialDistribution(const M& metric) : metric { metric } {}

Inline virtual auto operator()(const coord_t<M::Dim>&) const -> real_t {
return ONE;
}

protected:
const M metric;
};
Expand All @@ -44,7 +40,7 @@ namespace arch {
struct Uniform : public SpatialDistribution<S, M> {
Uniform(const M& metric) : SpatialDistribution<S, M> { metric } {}

Inline auto operator()(const coord_t<M::Dim>&) const -> real_t override {
Inline auto operator()(const coord_t<M::Dim>&) const -> real_t {
return ONE;
}
};
Expand All @@ -69,7 +65,7 @@ namespace arch {
, target_density { target_density }
, target_max_density { target_max_density } {}

Inline auto operator()(const coord_t<M::Dim>& x_Ph) const -> real_t override {
Inline auto operator()(const coord_t<M::Dim>& x_Ph) const -> real_t {
coord_t<M::Dim> x_Cd { ZERO };
metric.template convert<Crd::Ph, Crd::Cd>(x_Ph, x_Cd);
real_t dens { ZERO };
Expand Down
4 changes: 2 additions & 2 deletions src/archetypes/tests/spatial_dist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct RadialDist : public SpatialDistribution<S, M> {

RadialDist(const M& metric) : SpatialDistribution<S, M> { metric } {}

Inline auto operator()(const coord_t<M::Dim>& x_Code) const -> real_t override {
auto operator()(const coord_t<M::Dim>& x_Code) const -> real_t {
coord_t<M::Dim> x_Sph { ZERO };
metric.template convert<Crd::Cd, Crd::Sph>(x_Code, x_Sph);
auto r { ZERO };
Expand Down Expand Up @@ -123,4 +123,4 @@ auto main(int argc, char* argv[]) -> int {
}
Kokkos::finalize();
return 0;
}
}
4 changes: 2 additions & 2 deletions src/global/utils/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ namespace raise {
const char* func,
int line,
const char* msg) {
printf("\n%s:%d @ %s\nError: %s", file, line, func, msg);
Kokkos::printf("\n%s:%d @ %s\nError: %s", file, line, func, msg);
Kokkos::abort("kernel error");
}

Inline void KernelNotImplementedError(const char* file, const char* func, int line) {
printf("\n%s:%d @ %s\n", file, line, func);
Kokkos::printf("\n%s:%d @ %s\n", file, line, func);
Kokkos::abort("kernel not implemented");
}

Expand Down
2 changes: 1 addition & 1 deletion src/kernels/tests/ampere_mink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void errorIf(bool condition, const std::string& message) {

Inline auto equal(real_t a, real_t b, const char* msg, real_t acc) -> bool {
if (not(math::abs(a - b) < acc)) {
printf("%.12e != %.12e [%.12e] %s\n", a, b, math::abs(a - b), msg);
Kokkos::printf("%.12e != %.12e [%.12e] %s\n", a, b, math::abs(a - b), msg);
return false;
}
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/kernels/tests/deposit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const real_t eps = std::is_same_v<real_t, double> ? (real_t)(1e-6)

Inline auto equal(real_t a, real_t b, const char* msg, real_t eps) -> bool {
if ((a - b) >= eps * math::max(math::fabs(a), math::fabs(b))) {
printf("%.12e != %.12e %s\n", a, b, msg);
printf("%.12e >= %.12e %s\n",
Kokkos::printf("%.12e != %.12e %s\n", a, b, msg);
Kokkos::printf("%.12e >= %.12e %s\n",
a - b,
eps * math::max(math::fabs(a), math::fabs(b)),
msg);
Expand Down
2 changes: 1 addition & 1 deletion src/kernels/tests/faraday_mink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void errorIf(bool condition, const std::string& message) {

Inline auto equal(real_t a, real_t b, const char* msg, real_t acc) -> bool {
if (not(math::abs(a - b) < acc)) {
printf("%.12e != %.12e [%.12e] %s\n", a, b, math::abs(a - b), msg);
Kokkos::printf("%.12e != %.12e [%.12e] %s\n", a, b, math::abs(a - b), msg);
return false;
}
return true;
Expand Down
26 changes: 13 additions & 13 deletions src/kernels/tests/flds_bc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct DummyFieldsBCs {

Inline auto equal(real_t a, real_t b, const char* msg, real_t acc) -> bool {
if (not(math::abs(a - b) < acc)) {
printf("%.12e != %.12e [%.12e] %s\n", a, b, math::abs(a - b), msg);
Kokkos::printf("%.12e != %.12e [%.12e] %s\n", a, b, math::abs(a - b), msg);
return false;
}
return true;
Expand Down Expand Up @@ -118,19 +118,19 @@ void testFldsBCs(const std::vector<std::size_t>& res) {
FOUR * math::abs(x + HALF - xg_edge) / dx_abs);
const auto factor2 = math::tanh(FOUR * math::abs(x - xg_edge) / dx_abs);
if (not cmp::AlmostEqual(flds(i1, em::ex1), TWO * (ONE - factor1))) {
printf("%f != %f\n", flds(i1, em::ex1), TWO * (ONE - factor1));
Kokkos::printf("%f != %f\n", flds(i1, em::ex1), TWO * (ONE - factor1));
raise::KernelError(HERE, "incorrect ex1");
}
if (not cmp::AlmostEqual(flds(i1, em::ex2), THREE * (ONE - factor2))) {
printf("%f != %f\n", flds(i1, em::ex2), THREE * (ONE - factor2));
Kokkos::printf("%f != %f\n", flds(i1, em::ex2), THREE * (ONE - factor2));
raise::KernelError(HERE, "incorrect ex2");
}
if (not cmp::AlmostEqual(flds(i1, em::bx2), FOUR * (ONE - factor1))) {
printf("%f != %f\n", flds(i1, em::bx2), FOUR * (ONE - factor1));
Kokkos::printf("%f != %f\n", flds(i1, em::bx2), FOUR * (ONE - factor1));
raise::KernelError(HERE, "incorrect bx2");
}
if (not cmp::AlmostEqual(flds(i1, em::bx3), FIVE * (ONE - factor1))) {
printf("%f != %f\n", flds(i1, em::bx3), FIVE * (ONE - factor1));
Kokkos::printf("%f != %f\n", flds(i1, em::bx3), FIVE * (ONE - factor1));
raise::KernelError(HERE, "incorrect bx3");
}
});
Expand All @@ -145,19 +145,19 @@ void testFldsBCs(const std::vector<std::size_t>& res) {
FOUR * math::abs(x + HALF - xg_edge) / dx_abs);
const auto factor2 = math::tanh(FOUR * math::abs(x - xg_edge) / dx_abs);
if (not cmp::AlmostEqual(flds(i1, i2, em::ex1), TWO * (ONE - factor1))) {
printf("%f != %f\n", flds(i1, i2, em::ex1), TWO * (ONE - factor1));
Kokkos::printf("%f != %f\n", flds(i1, i2, em::ex1), TWO * (ONE - factor1));
raise::KernelError(HERE, "incorrect ex1");
}
if (not cmp::AlmostEqual(flds(i1, i2, em::ex2), THREE * (ONE - factor2))) {
printf("%f != %f\n", flds(i1, i2, em::ex2), THREE * (ONE - factor2));
Kokkos::printf("%f != %f\n", flds(i1, i2, em::ex2), THREE * (ONE - factor2));
raise::KernelError(HERE, "incorrect ex2");
}
if (not cmp::AlmostEqual(flds(i1, i2, em::bx2), FOUR * (ONE - factor1))) {
printf("%f != %f\n", flds(i1, i2, em::bx2), FOUR * (ONE - factor1));
Kokkos::printf("%f != %f\n", flds(i1, i2, em::bx2), FOUR * (ONE - factor1));
raise::KernelError(HERE, "incorrect bx2");
}
if (not cmp::AlmostEqual(flds(i1, i2, em::bx3), FIVE * (ONE - factor1))) {
printf("%f != %f\n", flds(i1, i2, em::bx3), FIVE * (ONE - factor1));
Kokkos::printf("%f != %f\n", flds(i1, i2, em::bx3), FIVE * (ONE - factor1));
raise::KernelError(HERE, "incorrect bx3");
}
});
Expand All @@ -173,22 +173,22 @@ void testFldsBCs(const std::vector<std::size_t>& res) {
FOUR * math::abs(x + HALF - xg_edge) / dx_abs);
const auto factor2 = math::tanh(FOUR * math::abs(x - xg_edge) / dx_abs);
if (not cmp::AlmostEqual(flds(i1, i2, i3, em::ex1), TWO * (ONE - factor1))) {
printf("%f != %f\n", flds(i1, i2, i3, em::ex1), TWO * (ONE - factor1));
Kokkos::printf("%f != %f\n", flds(i1, i2, i3, em::ex1), TWO * (ONE - factor1));
raise::KernelError(HERE, "incorrect ex1");
}
if (not cmp::AlmostEqual(flds(i1, i2, i3, em::ex2),
THREE * (ONE - factor2))) {
printf("%f != %f\n", flds(i1, i2, i3, em::ex2), THREE * (ONE - factor2));
Kokkos::printf("%f != %f\n", flds(i1, i2, i3, em::ex2), THREE * (ONE - factor2));
raise::KernelError(HERE, "incorrect ex2");
}
if (not cmp::AlmostEqual(flds(i1, i2, i3, em::bx2),
FOUR * (ONE - factor1))) {
printf("%f != %f\n", flds(i1, i2, i3, em::bx2), FOUR * (ONE - factor1));
Kokkos::printf("%f != %f\n", flds(i1, i2, i3, em::bx2), FOUR * (ONE - factor1));
raise::KernelError(HERE, "incorrect bx2");
}
if (not cmp::AlmostEqual(flds(i1, i2, i3, em::bx3),
FIVE * (ONE - factor1))) {
printf("%f != %f\n", flds(i1, i2, i3, em::bx3), FIVE * (ONE - factor1));
Kokkos::printf("%f != %f\n", flds(i1, i2, i3, em::bx3), FIVE * (ONE - factor1));
raise::KernelError(HERE, "incorrect bx3");
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/kernels/tests/prtl_bc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void errorIf(bool condition, const std::string& message = "") {

Inline auto equal(real_t a, real_t b, const std::string& msg) -> bool {
if (not(math::abs(a - b) < 1e-4)) {
printf("%.12e != %.12e %s\n", a, b, msg.c_str());
Kokkos::printf("%.12e != %.12e %s\n", a, b, msg.c_str());
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/tests/coord_trans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Inline auto equal(const coord_t<D>& a,
const auto eps = epsilon * acc;
for (auto d { 0u }; d < D; ++d) {
if (not cmp::AlmostEqual(a[d], b[d], eps)) {
printf("%d : %.12e != %.12e %s\n", d, a[d], b[d], msg);
Kokkos::printf("%d : %.12e != %.12e %s\n", d, a[d], b[d], msg);
return false;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/metrics/tests/ks-qks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Inline auto equal(const vec_t<D>& a,
const auto eps = epsilon * acc;
for (auto d { 0u }; d < D; ++d) {
if (not cmp::AlmostEqual(a[d], b[d], eps)) {
printf("%s: %.12e : %.12e\n", msg, a[d], b[d]);
Kokkos::printf("%s: %.12e : %.12e\n", msg, a[d], b[d]);
return false;
}
}
Expand Down Expand Up @@ -138,7 +138,7 @@ void testMetric(const std::vector<std::size_t>& res,
vec_t<Dim::_3D> h_ij_expect { h_11_expect, h_22_expect, h_33_expect };

if (not equal<Dim::_3D>(h_ij_predict, h_ij_expect, "h_ij", acc)) {
printf("h_ij: %.12e %.12e %.12e : %.12e %.12e %.12e\n",
Kokkos::printf("h_ij: %.12e %.12e %.12e : %.12e %.12e %.12e\n",
h_ij_predict[0],
h_ij_predict[1],
h_ij_predict[2],
Expand All @@ -148,11 +148,11 @@ void testMetric(const std::vector<std::size_t>& res,
Kokkos::abort("h_ij");
}
if (not equal<Dim::_1D>(h_13_predict, { h_13_expect }, "h_13", acc)) {
printf("h_13: %.12e : %.12e\n", h_13_predict[0], h_13_expect);
Kokkos::printf("h_13: %.12e : %.12e\n", h_13_predict[0], h_13_expect);
Kokkos::abort("h_13");
}
if (not equal<Dim::_3D>(hij_predict, hij_expect, "hij", acc)) {
printf("hij: %.12e %.12e %.12e : %.12e %.12e %.12e\n",
Kokkos::printf("hij: %.12e %.12e %.12e : %.12e %.12e %.12e\n",
hij_predict[0],
hij_predict[1],
hij_predict[2],
Expand All @@ -162,7 +162,7 @@ void testMetric(const std::vector<std::size_t>& res,
Kokkos::abort("hij");
}
if (not equal<Dim::_1D>(h13_predict, { h13_expect }, "h13", acc)) {
printf("h13: %.12e : %.12e\n", h13_predict[0], h13_expect);
Kokkos::printf("h13: %.12e : %.12e\n", h13_predict[0], h13_expect);
Kokkos::abort("h13");
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/tests/minkowski.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Inline auto equal(const coord_t<D>& a, const coord_t<D>& b, real_t acc = ONE)
-> bool {
for (auto d { 0u }; d < D; ++d) {
if (not cmp::AlmostEqual(a[d], b[d], epsilon * acc)) {
printf("%d : %.12f != %.12f\n", d, a[d], b[d]);
Kokkos::printf("%d : %.12f != %.12f\n", d, a[d], b[d]);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/tests/sph-qsph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Inline auto equal(const vec_t<D>& a,
const auto eps = epsilon * acc;
for (auto d { 0u }; d < D; ++d) {
if (not cmp::AlmostEqual(a[d], b[d], eps)) {
printf("%d : %.12e != %.12e %s\n", d, a[d], b[d], msg);
Kokkos::printf("%d : %.12e != %.12e %s\n", d, a[d], b[d], msg);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/tests/sr-cart-sph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Inline auto equal(const coord_t<D>& a,
const auto eps = epsilon * acc;
for (auto d { 0u }; d < D; ++d) {
if (not cmp::AlmostEqual(a[d], b[d], eps)) {
printf("%d : %.12e != %.12e %s\n", d, a[d], b[d], msg);
Kokkos::printf("%d : %.12e != %.12e %s\n", d, a[d], b[d], msg);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/metrics/tests/vec_trans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Inline auto equal(const vec_t<D>& a,
const auto eps = epsilon * acc;
for (auto d { 0u }; d < D; ++d) {
if (not cmp::AlmostEqual(a[d], b[d], eps)) {
printf("%d : %.12e != %.12e %s\n", d, a[d], b[d], msg);
Kokkos::printf("%d : %.12e != %.12e %s\n", d, a[d], b[d], msg);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/output/tests/writer-mpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ auto main(int argc, char* argv[]) -> int {
if (not cmp::AlmostEqual(
field_read(i1),
field(i1 * dwn1 + first_cell + i1min, cntr))) {
printf("\n:::::::::::::::\nfield_read(%ld) = %f != "
Kokkos::printf("\n:::::::::::::::\nfield_read(%ld) = %f != "
"field(%ld, %d) = %f\n:::::::::::::::\n",
i1,
field_read(i1),
Expand Down
2 changes: 1 addition & 1 deletion src/output/tests/writer-nompi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ auto main(int argc, char* argv[]) -> int {
i2 * dwn2 + i2min,
i3 * dwn3 + i3min,
cntr))) {
printf("\n:::::::::::::::\nfield_read(%ld, %ld, %ld) = %f != "
Kokkos::printf("\n:::::::::::::::\nfield_read(%ld, %ld, %ld) = %f != "
"field(%ld, %ld, %ld, %d) = %f\n:::::::::::::::\n",
i1,
i2,
Expand Down