Skip to content
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
21 changes: 17 additions & 4 deletions src/diagnostics/Diagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,13 @@ Diagnostic::ResizeFDiagFAB (amrex::Vector<amrex::Geometry>& field_geom,
}
}

const amrex::Box sim_domain = domain;
amrex::Box cut_domain = domain;
{
// shrink box to user specified bounds m_diag_lo and m_diag_hi (in real space)
const amrex::Real poff_x = GetPosOffset(0, geom, geom.Domain());
const amrex::Real poff_y = GetPosOffset(1, geom, geom.Domain());
const amrex::Real poff_z = GetPosOffset(2, geom, geom.Domain());
amrex::Box cut_domain = domain;
if (fd.m_use_custom_size_lo) {
cut_domain.setSmall({
static_cast<int>(std::round((fd.m_diag_lo[0] - poff_x)/geom.CellSize(0))),
Expand All @@ -385,6 +386,10 @@ Diagnostic::ResizeFDiagFAB (amrex::Vector<amrex::Geometry>& field_geom,
static_cast<int>(std::round((fd.m_diag_hi[2] - poff_z)/geom.CellSize(2)))
});
}
// sometimes the cut_domain is off by one cell due to rounding errors
if (!(domain & cut_domain).ok()) {
cut_domain.grow(1);
}
// calculate intersection of boxes to prevent them getting larger
domain &= cut_domain;
}
Expand All @@ -402,13 +407,21 @@ Diagnostic::ResizeFDiagFAB (amrex::Vector<amrex::Geometry>& field_geom,

domain.coarsen(fd.m_diag_coarsen);

fd.m_geom_io = amrex::Geometry(domain, &diag_domain, geom.Coord());
fd.m_has_field = hasFieldOutput(fd, output_step, max_step, output_time, max_time);

fd.m_has_field = domain.ok()
&& hasFieldOutput(fd, output_step, max_step, output_time, max_time);
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(domain.ok(),
"Box for diagnostic object '" + fd.m_diag_name + "' is empty. "
"Make sure that it intersects with the simulation domain!\n"
"Simulation: " + amrex::ToString(sim_domain) + "\n"
"Diagnostic: " + amrex::ToString(cut_domain) + "\n"
"Intersection: " + amrex::ToString(domain)
);

if(fd.m_has_field) {
HIPACE_PROFILE("Diagnostic::ResizeFDiagFAB()");

fd.m_geom_io = amrex::Geometry(domain, &diag_domain, geom.Coord());

switch (fd.m_base_geom_type) {
case FieldDiagnosticData::geom_type::field:
fd.m_F.resize(domain, fd.m_nfields, amrex::The_Pinned_Arena());
Expand Down
Loading