WarpX
Public Member Functions | Private Member Functions | Private Attributes | List of all members
BTDiagnostics Class Referencefinal

#include <BTDiagnostics.H>

Inheritance diagram for BTDiagnostics:
Diagnostics

Public Member Functions

 BTDiagnostics (int i, std::string name)
 
- Public Member Functions inherited from Diagnostics
 Diagnostics (int i, std::string name)
 
virtual ~Diagnostics ()
 
void ComputeAndPack ()
 
void InitData ()
 
void NewIteration ()
 
void FilterComputePackFlush (int step, bool force_flush=false)
 
bool DoDumpLastTimestep () const
 

Private Member Functions

void ReadParameters ()
 
void Flush (int i_buffer) 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 InitializeParticleBuffer () override
 
void PrepareFieldDataForOutput () override
 
bool GetZSliceInDomainFlag (const int i_buffer, const int lev)
 
void InitializeFieldBufferData (int i_buffer, int lev) override
 
void DefineCellCenteredMultiFab (int lev)
 
void DefineFieldBufferMultiFab (const int i_buffer, const int lev)
 
void DefineSnapshotGeometry (const int i_buffer, const int lev)
 
amrex::Real UpdateCurrentZBoostCoordinate (amrex::Real t_lab, amrex::Real t_boost)
 
amrex::Real UpdateCurrentZLabCoordinate (amrex::Real t_lab, amrex::Real t_boost)
 
amrex::Real dz_lab (amrex::Real dt, amrex::Real ref_ratio)
 
int k_index_zlab (int i_buffer, int lev)
 
bool buffer_full (int i_buffer)
 
bool buffer_empty (int i_buffer)
 
void ResetBufferCounter (int i_buffer)
 
void IncrementBufferFlushCounter (int i_buffer)
 
void TMP_ClearSpeciesDataForBTD () override
 
void MergeBuffersForPlotfile (int i_snapshot)
 
void InterleaveBufferAndSnapshotHeader (std::string buffer_Header, std::string snapshot_Header)
 
void InterleaveFabArrayHeader (std::string Buffer_FabHeaderFilename, std::string snapshot_FabHeaderFilename, std::string newsnapshot_FabFilename)
 

Private Attributes

bool m_plot_raw_fields = false
 
bool m_plot_raw_fields_guards = false
 
bool m_plot_raw_rho = false
 
bool m_plot_raw_F = false
 
bool m_do_back_transformed_fields = true
 
bool m_do_back_transformed_particles = true
 
amrex::Real m_gamma_boost
 
amrex::Real m_beta_boost
 
int m_moving_window_dir
 
int m_num_snapshots_lab = std::numeric_limits<int>::lowest()
 
amrex::Real m_dt_snapshots_lab = std::numeric_limits<amrex::Real>::lowest()
 
amrex::Real m_dz_snapshots_lab = 0.0
 
int m_buffer_size = 256
 
int m_max_box_size = 256
 
amrex::Vector< amrex::Real > m_t_lab
 
amrex::Vector< amrex::RealBox > m_prob_domain_lab
 
amrex::Vector< amrex::RealBox > m_snapshot_domain_lab
 
amrex::Vector< amrex::RealBox > m_buffer_domain_lab
 
amrex::Vector< amrex::IntVect > m_snapshot_ncells_lab
 
amrex::Vector< amrex::Box > m_snapshot_box
 
amrex::Vector< amrex::Box > m_buffer_box
 
amrex::Vector< amrex::Real > m_current_z_lab
 
amrex::Vector< amrex::Real > m_current_z_boost
 
amrex::Vector< amrex::Vector< amrex::Geometry > > m_geom_snapshot
 
amrex::Vector< int > m_buffer_counter
 
amrex::Vector< int > m_max_buffer_multifabs
 
amrex::Vector< int > m_buffer_flush_counter
 
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_cell_centered_data
 
amrex::Vector< amrex::Vector< std::unique_ptr< ComputeDiagFunctor const > > > m_cell_center_functors
 
amrex::Vector< std::string > m_cellcenter_varnames
 

Additional Inherited Members

- Protected Member Functions inherited from Diagnostics
bool BaseReadParameters ()
 
void InitBaseData ()
 
virtual void MovingWindowAndGalileanDomainShift (int)
 
- Protected Attributes inherited from Diagnostics
std::string m_diag_name
 
std::string m_file_prefix
 
int m_file_min_digits = 5
 
int m_diag_index
 
