Skip to content

Commit 398344f

Browse files
committed
record total changes of th and rv due to surface
1 parent 87a899d commit 398344f

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

src/solvers/slvr_common.hpp

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ class slvr_common : public slvr_dim<ct_params_t>
3535
int spinup; // number of timesteps
3636
static constexpr int n_flxs = ct_params_t::n_dims + 1; // number of surface fluxes = number of hori velocities + th + rv
3737

38+
// accumulated total changes of th and rv at top and bottom
39+
real_t tot_rv_change_top,
40+
tot_rv_change_bot,
41+
tot_th_change_top,
42+
tot_th_change_bot;
43+
3844
// array with index of inversion
3945
blitz::Array<real_t, parent_t::n_dims-1> k_i; // TODO: allocate k_i with alloc surf + in MPI calc average k_i over all processes
4046

@@ -204,29 +210,39 @@ class slvr_common : public slvr_dim<ct_params_t>
204210
//const real_t side_wall_rv = 0.00699107203438; // 80% RH
205211
const real_t side_wall_rv = 0.00611718803008; // 70% RH
206212
//const real_t side_wall_rv = 0.00524330402578; // 60% RH
213+
214+
const real_t top_wall_th = 280;
215+
const real_t bot_wall_th = 299;
216+
const real_t side_wall_th = 285;
207217

208218
// hack to set temperature and moisture of top and bottom walls of a Pi chamber
209-
this->state(ix::th)(this->hrzntl_slice(this->ijk.lbound(parent_t::n_dims-1))) = 299;
219+
tot_th_change_bot += bot_wall_th - blitz::sum(this->state(ix::th)(this->hrzntl_slice(this->ijk.lbound(parent_t::n_dims-1))));
220+
tot_rv_change_bot += bot_wall_rv - blitz::sum(this->state(ix::rv)(this->hrzntl_slice(this->ijk.lbound(parent_t::n_dims-1))));
221+
222+
tot_th_change_top += top_wall_th - blitz::sum(this->state(ix::th)(this->hrzntl_slice(this->ijk.ubound(parent_t::n_dims-1))));
223+
tot_rv_change_top += top_wall_rv - blitz::sum(this->state(ix::rv)(this->hrzntl_slice(this->ijk.ubound(parent_t::n_dims-1))));
224+
225+
this->state(ix::th)(this->hrzntl_slice(this->ijk.lbound(parent_t::n_dims-1))) = bot_wall_th;
210226
this->state(ix::rv)(this->hrzntl_slice(this->ijk.lbound(parent_t::n_dims-1))) = bot_wall_rv;
211227

212-
this->state(ix::th)(this->hrzntl_slice(this->ijk.ubound(parent_t::n_dims-1))) = 280;
228+
this->state(ix::th)(this->hrzntl_slice(this->ijk.ubound(parent_t::n_dims-1))) = top_wall_th;
213229
this->state(ix::rv)(this->hrzntl_slice(this->ijk.ubound(parent_t::n_dims-1))) = top_wall_rv;
214230

215231

216232
// side walls perpendicular to x
217-
this->set_vertcl_slice_x(this->state(ix::th), 0, 285);
233+
this->set_vertcl_slice_x(this->state(ix::th), 0, side_wall_th);
218234
this->set_vertcl_slice_x(this->state(ix::rv), 0, side_wall_rv);
219235

220-
this->set_vertcl_slice_x(this->state(ix::th), params.grid_size[0]-1, 285);
236+
this->set_vertcl_slice_x(this->state(ix::th), params.grid_size[0]-1, side_wall_th);
221237
this->set_vertcl_slice_x(this->state(ix::rv), params.grid_size[0]-1, side_wall_rv);
222238

223239
// side walls perpendicular to y
224240
if(parent_t::n_dims==3)
225241
{
226-
this->state(ix::th)(this->vertcl_slice_y(this->ijk.lbound(1))) = 285;
242+
this->state(ix::th)(this->vertcl_slice_y(this->ijk.lbound(1))) = side_wall_th;
227243
this->state(ix::rv)(this->vertcl_slice_y(this->ijk.lbound(1))) = side_wall_rv;
228244

229-
this->state(ix::th)(this->vertcl_slice_y(this->ijk.ubound(1))) = 285;
245+
this->state(ix::th)(this->vertcl_slice_y(this->ijk.ubound(1))) = side_wall_th;
230246
this->state(ix::rv)(this->vertcl_slice_y(this->ijk.ubound(1))) = side_wall_rv;
231247
}
232248

@@ -497,6 +513,11 @@ class slvr_common : public slvr_dim<ct_params_t>
497513
real_t sum = this->mem->distmem.sum(puddle.at(static_cast<cmn::output_t>(i)));
498514
this->record_aux_scalar(cmn::output_names.at(static_cast<cmn::output_t>(i)), "puddle", sum);
499515
}
516+
517+
this->record_aux_scalar("tot_th_change_bot", tot_th_change_bot);
518+
this->record_aux_scalar("tot_th_change_top", tot_th_change_top);
519+
this->record_aux_scalar("tot_rv_change_bot", tot_rv_change_bot);
520+
this->record_aux_scalar("tot_rv_change_top", tot_rv_change_top);
500521
}
501522

502523
void record_all()
@@ -558,7 +579,11 @@ class slvr_common : public slvr_dim<ct_params_t>
558579
U_ground(args.mem->tmp[__FILE__][1][3]),
559580
surf_flux_tmp(args.mem->tmp[__FILE__][1][4]),
560581
surf_flux_u(args.mem->tmp[__FILE__][1][5]),
561-
surf_flux_v(args.mem->tmp[__FILE__][1][6]) // flux_v needs to be last
582+
surf_flux_v(args.mem->tmp[__FILE__][1][6]), // flux_v needs to be last
583+
tot_rv_change_top(0),
584+
tot_rv_change_bot(0),
585+
tot_th_change_top(0),
586+
tot_th_change_bot(0)
562587
{
563588
k_i.resize(this->shape(this->hrzntl_subdomain));
564589
k_i.reindexSelf(this->base(this->hrzntl_subdomain));

0 commit comments

Comments
 (0)