Skip to content

Commit

Permalink
Abort if BTD selected for RZ, and unsupported field/particle varnames (
Browse files Browse the repository at this point in the history
…ECP-WarpX#3074)

* abort if BTD selected for RZ, and unsupported field/particle varnames

* add doc

* particle fields to plot not supported for BTD

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* WARPX_ALWAYS_ASSERT_WITH_MESSAGE

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* use unified txt message syntax for abort

* fix logic in assert

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
RevathiJambunathan and pre-commit-ci[bot] authored May 3, 2022
1 parent 1af7c05 commit 2106601
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,7 @@ In-situ capabilities can be used by turning on Sensei or Ascent (provided they a
* ``<diag_name>.fields_to_plot`` (list of `strings`, optional)
Fields written to output.
Possible scalar fields: ``part_per_cell`` ``rho`` ``phi`` ``F`` ``part_per_grid`` ``divE`` ``divB`` and ``rho_<species_name>``, where ``<species_name>`` must match the name of one of the available particle species. Note that ``phi`` will only be written out when do_electrostatic==labframe.
Possible scalar fields: ``part_per_cell`` ``rho`` ``phi`` ``F`` ``part_per_grid`` ``divE`` ``divB`` and ``rho_<species_name>``, where ``<species_name>`` must match the name of one of the available particle species. Note that ``phi`` will only be written out when do_electrostatic==labframe. Also, note that for ``<diag_name>.diag_type = BackTransformed``, the only scalar field currently supported is ``rho``.
Possible vector field components in Cartesian geometry: ``Ex`` ``Ey`` ``Ez`` ``Bx`` ``By`` ``Bz`` ``jx`` ``jy`` ``jz``.
Possible vector field components in RZ geometry: ``Er`` ``Et`` ``Ez`` ``Br`` ``Bt`` ``Bz`` ``jr`` ``jt`` ``jz``.
Default is ``<diag_name>.fields_to_plot = Ex Ey Ez Bx By Bz jx jy jz``,
Expand All @@ -2006,6 +2006,7 @@ In-situ capabilities can be used by turning on Sensei or Ascent (provided they a
Note that these averages do not respect the particle shape factor, and instead use nearest-grid point interpolation.
Default is none.
Parser functions for these field names are specified by ``<diag_name>.particle_fields.<field_name>(x,y,z,ux,uy,uz)``.
Also, note that this option is only available for ``<diag_name>.diag_type = Full``

* ``<diag_name>.particle_fields_species`` (list of `strings`, optional)
Species for which to calculate ``particle_fields_to_plot``.
Expand Down Expand Up @@ -2115,7 +2116,7 @@ In-situ capabilities can be used by turning on Sensei or Ascent (provided they a
BackTransformed Diagnostics (with support for Plotfile/openPMD output)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``BackTransformed`` diag type are used when running a simulation in a boosted frame, to reconstruct output data to the lab frame. This option can be set using ``<diag_name>.diag_type = BackTransformed``. Additional options for this diagnostic include:
``BackTransformed`` diag type are used when running a simulation in a boosted frame, to reconstruct output data to the lab frame. This option can be set using ``<diag_name>.diag_type = BackTransformed``. Note that this diagnostic is not currently supported for RZ. Additional options for this diagnostic include:

* ``<diag_name>.num_snapshots_lab`` (`integer`)
Only used when ``<diag_name>.diag_type`` is ``BackTransformed``.
Expand Down
14 changes: 14 additions & 0 deletions Source/Diagnostics/BTDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,20 @@ BTDiagnostics::ReadParameters ()
if(m_max_box_size < m_buffer_size) m_max_box_size = m_buffer_size;
}


amrex::Vector< std::string > BTD_varnames_supported = {"Ex", "Ey", "Ez",
"Bx", "By", "Bz",
"jx", "jy", "jz", "rho"};

for (const auto& var : m_varnames) {
WARPX_ALWAYS_ASSERT_WITH_MESSAGE( (WarpXUtilStr::is_in(BTD_varnames_supported, var )), "Input error: field variable " + var + " in " + m_diag_name
+ ".fields_to_plot is not supported for BackTransformed diagnostics. Currently supported field variables for BackTransformed diagnostics include Ex, Ey, Ez, Bx, By, Bz, jx, jy, jz, and rho");
}

bool particle_fields_to_plot_specified = pp_diag_name.queryarr("particle_fields_to_plot", m_pfield_varnames);
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(!particle_fields_to_plot_specified, "particle_fields_to_plot is currently not supported for BackTransformed Diagnostics");


}

bool
Expand Down
5 changes: 4 additions & 1 deletion Source/Diagnostics/BackTransformedDiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "Parallelization/WarpXCommUtil.H"
#include "Utils/WarpXConst.H"
#include "Utils/WarpXProfilerWrapper.H"
#include "Utils/TextMsg.H"
#include "WarpX.H"

#include <AMReX_Array4.H>
Expand Down Expand Up @@ -577,7 +578,9 @@ BackTransformedDiagnostic (Real zmin_lab, Real zmax_lab, Real v_window_lab,
m_particle_slice_width_lab_(particle_slice_width_lab)
{


#ifdef WARPX_DIM_RZ
amrex::Abort(Utils::TextMsg::Err("BackTransformed diagnostics is currently not supported with RZ"));
#endif
WARPX_PROFILE("BackTransformedDiagnostic::BackTransformedDiagnostic");

AMREX_ALWAYS_ASSERT(WarpX::do_back_transformed_fields or
Expand Down
5 changes: 5 additions & 0 deletions Source/Diagnostics/MultiDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "Diagnostics/BTDiagnostics.H"
#include "Diagnostics/FullDiagnostics.H"
#include "Utils/TextMsg.H"

#include <AMReX_ParmParse.H>
#include <AMReX.H>
Expand All @@ -22,7 +23,11 @@ MultiDiagnostics::MultiDiagnostics ()
if ( diags_types[i] == DiagTypes::Full ){
alldiags[i] = std::make_unique<FullDiagnostics>(i, diags_names[i]);
} else if ( diags_types[i] == DiagTypes::BackTransformed ){
#ifdef WARPX_DIM_RZ
amrex::Abort(Utils::TextMsg::Err("BackTransformed diagnostics is currently not supported for RZ"));
#else
alldiags[i] = std::make_unique<BTDiagnostics>(i, diags_names[i]);
#endif
} else {
amrex::Abort("Unknown diagnostic type");
}
Expand Down

0 comments on commit 2106601

Please sign in to comment.