aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Docs/source/usage/parameters.rst1
-rwxr-xr-xExamples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py7
-rw-r--r--Python/pywarpx/picmi.py2
-rw-r--r--Regression/Checksum/benchmarks_json/LaserIonAcc2d_no_field_diag.json24
-rw-r--r--Regression/WarpX-tests.ini40
-rw-r--r--Source/Diagnostics/Diagnostics.cpp4
-rw-r--r--Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp20
-rw-r--r--Source/Diagnostics/FullDiagnostics.cpp5
8 files changed, 92 insertions, 11 deletions
diff --git a/Docs/source/usage/parameters.rst b/Docs/source/usage/parameters.rst
index 285d731ab..02eed3fce 100644
--- a/Docs/source/usage/parameters.rst
+++ b/Docs/source/usage/parameters.rst
@@ -1998,6 +1998,7 @@ In-situ capabilities can be used by turning on Sensei or Ascent (provided they a
Default is ``<diag_name>.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz``,
unless in RZ geometry with ``<diag_name>.format == openpmd``,
then default is ``<diag_name>.fields_to_plot = Er Et Ez Br Bt Bz jr jt jz``.
+ When the special value ``none`` is specified, no fields are written out.
Note that the fields are averaged on the cell centers before they are written to file.
Also, when ``<diag_name>.format = openpmd``, the RZ modes for all fields are written.
Otherwise, we reconstruct a 2D Cartesian slice of the fields for output at :math:`\theta=0`.
diff --git a/Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py b/Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py
index fc965787f..b9d060343 100755
--- a/Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py
+++ b/Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py
@@ -10,6 +10,11 @@ parser = argparse.ArgumentParser(description="Gaussian beam PICMI example")
parser.add_argument('--diagformat', type=str,
help='Format of the full diagnostics (plotfile, openpmd, ascent, sensei, ...)',
default='plotfile')
+parser.add_argument('--fields_to_plot', type=str,
+ help='List of fields to write to diagnostics',
+ default=['E', 'B', 'J', 'part_per_cell'],
+ nargs = '*')
+
args = parser.parse_args()
constants = picmi.constants
@@ -59,7 +64,7 @@ protons = picmi.Species(particle_type='proton', name='protons', initial_distribu
field_diag1 = picmi.FieldDiagnostic(name = 'diag1',
grid = grid,
period = 10,
- data_list = ['E', 'B', 'J', 'part_per_cell'],
+ data_list = args.fields_to_plot,
warpx_format = args.diagformat,
write_dir = '.',
warpx_file_prefix = 'Python_gaussian_beam_plt')
diff --git a/Python/pywarpx/picmi.py b/Python/pywarpx/picmi.py
index bb50ed42d..a79a2d7a1 100644
--- a/Python/pywarpx/picmi.py
+++ b/Python/pywarpx/picmi.py
@@ -1243,6 +1243,8 @@ class FieldDiagnostic(picmistandard.PICMI_FieldDiagnostic):
self.plot_finepatch = 1
elif dataname == 'crsepatch':
self.plot_crsepatch = 1
+ elif dataname == 'none':
+ fields_to_plot = set(('none',))
# --- Convert the set to a sorted list so that the order
# --- is the same on all processors.
diff --git a/Regression/Checksum/benchmarks_json/LaserIonAcc2d_no_field_diag.json b/Regression/Checksum/benchmarks_json/LaserIonAcc2d_no_field_diag.json
new file mode 100644
index 000000000..ae3cb2d63
--- /dev/null
+++ b/Regression/Checksum/benchmarks_json/LaserIonAcc2d_no_field_diag.json
@@ -0,0 +1,24 @@
+{
+ "electrons": {
+ "particle_cpu": 0.0,
+ "particle_id": 2101654260.0,
+ "particle_momentum_x": 3.819006669880345e-19,
+ "particle_momentum_y": 0.0,
+ "particle_momentum_z": 1.6442919544438796e-18,
+ "particle_position_x": 0.008132686129387588,
+ "particle_position_y": 0.030529759891592873,
+ "particle_weight": 2.641331189632942e+17
+ },
+ "hydrogen": {
+ "particle_cpu": 0.0,
+ "particle_id": 8663540542.0,
+ "particle_momentum_x": 2.2442931423587623e-18,
+ "particle_momentum_y": 0.0,
+ "particle_momentum_z": 1.0841108905602765e-18,
+ "particle_position_x": 0.008258183385250792,
+ "particle_position_y": 0.03668783554832863,
+ "particle_weight": 2.701906737218416e+17
+ },
+ "lev=0": {
+ }
+}
diff --git a/Regression/WarpX-tests.ini b/Regression/WarpX-tests.ini
index cd5c748c5..802ee74ff 100644
--- a/Regression/WarpX-tests.ini
+++ b/Regression/WarpX-tests.ini
@@ -1720,6 +1720,46 @@ compareParticles = 1
particleTypes = electrons
analysisRoutine =
+[Python_gaussian_beam_no_field_output]
+buildDir = .
+inputFile = Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py
+customRunCmd = python3 PICMI_inputs_gaussian_beam.py --fields_to_plot none
+runtime_params =
+dim = 3
+addToCompileString = USE_PYTHON_MAIN=TRUE
+cmakeSetupOpts = -DWarpX_DIMS=3 -DWarpX_APP=OFF
+target = pip_install
+restartTest = 0
+useMPI = 1
+numprocs = 2
+useOMP = 1
+numthreads = 1
+compileTest = 0
+doVis = 0
+compareParticles = 1
+particleTypes = electrons
+analysisRoutine =
+
+[Python_gaussian_beam_opmd_no_field_output]
+buildDir = .
+inputFile = Examples/Modules/gaussian_beam/PICMI_inputs_gaussian_beam.py
+customRunCmd = python PICMI_inputs_gaussian_beam.py --diagformat=openpmd --fields_to_plot none
+runtime_params =
+dim = 3
+addToCompileString = USE_OPENPMD=TRUE USE_PYTHON_MAIN=TRUE
+cmakeSetupOpts = -DWarpX_DIMS=3 -DWarpX_OPENPMD=ON -DWarpX_APP=OFF
+target = pip_install
+restartTest = 0
+useMPI = 1
+numprocs = 2
+useOMP = 1
+numthreads = 1
+compileTest = 0
+doVis = 0
+compareParticles = 1
+particleTypes = electrons
+analysisRoutine =
+
[PlasmaAccelerationBoost2d]
buildDir = .
inputFile = Examples/Physics_applications/plasma_acceleration/inputs_2d_boost
diff --git a/Source/Diagnostics/Diagnostics.cpp b/Source/Diagnostics/Diagnostics.cpp
index caf9aea13..3259994bd 100644
--- a/Source/Diagnostics/Diagnostics.cpp
+++ b/Source/Diagnostics/Diagnostics.cpp
@@ -169,6 +169,10 @@ Diagnostics::BaseReadParameters ()
);
}
+ if (WarpXUtilStr::is_in(m_varnames_fields, "none")){
+ m_varnames_fields.clear();
+ }
+
m_varnames = m_varnames_fields;
// Generate names of averaged particle fields and append to m_varnames
for (int ivar=0; ivar<m_pfield_varnames.size(); ivar++) {
diff --git a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp
index 4655128d5..513d97f3a 100644
--- a/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp
+++ b/Source/Diagnostics/FlushFormats/FlushFormatPlotfile.cpp
@@ -71,15 +71,17 @@ FlushFormatPlotfile::WriteToFile (
VisMF::Header::Version current_version = VisMF::GetHeaderVersion();
VisMF::SetHeaderVersion(amrex::VisMF::Header::Version_v1);
if (plot_raw_fields) rfs.emplace_back("raw_fields");
- amrex::WriteMultiLevelPlotfile(filename, nlev,
- amrex::GetVecOfConstPtrs(mf),
- varnames, geom,
- static_cast<Real>(time), iteration, warpx.refRatio(),
- "HyperCLaw-V1.1",
- "Level_",
- "Cell",
- rfs
- );
+ if (varnames.size() > 0) {
+ amrex::WriteMultiLevelPlotfile(filename, nlev,
+ amrex::GetVecOfConstPtrs(mf),
+ varnames, geom,
+ static_cast<Real>(time), iteration, warpx.refRatio(),
+ "HyperCLaw-V1.1",
+ "Level_",
+ "Cell",
+ rfs
+ );
+ }
WriteAllRawFields(plot_raw_fields, nlev, filename, plot_raw_fields_guards);
diff --git a/Source/Diagnostics/FullDiagnostics.cpp b/Source/Diagnostics/FullDiagnostics.cpp
index cb51301ee..5fb9abbcb 100644
--- a/Source/Diagnostics/FullDiagnostics.cpp
+++ b/Source/Diagnostics/FullDiagnostics.cpp
@@ -541,7 +541,10 @@ FullDiagnostics::InitializeBufferData (int i_buffer, int lev ) {
// Allocate output MultiFab for diagnostics. The data will be stored at cell-centers.
int ngrow = (m_format == "sensei" || m_format == "ascent") ? 1 : 0;
// The zero is hard-coded since the number of output buffers = 1 for FullDiagnostics
- m_mf_output[i_buffer][lev] = amrex::MultiFab(ba, dmap, static_cast<int>(m_varnames.size()), ngrow);
+ int const ncomp = static_cast<int>(m_varnames.size());
+ if (ncomp > 0) {
+ m_mf_output[i_buffer][lev] = amrex::MultiFab(ba, dmap, ncomp, ngrow);
+ }
if (lev == 0) {