WarpX
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Diagnostics Class Referenceabstract

base class for diagnostics. Contains main routines to filter, compute and flush diagnostics. More...

#include <Diagnostics.H>

Inheritance diagram for Diagnostics:
BTDiagnostics FullDiagnostics

Public Member Functions

 Diagnostics (int i, std::string name)
 
virtual ~Diagnostics ()
 
void ComputeAndPack ()
 
virtual void Flush (int i_buffer)=0
 Flush particle and field buffers to file using the FlushFormat member variable. More...
 
void InitData ()
 
virtual void InitializeFieldFunctors (int lev)=0
 
virtual bool DoComputeAndPack (int step, bool force_flush=false)=0
 
virtual bool DoDump (int step, int i_buffer, bool force_flush=false)=0
 
void NewIteration ()
 
void FilterComputePackFlush (int step, bool force_flush=false)
 

Protected Member Functions

bool BaseReadParameters ()
 
void InitBaseData ()
 
virtual void InitializeFieldBufferData (int i_buffer, int lev)=0
 
virtual void DerivedInitData ()
 
virtual void InitializeParticleBuffer ()=0
 
virtual void PrepareFieldDataForOutput ()
 
virtual void MovingWindowAndGalileanDomainShift ()
 

Protected Attributes

std::string m_diag_name
 
std::string m_file_prefix
 
int m_diag_index
 
amrex::Vector< std::string > m_varnames
 
std::string m_format = "plotfile"
 
int m_already_done = false
 
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_species_names
 
amrex::Vector< ParticleDiagm_all_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
 

Detailed Description

base class for diagnostics. Contains main routines to filter, compute and flush diagnostics.

Each specific diagnostics derives from this class.

Constructor & Destructor Documentation

◆ Diagnostics()

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

◆ ~Diagnostics()

Diagnostics::~Diagnostics ( )
virtual

Virtual Destructor to handle clean destruction of derived classes

Member Function Documentation

◆ BaseReadParameters()

bool Diagnostics::BaseReadParameters ( )
protected

Read Parameters of the base Diagnostics class

◆ ComputeAndPack()

void Diagnostics::ComputeAndPack ( )

Pack (stack) all fields in the cell-centered output MultiFab m_mf_output.

Fields are computed (e.g., cell-centered or back-transformed) on-the-fly using a functor.

◆ DerivedInitData()

virtual void Diagnostics::DerivedInitData ( )
inlineprotectedvirtual

Initialize member variables and arrays specific to the diagnostics in the derived classes.(FullDiagnostics, BTDiagnostics)

Reimplemented in BTDiagnostics.

◆ DoComputeAndPack()

virtual bool Diagnostics::DoComputeAndPack ( int  step,
bool  force_flush = false 
)
pure virtual

whether to compute and pack data in output buffers at this time step

Parameters
[in]stepcurrent time step
[in]force_flushif true, return true for any step
Returns
bool, whether to compute and pack data

Implemented in BTDiagnostics, and FullDiagnostics.

◆ DoDump()

virtual bool Diagnostics::DoDump ( int  step,
int  i_buffer,
bool  force_flush = false 
)
pure virtual

whether to flush at this time step

Parameters
[in]stepcurrent time step
[in]force_flushif true, return true for any step
Returns
bool, whether to flush

Implemented in FullDiagnostics, and BTDiagnostics.

◆ FilterComputePackFlush()

void Diagnostics::FilterComputePackFlush ( int  step,
bool  force_flush = false 
)

Perform necessary operations with user-defined diagnostic parameters to filter (coarsen, slice), compute (cell-center, back-transform), and flush the output data stored in buffers, m_mf_output.

Parameters
[in]stepcurrent timestep
[in]force_flushused to force-fully write data stored in buffers.

◆ Flush()

virtual void Diagnostics::Flush ( int  i_buffer)
pure virtual

Flush particle and field buffers to file using the FlushFormat member variable.

This function should belong to class Diagnostics and not be virtual, as it flushes the particle buffers (name not found yet) and the field buffers (m_mf_output), both of which are members of Diagnostics. Yet, the implementation is left to derived classes for now because:

Implemented in FullDiagnostics, and BTDiagnostics.

◆ InitBaseData()

void Diagnostics::InitBaseData ( )
protected

Initialize member variables of the base Diagnostics class.

◆ InitData()

void Diagnostics::InitData ( )

Initialize pointers to main fields and allocate output multifab m_mf_output.

◆ InitializeFieldBufferData()

virtual void Diagnostics::InitializeFieldBufferData ( int  i_buffer,
int  lev 
)
protectedpure virtual

Initialize m_mf_output vectors and data required to construct the buffers

Parameters
[in]i_bufferindex of buffer for which the output MultiFab is defined.
[in]levlevel on which the output MultiFab is defined

Implemented in BTDiagnostics, and FullDiagnostics.

◆ InitializeFieldFunctors()

