1 #include "../coordinates/coordinates.hpp"
2 #include "../hydro/hydro.hpp"
3 #include "../hydro/srcterms/hydro_srcterms.hpp"
4 #include "../thermodynamics/thermodynamics.hpp"
7 LatentHeating::LatentHeating(MeshBlock *pmb) :
Diagnostics(pmb,
"Lvheating") {
10 long_name =
"Latent Heating";
12 data.NewAthenaArray(1, 1, 1, ncells1_);
15 LatentHeating::~LatentHeating() {
data.DeleteAthenaArray(); }
18 MeshBlock *pmb = pmy_block_;
19 Hydro *phydro = pmb->phydro;
23 int is = pmb->is, js = pmb->js, ks = pmb->ks;
24 int ie = pmb->ie, je = pmb->je, ke = pmb->ke;
25 int iH2O = 1, iH2Oc = 3, iH2Op = 5;
32 std::fill(
data.data(),
data.data() +
data.GetSize(), 0.);
35 for (
int k = ks; k <= ke; ++k)
36 for (
int j = js;
j <= je; ++
j) {
37 pcoord->CellVolume(k,
j, is, ie, vol_);
38 for (
int i = is; i <= ie; ++i) {
42 Real x1area_l, x1area_r, x2area_l, x2area_r, x3area_l, x3area_r;
44 x1area_l = pcoord->GetFace1Area(k,
j, i);
45 x1area_r = pcoord->GetFace1Area(k,
j, i + 1);
46 x2area_l = pcoord->GetFace2Area(k,
j, i);
47 x2area_r = pcoord->GetFace2Area(k,
j + 1, i);
48 x3area_l = pcoord->GetFace3Area(k,
j, i);
49 x3area_r = pcoord->GetFace3Area(k + 1,
j, i);
51 div = (x1area_r * x1flux(iH2O, k,
j, i + 1) -
52 x1area_l * x1flux(iH2O, k,
j, i)) +
53 (x2area_r * x2flux(iH2O, k,
j + 1, i) -
54 x2area_l * x2flux(iH2O, k,
j, i)) +
55 (x3area_r * x3flux(iH2O, k + 1,
j, i) -
56 x3area_l * x3flux(iH2O, k,
j, i));
60 Real dqdt = (w(iH2O, k,
j, i) * w(IDN, k,
j, i) -
61 pmb->ruser_meshblock_data[4](iH2O, k,
j, i)) /
67 data(i) -= Lv * (dqdt - div) * vol_(i);
68 pmb->ruser_meshblock_data[4](iH2O, k,
j, i) =
69 w(iH2O, k,
j, i) * w(IDN, k,
j, i);
76 MeshBlock *pmb = pmy_block_;
78 int is = pmb->is, js = pmb->js, ks = pmb->ks;
79 int ie = pmb->ie, je = pmb->je, ke = pmb->ke;
81 Real *total_vol =
new Real[ncells1_];
82 std::fill(total_vol, total_vol + ncells1_, 0.);
84 for (
int k = ks; k <= ke; ++k)
85 for (
int j = js;
j <= je; ++
j) {
86 pmb->pcoord->CellVolume(k,
j, is, ie, vol_);
87 for (
int i = is; i <= ie; ++i) total_vol[i] += vol_(i);
94 MPI_Allreduce(MPI_IN_PLACE,
data.data(),
data.GetSize(), MPI_ATHENA_REAL,
95 MPI_SUM, MPI_COMM_WORLD);
96 MPI_Allreduce(MPI_IN_PLACE, total_vol, ncells1_, MPI_ATHENA_REAL, MPI_SUM,
99 for (
int i = is; i <= ie; ++i) {
100 data(i) /= ncycle * total_vol[i];