WarpX
BTDiagnostics.H
Go to the documentation of this file.
1 /* Copyright 2021 Revathi Jambunathan
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 #ifndef WARPX_BTDIAGNOSTICS_H_
8 #define WARPX_BTDIAGNOSTICS_H_
9 
10 #include "Diagnostics.H"
12 #include "Utils/WarpXConst.H"
14 
15 #include <AMReX_Box.H>
16 #include <AMReX_Geometry.H>
17 #include <AMReX_IntVect.H>
18 #include <AMReX_MultiFab.H>
19 #include <AMReX_REAL.H>
20 #include <AMReX_RealBox.H>
21 #include <AMReX_Vector.H>
22 
23 #include <limits>
24 #include <memory>
25 #include <string>
26 
27 class
28 BTDiagnostics final : public Diagnostics
29 {
30 public:
31 
32  BTDiagnostics (int i, std::string name);
33 
34 private:
36  bool m_plot_raw_fields = false;
38  bool m_plot_raw_fields_guards = false;
40  void ReadParameters ();
50  void Flush (int i_buffer) override;
59  bool DoDump (int step, int i_buffer, bool force_flush=false) override;
67  bool DoComputeAndPack (int step, bool force_flush=false) override;
69  void DerivedInitData () override;
76  void InitializeFieldFunctors (int lev) override;
83  void InitializeFieldFunctorsRZopenPMD (int lev) override;
95  void AddRZModesToOutputNames (const std::string& field, const int ncomp, bool cellcenter_data);
100  void InitializeParticleBuffer () override;
104  void PrepareBufferData () override;
106  void UpdateBufferData () override;
114  void PrepareFieldDataForOutput () override;
116  void PrepareParticleDataForOutput() override;
117 
126  bool GetZSliceInDomainFlag (const int i_buffer, const int lev);
127 
133  void InitializeBufferData ( int i_buffer , int lev) override;
137  bool m_do_back_transformed_fields = true;
141  bool m_do_back_transformed_particles = true;
142 
150  amrex::Real m_gamma_boost;
151  amrex::Real m_beta_boost;
157 
159  int m_num_snapshots_lab = std::numeric_limits<int>::lowest();
161  amrex::Real m_dt_snapshots_lab = std::numeric_limits<amrex::Real>::lowest();
165  amrex::Real m_dz_snapshots_lab = 0.0;
166 
168  int m_buffer_size = 256;
170  int m_max_box_size = 256;
171 
249  void DefineCellCenteredMultiFab(int lev);
256  void DefineFieldBufferMultiFab (const int i_buffer, const int lev);
257 
264  void DefineSnapshotGeometry (const int i_buffer, const int lev);
265 
270  amrex::Real UpdateCurrentZBoostCoordinate(amrex::Real t_lab, amrex::Real t_boost)
271  {
272  amrex::Real current_z_boost = (t_lab / m_gamma_boost - t_boost) * PhysConst::c / m_beta_boost;
273  return current_z_boost;
274  }
279  amrex::Real UpdateCurrentZLabCoordinate(amrex::Real t_lab, amrex::Real t_boost)
280  {
281  amrex::Real current_z_lab = (t_lab - t_boost / m_gamma_boost ) * PhysConst::c / m_beta_boost;
282  return current_z_lab;
283  }
289  amrex::Real dz_lab (amrex::Real dt, amrex::Real ref_ratio);
295  int k_index_zlab (int i_buffer, int lev);
301  bool buffer_full (int i_buffer) {
302  return (k_index_zlab(i_buffer,0) == m_buffer_box[i_buffer].smallEnd(m_moving_window_dir));
303  }
304 
309  bool buffer_empty (int i_buffer) {
310  return ( m_buffer_counter[i_buffer] == 0) ;
311  }
312 
316  void ResetBufferCounter(int i_buffer) {
317  m_buffer_counter[i_buffer] = 0;
318  }
322  void IncrementBufferFlushCounter(int i_buffer) {
323  m_buffer_flush_counter[i_buffer]++;
324  }
330  void SetSnapshotFullStatus (const int i_buffer);
335 #ifdef WARPX_DIM_RZ
336  amrex::Vector< std::string > m_cellcenter_varnames = {"Er", "Et", "Ez",
337  "Br", "Bt", "Bz",
338  "jr", "jt", "jz", "rho"};
339  amrex::Vector< std::string > m_cellcenter_varnames_fields = {"Er", "Et", "Ez",
340  "Br", "Bt", "Bz",
341  "jr", "jt", "jz",
342  "rho"};
343 #else
344  amrex::Vector< std::string > m_cellcenter_varnames = {"Ex", "Ey", "Ez",
345  "Bx", "By", "Bz",
346  "jx", "jy", "jz", "rho"};
347 #endif
348 
349 
353  void MergeBuffersForPlotfile (int i_snapshot);
357  void InterleaveBufferAndSnapshotHeader ( std::string buffer_Header,
358  std::string snapshot_Header);
362  void InterleaveFabArrayHeader( std::string Buffer_FabHeaderFilename,
363  std::string snapshot_FabHeaderFilename,
364  std::string newsnapshot_FabFilename);
368  void InterleaveSpeciesHeader(std::string buffer_species_Header_path,
369  std::string snapshot_species_Header_path,
370  std::string species_name, const int new_data_index);
371 
375  void InterleaveParticleDataHeader( std::string buffer_ParticleHdrFilename,
376  std::string snapshot_ParticleHdrFilename);
379  void InitializeParticleFunctors () override;
380 
382  void UpdateTotalParticlesFlushed(int i_buffer);
384  void ResetTotalParticlesInBuffer(int i_buffer);
386  void ClearParticleBuffer(int i_buffer);
388  void RedistributeParticleBuffer (const int i_buffer);
389  void UpdateVarnamesForRZopenPMD();
390 
391 };
392 #endif // WARPX_BTDIAGNOSTICS_H_
amrex::Vector< int > m_lastValidZSlice
Definition: BTDiagnostics.H:228
void ResetBufferCounter(int i_buffer)
Definition: BTDiagnostics.H:316
utils::parser::BTDIntervalsParser m_intervals
Definition: BTDiagnostics.H:42
amrex::Vector< amrex::Vector< amrex::Geometry > > m_geom_snapshot
Definition: BTDiagnostics.H:207
static constexpr auto c
vacuum speed of light [m/s]
Definition: constant.H:44
This class is a parser for multiple slices of the form x,y,z,... where x, y and z are slices of the f...
Definition: IntervalsParser.H:175
amrex::Vector< amrex::RealBox > m_snapshot_domain_lab
Definition: BTDiagnostics.H:176
void IncrementBufferFlushCounter(int i_buffer)
Definition: BTDiagnostics.H:322
int dt
Definition: Stencil.py:468
amrex::Vector< amrex::Box > m_snapshot_box
Definition: BTDiagnostics.H:184
amrex::Vector< int > m_buffer_counter
Definition: BTDiagnostics.H:214
int m_moving_window_dir
Definition: BTDiagnostics.H:156
amrex::Vector< amrex::Real > m_current_z_boost
Definition: BTDiagnostics.H:193
amrex::Vector< amrex::Real > m_t_lab
Definition: BTDiagnostics.H:173
amrex::Vector< amrex::RealBox > m_buffer_domain_lab
Definition: BTDiagnostics.H:179
amrex::Vector< int > m_snapshot_full
Definition: BTDiagnostics.H:223
amrex::Vector< amrex::IntVect > m_snapshot_ncells_lab
Definition: BTDiagnostics.H:181
amrex::Real UpdateCurrentZBoostCoordinate(amrex::Real t_lab, amrex::Real t_boost)
Definition: BTDiagnostics.H:270
amrex::Vector< amrex::Real > m_current_z_lab
Definition: BTDiagnostics.H:190
amrex::Vector< int > m_buffer_flush_counter
Definition: BTDiagnostics.H:231
i
Definition: check_interp_points_and_weights.py:173
amrex::Vector< amrex::Vector< std::unique_ptr< ComputeDiagFunctor const > > > m_cell_center_functors
Definition: BTDiagnostics.H:243
amrex::Vector< int > m_buffer_k_index_hi
Definition: BTDiagnostics.H:232
amrex::Real m_gamma_boost
Definition: BTDiagnostics.H:150
string name
Definition: Stencil.py:485
amrex::Vector< amrex::Real > m_old_z_boost
Definition: BTDiagnostics.H:196
amrex::Vector< int > m_max_buffer_multifabs
Definition: BTDiagnostics.H:219
amrex::Vector< amrex::Box > m_buffer_box
Definition: BTDiagnostics.H:187
string field
Definition: video_yt.py:31
bool buffer_full(int i_buffer)
Definition: BTDiagnostics.H:301
amrex::Real UpdateCurrentZLabCoordinate(amrex::Real t_lab, amrex::Real t_boost)
Definition: BTDiagnostics.H:279
bool buffer_empty(int i_buffer)
Definition: BTDiagnostics.H:309
amrex::Vector< std::unique_ptr< amrex::MultiFab > > m_cell_centered_data
Definition: BTDiagnostics.H:239
Definition: BTDiagnostics.H:27
amrex::Real m_beta_boost
Definition: BTDiagnostics.H:151
base class for diagnostics. Contains main routines to filter, compute and flush diagnostics.
Definition: Diagnostics.H:30