Skip to content

Commit bd7d6f6

Browse files
MaxThevenetburlen
andauthored
Move sensei to new diagnostics (#1040)
* move ascent to new diagnostics * move Sensei to the new diagnostics * minor cleaning in new diagnostics * oops, had forgotten some files * fix typo * another typo introduced when merging master into this branch * FlushFormat::WriteToFile takes Vector<MultiFab>& instead of Vector<const MultiFab*> * IO output multifab has 1 guard cell when using sensei * updates to FlushFormatSensei * add some documentation to the class * add refrence to AmrMesh instance needed by the adaptor * add some error output in the case WarpX was not compiled w/ SENSEI * tested with SENSEI 3.2.0 Co-authored-by: Burlen Loring <[email protected]>
1 parent d337f7c commit bd7d6f6

18 files changed

+199
-167
lines changed

Source/Diagnostics/Diagnostics.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "FlushFormats/FlushFormatPlotfile.H"
88
#include "FlushFormats/FlushFormatCheckpoint.H"
99
#include "FlushFormats/FlushFormatAscent.H"
10+
#include "FlushFormats/FlushFormatSensei.H"
1011
#ifdef WARPX_USE_OPENPMD
1112
# include "FlushFormats/FlushFormatOpenPMD.H"
1213
#endif
@@ -39,8 +40,10 @@ Diagnostics::ReadParameters ()
3940
m_intervals = IntervalsParser(period_string);
4041
pp.query("format", m_format);
4142
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(
42-
m_format == "plotfile" || m_format == "openpmd" || m_format == "checkpoint" || m_format == "ascent",
43-
"<diag>.format must be plotfile or openpmd or checkpoint or ascent");
43+
m_format == "plotfile" || m_format == "openpmd" ||
44+
m_format == "checkpoint" || m_format == "ascent" ||
45+
m_format == "sensei",
46+
"<diag>.format must be plotfile or openpmd or checkpoint or ascent or sensei");
4447
bool raw_specified = pp.query("plot_raw_fields", m_plot_raw_fields);
4548
raw_specified += pp.query("plot_raw_fields_guards", m_plot_raw_fields_guards);
4649
bool varnames_specified = pp.queryarr("fields_to_plot", m_varnames);
@@ -148,6 +151,14 @@ Diagnostics::InitData ()
148151
m_flush_format = new FlushFormatCheckpoint;
149152
} else if (m_format == "ascent"){
150153
m_flush_format = new FlushFormatAscent;
154+
} else if (m_format == "sensei"){
155+
#ifdef BL_USE_SENSEI_INSITU
156+
m_flush_format = new FlushFormatSensei(
157+
dynamic_cast<amrex::AmrMesh*>(const_cast<WarpX*>(&warpx)),
158+
m_diag_name);
159+
#else
160+
amrex::Abort("To use SENSEI in situ, compile with USE_SENSEI=TRUE");
161+
#endif
151162
} else if (m_format == "openpmd"){
152163
#ifdef WARPX_USE_OPENPMD
153164
m_flush_format = new FlushFormatOpenPMD(m_diag_name);
@@ -195,7 +206,7 @@ Diagnostics::Flush ()
195206
{
196207
auto & warpx = WarpX::GetInstance();
197208
m_flush_format->WriteToFile(
198-
m_varnames, GetVecOfConstPtrs(m_mf_output), warpx.Geom(), warpx.getistep(),
209+
m_varnames, m_mf_output, warpx.Geom(), warpx.getistep(),
199210
warpx.gett_new(0), m_all_species, nlev, m_file_prefix,
200211
m_plot_raw_fields, m_plot_raw_fields_guards, m_plot_raw_rho, m_plot_raw_F);
201212
}
@@ -401,7 +412,8 @@ Diagnostics::DefineDiagMultiFab ( int lev ) {
401412
// is different from the lo and hi physical co-ordinates of the simulation domain.
402413
if (use_warpxba == false) dmap = DistributionMapping{ba};
403414
// Allocate output MultiFab for diagnostics. The data will be stored at cell-centers.
404-
m_mf_output[lev] = MultiFab(ba, dmap, m_varnames.size(), 0);
415+
int ngrow = (m_format == "sensei") ? 1 : 0;
416+
m_mf_output[lev] = MultiFab(ba, dmap, m_varnames.size(), ngrow);
405417
}
406418

407419

Source/Diagnostics/FlushFormats/FlushFormat.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public:
1010
/** Flush fields and particles to file */
1111
virtual void WriteToFile (
1212
const amrex::Vector<std::string> varnames,
13-
const amrex::Vector<const amrex::MultiFab*> mf,
13+
const amrex::Vector<amrex::MultiFab>& mf,
1414
amrex::Vector<amrex::Geometry>& geom,
1515
const amrex::Vector<int> iteration, const double time,
1616
const amrex::Vector<ParticleDiag>& particle_diags, int nlev,

Source/Diagnostics/FlushFormats/FlushFormatAscent.H

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "FlushFormat.H"
55
#include "Diagnostics/ParticleDiag/ParticleDiag.H"
66

7-
87
#ifdef AMREX_USE_ASCENT
98
# include <ascent.hpp>
109
# include <AMReX_Conduit_Blueprint.H>
@@ -21,7 +20,7 @@ public:
2120
/** Do in-situ visualization for field and particle data */
2221
virtual void WriteToFile (
2322
const amrex::Vector<std::string> varnames,
24-
const amrex::Vector<const amrex::MultiFab*> mf,
23+
const amrex::Vector<amrex::MultiFab>& mf,
2524
amrex::Vector<amrex::Geometry>& geom,
2625
const amrex::Vector<int> iteration, const double time,
2726
const amrex::Vector<ParticleDiag>& particle_diags, int nlev, const std::string prefix,

Source/Diagnostics/FlushFormats/FlushFormatAscent.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using namespace amrex;
66
void
77
FlushFormatAscent::WriteToFile (
88
const amrex::Vector<std::string> varnames,
9-
const amrex::Vector<const amrex::MultiFab*> mf,
9+
const amrex::Vector<amrex::MultiFab>& mf,
1010
amrex::Vector<amrex::Geometry>& geom,
1111
const amrex::Vector<int> iteration, const double time,
1212
const amrex::Vector<ParticleDiag>& particle_diags, int nlev,
@@ -20,7 +20,7 @@ FlushFormatAscent::WriteToFile (
2020
// wrap mesh data
2121
conduit::Node bp_mesh;
2222
amrex::MultiLevelToBlueprint(
23-
nlev, mf, varnames, geom, time, iteration, warpx.refRatio(), bp_mesh);
23+
nlev, amrex::GetVecOfConstPtrs(mf), varnames, geom, time, iteration, warpx.refRatio(), bp_mesh);
2424

2525
WriteParticles(particle_diags, bp_mesh);
2626

Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class FlushFormatCheckpoint final : public FlushFormatPlotfile
88
/** Flush fields and particles to plotfile */
99
virtual void WriteToFile (
1010
const amrex::Vector<std::string> varnames,
11-
const amrex::Vector<const amrex::MultiFab*> mf,
11+
const amrex::Vector<amrex::MultiFab>& mf,
1212
amrex::Vector<amrex::Geometry>& geom,
1313
const amrex::Vector<int> iteration, const double time,
1414
const amrex::Vector<ParticleDiag>& particle_diags, int nlev, const std::string prefix,

Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace
1414
void
1515
FlushFormatCheckpoint::WriteToFile (
1616
const amrex::Vector<std::string> varnames,
17-
const amrex::Vector<const amrex::MultiFab*> mf,
17+
const amrex::Vector<amrex::MultiFab>& mf,
1818
amrex::Vector<amrex::Geometry>& geom,
1919
const amrex::Vector<int> iteration, const double time,
2020
const amrex::Vector<ParticleDiag>& particle_diags, int nlev, const std::string prefix,

Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public:
1919
/** Flush fields and particles to plotfile */
2020
virtual void WriteToFile (
2121
const amrex::Vector<std::string> varnames,
22-
const amrex::Vector<const amrex::MultiFab*> mf,
22+
const amrex::Vector<amrex::MultiFab>& mf,
2323
amrex::Vector<amrex::Geometry>& geom,
2424
const amrex::Vector<int> iteration, const double time,
2525
const amrex::Vector<ParticleDiag>& particle_diags, int nlev, const std::string prefix,

Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66

77
using namespace amrex;
88

9-
namespace
10-
{
11-
const std::string level_prefix {"Level_"};
12-
}
13-
149
FlushFormatOpenPMD::FlushFormatOpenPMD (const std::string& diag_name)
1510
{
1611
ParmParse pp(diag_name);
@@ -29,7 +24,7 @@ FlushFormatOpenPMD::FlushFormatOpenPMD (const std::string& diag_name)
2924
void
3025
FlushFormatOpenPMD::WriteToFile (
3126
const amrex::Vector<std::string> varnames,
32-
const amrex::Vector<const amrex::MultiFab*> mf,
27+
const amrex::Vector<amrex::MultiFab>& mf,
3328
amrex::Vector<amrex::Geometry>& geom,
3429
const amrex::Vector<int> iteration, const double time,
3530
const amrex::Vector<ParticleDiag>& particle_diags, int nlev,
@@ -47,7 +42,7 @@ FlushFormatOpenPMD::WriteToFile (
4742

4843
// fields: only dumped for coarse level
4944
m_OpenPMDPlotWriter->WriteOpenPMDFields(
50-
varnames, *mf[0], geom[0], iteration[0], time);
45+
varnames, mf[0], geom[0], iteration[0], time);
5146

5247
// particles: all (reside only on locally finest level)
5348
m_OpenPMDPlotWriter->WriteOpenPMDParticles(particle_diags);

Source/Diagnostics/FlushFormats/FlushFormatPlotfile.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public:
1515
/** Flush fields and particles to plotfile */
1616
virtual void WriteToFile (
1717
const amrex::Vector<std::string> varnames,
18-
const amrex::Vector<const amrex::MultiFab*> mf,
18+
const amrex::Vector<amrex::MultiFab>& mf,
1919
amrex::Vector<amrex::Geometry>& geom,
2020
const amrex::Vector<int> iteration, const double time,
2121
const amrex::Vector<ParticleDiag>& particle_diags, int nlev, const std::string prefix,

Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace
1515
void
1616
FlushFormatPlotfile::WriteToFile (
1717
const amrex::Vector<std::string> varnames,
18-
const amrex::Vector<const amrex::MultiFab*> mf,
18+
const amrex::Vector<amrex::MultiFab>& mf,
1919
amrex::Vector<amrex::Geometry>& geom,
2020
const amrex::Vector<int> iteration, const double time,
2121
const amrex::Vector<ParticleDiag>& particle_diags, int nlev,
@@ -31,7 +31,7 @@ FlushFormatPlotfile::WriteToFile (
3131
VisMF::SetHeaderVersion(amrex::VisMF::Header::Version_v1);
3232
if (plot_raw_fields) rfs.emplace_back("raw_fields");
3333
amrex::WriteMultiLevelPlotfile(filename, nlev,
34-
mf,
34+
amrex::GetVecOfConstPtrs(mf),
3535
varnames, geom,
3636
time, iteration, warpx.refRatio(),
3737
"HyperCLaw-V1.1",

0 commit comments

Comments
 (0)