REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA_make_new_level.cpp
Go to the documentation of this file.
1/**
2 * \file REMORA_make_new_level.cpp
3 */
4
5#include <REMORA.H>
7
8#include <AMReX_buildInfo.H>
9
10using namespace amrex;
11
12/**
13 * Make a new level using provided BoxArray and DistributionMapping and
14 * fill with interpolated coarse level data (overrides the pure virtual function in AmrCore)
15 * regrid --> RemakeLevel (if level already existed)
16 * regrid --> MakeNewLevelFromCoarse (if adding new level)
17 *
18 * @param[in ] lev level to make
19 * @param[in ] time current time
20 * @param[in ] ba BoxArray for the level
21 * @param[in ] dm DistributionMapping for the level
22 */
23void
24REMORA::MakeNewLevelFromCoarse (int lev, Real time, const BoxArray& ba,
25 const DistributionMapping& dm)
26{
27 BoxList bl2d = ba.boxList();
28 for (auto& b : bl2d) {
29 b.setRange(2,0);
30 }
31 BoxArray ba2d(std::move(bl2d));
32
33 amrex::Print() << "Making level " << lev << " from coarse" << std::endl;
34 amrex::Print() << "GRIDS AT LEVEL " << lev << " ARE " << ba << std::endl;
35
36 cons_new[lev] = new MultiFab(ba, dm, ncons, cons_new[lev-1]->nGrowVect());
37 cons_old[lev] = new MultiFab(ba, dm, ncons, cons_new[lev-1]->nGrowVect());
38
39 xvel_new[lev] = new MultiFab(convert(ba, IntVect(1,0,0)), dm, 1, xvel_new[lev-1]->nGrowVect());
40 xvel_old[lev] = new MultiFab(convert(ba, IntVect(1,0,0)), dm, 1, xvel_new[lev-1]->nGrowVect());
41
42 yvel_new[lev] = new MultiFab(convert(ba, IntVect(0,1,0)), dm, 1, yvel_new[lev-1]->nGrowVect());
43 yvel_old[lev] = new MultiFab(convert(ba, IntVect(0,1,0)), dm, 1, yvel_new[lev-1]->nGrowVect());
44
45 zvel_new[lev] = new MultiFab(convert(ba, IntVect(0,0,1)), dm, 1, zvel_new[lev-1]->nGrowVect());
46 zvel_old[lev] = new MultiFab(convert(ba, IntVect(0,0,1)), dm, 1, zvel_new[lev-1]->nGrowVect());
47
49
50 vec_Zt_avg1[lev].reset(new MultiFab(ba2d ,dm,1,IntVect(NGROW+1,NGROW+1,0))); //2d, average of the free surface (zeta)
51 vec_h[lev].reset(new MultiFab(ba2d ,dm,2,IntVect(NGROW+1,NGROW+1,0))); //2d, average of the free surface (zeta)
52 vec_ubar[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,3,IntVect(NGROW,NGROW,0)));
53 vec_vbar[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,3,IntVect(NGROW,NGROW,0)));
54
55 vec_ru[lev].reset(new MultiFab(convert(ba,IntVect(1,0,0)),dm,2,IntVect(NGROW,NGROW,0))); // RHS u (incl horizontal and vertical advection)
56 vec_rv[lev].reset(new MultiFab(convert(ba,IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0))); // RHS v
57
58 vec_ru2d[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,2,IntVect(NGROW,NGROW,0))); // RHS u for 2d
59 vec_rv2d[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0))); // RHS v for 2d
60
61 t_new[lev] = time;
63
65
67
68 cons_new[lev]->setVal(zero);
69 xvel_new[lev]->setVal(zero);
70 yvel_new[lev]->setVal(zero);
71 zvel_new[lev]->setVal(zero);
72
73 cons_old[lev]->setVal(zero);
74 xvel_old[lev]->setVal(zero);
75 yvel_old[lev]->setVal(zero);
76 zvel_old[lev]->setVal(zero);
77
78 vec_ru[lev]->setVal(zero);
79 vec_rv[lev]->setVal(zero);
80
81 vec_ru2d[lev]->setVal(zero);
82 vec_rv2d[lev]->setVal(zero);
83
84 vec_ubar[lev]->setVal(zero);
85 vec_vbar[lev]->setVal(zero);
86
87
88 // Before the fills: FillPatch masks domain-boundary ghosts through physbcs, so these must
89 // hold the real coastline rather than init_masks' all-water placeholder. Order matters:
90 // init_stuff reallocates the coordinates set_grid_scale fills, which set_masks may read.
93
94 // init_stuff reallocated the nudging coefficients; init_only fills them only
95 // for a level made from scratch. The radiation conditions below and the
96 // climatology nudging read them.
98
99#ifdef REMORA_USE_NETCDF
100 // The per-level NetCDF boundary series are otherwise built only by init_only,
101 // for a level made from scratch. The FillCoarsePatch calls below apply the
102 // file's boundary data to this level and index boundary_series[lev], so a
103 // level first created at a regrid needs its series built here.
106 }
107#endif
108
113
114 if (lev > hires_grid_level) {
115 FillCoarsePatch(lev, time, vec_h[lev].get(), vec_h[lev-1].get(),
117 FillCoarsePatch(lev, time, vec_h[lev].get(), vec_h[lev-1].get(),
119 } else {
121 }
122
123 // The free surface before the barotropic velocities: a Flather condition on
124 // ubar or vbar at a domain edge reads zeta, and h, on this level.
126 bool apply_eminusp = false;
128 for (int icomp=0; icomp<3; icomp++) {
129 FillCoarsePatch(lev, time, vec_ubar[lev].get(), vec_ubar[lev-1].get(), ubar_bc(),
130 bdy_ubar(),icomp,false);
131 FillCoarsePatch(lev, time, vec_vbar[lev].get(), vec_vbar[lev-1].get(), vbar_bc(),
132 bdy_vbar(),icomp,false);
133 }
134 for (int icomp=0; icomp<2; icomp++) {
135 FillCoarsePatch(lev, time, vec_ru[lev].get(), vec_ru[lev-1].get(), xvel_bc(),
136 BdyVars::null,icomp,false);
137 FillCoarsePatch(lev, time, vec_rv[lev].get(), vec_rv[lev-1].get(), yvel_bc(),
138 BdyVars::null,icomp,false);
139 FillCoarsePatch(lev, time, vec_ru2d[lev].get(), vec_ru2d[lev-1].get(), xvel_bc(),
140 BdyVars::null,icomp,false);
141 FillCoarsePatch(lev, time, vec_rv2d[lev].get(), vec_rv2d[lev-1].get(), yvel_bc(),
142 BdyVars::null,icomp,false);
143 }
144
146
150
151#ifdef REMORA_USE_NETCDF
154 }
155#endif
156
157 // ********************************************************************************************
158 // If we are making a new level then the FillPatcher for this level hasn't been allocated yet
159 // ********************************************************************************************
160 if (cf_width >= 0) {
163 }
165
166#ifdef REMORA_USE_PARTICLES
167 // particleData.Redistribute();
168#endif
169}
170
171/**
172 * Remake an existing level using provided BoxArray and DistributionMapping and
173 * fill with existing fine and coarse data.
174 * overrides the pure virtual function in AmrCore
175 * @param[in ] lev level to make
176 * @param[in ] time current time
177 * @param[in ] ba BoxArray for the level
178 * @param[in ] dm DistributionMapping for the level
179 */
180void
181REMORA::RemakeLevel (int lev, Real time, const BoxArray& ba, const DistributionMapping& dm)
182{
183
184 BoxList bl2d = ba.boxList();
185 for (auto& b : bl2d) {
186 b.setRange(2,0);
187 }
188 BoxArray ba2d(std::move(bl2d));
189
190 amrex::Print() << "Remaking level " << lev << std::endl;
191 amrex::Print() << "GRIDS AT LEVEL " << lev << " ARE " << ba << std::endl;
192
193 int ngrow_state = 3;
194 int ngrow_vels = 3;
195 int ngrow_zeta = 3;
196 int ngrow_h = 3;
197 int ngrow_velbar = 2;
198
199 MultiFab tmp_cons_new(ba, dm, ncons, ngrow_state);
200 MultiFab tmp_cons_old(ba, dm, ncons, ngrow_state);
201
202 MultiFab tmp_xvel_new(convert(ba, IntVect(1,0,0)), dm, 1, ngrow_vels);
203 MultiFab tmp_xvel_old(convert(ba, IntVect(1,0,0)), dm, 1, ngrow_vels);
204
205 MultiFab tmp_yvel_new(convert(ba, IntVect(0,1,0)), dm, 1, ngrow_vels);
206 MultiFab tmp_yvel_old(convert(ba, IntVect(0,1,0)), dm, 1, ngrow_vels);
207
208 MultiFab tmp_zvel_new(convert(ba, IntVect(0,0,1)), dm, 1, IntVect(ngrow_vels,ngrow_vels,0));
209 MultiFab tmp_zvel_old(convert(ba, IntVect(0,0,1)), dm, 1, IntVect(ngrow_vels,ngrow_vels,0));
210
211 MultiFab tmp_Zt_avg1_new(ba2d, dm, 1, IntVect(ngrow_zeta,ngrow_zeta,0));
212 MultiFab tmp_h(ba2d, dm, 2, IntVect(ngrow_h,ngrow_h,0));
213
214 MultiFab tmp_ubar_new(convert(ba2d, IntVect(1,0,0)), dm, 3, IntVect(ngrow_velbar,ngrow_velbar,0));
215
216 MultiFab tmp_vbar_new(convert(ba2d, IntVect(0,1,0)), dm, 3, IntVect(ngrow_velbar,ngrow_velbar,0));
217
218 MultiFab tmp_ru_new(convert(ba, IntVect(1,0,0)),dm,2,IntVect(NGROW,NGROW,0));
219 MultiFab tmp_rv_new(convert(ba, IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0));
220
221 MultiFab tmp_ru2d_new(convert(ba2d, IntVect(1,0,0)),dm,2,IntVect(NGROW,NGROW,0));
222 MultiFab tmp_rv2d_new(convert(ba2d, IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0));
223
224 init_masks(lev, ba, dm);
225
226 tmp_cons_new.setVal(zero);
227 tmp_xvel_new.setVal(zero);
228 tmp_yvel_new.setVal(zero);
229 tmp_zvel_new.setVal(zero);
230
231 tmp_cons_old.setVal(zero);
232 tmp_xvel_old.setVal(zero);
233 tmp_yvel_old.setVal(zero);
234 tmp_zvel_old.setVal(zero);
235
236 tmp_ru_new.setVal(zero);
237 tmp_rv_new.setVal(zero);
238
239 tmp_ru2d_new.setVal(zero);
240 tmp_rv2d_new.setVal(zero);
241
242 tmp_ubar_new.setVal(zero);
243 tmp_vbar_new.setVal(zero);
244
245
246 // As in MakeNewLevelFromCoarse. init_stuff comes along because set_grid_scale follows it.
247 init_stuff(lev, ba, dm);
249 set_masks(lev);
250 // init_stuff reallocated the nudging coefficients the fills below may read
252
253 // This will fill the temporary MultiFabs with data from previous fine data as well as coarse where needed
259
260 for (int icomp=0; icomp<3; icomp++) {
263 }
264 for (int icomp=0; icomp<2; icomp++) {
267 // These might want to have BCVars::ubar_bc and vbar_bc
270 }
271
272 MultiFab::Copy(tmp_cons_old,tmp_cons_new,0,0,ncons,tmp_cons_new.nGrowVect());
273 MultiFab::Copy(tmp_xvel_old,tmp_xvel_new,0,0, 1,tmp_xvel_new.nGrowVect());
274 MultiFab::Copy(tmp_yvel_old,tmp_yvel_new,0,0, 1,tmp_yvel_new.nGrowVect());
275 MultiFab::Copy(tmp_zvel_old,tmp_zvel_new,0,0, 1,tmp_zvel_new.nGrowVect());
276
277 std::swap(tmp_cons_new, *cons_new[lev]);
278 std::swap(tmp_cons_old, *cons_old[lev]);
279 std::swap(tmp_xvel_new, *xvel_new[lev]);
280 std::swap(tmp_xvel_old, *xvel_old[lev]);
281 std::swap(tmp_yvel_new, *yvel_new[lev]);
282 std::swap(tmp_yvel_old, *yvel_old[lev]);
283 std::swap(tmp_zvel_new, *zvel_new[lev]);
284 std::swap(tmp_zvel_old, *zvel_old[lev]);
285 std::swap(tmp_Zt_avg1_new, *vec_Zt_avg1[lev]);
286 std::swap(tmp_ubar_new, *vec_ubar[lev]);
287 std::swap(tmp_vbar_new, *vec_vbar[lev]);
288 std::swap(tmp_ru_new, *vec_ru[lev]);
289 std::swap(tmp_rv_new, *vec_rv[lev]);
290 std::swap(tmp_ru2d_new, *vec_ru2d[lev]);
291 std::swap(tmp_rv2d_new, *vec_rv2d[lev]);
292
293 // Handle bathymetry separately
294 if (lev > hires_grid_level) {
297 std::swap(tmp_h, *vec_h[lev]);
298 } else {
299 // Swap first: vec_h[lev] is still on the pre-regrid BoxArray at this point, and the
300 // branch above is what moves it onto the new one. set_bathymetry_averaged_down takes
301 // its data from vec_h_full_domain rather than from the old grids, so the old contents
302 // are not needed -- but its FillPatch uses the land masks, which init_masks has
303 // already rebuilt on the new BoxArray, so leaving vec_h[lev] on the old one mixes two
304 // BoxArrays inside REMORAPhysBCFunct.
305 std::swap(tmp_h, *vec_h[lev]);
307 }
308
309 t_new[lev] = time;
311
313
317 bool apply_eminusp = false;
319
320#ifdef REMORA_USE_NETCDF
323 }
324#endif
325
326 // Both of these hold this level's layout and the one below it, so both have to be rebuilt
327 // whenever either changes. Unconditionally: AmrCore::regrid calls RemakeLevel only when
328 // this level's BoxArray changed or the coarser one's did, and in the latter case it
329 // passes this level's own ba and dm unchanged -- so testing them here would skip exactly
330 // the case where only the coarse side moved.
331 if (lev > 0 && cf_width >= 0) {
334 }
335
336#ifdef REMORA_USE_PARTICLES
338#endif
339}
340
341/**
342 * Make a new level from scratch using provided BoxArray and DistributionMapping.
343 * This is called both for initialization and for restart
344 * (overrides the pure virtual function in AmrCore)
345 * main.cpp --> REMORA::InitData --> InitFromScratch --> MakeNewGrids --> MakeNewLevelFromScratch
346 * restart --> MakeNewGrids --> MakeNewLevelFromScratch
347 *
348 * @param[in ] lev level to make
349 * @param[in ] time current time
350 * @param[in ] ba BoxArray for the level
351 * @param[in ] dm DistributionMapping for the level
352 */
353void REMORA::MakeNewLevelFromScratch (int lev, Real time, const BoxArray& ba,
354 const DistributionMapping& dm)
355{
356 // Set BoxArray grids and DistributionMapping dmap in AMReX_AmrMesh.H class
359
360 BoxList bl2d = ba.boxList();
361 for (auto& b : bl2d) {
362 b.setRange(2,0);
363 }
364 BoxArray ba2d(std::move(bl2d));
365
366 amrex::Print() << "Making level " << lev << " from scratch" << std::endl;
367 amrex::Print() << "GRIDS AT LEVEL " << lev << " ARE " << ba << std::endl;
368
369 int ngrow_state = 3;
370 int ngrow_vels = 3;
371
372 cons_old[lev] = new MultiFab(ba, dm, ncons, ngrow_state);
373 cons_new[lev] = new MultiFab(ba, dm, ncons, ngrow_state);
374
375 xvel_new[lev] = new MultiFab(convert(ba, IntVect(1,0,0)), dm, 1, ngrow_vels);
376 xvel_old[lev] = new MultiFab(convert(ba, IntVect(1,0,0)), dm, 1, ngrow_vels);
377
378 yvel_new[lev] = new MultiFab(convert(ba, IntVect(0,1,0)), dm, 1, ngrow_vels);
379 yvel_old[lev] = new MultiFab(convert(ba, IntVect(0,1,0)), dm, 1, ngrow_vels);
380
381 zvel_new[lev] = new MultiFab(convert(ba, IntVect(0,0,1)), dm, 1, IntVect(ngrow_vels,ngrow_vels,0));
382 zvel_old[lev] = new MultiFab(convert(ba, IntVect(0,0,1)), dm, 1, IntVect(ngrow_vels,ngrow_vels,0));
383
385
386 vec_Zt_avg1[lev].reset(new MultiFab(ba2d ,dm,1,IntVect(NGROW+1,NGROW+1,0))); //2d, average of the free surface (zeta)
387 vec_h[lev].reset(new MultiFab(ba2d ,dm,2,IntVect(NGROW+1,NGROW+1,0))); //2d, bathymetry
388 vec_ubar[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,3,IntVect(NGROW,NGROW,0)));
389 vec_vbar[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,3,IntVect(NGROW,NGROW,0)));
390
391 vec_ru[lev].reset(new MultiFab(convert(ba,IntVect(1,0,0)),dm,2,IntVect(NGROW,NGROW,0))); // RHS u (incl horizontal and vertical advection)
392 vec_rv[lev].reset(new MultiFab(convert(ba,IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0))); // RHS v
393
394 vec_ru2d[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,2,IntVect(NGROW,NGROW,0))); // RHS u (incl horizontal and vertical advection)
395 vec_rv2d[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0))); // RHS v
396
397 init_masks(lev, ba, dm);
398 init_stuff(lev, ba, dm);
399
401
402#ifdef REMORA_USE_PARTICLES
403 if (restart_chkfile.empty()) {
404 if (lev == 0) {
406 } else {
408 }
409 }
410#endif
411}
412
413/**
414 * @param[in ] lev level do operate on
415 */
417{
418 vec_z_phys_nd.resize(lev+1);
419
421 // Sized for both hires knobs: the initial-state cascade needs a mask at
422 // hires_init_level, which may sit above hires_grid_level.
424
425 vec_h.resize(lev+1);
426 vec_Zt_avg1.resize(lev+1);
427 vec_z_w.resize(lev+1);
428 vec_z_r.resize(lev+1);
429 vec_Hz.resize(lev+1);
430 vec_Huon.resize(lev+1);
431 vec_Hvom.resize(lev+1);
432 vec_Akv.resize(lev+1);
433 vec_Akt.resize(lev+1);
434 vec_visc2_p.resize(lev+1);
435 vec_visc2_r.resize(lev+1);
436 vec_diff2.resize(lev+1);
437 vec_ru.resize(lev+1);
438 vec_rv.resize(lev+1);
439 vec_ru2d.resize(lev+1);
440 vec_rv2d.resize(lev+1);
441 vec_rufrc.resize(lev+1);
442 vec_rvfrc.resize(lev+1);
443 vec_sustr.resize(lev+1);
444 vec_svstr.resize(lev+1);
445 vec_btflx.resize(lev+1);
446 vec_stflx.resize(lev+1);
447 vec_btflux.resize(lev+1);
448 vec_stflux.resize(lev+1);
449 vec_lrflx.resize(lev+1);
450 vec_longwave_down.resize(lev+1);
451 vec_lhflx.resize(lev+1);
452 vec_shflx.resize(lev+1);
453 vec_rain.resize(lev+1);
454 vec_evap.resize(lev+1);
455 vec_rdrag.resize(lev+1);
456 vec_rdrag2.resize(lev+1);
457 vec_ZoBot.resize(lev+1);
458 vec_bustr.resize(lev+1);
459 vec_bvstr.resize(lev+1);
460 vec_uwind.resize(lev+1);
461 vec_vwind.resize(lev+1);
462 vec_Tair.resize(lev+1);
463 vec_qair.resize(lev+1);
464 vec_Pair.resize(lev+1);
465 vec_srflx.resize(lev+1);
466 vec_cloud.resize(lev+1);
467 vec_EminusP.resize(lev+1);
468 vec_alpha.resize(lev+1);
469 vec_beta.resize(lev+1);
470
471 vec_DU_avg1.resize(lev+1);
472 vec_DU_avg2.resize(lev+1);
473 vec_DV_avg1.resize(lev+1);
474 vec_DV_avg2.resize(lev+1);
475 vec_Dubar_old.resize(lev+1);
476 vec_Dubar_new.resize(lev+1);
477 vec_Dvbar_old.resize(lev+1);
478 vec_Dvbar_new.resize(lev+1);
479 vec_rubar.resize(lev+1);
480 vec_rvbar.resize(lev+1);
481 vec_rzeta.resize(lev+1);
482 vec_ubar.resize(lev+1);
483 vec_vbar.resize(lev+1);
484 vec_zeta.resize(lev+1);
486 vec_mskr.resize(lev+1);
487 vec_msku.resize(lev+1);
488 vec_mskv.resize(lev+1);
489 vec_mskp.resize(lev+1);
490 vec_mskr3d.resize(lev+1);
491 // Indexed by the coarse level of a pair, so lev entries would do; sized like the rest to
492 // keep the indexing uniform.
493 vec_mskr_crse_on_fine.resize(lev+1);
494 vec_msku_crse_on_fine.resize(lev+1);
495 vec_mskv_crse_on_fine.resize(lev+1);
496 vec_sstore.resize(lev+1);
497
501
502 vec_pm.resize(lev+1);
503 vec_pn.resize(lev+1);
504 vec_fcor.resize(lev+1);
507
508 vec_xr.resize(lev+1);
509 vec_yr.resize(lev+1);
510 vec_xu.resize(lev+1);
511 vec_yu.resize(lev+1);
512 vec_xv.resize(lev+1);
513 vec_yv.resize(lev+1);
514 vec_xp.resize(lev+1);
515 vec_yp.resize(lev+1);
516 vec_lonp.resize(lev+1);
517 vec_latp.resize(lev+1);
518
519 vec_dndx.resize(lev+1);
520 vec_dmde.resize(lev+1);
521
522 vec_rhoS.resize(lev+1);
523 vec_rhoA.resize(lev+1);
524 vec_bvf.resize(lev+1);
525
526 vec_tke.resize(lev+1);
527 vec_gls.resize(lev+1);
528 vec_Lscale.resize(lev+1);
529 vec_Akk.resize(lev+1);
530 vec_Akp.resize(lev+1);
531
532 vec_river_position.resize(lev+1);
533
534 if (lev==0) vec_nudg_coeff.resize(num_bdy_vars());
535
536 vec_nudg_coeff[BdyVars::u].resize(lev+1);
537 vec_nudg_coeff[BdyVars::v].resize(lev+1);
538 for (int icomp = 0; icomp < ncons; ++icomp) {
540 }
541 vec_nudg_coeff[bdy_ubar()].resize(lev+1);
542 vec_nudg_coeff[bdy_vbar()].resize(lev+1);
543 vec_nudg_coeff[bdy_zeta()].resize(lev+1);
544}
545
546/**
547 * @param[in ] lev level to operate on
548 * @param[in ] ba BoxArray for the level
549 * @param[in ] dm DistributionMapping for the level
550 */
551void REMORA::init_masks (int lev, const BoxArray& ba, const DistributionMapping& dm)
552{
553 BoxList bl2d = ba.boxList();
554 for (auto& b : bl2d) {
555 b.setRange(2,0);
556 }
557
558 BoxArray ba2d(std::move(bl2d));
559 vec_mskr[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
560 vec_msku[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW+1,NGROW+1,0)));
561 vec_mskv[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW+1,NGROW+1,0)));
562 vec_mskp[lev].reset(new MultiFab(convert(ba2d,IntVect(1,1,0)),dm,1,IntVect(NGROW+1,NGROW+1,0)));
563
564 vec_mskr3d[lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,0)));
565
566 vec_mskr[lev]->setVal(one);
567 vec_msku[lev]->setVal(one);
568 vec_mskv[lev]->setVal(one);
569 vec_mskp[lev]->setVal(one);
570
571 vec_mskr3d[lev]->setVal(one);
572}
573
574/**
575 * @param[in ] lev level to operate on
576 * @param[in ] ba BoxArray for the level
577 * @param[in ] dm DistributionMapping for the level
578 */
579void REMORA::init_stuff (int lev, const BoxArray& ba, const DistributionMapping& dm)
580{
581 // ********************************************************************************************
582 // Initialize the boundary conditions
583 // ********************************************************************************************
584 physbcs[lev] = std::make_unique<REMORAPhysBCFunct> (lev, geom[lev], domain_bcs_type, domain_bcs_type_d,
586
587 BoxList bl2d = ba.boxList();
588 for (auto& b : bl2d) {
589 b.setRange(2,0);
590 }
591 BoxArray ba2d(std::move(bl2d));
592
593 BoxList bl1d = ba.boxList();
594 for (auto& b : bl1d) {
595 b.setRange(0,0);
596 b.setRange(1,0);
597 }
598 BoxArray ba1d(std::move(bl1d));
599
600 BoxArray ba_nd(ba);
601 ba_nd.surroundingNodes();
602 BoxArray ba_w(ba);
603 ba_w.surroundingNodes(2);
604
605 vec_z_phys_nd[lev].reset (new MultiFab(ba_nd,dm,1,IntVect(NGROW,NGROW,1))); // z at psi points (nodes) MIGHT NEED NGROW+1
606 vec_z_w[lev].reset (new MultiFab(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW+1,NGROW+1,0))); // z at w points (cell faces)
607 vec_z_r[lev].reset (new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,0))); // z at r points (cell center)
608 vec_Hz[lev].reset (new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,NGROW+1))); // like in ROMS, thickness of cell in z
609
610 vec_Huon[lev].reset (new MultiFab(convert(ba,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0))); // mass flux for u component
611 vec_Hvom[lev].reset (new MultiFab(convert(ba,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0))); // mass flux for v component
612
613 vec_Akv[lev].reset (new MultiFab(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW,NGROW,0))); // vertical mixing coefficient (.in)
614 // NAT components, not ncons: vertical mixing coefficients exist for the active tracers
615 // alone, and passive tracers mix with the salinity one. See akt_comp().
616 vec_Akt[lev].reset (new MultiFab(convert(ba,IntVect(0,0,1)),dm,NAT,IntVect(NGROW,NGROW,0))); // vertical mixing coefficient (.in)
617
618 // check dimensionality
619 vec_visc2_p[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); // harmonic viscosity at psi points -- difference to 3d?
620 vec_visc2_r[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); // harmonic viscosity at rho points
621 vec_diff2[lev].reset(new MultiFab(ba2d,dm,ncons,IntVect(NGROW,NGROW,0))); // harmonic diffusivity temperature/salt
622
623 //2d, (incl advection terms and surface/bottom stresses, integral over the whole column, k=0)
624 vec_rufrc[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,2,IntVect(NGROW,NGROW,0)));
625 vec_rvfrc[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0))); //2d, same as above but v
626
627 vec_sustr[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0))); //2d, surface stress
628 vec_svstr[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0))); //2d
629
631 //2d, linear drag coefficient [m/s], defined at rho, somehow related to rdrg
632 vec_rdrag[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
634 vec_rdrag2[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
635 }
636
639 vec_ZoBot[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
640 }
641
642 vec_bustr[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0))); //2d, bottom stress
643 vec_bvstr[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
644
645 //all 2d -- all associated with the 2D advance
646 //2d DU: sum(height[incl free surface?] * u)
647 vec_DU_avg1[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
648
649 //2d like above, but correct(or)?
650 vec_DU_avg2[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
651
652 vec_DV_avg1[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
653 vec_DV_avg2[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
654
655 // D*ubar and D*vbar: DU_avg2/on_u and DV_avg2/om_v, at the two ends of this level's step
656 vec_Dubar_old[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
657 vec_Dubar_new[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
658 vec_Dvbar_old[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
659 vec_Dvbar_new[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
660
661 vec_rubar[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,4,IntVect(NGROW,NGROW,0))); // 2d RHS ubar
662 vec_rvbar[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,4,IntVect(NGROW,NGROW,0)));
663 vec_rzeta[lev].reset(new MultiFab(ba2d,dm,4,IntVect(NGROW,NGROW,0))); // 2d RHS zeta
664
665 // starts off kind of like a depth-averaged u, but exists at more points and more timesteps (b/c fast 2D update) than full u
666 vec_zeta[lev].reset(new MultiFab(ba2d,dm,3,IntVect(NGROW+1,NGROW+1,0))); // 2d free surface
667
668 vec_pm[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+2,0)));
669 vec_pn[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+2,NGROW+1,0)));
670 vec_fcor[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
671
672 vec_xr[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
673 vec_yr[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
674
675 vec_xu[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
676 vec_yu[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
677 vec_xv[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
678 vec_yv[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
679 vec_xp[lev].reset(new MultiFab(convert(ba2d,IntVect(1,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
680 vec_yp[lev].reset(new MultiFab(convert(ba2d,IntVect(1,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
681
683 vec_dndx[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
684 vec_dmde[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
685 }
686
687 // tempstore, saltstore, etc
688 vec_sstore[lev].reset(new MultiFab(ba,dm,ncons,IntVect(NGROW,NGROW,0)));
689
690 vec_rhoS[lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW,NGROW,0)));
691 vec_rhoA[lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW,NGROW,0)));
692 vec_bvf[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW,NGROW,0)));
693
694 vec_tke[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,3,IntVect(NGROW,NGROW,0)));
695 vec_gls[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,3,IntVect(NGROW,NGROW,0)));
696 vec_Lscale[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW,NGROW,0)));
697 vec_Akk[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW,NGROW,0)));
698 vec_Akp[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW,NGROW,0)));
699
700 // surface/bottom tracer fluxes for update
701 vec_stflx[lev].reset(new MultiFab(ba2d,dm,ncons,IntVect(NGROW,NGROW,0)));
702 vec_btflx[lev].reset(new MultiFab(ba2d,dm,ncons,IntVect(NGROW,NGROW,0)));
703 // surface/bottom tracer fluxes to be filled by inputs
704 vec_stflux[lev].reset(new MultiFab(ba2d,dm,ncons,IntVect(NGROW,NGROW,0)));
705 vec_btflux[lev].reset(new MultiFab(ba2d,dm,ncons,IntVect(NGROW,NGROW,0)));
706
708 vec_uwind[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, surface wind u
709 vec_vwind[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, surface wind v
710 vec_Tair[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, air temperature
711 vec_qair[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, specific humidity
712 vec_Pair[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, air pressure
713 vec_srflx[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, shortwave radiation flux
714 vec_longwave_down[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, external longwave radiation flux
715 vec_cloud[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, cloud cover fraction
716 vec_EminusP[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, evaporation minus precipitation
717 vec_alpha[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
718 vec_beta[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
719 vec_lrflx[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
720 vec_lhflx[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
721 vec_shflx[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
722 vec_rain[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
723 vec_evap[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
724
727 vec_Tair[lev]->setVal(solverChoice.Tair);
728 vec_qair[lev]->setVal(solverChoice.Hair); // Hair can be specific humidity or RH
729 vec_Pair[lev]->setVal(solverChoice.Pair);
734 vec_rain[lev]->setVal(solverChoice.rain);
735
736 // Set flux vars that will be computed in bulk_fluxes to zero so initial plotting works
737 vec_stflx[lev]->setVal(zero);
738 vec_lhflx[lev]->setVal(zero);
739 vec_shflx[lev]->setVal(zero);
740 vec_lrflx[lev]->setVal(zero); // possibly this should be set to longwave_rad like longwave_down
741 vec_evap[lev]->setVal(zero);
742 }
743
745 vec_river_position[lev].reset(new iMultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
746 vec_river_position[lev]->setVal(-1);
747 }
748
749 vec_nudg_coeff[BdyVars::u][lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,0)));
750 vec_nudg_coeff[BdyVars::v][lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,0)));
751 for (int icomp = 0; icomp < ncons; ++icomp) {
752 vec_nudg_coeff[BdyVars::cons(icomp)][lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,0)));
753 }
754 vec_nudg_coeff[bdy_ubar()][lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
755 vec_nudg_coeff[bdy_vbar()][lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
756 vec_nudg_coeff[bdy_zeta()][lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
757
759
760 vec_DU_avg1[lev]->setVal(zero);
761 vec_DU_avg2[lev]->setVal(zero);
762 vec_DV_avg1[lev]->setVal(zero);
763 vec_DV_avg2[lev]->setVal(zero);
764 vec_Dubar_old[lev]->setVal(zero);
765 vec_Dubar_new[lev]->setVal(zero);
766 vec_Dvbar_old[lev]->setVal(zero);
767 vec_Dvbar_new[lev]->setVal(zero);
768 vec_rubar[lev]->setVal(zero);
769 vec_rvbar[lev]->setVal(zero);
770 vec_rzeta[lev]->setVal(zero);
771
772 // Initialize these vars even if we aren't using GLS to
773 // avoid issues on e.g. checkpoint
776 vec_Lscale[lev]->setVal(zero);
779
780 vec_stflx[lev]->setVal(zero);
781 vec_btflx[lev]->setVal(zero);
782 vec_stflux[lev]->setVal(zero);
783 vec_btflux[lev]->setVal(zero);
784 vec_sustr[lev]->setVal(zero);
785 vec_svstr[lev]->setVal(zero);
786
787 // Set initial linear drag coefficient
792 }
793
796 vec_ZoBot[lev]->setVal(solverChoice.Zob);
797 }
798
799
800 // ********************************************************************************************
801 // Create the REMORAFillPatcher object
802 // ********************************************************************************************
803 if (lev > 0 && cf_width >= 0) {
806 }
807}
808
809/**
810 * Delete level data. Overrides the pure virtual function in AmrCore
811 *
812 * @param[in ] lev level to operate on
813 */
814void
816{
817 delete cons_new[lev]; delete xvel_new[lev]; delete yvel_new[lev]; delete zvel_new[lev];
818 delete cons_old[lev]; delete xvel_old[lev]; delete yvel_old[lev]; delete zvel_old[lev];
819}
820
821/**
822 * @param[in ] lev level to operate on
823 */
824void
826{
827 // Even if we're using high-resolution grid initialization, don't set it up with average-down
830 const auto dxi = Geom(lev).InvCellSize();
831 vec_pm[lev]->setVal(dxi[0]); vec_pm[lev]->FillBoundary(geom[lev].periodicity());
832 vec_pn[lev]->setVal(dxi[1]); vec_pn[lev]->FillBoundary(geom[lev].periodicity());
834 prob->init_analytic_grid_scale(lev, Geom(lev), solverChoice, *this, *vec_pm[lev].get(), *vec_pn[lev].get());
835 vec_pm[lev]->FillBoundary(geom[lev].periodicity());
836 vec_pn[lev]->FillBoundary(geom[lev].periodicity());
837 }
839#ifdef REMORA_USE_NETCDF
840 } else if (solverChoice.ic_type == IC_Type::netcdf) {
841 if (lev == 0 && hires_grid_level < 0) {
843 } else if (lev > hires_grid_level) {
844 Real dummy_time = zero;
847
848 int rrx = ref_ratio[lev-1][0];
849 int rry = ref_ratio[lev-1][1];
850 // pm and pn need to be rescaled by the refinement ratio
851 for ( MFIter mfi(*vec_pm[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
852 {
853 Array4<Real> const& pm = vec_pm[lev]->array(mfi);
854 Array4<Real> const& pn = vec_pn[lev]->array(mfi);
855 Box ubx = mfi.growntilebox(IntVect(NGROW+1,NGROW+2,0));
856 Box vbx = mfi.growntilebox(IntVect(NGROW+2,NGROW+1,0));
857 ParallelFor(ubx, [=] AMREX_GPU_DEVICE (int i, int j, int ) {
858 pm(i,j,0) = pm(i,j,0) * (rrx);
859 });
860 ParallelFor(vbx, [=] AMREX_GPU_DEVICE (int i, int j, int ) {
861 pn(i,j,0) = pn(i,j,0) * (rry);
862 });
863 }
865 } else {
868 }
869#endif
870 }
873 }
874}
875
876/**
877 * @param[in ]lev level to operate on
878 */
879void
881 for ( MFIter mfi(*vec_xr[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
882 {
883 Array4<const Real> const& pm = vec_pm[lev]->const_array(mfi);
884 Array4<const Real> const& pn = vec_pn[lev]->const_array(mfi);
885 Array4<Real> const& xr = vec_xr[lev]->array(mfi);
886 Array4<Real> const& yr = vec_yr[lev]->array(mfi);
887 Array4<Real> const& xu = vec_xu[lev]->array(mfi);
888 Array4<Real> const& yu = vec_yu[lev]->array(mfi);
889 Array4<Real> const& xv = vec_xv[lev]->array(mfi);
890 Array4<Real> const& yv = vec_yv[lev]->array(mfi);
891 Array4<Real> const& xp = vec_xp[lev]->array(mfi);
892 Array4<Real> const& yp = vec_yp[lev]->array(mfi);
893
894 Box bx = mfi.growntilebox(IntVect(NGROW,NGROW,0));
895 ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int)
896 {
897 xr(i,j,0) = (i + Real(0.5)) / pm(i,j,0);
898 yr(i,j,0) = (j + Real(0.5)) / pn(i,j,0);
899 });
900
901 ParallelFor(mfi.tilebox(IntVect(1,0,0),IntVect(NGROW,NGROW,0)), [=] AMREX_GPU_DEVICE (int i, int j, int)
902 {
903 xu(i,j,0) = i / pm(i,j,0);
904 yu(i,j,0) = (j + Real(0.5)) / pn(i,j,0);
905 });
906
907 ParallelFor(mfi.tilebox(IntVect(0,1,0),IntVect(NGROW,NGROW,0)), [=] AMREX_GPU_DEVICE (int i, int j, int)
908 {
909 xv(i,j,0) = (i + Real(0.5)) / pm(i,j,0);
910 yv(i,j,0) = j / pn(i,j,0);
911 });
912
913 ParallelFor(mfi.tilebox(IntVect(1,1,0),IntVect(NGROW,NGROW,0)), [=] AMREX_GPU_DEVICE (int i, int j, int)
914 {
915 xp(i,j,0) = i / pm(i,j,0);
916 yp(i,j,0) = j / pn(i,j,0);
917 });
918 }
919}
920
921/**
922 * @param[in ]lev level to operate on
923 */
924void
926 for ( MFIter mfi(*vec_dndx[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
927 {
928 Array4<const Real> const& pm = vec_pm[lev]->const_array(mfi);
929 Array4<const Real> const& pn = vec_pn[lev]->const_array(mfi);
930 Array4<Real> const& dndx = vec_dndx[lev]->array(mfi);
931 Array4<Real> const& dmde = vec_dmde[lev]->array(mfi);
932
933 Box bx = mfi.growntilebox(IntVect(NGROW,NGROW,0));
934 ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int)
935 {
936 dndx(i,j,0) = Real(0.5) * (one / pn(i+1,j ,0) - one / pn(i-1,j ,0));
937 dmde(i,j,0) = Real(0.5) * (one / pm(i ,j+1,0) - one / pm(i ,j-1,0));
938 });
939 }
940}
941
942/**
943 * @param[in ] lev level to operate on
944 * @param[in ] apply_eminusp whether to apply the evaporation-minus-precipitation correction to Zt_avg1
945 */
946void
948{
949 BL_PROFILE("REMORA::set_zeta_to_Ztavg()");
950 std::unique_ptr<MultiFab>& mf_zeta = vec_zeta[lev];
951 std::unique_ptr<MultiFab>& mf_Zt_avg1 = vec_Zt_avg1[lev];
953 for ( MFIter mfi(*vec_zeta[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
954 {
955 Array4<Real> const& Zt_avg1 = (mf_Zt_avg1)->array(mfi);
956 Array4<const Real> const& evap = vec_evap[lev]->const_array(mfi);
957 Array4<const Real> const& rain = vec_rain[lev]->const_array(mfi);
958 Array4<const Real> const& EminusP = vec_EminusP[lev]->const_array(mfi);
961
962 Box bx2 = mfi.growntilebox(IntVect(NGROW,NGROW,0));// bx2.grow(IntVect(NGROW,NGROW,0));
963
964 Real cff = dt[lev] / rhow;
965 Real dt_lev = dt[lev];
966
967 ParallelFor(bx2, [=] AMREX_GPU_DEVICE (int i, int j, int )
968 {
970 // EminusP is treated as a kinematic freshwater flux (m/s).
971 Zt_avg1(i,j,0) = Zt_avg1(i,j,0) - EminusP(i,j,0) * dt_lev;
972 } else {
973 Zt_avg1(i,j,0) = Zt_avg1(i,j,0) - (evap(i,j,0) - rain(i,j,0)) * cff;
974 }
975 });
976 }
977 }
978 Gpu::streamSynchronize();
979
980 vec_Zt_avg1[lev]->FillBoundary(geom[lev].periodicity());
981
982 for ( MFIter mfi(*vec_zeta[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
983 {
984 Box bx3 = mfi.tilebox(); bx3.grow(IntVect(NGROW+1,NGROW+1,0));
985 Array4<Real> const& zeta = mf_zeta->array(mfi);
986 Array4<Real> const& Zt_avg1 = (mf_Zt_avg1)->array(mfi);
987
988 ParallelFor(bx3, 3, [=] AMREX_GPU_DEVICE (int i, int j, int , int n)
989 {
990 zeta(i,j,0,n) = Zt_avg1(i,j,0);
991 });
992 }
993}
994
995
996/**
997 * @param[in ] lev level to operate on
998 */
999void
1001{
1002 for ( MFIter mfi(*vec_mskr[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
1003 {
1004 Array4<const Real> const& mskr = vec_mskr[lev]->const_array(mfi);
1005 Array4< Real> const& msku = vec_msku[lev]->array(mfi);
1006 Array4< Real> const& mskv = vec_mskv[lev]->array(mfi);
1007 Array4< Real> const& mskp = vec_mskp[lev]->array(mfi);
1008
1009 // NGROW rings, not one: the stencil reaches mskr(i-1,j-1), and mskr carries NGROW+1.
1010 Box bx = mfi.tilebox(); bx.grow(IntVect(NGROW,NGROW,0)); bx.makeSlab(2,0);
1011
1012 ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int)
1013 {
1014 msku(i,j,0) = mskr(i-1,j ,0) * mskr(i,j,0);
1015 mskv(i,j,0) = mskr(i ,j-1,0) * mskr(i,j,0);
1016 // mskp is 2 along a straight land-sea boundary
1017 if ((mskr(i-1,j,0) > Real(0.5)) and (mskr(i,j,0) > Real(0.5)) and (mskr(i-1,j-1,0) > Real(0.5)) and (mskr(i,j-1,0) > Real(0.5))) {
1018 mskp(i,j,0) = one;
1019 } else if ((mskr(i-1,j,0) < Real(0.5)) and (mskr(i,j,0) > Real(0.5)) and (mskr(i-1,j-1,0) > Real(0.5)) and (mskr(i,j-1,0) > Real(0.5))) {
1020 mskp(i,j,0) = one;
1021 } else if ((mskr(i-1,j,0) > Real(0.5)) and (mskr(i,j,0) < Real(0.5)) and (mskr(i-1,j-1,0) > Real(0.5)) and (mskr(i,j-1,0) > Real(0.5))) {
1022 mskp(i,j,0) = one;
1023 } else if ((mskr(i-1,j,0) > Real(0.5)) and (mskr(i,j,0) > Real(0.5)) and (mskr(i-1,j-1,0) < Real(0.5)) and (mskr(i,j-1,0) > Real(0.5))) {
1024 mskp(i,j,0) = one;
1025 } else if ((mskr(i-1,j,0) > Real(0.5)) and (mskr(i,j,0) > Real(0.5)) and (mskr(i-1,j-1,0) > Real(0.5)) and (mskr(i,j-1,0) < Real(0.5))) {
1026 mskp(i,j,0) = one;
1027 } else if ((mskr(i-1,j,0) > Real(0.5)) and (mskr(i,j,0) < Real(0.5)) and (mskr(i-1,j-1,0) > Real(0.5)) and (mskr(i,j-1,0) < Real(0.5))) {
1028 mskp(i,j,0) = two;
1029 } else if ((mskr(i-1,j,0) < Real(0.5)) and (mskr(i,j,0) > Real(0.5)) and (mskr(i-1,j-1,0) < Real(0.5)) and (mskr(i,j-1,0) > Real(0.5))) {
1030 mskp(i,j,0) = two;
1031 } else if ((mskr(i-1,j,0) > Real(0.5)) and (mskr(i,j,0) > Real(0.5)) and (mskr(i-1,j-1,0) < Real(0.5)) and (mskr(i,j-1,0) < Real(0.5))) {
1032 mskp(i,j,0) = two;
1033 } else if ((mskr(i-1,j,0) < Real(0.5)) and (mskr(i,j,0) < Real(0.5)) and (mskr(i-1,j-1,0) > Real(0.5)) and (mskr(i,j-1,0) > Real(0.5))) {
1034 mskp(i,j,0) = two;
1035 } else {
1036 mskp(i,j,0) = zero;
1037 }
1038 });
1039 }
1040}
1041
1042/**
1043 * Rebuild the u-, v- and psi-point masks from vec_mskr and fill their ghost cells.
1044 *
1045 * Every path goes through here, so the levels cannot end up with different definitions.
1046 *
1047 * @param[in ] lev level to operate on
1048 */
1049void
1051{
1053
1054 vec_msku[lev]->FillBoundary(geom[lev].periodicity());
1055 vec_mskv[lev]->FillBoundary(geom[lev].periodicity());
1056 vec_mskp[lev]->FillBoundary(geom[lev].periodicity());
1057}
1058
1059/**
1060 * @param[in ] lev level to operate on
1061 */
1062void
1064{
1065 for ( MFIter mfi(*vec_mskr3d[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
1066 {
1067 Array4<const Real> const& mskr = vec_mskr[lev]->const_array(mfi);
1068 Array4< Real> const& mskr3d = vec_mskr3d[lev]->array(mfi);
1069
1070 // No stencil, so this can fill every ring mskr has.
1071 Box bx = mfi.tilebox(); bx.grow(IntVect(NGROW+1,NGROW+1,0));
1072
1073 ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
1074 {
1075 mskr3d(i,j,k) = mskr(i,j,0);
1076 });
1077 }
1078}
constexpr amrex::Real two
constexpr amrex::Real bogus_large_value
constexpr amrex::Real one
constexpr amrex::Real zero
constexpr amrex::Real rhow
#define NGROW
#define NAT
mf_h setVal(geomdata.ProbHi(2))
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr_full_domain
Land/sea mask at cell centers on the whole domain at each potential level. Specified at hires_grid_le...
Definition REMORA.H:421
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_EminusP
evaporation minus precipitation [kg/m^2/s], defined at rho-points
Definition REMORA.H:521
void set_grid_vars_averaged_down(int lev)
Set pm/pn by averaging down from higher-resolution grid.
Definition REMORA.cpp:828
int foextrap_periodic_bc() const noexcept
Definition REMORA.H:1492
int ncons
Number of conserved scalars in the state (temperature + salt + passive scalars + biology tracers)
Definition REMORA.H:1839
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr_crse_on_fine
the level's rho-, u- and v-masks copied onto the layout of the level above it coarsened,...
Definition REMORA.H:598
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta_full_domain
high resolution initial free surface height (2D)
Definition REMORA.H:581
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv2d
v velocity RHS (2D, includes horizontal and vertical advection)
Definition REMORA.H:436
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_evap
evaporation rate [kg/m^2/s]
Definition REMORA.H:517
int zvel_bc() const noexcept
Definition REMORA.H:1487
int xvel_bc() const noexcept
Definition REMORA.H:1485
amrex::Vector< amrex::BCRec > domain_bcs_type
vector (over BCVars) of BCRecs
Definition REMORA.H:1772
void calculate_nodal_masks(int lev)
Calculate u-, v-, and psi-point masks based on rho-point masks after analytic initialization.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_fcor
coriolis factor (2D)
Definition REMORA.H:612
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_btflux
Bottom tracer flux; input arrays.
Definition REMORA.H:512
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rubar
barotropic x velocity for the RHS (2D)
Definition REMORA.H:568
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xvel_full_domain
multilevel data container for high res initial x velocities (u in ROMS)
Definition REMORA.H:404
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_h
multilevel data container for current step's z velocities (largely unused; W stored separately)
Definition REMORA.H:413
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pm
horizontal scaling factor: 1 / dx (2D)
Definition REMORA.H:603
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ZoBot
Bottom roughness length [m], defined at rho points.
Definition REMORA.H:537
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DU_avg2
correct time average of barotropic x velocity flux for coupling (2D)
Definition REMORA.H:547
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_lrflx
longwave radiation
Definition REMORA.H:497
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yv
y_grid on v-points (2D)
Definition REMORA.H:627
amrex::Vector< amrex::MultiFab * > cons_new
multilevel data container for current step's scalar data: temperature, salinity, passive tracer
Definition REMORA.H:393
virtual void MakeNewLevelFromCoarse(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Make a new level using provided BoxArray and DistributionMapping and fill with interpolated coarse le...
void stretch_transform(int lev)
Calculate vertical stretched coordinates.
void define_flux_register(int lev)
build or rebuild the flux register between lev and lev-1
Definition REMORA.cpp:2799
void set_curvilinear_terms_from_grid_scale(int lev)
Set curvilinear derivative terms on level lev based on pm and pn.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vwind
Wind in the v direction, defined at rho-points.
Definition REMORA.H:486
std::unique_ptr< ProblemBase > prob
Pointer to container of analytical functions for problem definition.
Definition REMORA.H:1723
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr
land/sea mask at cell centers (2D)
Definition REMORA.H:584
void initializeTracers(amrex::ParGDBBase *, const amrex::Vector< std::unique_ptr< amrex::MultiFab > > &)
Initialize tracer and hydro particles.
void Construct_REMORAFillPatchers(int lev)
Construct FillPatchers.
Definition REMORA.cpp:586
void init_grid_vars_from_netcdf(int lev)
Grid variable initialization from NetCDF file.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rain
precipitation rate [kg/m^2/s]
Definition REMORA.H:515
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_tke
Turbulent kinetic energy.
Definition REMORA.H:667
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_stflx
Surface tracer flux; working arrays.
Definition REMORA.H:506
void update_nodal_masks(int lev)
Rebuild the u-, v- and psi-point masks from vec_mskr and fill their ghosts.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_gls
Turbulent generic length scale.
Definition REMORA.H:669
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_sustr
Surface stress in the u direction.
Definition REMORA.H:479
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yp
y_grid on psi-points (2D)
Definition REMORA.H:632
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xr
x_grid on rho points (2D)
Definition REMORA.H:615
int yvel_bc() const noexcept
Definition REMORA.H:1486
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Dvbar_new
see vec_Dvbar_old (2D)
Definition REMORA.H:560
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru2d
u velocity RHS (2D, includes horizontal and vertical advection)
Definition REMORA.H:434
virtual void ClearLevel(int lev) override
Delete level data Overrides the pure virtual function in AmrCore.
amrex::Vector< amrex::MultiFab * > zvel_new
multilevel data container for current step's z velocities (largely unused; W stored separately)
Definition REMORA.H:399
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_sstore
additional scratch space for calculations on temp, salt, etc
Definition REMORA.H:647
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xv
x_grid on v-points (2D)
Definition REMORA.H:625
void init_only(int lev, amrex::Real time)
Init (NOT restart or regrid)
Definition REMORA.cpp:1857
void init_set_vmix(int lev)
Initialize vertical mixing coefficients from file or analytic.
Definition REMORA.cpp:959
void set_grid_scale(int lev)
Set pm and pn arrays and x/y coords on level lev.
void set_coriolis(int lev)
Initialize Coriolis factor from file or analytic.
Definition REMORA.cpp:930
int foextrap_bc() const noexcept
Definition REMORA.H:1493
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Lscale
Vertical mixing turbulent length scale.
Definition REMORA.H:671
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Hz
Width of cells in the vertical (z-) direction (3D, Hz in ROMS)
Definition REMORA.H:424
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akt
Vertical diffusion coefficient (3D)
Definition REMORA.H:444
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_msku
land/sea mask at x-faces (2D)
Definition REMORA.H:586
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rvfrc
v velocity RHS, integrated, including advection and bottom/surface stresses (2D)
Definition REMORA.H:440
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pm_full_domain
horizontal scaling factor: 1 / dx (2D) on whole domain
Definition REMORA.H:607
amrex::Vector< amrex::MultiFab * > xvel_old
multilevel data container for last step's x velocities (u in ROMS)
Definition REMORA.H:386
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Dubar_old
DU_avg2 per unit cell edge length, at the start and end of this level's step. What a subcycled finer ...
Definition REMORA.H:554
amrex::Vector< amrex::MultiFab * > yvel_new
multilevel data container for current step's y velocities (v in ROMS)
Definition REMORA.H:397
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_uwind
Wind in the u direction, defined at rho-points.
Definition REMORA.H:484
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rufrc
u velocity RHS, integrated, including advection and bottom/surface stresses (2D)
Definition REMORA.H:438
int zeta_bc() const noexcept
Definition REMORA.H:1490
void Define_REMORAFillPatchers(int lev)
Define FillPatchers.
Definition REMORA.cpp:642
int num_bdy_vars() const noexcept
Definition REMORA.H:1504
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_shflx
sensible heat flux
Definition REMORA.H:503
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_visc2_p
Harmonic viscosity defined on the psi points (corners of horizontal grid cells)
Definition REMORA.H:446
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_dmde
d(1/m)/d(eta)
Definition REMORA.H:644
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rvbar
barotropic y velocity for the RHS (2D)
Definition REMORA.H:570
amrex::Vector< amrex::MultiFab * > zvel_old
multilevel data container for last step's z velocities (largely unused; W stored separately)
Definition REMORA.H:390
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_z_r
z coordinates at rho points (cell centers)
Definition REMORA.H:453
amrex::Vector< amrex::MultiFab * > xvel_new
multilevel data container for current step's x velocities (u in ROMS)
Definition REMORA.H:395
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_lhflx
latent heat flux
Definition REMORA.H:501
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskp
land/sea mask at cell corners (2D)
Definition REMORA.H:590
int bdy_zeta() const noexcept
Definition REMORA.H:1503
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_bvf
Brunt-Vaisala frequency (3D)
Definition REMORA.H:654
virtual void RemakeLevel(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Remake an existing level using provided BoxArray and DistributionMapping and fill with existing fine ...
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_lonp
longitude on psi-points (2D, degrees east); only filled when the grid NetCDF file carries lon_psi
Definition REMORA.H:636
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskv
land/sea mask at y-faces (2D)
Definition REMORA.H:588
void init_masks(int lev, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm)
Allocate MultiFabs for masks.
amrex::Vector< std::unique_ptr< REMORAPhysBCFunct > > physbcs
Vector (over level) of functors to apply physical boundary conditions.
Definition REMORA.H:1754
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_msku_crse_on_fine
Definition REMORA.H:599
void fill_3d_masks(int lev)
Copy maskr to all z levels.
void FillCoarsePatch(int lev, amrex::Real time, amrex::MultiFab *mf_fine, amrex::MultiFab *mf_crse, const int bccomp, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=zero, const amrex::MultiFab &mf_calc=amrex::MultiFab())
fill an entire multifab by interpolating from the coarser level
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rhoS
density perturbation
Definition REMORA.H:650
void init_riv_pos_from_netcdf(int lev)
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_visc2_r
Harmonic viscosity defined on the rho points (centers)
Definition REMORA.H:448
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yvel_full_domain
multilevel data container for high res initial y velocities (v in ROMS)
Definition REMORA.H:406
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_svstr
Surface stress in the v direction.
Definition REMORA.H:481
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Huon
u-volume flux (3D)
Definition REMORA.H:426
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_h_full_domain
Bathymetry data on the whole domain at each potential level.
Definition REMORA.H:416
amrex::Vector< amrex::MultiFab * > yvel_old
multilevel data container for last step's y velocities (v in ROMS)
Definition REMORA.H:388
void init_stuff(int lev, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm)
Allocate MultiFabs for state and evolution variables.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rhoA
vertically-averaged density
Definition REMORA.H:652
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DV_avg1
time average of barotropic y velocity flux
Definition REMORA.H:549
int hires_init_level
Which level the high resolution initialization data is at.
Definition REMORA.H:2087
int bdy_vbar() const noexcept
Definition REMORA.H:1502
amrex::Vector< amrex::Real > t_new
new time at each level, in seconds since start_time
Definition REMORA.H:1744
void init_bdry_from_netcdf(int lev)
Boundary data initialization from NetCDF file.
static SolverChoice solverChoice
Container for algorithmic choices.
Definition REMORA.H:2017
void set_grid_coords_from_grid_scale(int lev)
Set x/y coords on level lev based on pm and pn.
void resize_stuff(int lev)
Resize variable containers to accommodate data on levels 0 to max_lev.
amrex::Vector< std::unique_ptr< amrex::iMultiFab > > vec_river_position
iMultiFab for river positions; contents are indices of rivers
Definition REMORA.H:1671
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akk
Turbulent kinetic energy vertical diffusion coefficient.
Definition REMORA.H:673
void set_masks(int lev)
Initialize land-sea masks from file or analytic.
Definition REMORA.cpp:999
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rdrag2
Quadratic drag coefficient [unitless], defined at rho points.
Definition REMORA.H:535
void set_zeta_to_Ztavg(int lev, bool apply_eminusp=true)
Set zeta components to be equal to time-averaged Zt_avg1.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru
u velocity RHS (3D, includes horizontal and vertical advection)
Definition REMORA.H:430
int bdy_ubar() const noexcept
Definition REMORA.H:1501
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xp
x_grid on psi-points (2D)
Definition REMORA.H:630
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_longwave_down
Downward longwave radiation.
Definition REMORA.H:499
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta
free surface height (2D)
Definition REMORA.H:578
int ubar_bc() const noexcept
Definition REMORA.H:1488
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vbar
barotropic y velocity (2D)
Definition REMORA.H:576
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DU_avg1
time average of barotropic x velocity flux (2D)
Definition REMORA.H:545
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_alpha
Thermal expansion coefficient (3D)
Definition REMORA.H:656
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ubar
barotropic x velocity (2D)
Definition REMORA.H:574
void FillPatch(int lev, amrex::Real time, amrex::MultiFab &mf_to_be_filled, amrex::Vector< amrex::MultiFab * > const &mfs, const int bccomp, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const bool fill_set=false, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=zero, const amrex::MultiFab &mf_calc=amrex::MultiFab(), amrex::Vector< amrex::MultiFab * > const &mfs_crse_old={}, amrex::Vector< amrex::MultiFab * > const &mfs_crse_new={})
Fill a new MultiFab by copying in phi from valid region and filling ghost cells.
amrex::Vector< amrex::MultiFab * > cons_old
multilevel data container for last step's scalar data: temperature, salinity, passive tracer
Definition REMORA.H:384
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_bustr
Bottom stress in the u direction.
Definition REMORA.H:540
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_cons_full_domain
multilevel data container for high res initial data: temperature, salinity, passive tracer
Definition REMORA.H:402
int vbar_bc() const noexcept
Definition REMORA.H:1489
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DV_avg2
correct time average of barotropic y velocity flux for coupling (2D)
Definition REMORA.H:551
void set_hmixcoef(int lev)
Initialize horizontal mixing coefficients.
Definition REMORA.cpp:1424
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yu
y_grid on u-points (2D)
Definition REMORA.H:622
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_dndx
d(1/n)/d(xi)
Definition REMORA.H:642
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_bvstr
Bottom stress in the v direction.
Definition REMORA.H:542
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rzeta
free surface height for the RHS (2D)
Definition REMORA.H:572
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_z_phys_nd
z coordinates at psi points (cell nodes)
Definition REMORA.H:473
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Dvbar_old
DV_avg2 per unit cell edge length, see vec_Dubar_old (2D)
Definition REMORA.H:558
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xu
x_grid on u-points (2D)
Definition REMORA.H:620
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pn_full_domain
horizontal scaling factor: 1 / dy (2D) on whole domain
Definition REMORA.H:609
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > vec_nudg_coeff
Climatology nudging coefficients.
Definition REMORA.H:678
void set_weights(int lev)
Set weights for averaging 3D variables to 2D.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pn
horizontal scaling factor: 1 / dy (2D)
Definition REMORA.H:605
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akv
Vertical viscosity coefficient (3D)
Definition REMORA.H:442
virtual void MakeNewLevelFromScratch(int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) override
Make a new level from scratch using provided BoxArray and DistributionMapping. Only used during initi...
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskv_crse_on_fine
Definition REMORA.H:600
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_stflux
Surface tracer flux; input arrays.
Definition REMORA.H:508
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Dubar_new
see vec_Dubar_old (2D)
Definition REMORA.H:556
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rdrag
Linear drag coefficient [m/s], defined at rho points.
Definition REMORA.H:533
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_cloud
cloud cover fraction [0-1], defined at rho-points
Definition REMORA.H:519
ParticleData particleData
Particle container with all particle species.
Definition REMORA.H:2030
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Zt_avg1
Average of the free surface, zeta (2D)
Definition REMORA.H:476
std::string restart_chkfile
If set, restart from this checkpoint file.
Definition REMORA.H:1825
void init_clim_nudg_coeff(int lev)
Wrapper to initialize climatology nudging coefficient.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv
v velocity RHS (3D, includes horizontal and vertical advection)
Definition REMORA.H:432
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_btflx
Bottom tracer flux; working arrays.
Definition REMORA.H:510
int cf_width
Nudging width at coarse-fine interface.
Definition REMORA.H:1681
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_beta
Saline contraction coefficient (3D)
Definition REMORA.H:658
amrex::Vector< amrex::Real > t_old
old time at each level, in seconds since start_time
Definition REMORA.H:1746
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr3d
land/sea mask at cell centers, copied to all z levels (3D)
Definition REMORA.H:592
amrex::Vector< amrex::GpuArray< amrex::Real, AMREX_SPACEDIM *2 > > m_bc_extdir_vals
Array holding the Dirichlet values at walls which need them.
Definition REMORA.H:1780
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_srflx
Shortwave radiation flux [W/m²], defined at rho-points.
Definition REMORA.H:495
void set_bathymetry_averaged_down(int lev)
Copy over bathymetry data that has been averaged down from high resolution input netcdf file.
Definition REMORA.cpp:813
amrex::Vector< amrex::Real > dt
time step at each level
Definition REMORA.H:1748
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Pair
Air pressure [mb], defined at rho-points.
Definition REMORA.H:492
amrex::Gpu::DeviceVector< amrex::BCRec > domain_bcs_type_d
GPU vector (over BCVars) of BCRecs.
Definition REMORA.H:1774
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_qair
Specific humidity [kg/kg], defined at rho-points.
Definition REMORA.H:490
int hires_grid_level
Which level the high resolution bathymetry is at.
Definition REMORA.H:2080
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_z_w
z coordinates at w points (faces between z-cells)
Definition REMORA.H:456
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Tair
Air temperature [°C], defined at rho-points.
Definition REMORA.H:488
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yr
y_grid on rho points (2D)
Definition REMORA.H:617
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Hvom
v-volume flux (3D)
Definition REMORA.H:428
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akp
Turbulent length scale vertical diffusion coefficient.
Definition REMORA.H:675
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_diff2
Harmonic diffusivity for temperature / salinity.
Definition REMORA.H:450
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_latp
latitude on psi-points (2D, degrees north); only filled when the grid NetCDF file carries lat_psi
Definition REMORA.H:639
static constexpr int cons_bc
static constexpr int Temp_bc_comp
static constexpr int t
cons component Temp_comp
static constexpr int u
static constexpr int v
int cons(int icomp) noexcept
static constexpr int null
@ EminusP
evaporation minus precipitation [m/s]
amrex::Real rdrag2
amrex::Real Akk_bak
amrex::Real EminusP
BottomStressType bottom_stress_type
amrex::Real longwave_rad
amrex::Real gls_Kmin
amrex::Real rdrag
VertMixingType vert_mixing_type
std::array< BulkForcingType, BulkFlux::NumTypes > bulk_flux_type
GridScaleType grid_scale_type
amrex::Real gls_Pmin
amrex::Real Akp_bak