amrex::Vector< std::string > m_varnames
 
bool m_dump_last_timestep = true
 
std::string m_format = "plotfile"
 
int m_already_done = false
 
std::unique_ptr< FlushFormatm_flush_format
 
amrex::Vector< amrex::Vector< amrex::MultiFab > > m_mf_output
 
amrex::Vector< amrex::Vector< amrex::Geometry > > m_geom_output
 
int nlev
 
int nmax_lev
 
int nlev_output
 
std::vector< std::string > m_output_species_names
 
std::vector< std::string > m_all_species_names
 
amrex::Vector< ParticleDiagm_output_species
 
amrex::Vector< amrex::Vector< std::unique_ptr< ComputeDiagFunctor > > > m_all_field_functors
 
amrex::IntVect m_crse_ratio = amrex::IntVect(1)
 
amrex::Vector< amrex::Real > m_lo
 
amrex::Vector< amrex::Real > m_hi
 
int m_num_buffers
 
amrex::Vector< int > m_rho_per_species_index
 

Constructor & Destructor Documentation

◆ BTDiagnostics()

BTDiagnostics::BTDiagnostics ( int  i,
std::string  name 
)

Member Function Documentation

◆ buffer_empty()

bool BTDiagnostics::buffer_empty ( int  i_buffer)
inlineprivate

whether field buffer is empty.

Parameters
[in]i_bufferbuffer id for which the buffer size is checked. returns bool = true is buffer is empty i.e., when buffer counter is zero.

◆ buffer_full()

bool BTDiagnostics::buffer_full ( int  i_buffer)
inlineprivate

whether field buffer is full

Parameters
[in]i_bufferbuffer 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

◆ DefineCellCenteredMultiFab()

void BTDiagnostics::DefineCellCenteredMultiFab ( int  lev)
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)

Parameters
[in]levlevel at which the cell-centered MultiFab is defined.

◆ DefineFieldBufferMultiFab()

void BTDiagnostics::DefineFieldBufferMultiFab ( const int  i_buffer,
const int  lev 
)
private

Define the cell-centered multi-component output buffer MultiFab for snapshot, i_buffer, at level, lev

Parameters
[in]i_bufferbuffer-id of the back-transformed snapshot
[in]lev,levelat which the output buffer MultiFab is defined

◆ DefineSnapshotGeometry()

void BTDiagnostics::DefineSnapshotGeometry ( const int  i_buffer,
const int  lev 
)
private

Define the geometry object that spans the user-defined region for the ith snapshot, i_buffer, at level, lev.

Parameters
[in]i_bufferid of the back-transformed snapshot
[in]lev,levelat which the geometry object is defined

◆ DerivedInitData()

void BTDiagnostics::DerivedInitData ( )
overrideprivatevirtual

Initialize Data required to compute back-transformed diagnostics

Reimplemented from Diagnostics.

◆ DoComputeAndPack()

bool BTDiagnostics::DoComputeAndPack ( int  step,
bool  force_flush = false 
)
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.

Parameters
[in]stepcurrent time step, return true for any step >= 0
[in]force_flushif true, return true for any step

Implements Diagnostics.

◆ DoDump()

bool BTDiagnostics::DoDump ( int  step,
int  i_buffer,
bool  force_flush = false 
)
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.

Parameters
[in]stepcurrent time step
[in]force_flushif true, return true for any step The return bool is used to determine when to write buffer data out

Implements Diagnostics.

◆ dz_lab()

amrex::Real BTDiagnostics::dz_lab ( amrex::Real  dt,
amrex::Real  ref_ratio 
)
private

Compute and return cell-size in z-dimension in the lab-frame at level, lev

Parameters
[in]dt,timestepin boosted-frame at level, lev
[in]ref_ratio,refinementratio in the z-direction at level, lev-1. The ref-ratio in the z-direction for single-level diagnostics is 1.

◆ Flush()

void BTDiagnostics::Flush ( int  i_buffer)
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.

◆ GetZSliceInDomainFlag()

bool BTDiagnostics::GetZSliceInDomainFlag ( const int  i_buffer,
const int  lev 
)
private

whether z-slice that corresponds to the buffer, i_buffer, is within the boosted-domain and lab-frame domains at level, lev.

Parameters
[in]i_bufferindex 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.

◆ IncrementBufferFlushCounter()

void BTDiagnostics::IncrementBufferFlushCounter ( int  i_buffer)
inlineprivate

Increment buffer counter by one when the buffer of a snapshot has been flushed.