virtual void Diagnostics::InitializeFieldFunctors ( int  lev)
pure virtual

Initialize functors that store pointers to the fields requested by the user.

Derived classes MUST implement this function, and it must allocate m_all_field_functors and fill it with ComputeDiagFunctor objects. The functions is called at intiailization and when the domain is decomposed during the simulation to load-balance.

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

Implemented in FullDiagnostics, and BTDiagnostics.

◆ InitializeParticleBuffer()

virtual void Diagnostics::InitializeParticleBuffer ( )
protectedpure virtual

This function initialized particle buffers (not implemented in diagnostics, yet)

Implemented in FullDiagnostics, and BTDiagnostics.

◆ MovingWindowAndGalileanDomainShift()

virtual void Diagnostics::MovingWindowAndGalileanDomainShift ( )
inlineprotectedvirtual

Shift the diag-domain boundary for moving window and galilean simulations

Reimplemented in FullDiagnostics.

◆ NewIteration()

void Diagnostics::NewIteration ( )
inline

Start a new iteration, i.e., dump has not been done yet.

◆ PrepareFieldDataForOutput()

virtual void Diagnostics::PrepareFieldDataForOutput ( )
inlineprotectedvirtual

Prepare data (either fill-boundary or cell-centered data for back-transform diagnostics) to be processed for diagnostics.

Reimplemented in FullDiagnostics, and BTDiagnostics.

Member Data Documentation

◆ m_all_field_functors

amrex::Vector< amrex::Vector <std::unique_ptr<ComputeDiagFunctor > > > Diagnostics::m_all_field_functors
protected

Vector of (pointers to) functors to compute output fields, per level, per component. This allows for simple operations (averaging to cell-center for standard EB fields) as well as more involved operations (back-transformed diagnostics, filtering, reconstructing cartesian fields in cylindrical).

◆ m_all_species

amrex::Vector< ParticleDiag > Diagnostics::m_all_species
protected

Each element of this vector handles output for 1 species

◆ m_already_done

int Diagnostics::m_already_done = false
protected

Whether this iteration has already been dumped, to avoid writing data twice

◆ m_crse_ratio

amrex::IntVect Diagnostics::m_crse_ratio = amrex::IntVect(1)
protected

Coarsening ratio such that, fields are averaged to the coarsened grid. The ratio should render the grid to be coarsenable (as defined by AMReX).

◆ m_diag_index

int Diagnostics::m_diag_index
protected

Index of diagnostics in MultiDiagnostics::alldiags

◆ m_diag_name

std::string Diagnostics::m_diag_name
protected

Name of diagnostics: runtime parameter given in the input file.

◆ m_file_prefix

std::string Diagnostics::m_file_prefix
protected

Prefix for output directories

◆ m_flush_format

FlushFormat* Diagnostics::m_flush_format
protected

This class is responsible for flushing the data to file

◆ m_format

std::string Diagnostics::m_format = "plotfile"
protected

format for output files, "plotfile" or "openpmd" or "sensei" or "ascent" The checkpoint format is applicable for FullDiagnostics only.

◆ m_geom_output

amrex::Vector< amrex::Vector <amrex::Geometry> > Diagnostics::m_geom_output
protected

Geometry that defines the domain attributes corresponding to output multifab. Specifically, the user-defined physical co-ordinates for the diagnostics is used to construct the geometry information for each MultiFab at the respective levels. This geometry will be used to write out plotfile data using the WriteToFile() function

◆ m_hi

amrex::Vector< amrex::Real> Diagnostics::m_hi
protected

Higher corner of the diagnostics output, in physical coordinates

◆ m_lo

amrex::Vector< amrex::Real> Diagnostics::m_lo
protected

Lower corner of the diagnostics output, in physical coordinates

◆ m_mf_output

amrex::Vector< amrex::Vector< amrex::MultiFab > > Diagnostics::m_mf_output
protected

output multifab, where all fields are computed (cell-centered or back-transformed) and stacked. The first vector is for total number of snapshots. (=1 for FullDiagnostics) The second vector is loops over the total number of levels.

◆ m_num_buffers

int Diagnostics::m_num_buffers
protected

Number of output buffers. The value is set to 1 for all FullDiagnostics

◆ m_rho_per_species_index

amrex::Vector<int> Diagnostics::m_rho_per_species_index
protected

Array of species indices that dump rho per species

◆ m_species_names

std::vector< std::string > Diagnostics::m_species_names
protected

Name of species to write to file

◆ m_varnames

amrex::Vector< std::string > Diagnostics::m_varnames
protected

Names of each component requested by the user. in cylindrical geometry, this list is appended with automatically-constructed names for all modes of all fields

◆ nlev

int Diagnostics::nlev
protected

number of levels to output

◆ nlev_output

int Diagnostics::nlev_output
protected

Number of levels to be output

◆ nmax_lev

int Diagnostics::nmax_lev
protected

max_level to allocate output multifab and vector of field functors.


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