Canoe
Comprehensive Atmosphere N' Ocean Engine
diagnostics.hpp
Go to the documentation of this file.
1 #ifndef DIAGNOSTICS_HPP_
2 #define DIAGNOSTICS_HPP_
3 
4 // C++ header
5 #include <string>
6 
7 // Athena++ headers
8 #include "../athena_arrays.hpp"
9 #include "../mesh/mesh.hpp"
10 
11 class ParameterInput;
12 
13 class Diagnostics {
14  public:
15  // data
16  std::string myname, type, grid;
17  std::string varname, long_name, units;
20  int ncycle;
21 
22  // functions
23  Diagnostics(MeshBlock *pmb, ParameterInput *pin);
24  Diagnostics(MeshBlock *pmb, std::string name);
25  virtual ~Diagnostics();
26 
27  Diagnostics *operator[](std::string name);
28 
29  template <typename Dg>
30  Diagnostics *AddDiagnostics(Dg const &d) {
31  Dg *pd = new Dg(d);
32  Diagnostics *p = this;
33  while (p->next != nullptr) p = p->next;
34  p->next = pd;
35  p->next->prev = p;
36  p->next->next = nullptr;
37  return p->next;
38  }
39 
40  virtual void Progress(AthenaArray<Real> const &w) {}
41  virtual void Finalize(AthenaArray<Real> const &w) {}
42 
43  protected:
44  MeshBlock *pmy_block_;
46 
49 
51  std::vector<int> color_;
53  std::vector<int> brank_;
54 
60 
61  void setColor_(int *color, CoordinateDirection dir);
62  void gatherAllData23_(AthenaArray<Real> &total_vol,
63  AthenaArray<Real> &total_data);
64 };
65 
66 // register all diagnostics
67 // 1. divergence
68 class Divergence : public Diagnostics {
69  public:
70  Divergence(MeshBlock *pmb);
71  virtual ~Divergence() {}
72  void Finalize(AthenaArray<Real> const &w);
73 
74  protected:
76 };
77 
78 // 2. curl
79 class Curl : public Diagnostics {
80  public:
81  Curl(MeshBlock *pmb);
82  virtual ~Curl() {}
83  void Finalize(AthenaArray<Real> const &w);
84 
85  protected:
87 };
88 
89 // 3. hydro mean
90 class HydroMean : public Diagnostics {
91  public:
92  HydroMean(MeshBlock *pmb);
93  virtual ~HydroMean();
94  void Progress(AthenaArray<Real> const &w);
95  void Finalize(AthenaArray<Real> const &w);
96 
97  protected:
99 };
100 
101 // 4. temperature anomaly
103  public:
104  TemperatureAnomaly(MeshBlock *pmb);
105  virtual ~TemperatureAnomaly() {}
106  void Finalize(AthenaArray<Real> const &w);
107 };
108 
109 // 5. pressure anomaly
110 class PressureAnomaly : public Diagnostics {
111  public:
112  PressureAnomaly(MeshBlock *pmb);
113  virtual ~PressureAnomaly() {}
114  void Finalize(AthenaArray<Real> const &w);
115 };
116 
117 // 6. eddy flux
118 class EddyFlux : public Diagnostics {
119  public:
120  EddyFlux(MeshBlock *pmb);
121  virtual ~EddyFlux();
122  void Progress(AthenaArray<Real> const &w);
123  void Finalize(AthenaArray<Real> const &w);
124 };
125 
126 // 7. hydro flux
127 class HydroFlux : public Diagnostics {
128  public:
129  HydroFlux(MeshBlock *pmb);
130  virtual ~HydroFlux() {}
131  void Progress(AthenaArray<Real> const &w);
132  void Finalize(AthenaArray<Real> const &w);
133 };
134 
135 // 8. horizontal divergence
137  public:
138  HorizontalDivergence(MeshBlock *pmb);
139  virtual ~HorizontalDivergence();
140  void Finalize(AthenaArray<Real> const &w);
141 
142  protected:
144 };
145 
146 // 9. Buoyancy
147 class Buoyancy : public Diagnostics {
148  public:
149  Buoyancy(MeshBlock *pmb);
150  virtual ~Buoyancy() {}
151  void Finalize(AthenaArray<Real> const &w);
152 
153  protected:
155  Real grav_;
156 };
157 
158 // 10. total radiative flux
159 class RadiativeFlux : public Diagnostics {
160  public:
161  RadiativeFlux(MeshBlock *pmb);
162  virtual ~RadiativeFlux() {}
163  void Progress(AthenaArray<Real> const &w);
164  void Finalize(AthenaArray<Real> const &w);
165 };
166 
167 // 11. total angular momentum
168 class AngularMomentum : public Diagnostics {
169  public:
170  AngularMomentum(MeshBlock *pmb);
171  virtual ~AngularMomentum() {}
172  void Finalize(AthenaArray<Real> const &w);
173 };
174 
175 // 12. eddy kinetic energy
177  public:
178  EddyKineticEnergy(MeshBlock *pmb);
179  virtual ~EddyKineticEnergy() {}
180  void Finalize(AthenaArray<Real> const &w);
181 };
182 
183 // 13. horizontal averaged tendency
184 class Tendency : public Diagnostics {
185  public:
186  Tendency(MeshBlock *pmb);
187  virtual ~Tendency() {}
188  void Finalize(AthenaArray<Real> const &w);
189 
190  protected:
193 };
194 
195 #endif
virtual ~AngularMomentum()
void Finalize(AthenaArray< Real > const &w)
AngularMomentum(MeshBlock *pmb)
Buoyancy(MeshBlock *pmb)
Definition: buoyancy.cpp:7
virtual ~Buoyancy()
AthenaArray< Real > pf_
void Finalize(AthenaArray< Real > const &w)
Definition: buoyancy.cpp:16
Curl(MeshBlock *pmb)
Definition: curl.cpp:5
AthenaArray< Real > v2f3_
Definition: diagnostics.hpp:86
AthenaArray< Real > v3f2_
Definition: diagnostics.hpp:86
AthenaArray< Real > v1f2_
Definition: diagnostics.hpp:86
void Finalize(AthenaArray< Real > const &w)
Definition: curl.cpp:25
AthenaArray< Real > v3f1_
Definition: diagnostics.hpp:86
AthenaArray< Real > v1f3_
Definition: diagnostics.hpp:86
AthenaArray< Real > v2f1_
Definition: diagnostics.hpp:86
virtual ~Curl()
Definition: diagnostics.hpp:82
void gatherAllData23_(AthenaArray< Real > &total_vol, AthenaArray< Real > &total_data)
AthenaArray< Real > x2area_p1_
Definition: diagnostics.hpp:56
virtual void Finalize(AthenaArray< Real > const &w)
Definition: diagnostics.hpp:41
std::string units
Definition: diagnostics.hpp:17
virtual void Progress(AthenaArray< Real > const &w)
Definition: diagnostics.hpp:40
AthenaArray< Real > x3edge_p1_
Definition: diagnostics.hpp:59
AthenaArray< Real > mean_
mean and eddy component
Definition: diagnostics.hpp:48
AthenaArray< Real > vol_
Definition: diagnostics.hpp:56
void setColor_(int *color, CoordinateDirection dir)
std::vector< int > color_
MPI color of each rank.
Definition: diagnostics.hpp:51
AthenaArray< Real > x2edge_p1_
Definition: diagnostics.hpp:58
AthenaArray< Real > x3area_
Definition: diagnostics.hpp:56
std::string long_name
Definition: diagnostics.hpp:17
std::string varname
Definition: diagnostics.hpp:17
Diagnostics(MeshBlock *pmb, ParameterInput *pin)
Definition: diagnostics.cpp:13
Diagnostics * next
Definition: diagnostics.hpp:18
AthenaArray< Real > x1area_
scratch geometric arrays
Definition: diagnostics.hpp:56
AthenaArray< Real > eddy_
Definition: diagnostics.hpp:48
Diagnostics * AddDiagnostics(Dg const &d)
Definition: diagnostics.hpp:30
AthenaArray< Real > x1edge_
Definition: diagnostics.hpp:58
std::string myname
Definition: diagnostics.hpp:16
Diagnostics * prev
Definition: diagnostics.hpp:18
std::string type
Definition: diagnostics.hpp:16
AthenaArray< Real > data
Definition: diagnostics.hpp:19
virtual ~Diagnostics()
std::vector< int > brank_
rank of the bottom block
Definition: diagnostics.hpp:53
AthenaArray< Real > x2edge_
Definition: diagnostics.hpp:58
AthenaArray< Real > x3edge_
Definition: diagnostics.hpp:58
AthenaArray< Real > x1edge_p1_
Definition: diagnostics.hpp:58
AthenaArray< Real > x2area_
Definition: diagnostics.hpp:56
AthenaArray< Real > x3area_p1_
Definition: diagnostics.hpp:56
Diagnostics * operator[](std::string name)
MeshBlock * pmy_block_
Definition: diagnostics.hpp:44
AthenaArray< Real > total_vol_
Definition: diagnostics.hpp:57
std::string grid
Definition: diagnostics.hpp:16
AthenaArray< Real > v3f3_
Definition: diagnostics.hpp:75
AthenaArray< Real > v2f2_
Definition: diagnostics.hpp:75
virtual ~Divergence()
Definition: diagnostics.hpp:71
Divergence(MeshBlock *pmb)
Definition: divergence.cpp:5
void Finalize(AthenaArray< Real > const &w)
Definition: divergence.cpp:17
AthenaArray< Real > v1f1_
Definition: diagnostics.hpp:75
void Finalize(AthenaArray< Real > const &w)
Definition: eddy_flux.cpp:89
void Progress(AthenaArray< Real > const &w)
Definition: eddy_flux.cpp:27
virtual ~EddyFlux()
Definition: eddy_flux.cpp:21
EddyFlux(MeshBlock *pmb)
Definition: eddy_flux.cpp:12
virtual ~EddyKineticEnergy()
EddyKineticEnergy(MeshBlock *pmb)
void Finalize(AthenaArray< Real > const &w)
AthenaArray< Real > v2f2_
AthenaArray< Real > v3f3_
HorizontalDivergence(MeshBlock *pmb)
void Finalize(AthenaArray< Real > const &w)
virtual ~HydroFlux()
void Progress(AthenaArray< Real > const &w)
Definition: total_flux.cpp:30
HydroFlux(MeshBlock *pmb)
Definition: total_flux.cpp:6
void Finalize(AthenaArray< Real > const &w)
Definition: total_flux.cpp:56
void Finalize(AthenaArray< Real > const &w)
Definition: hydro_mean.cpp:51
virtual ~HydroMean()
Definition: hydro_mean.cpp:29
int last_output_cycle_
Definition: diagnostics.hpp:98
HydroMean(MeshBlock *pmb)
Definition: hydro_mean.cpp:6
void Progress(AthenaArray< Real > const &w)
Definition: hydro_mean.cpp:31
void Finalize(AthenaArray< Real > const &w)
PressureAnomaly(MeshBlock *pmb)
virtual ~PressureAnomaly()
void Finalize(AthenaArray< Real > const &w)
void Progress(AthenaArray< Real > const &w)
RadiativeFlux(MeshBlock *pmb)
virtual ~RadiativeFlux()
void Finalize(AthenaArray< Real > const &w)
virtual ~TemperatureAnomaly()
TemperatureAnomaly(MeshBlock *pmb)
AthenaArray< Real > wh_
Real last_time_
virtual ~Tendency()
void Finalize(AthenaArray< Real > const &w)
Definition: tendency.cpp:46
Tendency(MeshBlock *pmb)
Definition: tendency.cpp:6
AthenaArray< Real > up_