Parameters
[in]i_buffer,ithbuffer for which the counter is incremented.

◆ InitializeFieldBufferData()

void BTDiagnostics::InitializeFieldBufferData ( int  i_buffer,
int  lev 
)
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.

Parameters
[in]i_bufferi^th snapshot or buffer
[in]levlevel for which the field buffer data is initialized.

Implements Diagnostics.

◆ InitializeFieldFunctors()

void BTDiagnostics::InitializeFieldFunctors ( int  lev)
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.

Parameters
[in]levlevel on which the vector of unique_ptrs to field functors is initialized.

Implements Diagnostics.

◆ InitializeParticleBuffer()

void BTDiagnostics::InitializeParticleBuffer ( )
inlineoverrideprivatevirtual

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.

◆ InterleaveBufferAndSnapshotHeader()

void BTDiagnostics::InterleaveBufferAndSnapshotHeader ( std::string  buffer_Header,
std::string  snapshot_Header 
)
private

Interleave lab-frame meta-data of the buffers to be consistent with the merged plotfile lab-frame data.

◆ InterleaveFabArrayHeader()

void BTDiagnostics::InterleaveFabArrayHeader ( std::string  Buffer_FabHeaderFilename,
std::string  snapshot_FabHeaderFilename,
std::string  newsnapshot_FabFilename 
)
private

Interleave meta-data of the buffer multifabs to be consistent with the merged plotfile lab-frame data.

◆ k_index_zlab()

int BTDiagnostics::k_index_zlab ( int  i_buffer,
int  lev 
)
private

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.

Parameters
[in]i_buffer,ithbuffer
[in]lev,levelat which the lab-frame z-index is computed

◆ MergeBuffersForPlotfile()

void BTDiagnostics::MergeBuffersForPlotfile ( int  i_snapshot)
private

Merge the lab-frame buffer multifabs so it can be visualized as a single plotfile

◆ PrepareFieldDataForOutput()

void BTDiagnostics::PrepareFieldDataForOutput ( )
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.

◆ ReadParameters()

void BTDiagnostics::ReadParameters ( )
private

Read relevant parameters for BTD

◆ ResetBufferCounter()

void BTDiagnostics::ResetBufferCounter ( int  i_buffer)
inlineprivate

Reset buffer counter to zero.

Parameters
[in]i_buffer,ithbuffer for which the counter is set to zero.

◆ TMP_ClearSpeciesDataForBTD()

void BTDiagnostics::TMP_ClearSpeciesDataForBTD ( )
overrideprivatevirtual

Temporarily clear species output for BTD until particle buffer is added

Reimplemented from Diagnostics.

◆ UpdateCurrentZBoostCoordinate()

amrex::Real BTDiagnostics::UpdateCurrentZBoostCoordinate ( amrex::Real  t_lab,
amrex::Real  t_boost 
)
inlineprivate

Compute and return z-position in the boosted-frame at the current timestep

Parameters
[in]t_lab,lab-frametime of the snapshot
[in]t_boost,boosted-frametime at level, lev

◆ UpdateCurrentZLabCoordinate()

amrex::Real BTDiagnostics::UpdateCurrentZLabCoordinate ( amrex::Real  t_lab,
amrex::Real  t_boost 
)
inlineprivate

Compute and return z-position in the lab-frame at the current timestep

Parameters
[in]t_lab,lab-frametime of the snapshot
[in]t_boost,boosted-frametime at level, lev

Member Data Documentation

◆ m_beta_boost

amrex::Real BTDiagnostics::m_beta_boost
private

◆ m_buffer_box

amrex::Vector<amrex::Box> BTDiagnostics::m_buffer_box
private

Vector of Box-dimension in boosted-frame index space corresponding to the buffer that covers a part of the full backtransformed snapshot

◆ m_buffer_counter

amrex::Vector<int> BTDiagnostics::m_buffer_counter
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.

◆ m_buffer_domain_lab

amrex::Vector<amrex::RealBox> BTDiagnostics::m_buffer_domain_lab
private

Vector of physical region corresponding to the buffer that spans a part of the full back-transformed snapshot

◆ m_buffer_flush_counter

amrex::Vector<int> BTDiagnostics::m_buffer_flush_counter
private

Vector of counters tracking number of times the buffer of multifab is flushed out and emptied before being refilled again for each snapshot

◆ m_buffer_size

int BTDiagnostics::m_buffer_size = 256
private

Number of z-slices in each buffer of the snapshot

