Canoe
Comprehensive Atmosphere N' Ocean Engine
hydro_mean.cpp
Go to the documentation of this file.
1 #include "../coordinates/coordinates.hpp"
2 #include "../reconstruct/interpolation.hpp"
3 #include "../thermodynamics/thermodynamics.hpp"
4 #include "diagnostics.hpp"
5 
6 HydroMean::HydroMean(MeshBlock *pmb) : Diagnostics(pmb, "mean") {
7  type = "VECTORS";
8  varname = "rho_bar,";
9  long_name = "mean density,";
10  units = "kg/m^3,";
11 
12  for (int n = 1; n <= NVAPOR; ++n) {
13  varname += "q" + std::to_string(n) + "_bar,";
14  units += "kg/kg,";
15  long_name += "mean vapor,";
16  }
17  for (int n = 0; n < 3; ++n) {
18  units += "m/s,";
19  varname += "vel" + std::to_string(n + 1) + "_bar,";
20  long_name += "mean velocity,";
21  }
22  units += "K";
23  varname += "T_bar";
24  long_name += "mean temperature";
25 
26  data.NewAthenaArray(NHYDRO, ncells3_, ncells2_, ncells1_);
27 }
28 
29 HydroMean::~HydroMean() { data.DeleteAthenaArray(); }
30 
32  MeshBlock *pmb = pmy_block_;
33 
34  if (ncycle == 0) std::fill(data.data(), data.data() + data.GetSize(), 0.);
35 
36  for (int n = 0; n < IPR; ++n)
37  for (int k = pmb->ks; k <= pmb->ke; ++k)
38  for (int j = pmb->js; j <= pmb->je; ++j)
39  for (int i = pmb->is; i <= pmb->ie; ++i)
40  data(n, k, j, i) += w(n, k, j, i);
41 
42  // Temperature field is save in IPR
43  for (int k = pmb->ks; k <= pmb->ke; ++k)
44  for (int j = pmb->js; j <= pmb->je; ++j)
45  for (int i = pmb->is; i <= pmb->ie; ++i)
46  data(IPR, k, j, i) += pmb->pthermo->GetTemp(w.at(k, j, i));
47 
48  ncycle++;
49 }
50 
52  MeshBlock *pmb = pmy_block_;
53 
54  // hydro mean
55  if (ncycle > 0) {
56  for (int n = 0; n < NHYDRO; ++n)
57  for (int k = pmb->ks; k <= pmb->ke; ++k)
58  for (int j = pmb->js; j <= pmb->je; ++j)
59  for (int i = pmb->is; i <= pmb->ie; ++i) data(n, k, j, i) /= ncycle;
60  } else {
61  for (int n = 0; n < IPR; ++n)
62  for (int k = pmb->ks; k <= pmb->ke; ++k)
63  for (int j = pmb->js; j <= pmb->je; ++j)
64  for (int i = pmb->is; i <= pmb->ie; ++i)
65  data(n, k, j, i) = w(n, k, j, i);
66 
67  for (int k = pmb->ks; k <= pmb->ke; ++k)
68  for (int j = pmb->js; j <= pmb->je; ++j)
69  for (int i = pmb->is; i <= pmb->ie; ++i)
70  data(IPR, k, j, i) = pmb->pthermo->GetTemp(w.at(k, j, i));
71  }
72 
73  // clear cycle
74  ncycle = 0;
75 }
std::string units
Definition: diagnostics.hpp:17
std::string long_name
Definition: diagnostics.hpp:17
std::string varname
Definition: diagnostics.hpp:17
std::string type
Definition: diagnostics.hpp:16
AthenaArray< Real > data
Definition: diagnostics.hpp:19
MeshBlock * pmy_block_
Definition: diagnostics.hpp:44
void Finalize(AthenaArray< Real > const &w)
Definition: hydro_mean.cpp:51
virtual ~HydroMean()
Definition: hydro_mean.cpp:29
HydroMean(MeshBlock *pmb)
Definition: hydro_mean.cpp:6
void Progress(AthenaArray< Real > const &w)
Definition: hydro_mean.cpp:31