WarpX
|
#include <BTDiagnostics.H>
Public Member Functions | |
BTDiagnostics (int i, const std::string &name) | |
![]() | |
Diagnostics (int i, std::string name) | |
virtual | ~Diagnostics () |
Diagnostics (Diagnostics const &)=delete | |
Diagnostics & | operator= (Diagnostics const &)=delete |
Diagnostics (Diagnostics &&)=default | |
Diagnostics & | operator= (Diagnostics &&)=default |
void | ComputeAndPack () |
void | InitData () |
void | InitDataBeforeRestart () |
void | InitDataAfterRestart () |
virtual void | InitializeFieldFunctorsRZopenPMD ([[maybe_unused]] int lev) |
void | NewIteration () |
void | FilterComputePackFlush (int step, bool force_flush=false) |
bool | DoDumpLastTimestep () const |
int | getnumbuffers () const |
virtual amrex::Real | gettlab ([[maybe_unused]] int i_buffer) |
virtual void | settlab ([[maybe_unused]] int i_buffer, [[maybe_unused]] amrex::Real tlab) |
virtual int | get_buffer_k_index_hi ([[maybe_unused]] int i_buffer) |
virtual void | set_buffer_k_index_hi ([[maybe_unused]] int i_buffer, [[maybe_unused]] int kindex) |
virtual amrex::Real | get_snapshot_domain_lo ([[maybe_unused]] int i_buffer, [[maybe_unused]] int idim) |
virtual amrex::Real | get_snapshot_domain_hi ([[maybe_unused]] int i_buffer, [[maybe_unused]] int idim) |
void | setSnapshotDomainLo (int i_buffer, int idim, amrex::Real domain_lab_lo) |
void | setSnapshotDomainHi (int i_buffer, int idim, amrex::Real domain_lab_hi) |
virtual int | get_flush_counter ([[maybe_unused]] int i_buffer) |
virtual void | set_flush_counter ([[maybe_unused]] int i_buffer, [[maybe_unused]] int flush_counter) |
virtual int | get_last_valid_Zslice ([[maybe_unused]] int i_buffer) |
virtual void | set_last_valid_Zslice ([[maybe_unused]] int i_buffer, [[maybe_unused]] int last_valid_Zslice) |
virtual int | get_snapshot_full_flag ([[maybe_unused]] int i_buffer) |
virtual void | set_snapshot_full ([[maybe_unused]] int i_buffer, [[maybe_unused]] int snapshot_full) |
Private Member Functions | |
void | ReadParameters () |
void | Flush (int i_buffer, bool force_flush) override |
Flush m_mf_output and particles to file. Currently, a temporary customized output format for the buffer data is implemented and called in this function. After implementing OpenPMD and plotfile formats, this function can be defined and implemented in Diagnostics.H, such that, the function call to flush out buffer data for FullDiagnostics and BTDiagnostics is the same. More... | |
bool | DoDump (int step, int i_buffer, bool force_flush=false) override |
bool | DoComputeAndPack (int step, bool force_flush=false) override |
void | DerivedInitData () override |
void | InitializeFieldFunctors (int lev) override |
void | InitializeFieldFunctorsRZopenPMD (int lev) override |
void | AddRZModesToOutputNames (const std::string &field, int ncomp, bool cellcenter_data) |
void | InitializeParticleBuffer () override |
void | PrepareBufferData () override |
void | UpdateBufferData () override |
void | PrepareFieldDataForOutput () override |
void | PrepareParticleDataForOutput () override |
bool | GetZSliceInDomainFlag (int i_buffer, int lev) |
bool | GetKIndexInSnapshotBoxFlag (int i_buffer, int lev) |
void | InitializeBufferData (int i_buffer, int lev, bool restart=false) override |
void | DefineCellCenteredMultiFab (int lev) |
void | DefineFieldBufferMultiFab (int i_buffer, int lev) |
void | DefineSnapshotGeometry (int i_buffer, int lev) |
amrex::Real | UpdateCurrentZBoostCoordinate (amrex::Real t_lab, amrex::Real t_boost) const |
amrex::Real | UpdateCurrentZLabCoordinate (amrex::Real t_lab, amrex::Real t_boost) const |
amrex::Real | dz_lab (amrex::Real dt, amrex::Real ref_ratio) const |
int | k_index_zlab (int i_buffer, int lev) const |
bool | buffer_full (int i_buffer) |
bool | buffer_empty (int i_buffer) |
void | NullifyFirstFlush (int i_buffer) |
void | ResetBufferCounter (int i_buffer) |
void | IncrementBufferFlushCounter (int i_buffer) |
void | SetSnapshotFullStatus (int i_buffer) |
void | MergeBuffersForPlotfile (int i_snapshot) |
void | InterleaveBufferAndSnapshotHeader (const std::string &buffer_Header, const std::string &snapshot_Header) |
void | InterleaveFabArrayHeader (const std::string &Buffer_FabHeader_path, const std::string &snapshot_FabHeader_path, const std::string &newsnapshot_FabFilename) |
void | InterleaveSpeciesHeader (const std::string &buffer_species_Header_path, const std::string &snapshot_species_Header_path, const std::string &species_name, int new_data_index) |
void | InterleaveParticleDataHeader (const std::string &buffer_ParticleHdrFilename, const std::string &snapshot_ParticleHdrFilename) |
void | InitializeParticleFunctors () override |
void | ResetTotalParticlesInBuffer (int i_buffer) |
void | ClearParticleBuffer (int i_buffer) |
void | RedistributeParticleBuffer (int i_buffer) |
void | UpdateVarnamesForRZopenPMD () |
amrex::Real | gettlab (int i_buffer) override |
void | settlab (int i_buffer, amrex::Real tlab) override |
int | get_buffer_k_index_hi (int i_buffer) override |
void | set_buffer_k_index_hi (int i_buffer, int kindex) override |
amrex::Real | get_snapshot_domain_lo (int i_buffer, int idim) override |
amrex::Real | get_snapshot_domain_hi (int i_buffer, int idim) override |
int | get_flush_counter (int i_buffer) override |
void | set_flush_counter ([[maybe_unused]] int i_buffer, int flush_counter) override |
int | get_last_valid_Zslice (int i_buffer) override |
void | set_last_valid_Zslice (int i_buffer, int last_valid_Zslice) override |
int | get_snapshot_full_flag (int i_buffer) override |
void | set_snapshot_full (int i_buffer, int snapshot_full) override |
BTDiagnostics::BTDiagnostics | ( | int | i, |
const std::string & | name | ||
) |
|
private |
Populating m_varnames with real and imaginary parts of each RZ mode. Modes are numbered from 0 to (nmodes-1) and mode 0 is purely real. Both m_cellcenter_varnames (storing cell-centered data) and m_varnames (storing back-transformed field data) are modified to include RZ modes to include field_modeid_real/imag. For example, for Er with two modes, the varnames are Er_0_real, Er_1_real, Er_1_imag
[in] | field | field-name |
[in] | ncomp | number of rz components (if 2 modes, the ncomp is 2*nmodes-1) |
[in] | cellcenter_data | if true, m_cellcenter_varnames are updated if false, m_varnames is updated |
|
inlineprivate |
whether field buffer is empty.
[in] | i_buffer | buffer id for which the buffer size is checked. returns bool = true is buffer is empty i.e., when buffer counter is zero. |
|
inlineprivate |
whether field buffer is full
[in] | i_buffer | buffer id for which the buffer size is checked. returns bool = true is buffer is full, that is, when buffer counter is equal to m_buffer_size |
|
private |
Clear particle data stored in the particle buffer
|
private |
Define the cell-centered multi-component MultiFab at level, lev. This function is called when the buffer counter for a snapshot is zero, or when the buffer is empty. Checked using buffer_empty(i_buffer)
[in] | lev | level at which the cell-centered MultiFab is defined. |
Define the cell-centered multi-component output buffer MultiFab for snapshot, i_buffer, at level, lev
[in] | i_buffer | buffer-id of the back-transformed snapshot |
[in] | lev | mesh-refinement level at which the output buffer MultiFab is defined |
Define the geometry object that spans the user-defined region for the ith snapshot, i_buffer, at level, lev.
[in] | i_buffer | id of the back-transformed snapshot |
[in] | lev | level at which the geometry object is defined |
|
overrideprivatevirtual |
Initialize Data required to compute back-transformed diagnostics
Reimplemented from Diagnostics.
|
overrideprivatevirtual |
whether to compute the back-transformed data and store buffer in this timestep The field-data is back-transformed from boosted-frame to lab-frame at every time step within the PIC loop. Back-transformation is not performed at initialization.
[in] | step | current time step, return true for any step >= 0 |
[in] | force_flush | if true, return true for any step |
Implements Diagnostics.
|
overrideprivatevirtual |
whether to write output files at this time step The data is flushed when the buffer is full and/or when the simulation ends or when forced.
[in] | step | current time step |
[in] | i_buffer | snapshot index |
[in] | force_flush | if true, return true for any step The return bool is used to determine when to write buffer data out |
Implements Diagnostics.
|
private |
Compute and return cell-size in z-dimension in the lab-frame at level, lev
[in] | dt | timestep in boosted-frame at level, lev |
[in] | ref_ratio | refinement ratio in the z-direction at level, lev-1. The ref-ratio in the z-direction for single-level diagnostics is 1. |
|
overrideprivatevirtual |
Flush m_mf_output and particles to file. Currently, a temporary customized output format for the buffer data is implemented and called in this function. After implementing OpenPMD and plotfile formats, this function can be defined and implemented in Diagnostics.H, such that, the function call to flush out buffer data for FullDiagnostics and BTDiagnostics is the same.
Implements Diagnostics.
whether the k-index corresponding to the z-slice for the ith buffer, i_buffer, is within the bounds of the box in index-space
[in] | i_buffer | index of the buffer for which the k-index is checked. |
[in] | lev | mesh-refinement level using which the k-index for the z-slice being filled in the ith buffer is computed Return true if the k-index of the z-slice is within the bounds of the box for the buffer being filled |
|
inlineoverrideprivate |
whether z-slice that corresponds to the buffer, i_buffer, is within the boosted-domain and lab-frame domains at level, lev.
[in] | i_buffer | index of the buffer for which the z-coordinates are checked Return true if the z co-ordinates stored in m_current_z_boost and m_current_z_lab for buffer, i_buffer, are within the bounds of the boosted-frame and lab-frame domain. |
[in] | lev | the mesh-refinement level |
|
inlineprivate |
Increment buffer counter by one when the buffer of a snapshot has been flushed.
[in] | i_buffer | snapshot index for which the counter is incremented. |
|
overrideprivatevirtual |
Initialize buffer domain, buffer box and lab-frame parameters such as m_t_lab, and z-positions for the i^th snapshot, i_buffer, and level, lev.
[in] | i_buffer | i^th snapshot or buffer |
[in] | lev | mesh-refinement level for which the field and/or particle buffer data is initialized. |
Implements Diagnostics.
|
overrideprivatevirtual |
Initialize functors that store pointers to the fields requested by the user. Additionally, the cell-center functors that stores pointers to all fields, namely, Ex, Ey, Ez, Bx, By, Bz, jx, jy, jz, and rho is also initialized.
[in] | lev | level on which the vector of unique_ptrs to field functors is initialized. |
Implements Diagnostics.
|
overrideprivate |
Initialize functors that store pointers to the fields in RZ requested by the user. Additionally, the cell-center functors that stores pointers to all fields, namely, Er, Et, Ez, Br, Bt, Bz, jr, jt, jz, and rho is also initialized.
[in] | lev | level on which the vector of unique_ptrs to field functors is initialized. |
|
overrideprivatevirtual |
This function allocates and initializes particle buffers for all the snapshots. This is currently an empty function: The particle containers required for this must be added to populate this function.
Implements Diagnostics.
|
overrideprivatevirtual |
Initialize particle functors for each species to compute the back-transformed lab-frame data.
Reimplemented from Diagnostics.
|
private |
Interleave lab-frame meta-data of the buffers to be consistent with the merged plotfile lab-frame data.
|
private |
Interleave meta-data of the buffer multifabs to be consistent with the merged plotfile lab-frame data.
|
private |
Interleave lab-frame metadata of the particle header file in the buffers to be consistent with the merged plotfile lab-frame data
|
private |
Interleave lab-frame metadata of the species header file in the buffers to be consistent with the merged plotfile lab-frame data
Compute k-index corresponding to current lab-frame z co-ordinate (m_current_z_lab) for the ith buffer i_buffer, and at level, lev.
[in] | i_buffer | snapshot index |
[in] | lev | mesh-refinement level at which the lab-frame z-index is computed |
|
private |
Merge the lab-frame buffer multifabs so it can be visualized as a single plotfile
|
inlineprivate |
Resets integer for first flush to 0 for the ith snapshot (i_buffer). This function is called after flush the first buffer after restarting the simulation
|
overrideprivatevirtual |
This function prepares the current z coordinate in the boosted-frame and lab-frame as required by the particle and fields.
Reimplemented from Diagnostics.
|
overrideprivatevirtual |
The cell-centered data for all fields, namely, Ex, Ey, Ez, Bx, By, Bz, jx, jy, jz, and rho is computed and stored in the multi-level cell-centered multifab, m_mf_cc. This MultiFab extends over the entire domain and is coarsened using the user-defined crse_ratio. For every lab-frame buffer, the data stored in this cell-centered MultiFab is sliced, back-transformed, and stored in the output multifab, m_mf_output.
Reimplemented from Diagnostics.
|
overrideprivatevirtual |
The Particle Geometry, BoxArray, and RealBox are set for the lab-frame output
Reimplemented from Diagnostics.
|
private |
Read relevant parameters for BTD
|
private |
Redistributes particles to the buffer box array in the lab-frame
|
inlineprivate |
Reset buffer counter to zero.
[in] | i_buffer | snapshot index for which the counter is set to zero. |
|
private |
Reset total number of particles in the particle buffer to 0 for ith snapshot
|
inlineoverrideprivate |
|
inlineoverrideprivate |
|
private |
Set Snapshot full status to 1 if the last valid zslice, m_lastValidZSlice, for the ith snapshot index, given by, i_buffer, is filled.
[in] | i_buffer | snapshot index |
|
inlineoverrideprivate |
|
overrideprivatevirtual |
This function increments the buffer counter and identifies if the snapshot is fully populated
Reimplemented from Diagnostics.
|
inlineprivate |
Compute and return z-position in the boosted-frame at the current timestep
[in] | t_lab | lab-frame time of the snapshot |
[in] | t_boost | boosted-frame time at level, lev |
|
inlineprivate |
Compute and return z-position in the lab-frame at the current timestep
[in] | t_lab | lab-frame time of the snapshot |
[in] | t_boost | boosted-frame time at level, lev |
|
private |
|
private |
|
private |
Vector of Box-dimension in boosted-frame index space corresponding to the buffer that covers a part of the full backtransformed snapshot
|
private |
Vector of counters tracking number of back-transformed z-slices filled in the output buffer multifab, m_mf_output, for each snapshot. When the buffer counter for a snapshot is equal to the maximum number of buffers (m_buffer_size), i.e., when the buffer is full, the data stored in the buffer multifab is flushed out and the counter is reset is zero.
|
private |
Vector of physical region corresponding to the buffer that spans a part of the full back-transformed snapshot
|
private |
Vector of counters tracking number of times the buffer of multifab is flushed out and emptied before being refilled again for each snapshot
|
private |
Vector of k-indices in the hi-end along the moving window direction for the buffer being filled for each snapshot.
|
private |
Number of z-slices in each buffer of the snapshot
|
private |
Vector of pointers to compute cell-centered data, per level, per component using the coarsening-ratio provided by the user.
|
private |
Multi-level cell-centered multifab with all field-data components, namely, Ex, Ey, Ez, Bx, By, Bz, jx, jy, jz, and rho. This cell-centered data extending over the entire domain will be used by all snapshots to obtain lab-frame data at the respective z slice location.
|
private |
Vector of field-data stored in the cell-centered multifab, m_cell_centered_data. All the fields are stored regardless of the specific fields to plot selected by the user.
|
private |
|
private |
Vector of boosted-frame z co-ordinate corresponding to each back-transformed snapshot at the current timestep
|
private |
Vector of lab-frame z co-ordinate of each back-transformed snapshot at the current timestep
|
private |
Whether to compute back-tranformed values for field-data. default value is true.
|
private |
Whether to compute back-tranformed values for particle-data default value is true.
|
private |
Time interval in lab-frame between the back-transformed snapshots
|
private |
Distance between the back-transformed snapshots in lab-frame m_dz_snapshots_lab = m_dt_snapshots_lab/c
|
private |
Vector of integers to indicate if the field buffer multifab, m_mf_output, is defined in DefineFieldBufferMultifab() function
|
private |
Vector of integers to indicate if is the first flush for a snapshot so that appropriate meta-data and geometry is written (0 if not, 1 if yes).
|
private |
m_gamma_boost, is a copy of WarpX::gamma_boost That is, the Lorentz factor of the boosted frame in which the simulation is run. The direction for Lorentz transformation is assumed to be along warpx.boost_direction
, which is the same as the moving window direction. Currently, back-transformed diagnostics only works if the boost-direction and moving window direction are along the z-direction in Cartesian co-ordinates.
|
private |
Geometry that defines the domain attributes corresponding to the full snapshot in the back-transformed lab-frame. Specifically, the user-defined physical co-ordinates for the diagnostics is used to construct the geometry information for each snapshot at the respective levels. This geometry will be used to integrate all the buffers that were dumped out with partial field data in the back-transformed frame at a particle snapshot, t_lab. WriteToFile() for BTD will include this additional geometry information to guide the integration process.
|
private |
Determines timesteps at which BTD diagnostics are written to file
|
private |
Vector of integers to store if the last valid slice in the lab-frame is being filled. When the value is 1, then the buffer is flushed, and m_snapshot_full is set to 1 for that snapshot index.
|
private |
Vector of maximum number of buffer multifabs that need to be flushed to generate each lab-frame snapshot. At the final flush, m_buffer_flush_counter will be equal to the predicted m_max_buffer_multifabs for each snapshot.
|
private |
m_moving_window_dir is a copy of WarpX::moving_window_dir Currently, back-transformed diagnostics only works if moving window is in z-direction for both 2D and 3D simulations in the Cartesian frame of reference.
Number of back-transformed snapshots in the lab-frame requested by the user
|
private |
Vector of previous boosted-frame z co-ordinate corresponding to each back-transformed snapshot
|
private |
Whether to plot raw (i.e., NOT cell-centered) fields
|
private |
Whether to plot guard cells of raw fields
|
private |
Vector of Box-dimension in boosted-frame index space for each back-transformed snapshot
|
private |
Vector of integers to indicate if the snapshot is full (0 not full, 1 for full). If the snapshot is full, then the snapshot files are closed.
|
private |
Vector of integers to indicate if the snapshot geometry is defined.
|
private |
Vector of number of cells in the lab-frame for each back-transformed snapshot
|
private |
Vector of lab-frame time corresponding to each snapshot