◆ m_cell_center_functors

amrex::Vector< amrex::Vector <std::unique_ptr<ComputeDiagFunctor const> > > BTDiagnostics::m_cell_center_functors
private

Vector of pointers to compute cell-centered data, per level, per component using the coarsening-ratio provided by the user.

◆ m_cell_centered_data

amrex::Vector<std::unique_ptr<amrex::MultiFab> > BTDiagnostics::m_cell_centered_data
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.

◆ m_cellcenter_varnames

amrex::Vector< std::string > BTDiagnostics::m_cellcenter_varnames
private
Initial value:
= {"Ex", "Ey", "Ez",
"Bx", "By", "Bz",
"jx", "jy", "jz", "rho"}

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.

◆ m_current_z_boost

amrex::Vector<amrex::Real> BTDiagnostics::m_current_z_boost
private

Vector of boosted-frame z co-ordinate corresponding to each back-transformed snapshot at the current timestep

◆ m_current_z_lab

amrex::Vector<amrex::Real> BTDiagnostics::m_current_z_lab
private

Vector of lab-frame z co-ordinate of each back-transformed snapshot at the current timestep

◆ m_do_back_transformed_fields

bool BTDiagnostics::m_do_back_transformed_fields = true
private

Whether to compute back-tranformed values for field-data. default value is true.

◆ m_do_back_transformed_particles

bool BTDiagnostics::m_do_back_transformed_particles = true
private

Whether to compute back-tranformed values for particle-data default value is true.

◆ m_dt_snapshots_lab

amrex::Real BTDiagnostics::m_dt_snapshots_lab = std::numeric_limits<amrex::Real>::lowest()
private

Time interval in lab-frame between the back-transformed snapshots

◆ m_dz_snapshots_lab

amrex::Real BTDiagnostics::m_dz_snapshots_lab = 0.0
private

Distance between the back-transformed snapshots in lab-frame m_dz_snapshots_lab = m_dt_snapshots_lab/c

◆ m_gamma_boost

amrex::Real BTDiagnostics::m_gamma_boost
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.

◆ m_geom_snapshot

amrex::Vector< amrex::Vector <amrex::Geometry> > BTDiagnostics::m_geom_snapshot
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.

◆ m_max_box_size

int BTDiagnostics::m_max_box_size = 256
private

max grid size used to generate BoxArray to define output MultiFabs

◆ m_max_buffer_multifabs

amrex::Vector<int> BTDiagnostics::m_max_buffer_multifabs
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.

◆ m_moving_window_dir

int BTDiagnostics::m_moving_window_dir
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.

◆ m_num_snapshots_lab

int BTDiagnostics::m_num_snapshots_lab = std::numeric_limits<int>::lowest()
private

Number of back-transformed snapshots in the lab-frame requested by the user

◆ m_plot_raw_F

bool BTDiagnostics::m_plot_raw_F = false
private

Whether to plot F (charge conservation error) in raw fields

◆ m_plot_raw_fields

bool BTDiagnostics::m_plot_raw_fields = false
private

Whether to plot raw (i.e., NOT cell-centered) fields

◆ m_plot_raw_fields_guards

bool BTDiagnostics::m_plot_raw_fields_guards = false
private

Whether to plot guard cells of raw fields

◆ m_plot_raw_rho

bool BTDiagnostics::m_plot_raw_rho = false
private

Whether to plot charge density rho in raw fields

◆ m_prob_domain_lab

amrex::Vector<amrex::RealBox> BTDiagnostics::m_prob_domain_lab
private

Vector of lab-frame physical domain corresponding to the boosted-frame simulation domain at lab-frame time corresponding to each snapshot

◆ m_snapshot_box

amrex::Vector<amrex::Box> BTDiagnostics::m_snapshot_box
private

Vector of Box-dimension in boosted-frame index space for each back-transformed snapshot

◆ m_snapshot_domain_lab

amrex::Vector<amrex::RealBox> BTDiagnostics::m_snapshot_domain_lab
private

Vector of user-defined physical region for diagnostics in lab-frame for each back-transformed snapshot

◆ m_snapshot_ncells_lab

amrex::Vector<amrex::IntVect> BTDiagnostics::m_snapshot_ncells_lab
private

Vector of number of cells in the lab-frame for each back-transformed snapshot

◆ m_t_lab

amrex::Vector<amrex::Real> BTDiagnostics::m_t_lab
private

Vector of lab-frame time corresponding to each snapshot


The documentation for this class was generated from the following files: