aboutsummaryrefslogtreecommitdiff
path: root/Source/Diagnostics/WarpXIO.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Diagnostics/WarpXIO.cpp')
-rw-r--r--Source/Diagnostics/WarpXIO.cpp86
1 files changed, 56 insertions, 30 deletions
diff --git a/Source/Diagnostics/WarpXIO.cpp b/Source/Diagnostics/WarpXIO.cpp
index 31a5f700d..f85b9df3b 100644
--- a/Source/Diagnostics/WarpXIO.cpp
+++ b/Source/Diagnostics/WarpXIO.cpp
@@ -1,3 +1,12 @@
+/* Copyright 2019-2020 Andrew Myers, Ann Almgren, Axel Huebl
+ * Burlen Loring, David Grote, Gunther H. Weber
+ * Junmin Gu, Maxence Thevenet, Remi Lehe
+ * Revathi Jambunathan, Weiqun Zhang
+ *
+ * This file is part of WarpX.
+ *
+ * License: BSD-3-Clause-LBNL
+ */
#include <AMReX_MultiFabUtil.H>
#include <AMReX_PlotFileUtil.H>
#include <AMReX_FillPatchUtil_F.H>
@@ -19,7 +28,7 @@
#endif
#ifdef WARPX_USE_OPENPMD
-#include "WarpXOpenPMD.H"
+# include "WarpXOpenPMD.H"
#endif
@@ -499,41 +508,68 @@ WarpX::UpdateInSitu () const
}
void
-WarpX::WritePlotFile () const
-{
- BL_PROFILE("WarpX::WritePlotFile()");
-
- const std::string& plotfilename = amrex::Concatenate(plot_file,istep[0]);
- amrex::Print() << " Writing plotfile " << plotfilename << "\n";
-
+WarpX::prepareFields(
+ int const step,
+ Vector<std::string>& varnames,
+ Vector<MultiFab>& mf_avg,
+ Vector<const MultiFab*>& output_mf,
+ Vector<Geometry>& output_geom
+) const {
// Average the fields from the simulation grid to the cell centers
const int ngrow = 0;
- Vector<std::string> varnames; // Name of the written fields
- // mf_avg will contain the averaged, cell-centered fields
- Vector<MultiFab> mf_avg;
WarpX::AverageAndPackFields( varnames, mf_avg, ngrow );
// Coarsen the fields, if requested by the user
- Vector<const MultiFab*> output_mf; // will point to the data to be written
Vector<MultiFab> coarse_mf; // will remain empty if there is no coarsening
- Vector<Geometry> output_geom;
if (plot_coarsening_ratio != 1) {
coarsenCellCenteredFields( coarse_mf, output_geom, mf_avg, Geom(),
- plot_coarsening_ratio, finest_level );
+ plot_coarsening_ratio, finest_level );
output_mf = amrex::GetVecOfConstPtrs(coarse_mf);
} else { // No averaging necessary, simply point to mf_avg
output_mf = amrex::GetVecOfConstPtrs(mf_avg);
output_geom = Geom();
}
+}
+
+void
+WarpX::WriteOpenPMDFile () const
+{
+ BL_PROFILE("WarpX::WriteOpenPMDFile()");
#ifdef WARPX_USE_OPENPMD
- m_OpenPMDPlotWriter->SetStep(istep[0]);
- if (dump_openpmd)
- m_OpenPMDPlotWriter->WriteOpenPMDFields(varnames,
- *output_mf[0], output_geom[0], istep[0], t_new[0] );
+ const auto step = istep[0];
+
+ Vector<std::string> varnames; // Name of the written fields
+ Vector<MultiFab> mf_avg; // contains the averaged, cell-centered fields
+ Vector<const MultiFab*> output_mf; // will point to the data to be written
+ Vector<Geometry> output_geom;
+
+ prepareFields(step, varnames, mf_avg, output_mf, output_geom);
+
+ m_OpenPMDPlotWriter->SetStep(step);
+ // fields: only dumped for coarse level
+ m_OpenPMDPlotWriter->WriteOpenPMDFields(
+ varnames, *output_mf[0], output_geom[0], step, t_new[0]);
+ // particles: all (reside only on locally finest level)
+ m_OpenPMDPlotWriter->WriteOpenPMDParticles(mypc);
#endif
+}
+
+void
+WarpX::WritePlotFile () const
+{
+ BL_PROFILE("WarpX::WritePlotFile()");
- if (dump_plotfiles || dump_openpmd) {
+ const auto step = istep[0];
+ const std::string& plotfilename = amrex::Concatenate(plot_file,step);
+ amrex::Print() << " Writing plotfile " << plotfilename << "\n";
+
+ Vector<std::string> varnames; // Name of the written fields
+ Vector<MultiFab> mf_avg; // contains the averaged, cell-centered fields
+ Vector<const MultiFab*> output_mf; // will point to the data to be written
+ Vector<Geometry> output_geom;
+
+ prepareFields(step, varnames, mf_avg, output_mf, output_geom);
// Write the fields contained in `mf_avg`, and corresponding to the
// names `varnames`, into a plotfile.
@@ -616,23 +652,13 @@ WarpX::WritePlotFile () const
}
}
-#ifdef WARPX_USE_OPENPMD
- // Write openPMD format: only for level 0
- if (dump_openpmd)
- m_OpenPMDPlotWriter->WriteOpenPMDParticles(mypc);
-#endif
- // leaving the option of binary output through AMREx around
- // regardless of openPMD. This can be adjusted later
- {
- mypc->WritePlotFile(plotfilename);
- }
+ mypc->WritePlotFile(plotfilename);
WriteJobInfo(plotfilename);
WriteWarpXHeader(plotfilename);
VisMF::SetHeaderVersion(current_version);
- } // endif: dump_plotfiles
}