Canoe
Comprehensive Atmosphere N' Ocean Engine
temperature_anomaly.cpp
Go to the documentation of this file.
1 #include "../coordinates/coordinates.hpp"
2 #include "../globals.hpp"
3 #include "../thermodynamics/thermodynamics.hpp"
4 #include "diagnostics.hpp"
5 
7  : Diagnostics(pmb, "tempa") {
8  type = "SCALARS";
9  long_name = "Temperature anomaly";
10  units = "K";
11  mean_.NewAthenaArray(ncells1_);
12  data.NewAthenaArray(ncells3_, ncells2_, ncells1_);
13 }
14 
16  MeshBlock *pmb = pmy_block_;
17  Coordinates *pcoord = pmb->pcoord;
18  Thermodynamics *pthermo = pmb->pthermo;
19  int is = pmb->is, js = pmb->js, ks = pmb->ks;
20  int ie = pmb->ie, je = pmb->je, ke = pmb->ke;
21 
22  mean_.ZeroClear();
23 
24  // calculate horizontal mean
25  for (int k = ks; k <= ke; ++k)
26  for (int j = js; j <= je; ++j) {
27  pcoord->CellVolume(k, j, is, ie, vol_);
28  for (int i = is; i <= ie; ++i)
29  mean_(i) += vol_(i) * pthermo->GetTemp(w.at(k, j, i));
30  }
31 
33 
34  // temperature anomaly
35  for (int k = ks; k <= ke; ++k)
36  for (int j = js; j <= je; ++j)
37  for (int i = is; i <= ie; ++i)
38  data(k, j, i) =
39  pthermo->GetTemp(w.at(k, j, i)) - mean_(i) / total_vol_(i);
40 }
void gatherAllData23_(AthenaArray< Real > &total_vol, AthenaArray< Real > &total_data)
std::string units
Definition: diagnostics.hpp:17
AthenaArray< Real > mean_
mean and eddy component
Definition: diagnostics.hpp:48
AthenaArray< Real > vol_
Definition: diagnostics.hpp:56
std::string long_name
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
AthenaArray< Real > total_vol_
Definition: diagnostics.hpp:57
void Finalize(AthenaArray< Real > const &w)
TemperatureAnomaly(MeshBlock *pmb)
Real GetTemp(MeshBlock const *pmb, int k, int j, int i) const
Calculate temperature from primitive variable.