Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CarpetX: openPMD: Don't output ghosts by default #159

Merged
merged 1 commit into from
Jul 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions CarpetX/src/io_openpmd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -763,19 +763,24 @@ void carpetx_openpmd_t::InputOpenPMD(const cGH *const cctkGH,
const amrex::Real *const xhi = geom.ProbHi();
const amrex::Real *const dx = geom.CellSize();
const box_t<CCTK_REAL, 3> rdomain{
.lo = {xlo[0] - nghosts[0] * dx[0], xlo[1] - nghosts[1] * dx[1],
xlo[2] - nghosts[2] * dx[2]},
.hi = {xhi[0] + nghosts[0] * dx[0], xhi[1] + nghosts[1] * dx[1],
xhi[2] + nghosts[2] * dx[2]}};
.lo = {xlo[0] - output_ghosts * nghosts[0] * dx[0],
xlo[1] - output_ghosts * nghosts[1] * dx[1],
xlo[2] - output_ghosts * nghosts[2] * dx[2]},
.hi = {xhi[0] + output_ghosts * nghosts[0] * dx[0],
xhi[1] + output_ghosts * nghosts[1] * dx[1],
xhi[2] + output_ghosts * nghosts[2] * dx[2]}};
const amrex::Box &dom = geom.Domain();
const amrex::IntVect &ilo = dom.smallEnd();
const amrex::IntVect &ihi = dom.bigEnd();
// The domain is always vertex centred. The tensor components are
// then staggered if necessary.
const box_t<int, 3> idomain{
.lo = {ilo[0] - nghosts[0], ilo[1] - nghosts[1], ilo[2] - nghosts[2]},
.hi = {ihi[0] + nghosts[0] + 1 + 1, ihi[1] + nghosts[1] + 1 + 1,
ihi[2] + nghosts[2] + 1 + 1}};
.lo = {ilo[0] - output_ghosts * nghosts[0],
ilo[1] - output_ghosts * nghosts[1],
ilo[2] - output_ghosts * nghosts[2]},
.hi = {ihi[0] + output_ghosts * nghosts[0] + 1 + 1,
ihi[1] + output_ghosts * nghosts[1] + 1 + 1,
ihi[2] + output_ghosts * nghosts[2] + 1 + 1}};
if (io_verbose) {
CCTK_VINFO("Level: %d", leveldata.level);
CCTK_VINFO(" xmin: [%f,%f,%f]", double(rdomain.lo[0]),
Expand Down Expand Up @@ -938,6 +943,7 @@ void carpetx_openpmd_t::InputOpenPMD(const cGH *const cctkGH,
const auto expand_box = [=](CCTK_REAL *const contig_ptr) {
for (int k = 0; k < contig_shape[2]; ++k)
for (int j = 0; j < contig_shape[1]; ++j)
#pragma omp simd
for (int i = 0; i < contig_shape[0]; ++i)
amrex_ptr[amrex_di * i + amrex_dj * j + amrex_dk * k] =
contig_ptr[contig_di * i + contig_dj * j +
Expand Down Expand Up @@ -1150,19 +1156,24 @@ void carpetx_openpmd_t::OutputOpenPMD(const cGH *const cctkGH,
const amrex::Real *const xhi = geom.ProbHi();
const amrex::Real *const dx = geom.CellSize();
const box_t<CCTK_REAL, 3> rdomain{
.lo = {xlo[0] - nghosts[0] * dx[0], xlo[1] - nghosts[1] * dx[1],
xlo[2] - nghosts[2] * dx[2]},
.hi = {xhi[0] + nghosts[0] * dx[0], xhi[1] + nghosts[1] * dx[1],
xhi[2] + nghosts[2] * dx[2]}};
.lo = {xlo[0] - output_ghosts * nghosts[0] * dx[0],
xlo[1] - output_ghosts * nghosts[1] * dx[1],
xlo[2] - output_ghosts * nghosts[2] * dx[2]},
.hi = {xhi[0] + output_ghosts * nghosts[0] * dx[0],
xhi[1] + output_ghosts * nghosts[1] * dx[1],
xhi[2] + output_ghosts * nghosts[2] * dx[2]}};
const amrex::Box &dom = geom.Domain();
const amrex::IntVect &ilo = dom.smallEnd();
const amrex::IntVect &ihi = dom.bigEnd();
// The domain is always vertex centred. The tensor components are
// then staggered if necessary.
const box_t<int, 3> idomain{
.lo = {ilo[0] - nghosts[0], ilo[1] - nghosts[1], ilo[2] - nghosts[2]},
.hi = {ihi[0] + nghosts[0] + 1 + 1, ihi[1] + nghosts[1] + 1 + 1,
ihi[2] + nghosts[2] + 1 + 1}};
.lo = {ilo[0] - output_ghosts * nghosts[0],
ilo[1] - output_ghosts * nghosts[1],
ilo[2] - output_ghosts * nghosts[2]},
.hi = {ihi[0] + output_ghosts * nghosts[0] + 1 + 1,
ihi[1] + output_ghosts * nghosts[1] + 1 + 1,
ihi[2] + output_ghosts * nghosts[2] + 1 + 1}};
if (io_verbose) {
CCTK_VINFO("Patch: %d, Level: %d", patchdata.patch, leveldata.level);
CCTK_VINFO(" xmin: [%f,%f,%f]", double(rdomain.lo[0]),
Expand Down Expand Up @@ -1361,6 +1372,7 @@ void carpetx_openpmd_t::OutputOpenPMD(const cGH *const cctkGH,
CCTK_REAL *restrict const contig_ptr = ptr.get();
for (int k = 0; k < contig_shape[2]; ++k)
for (int j = 0; j < contig_shape[1]; ++j)
#pragma omp simd
for (int i = 0; i < contig_shape[0]; ++i)
contig_ptr[contig_di * i + contig_dj * j +
contig_dk * k] =
Expand Down