Skip to content

Commit

Permalink
Coordinates: Set coordinates on device
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Jul 3, 2023
1 parent 6acb777 commit e17c3d2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Coordinates/interface.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

IMPLEMENTS: Coordinates

USES INCLUDE HEADER: loop.hxx
USES INCLUDE HEADER: loop_device.hxx

PUBLIC:

Expand Down
61 changes: 32 additions & 29 deletions Coordinates/src/coordinates.cxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <loop.hxx>
#include <loop_device.hxx>

#include <cctk.h>
#include <cctk_Arguments.h>
Expand All @@ -7,36 +7,39 @@
namespace Coordinates {

extern "C" void Coordinates_Setup(CCTK_ARGUMENTS) {
DECLARE_CCTK_ARGUMENTS_Coordinates_Setup;
DECLARE_CCTK_ARGUMENTSX_Coordinates_Setup;
DECLARE_CCTK_PARAMETERS;

const Loop::GF3D<CCTK_REAL, 0, 0, 0> vcoordx_(cctkGH, vcoordx);
const Loop::GF3D<CCTK_REAL, 0, 0, 0> vcoordy_(cctkGH, vcoordy);
const Loop::GF3D<CCTK_REAL, 0, 0, 0> vcoordz_(cctkGH, vcoordz);

const Loop::GF3D<CCTK_REAL, 1, 1, 1> ccoordx_(cctkGH, ccoordx);
const Loop::GF3D<CCTK_REAL, 1, 1, 1> ccoordy_(cctkGH, ccoordy);
const Loop::GF3D<CCTK_REAL, 1, 1, 1> ccoordz_(cctkGH, ccoordz);

const Loop::GF3D<CCTK_REAL, 1, 1, 1> cvol_(cctkGH, cvol);

Loop::loop_all<0, 0, 0>(
cctkGH, [&](const Loop::PointDesc &p) { vcoordx_(p.I) = p.x; });
Loop::loop_all<0, 0, 0>(
cctkGH, [&](const Loop::PointDesc &p) { vcoordy_(p.I) = p.y; });
Loop::loop_all<0, 0, 0>(
cctkGH, [&](const Loop::PointDesc &p) { vcoordz_(p.I) = p.z; });

Loop::loop_all<1, 1, 1>(
cctkGH, [&](const Loop::PointDesc &p) { ccoordx_(p.I) = p.x; });
Loop::loop_all<1, 1, 1>(
cctkGH, [&](const Loop::PointDesc &p) { ccoordy_(p.I) = p.y; });
Loop::loop_all<1, 1, 1>(
cctkGH, [&](const Loop::PointDesc &p) { ccoordz_(p.I) = p.z; });

Loop::loop_all<1, 1, 1>(cctkGH, [&](const Loop::PointDesc &p) {
cvol_(p.I) = p.dx * p.dy * p.dz;
});
grid.loop_all_device<0, 0, 0>(
grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p)
CCTK_ATTRIBUTE_ALWAYS_INLINE { vcoordx(p.I) = p.x; });
grid.loop_all_device<0, 0, 0>(
grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p)
CCTK_ATTRIBUTE_ALWAYS_INLINE { vcoordy(p.I) = p.y; });
grid.loop_all_device<0, 0, 0>(
grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p)
CCTK_ATTRIBUTE_ALWAYS_INLINE { vcoordz(p.I) = p.z; });

grid.loop_all_device<1, 1, 1>(
grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p)
CCTK_ATTRIBUTE_ALWAYS_INLINE { ccoordx(p.I) = p.x; });
grid.loop_all_device<1, 1, 1>(
grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p)
CCTK_ATTRIBUTE_ALWAYS_INLINE { ccoordy(p.I) = p.y; });
grid.loop_all_device<1, 1, 1>(
grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p)
CCTK_ATTRIBUTE_ALWAYS_INLINE { ccoordz(p.I) = p.z; });

grid.loop_all_device<1, 1, 1>(
grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p)
CCTK_ATTRIBUTE_ALWAYS_INLINE { cvol(p.I) = p.dx * p.dy * p.dz; });
}

} // namespace Coordinates

0 comments on commit e17c3d2

Please sign in to comment.