Hipace
Diagnostic.H
Go to the documentation of this file.
1 /* Copyright 2021-2022
2  *
3  * This file is part of HiPACE++.
4  *
5  * Authors: AlexanderSinn, MaxThevenet, Severin Diederichs
6  * License: BSD-3-Clause-LBNL
7  */
8 #ifndef DIAGNOSTIC_H_
9 #define DIAGNOSTIC_H_
10 
11 #include "utils/IOUtil.H"
12 
13 #include <AMReX_MultiFab.H>
14 #include <AMReX_Vector.H>
15 
16 #include <vector>
17 
18 
21 {
22  std::string m_diag_name;
23  int m_level = 0;
25  bool m_include_ghost_cells = false;
26  bool m_use_custom_size_lo = false;
27  bool m_use_custom_size_hi = false;
29  amrex::RealVect m_diag_lo {0., 0., 0.};
31  amrex::RealVect m_diag_hi {0., 0., 0.};
33  bool m_do_laser {false};
34  int m_nfields;
44  bool m_has_field;
47  int m_output_period = 0;
49  std::string m_laser_io_name = "laserEnvelope";
50 };
51 
52 
55 {
56 
57 public:
58 
60  explicit Diagnostic (int nlev);
61 
63  void Initialize (const int lev, bool do_laser);
64 
67 
70 
79  static bool hasFieldOutput (const FieldDiagnosticData& fd,
80  int output_step, int max_step,
81  amrex::Real output_time, amrex::Real max_time)
82  {
83  return (fd.m_nfields > 0 || fd.m_do_laser) &&
84  utils::doDiagnostics(fd.m_output_period, output_step, max_step,
85  output_time, max_time);
86  }
87 
95  bool hasAnyFieldOutput (int output_step, int max_step,
96  amrex::Real output_time, amrex::Real max_time) const
97  {
98  for (const auto& fd : m_field_data) {
99  if (hasFieldOutput(fd, output_step, max_step, output_time, max_time)) return true;
100  }
101  return false;
102  }
103 
111  bool hasBeamOutput (int output_step, int max_step,
112  amrex::Real output_time, amrex::Real max_time) const
113  {
114  return m_output_beam_names.size() > 0 &&
115  utils::doDiagnostics(m_beam_output_period, output_step, max_step,
116  output_time, max_time);
117  }
118 
126  bool hasAnyOutput (int output_step, int max_step,
127  amrex::Real output_time, amrex::Real max_time) const
128  {
129  return hasAnyFieldOutput(output_step, max_step, output_time, max_time) ||
130  hasBeamOutput(output_step, max_step, output_time, max_time);
131  }
132 
135  bool needsRho () const;
136 
139  bool needsRhoIndividual () const;
140 
147  void TrimIOBox (int slice_dir, amrex::Box& domain_3d, amrex::RealBox& rbox_3d);
148 
159  void ResizeFDiagFAB (const amrex::Box a_domain, const int lev,
160  amrex::Geometry const& geom, int output_step, int max_step,
161  amrex::Real output_time, amrex::Real max_time);
162 
163 private:
169  bool m_initialized = false;
170 };
171 
172 #endif // DIAGNOSTIC_H_
This class holds data for all diagnostics.
Definition: Diagnostic.H:55
static bool hasFieldOutput(const FieldDiagnosticData &fd, int output_step, int max_step, amrex::Real output_time, amrex::Real max_time)
determines if a single field diagnostic has any output on in this time step
Definition: Diagnostic.H:79
int m_beam_output_period
Definition: Diagnostic.H:167
void TrimIOBox(int slice_dir, amrex::Box &domain_3d, amrex::RealBox &rbox_3d)
calculate box which possibly was trimmed in case of slice IO
Definition: Diagnostic.cpp:295
Diagnostic(int nlev)
Constructor.
Definition: Diagnostic.cpp:13
void ResizeFDiagFAB(const amrex::Box a_domain, const int lev, amrex::Geometry const &geom, int output_step, int max_step, amrex::Real output_time, amrex::Real max_time)
resizes the FArrayBox of the diagnostics to the currently calculated box
Definition: Diagnostic.cpp:222
bool hasAnyOutput(int output_step, int max_step, amrex::Real output_time, amrex::Real max_time) const
determines if any field or beam diagnostic has any output on in this time step
Definition: Diagnostic.H:126
bool hasAnyFieldOutput(int output_step, int max_step, amrex::Real output_time, amrex::Real max_time) const
determines if any field diagnostic has any output on in this time step
Definition: Diagnostic.H:95
amrex::Vector< FieldDiagnosticData > m_field_data
Definition: Diagnostic.H:168
amrex::Vector< std::string > & getBeamNames()
return names of the beams to output
Definition: Diagnostic.H:66
bool needsRhoIndividual() const
determines if rho for every individual plasma is requested as a diagnostic
Definition: Diagnostic.cpp:104
bool needsRho() const
determines if rho is requested as a diagnostic
Definition: Diagnostic.cpp:88
bool m_initialized
Definition: Diagnostic.H:169
void Initialize(const int lev, bool do_laser)
Determine which data to output.
Definition: Diagnostic.cpp:121
bool hasBeamOutput(int output_step, int max_step, amrex::Real output_time, amrex::Real max_time) const
determines if any beam diagnostic has any output on in this time step
Definition: Diagnostic.H:111
amrex::Vector< FieldDiagnosticData > & getFieldData()
return data for all field diagnostics
Definition: Diagnostic.H:69
amrex::Vector< std::string > m_output_beam_names
Definition: Diagnostic.H:164
bool doDiagnostics(int output_period, int output_step, int max_step, amrex::Real output_time, amrex::Real max_time)
returns whether output should be writen to file
Definition: IOUtil.cpp:71
This struct holds data for one field diagnostic on one MR level.
Definition: Diagnostic.H:21
amrex::Geometry m_geom_io
Definition: Diagnostic.H:43
bool m_use_custom_size_hi
Definition: Diagnostic.H:27
bool m_include_ghost_cells
Definition: Diagnostic.H:25
int m_nfields
Definition: Diagnostic.H:34
bool m_use_custom_size_lo
Definition: Diagnostic.H:26
amrex::RealVect m_diag_lo
Definition: Diagnostic.H:29
bool m_has_field
Definition: Diagnostic.H:44
amrex::FArrayBox m_F
Definition: Diagnostic.H:39
amrex::Vector< std::string > m_comps_output
Definition: Diagnostic.H:35
int m_slice_dir
Definition: Diagnostic.H:24
amrex::BaseFab< complex_type > m_F_laser
Definition: Diagnostic.H:42
bool m_do_laser
Definition: Diagnostic.H:33
std::string m_laser_io_name
Definition: Diagnostic.H:49
int m_output_period
Definition: Diagnostic.H:47
amrex::RealVect m_diag_hi
Definition: Diagnostic.H:31
std::string m_diag_name
Definition: Diagnostic.H:22
amrex::IntVect m_diag_coarsen
Definition: Diagnostic.H:32
amrex::Gpu::DeviceVector< int > m_comps_output_idx
Definition: Diagnostic.H:37
int m_level
Definition: Diagnostic.H:23