Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions src/framework/domain/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#endif // MPI_ENABLED

#include <algorithm>
#include <filesystem>
#include <iterator>
#include <vector>

Expand Down Expand Up @@ -200,9 +199,9 @@ namespace ntt {
mesh.rangeActiveCells(),
Lambda(index_t i, index_t j) {
const real_t i_ { static_cast<real_t>(static_cast<int>(i) - (N_GHOSTS)) };
const auto k_min = (i2_min - (N_GHOSTS)) + 1;
const auto k_max = (j - (N_GHOSTS));
real_t A3 = ZERO;
const auto k_min = (i2_min - (N_GHOSTS)) + 1;
const auto k_max = (j - (N_GHOSTS));
real_t A3 = ZERO;
for (auto k { k_min }; k <= k_max; ++k) {
real_t k_ = static_cast<real_t>(k);
real_t sqrt_detH_ij1 { mesh.metric.sqrt_det_h({ i_, k_ - HALF }) };
Expand Down Expand Up @@ -434,8 +433,9 @@ namespace ntt {
c,
local_domain->mesh);
} else {
raise::Error("Vector potential can only be computed for GRPIC in 2D",
HERE);
raise::Error(
"Vector potential can only be computed for GRPIC in 2D",
HERE);
}
} else {
raise::Error("Wrong # of components requested for "
Expand Down
33 changes: 21 additions & 12 deletions src/output/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ namespace out {
m_trackers.insert({ type, tools::Tracker(type, interval, interval_time) });
}

auto Writer::shouldWrite(const std::string& type, timestep_t step, simtime_t time)
-> bool {
auto Writer::shouldWrite(const std::string& type,
timestep_t step,
simtime_t time) -> bool {
if (m_trackers.find(type) != m_trackers.end()) {
return m_trackers.at(type).shouldWrite(step, time);
} else {
Expand Down Expand Up @@ -360,6 +361,7 @@ namespace out {

void Writer::writeSpectrum(const array_t<real_t*>& counts,
const std::string& varname) {
auto var = m_io.InquireVariable<real_t>(varname);
auto counts_h = Kokkos::create_mirror_view(counts);
Kokkos::deep_copy(counts_h, counts);
#if defined(MPI_ENABLED)
Expand All @@ -375,31 +377,38 @@ namespace out {
MPI_ROOT_RANK,
MPI_COMM_WORLD);
if (rank == MPI_ROOT_RANK) {
auto var = m_io.InquireVariable<real_t>(varname);
var.SetSelection(adios2::Box<adios2::Dims>({}, { counts.extent(0) }));
var.SetSelection(
adios2::Box<adios2::Dims>({ 0u }, { counts_h_all.extent(0) }));
m_writer.Put<real_t>(var, counts_h_all, adios2::Mode::Sync);
} else {
var.SetSelection(adios2::Box<adios2::Dims>({ 0u }, { 0u }));
m_writer.Put<real_t>(var, nullptr);
}
#else
auto var = m_io.InquireVariable<real_t>(varname);
var.SetSelection(adios2::Box<adios2::Dims>({}, { counts.extent(0) }));
m_writer.Put<real_t>(var, counts_h, adios2::Mode::Sync);
#endif
}

void Writer::writeSpectrumBins(const array_t<real_t*>& e_bins,
const std::string& varname) {
auto var = m_io.InquireVariable<real_t>(varname);
auto e_bins_h = Kokkos::create_mirror_view(e_bins);
Kokkos::deep_copy(e_bins_h, e_bins);
#if defined(MPI_ENABLED)
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank != MPI_ROOT_RANK) {
return;
if (rank == MPI_ROOT_RANK) {
var.SetSelection(adios2::Box<adios2::Dims>({ 0u }, { e_bins_h.extent(0) }));
m_writer.Put<real_t>(var, e_bins_h.data(), adios2::Mode::Sync);
} else {
var.SetSelection(adios2::Box<adios2::Dims>({ 0u }, { 0u }));
m_writer.Put<real_t>(var, nullptr, adios2::Mode::Sync);
}
#endif
auto var = m_io.InquireVariable<real_t>(varname);
var.SetSelection(adios2::Box<adios2::Dims>({}, { e_bins.extent(0) }));
auto e_bins_h = Kokkos::create_mirror_view(e_bins);
Kokkos::deep_copy(e_bins_h, e_bins);
#else
var.SetSelection(adios2::Box<adios2::Dims>({}, { e_bins_h.extent(0) }));
m_writer.Put<real_t>(var, e_bins_h, adios2::Mode::Sync);
#endif
}

void Writer::writeMesh(unsigned short dim,
Expand Down