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
48 resize_stuff(lev);
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
64 init_masks(lev, ba, dm);
65
66 init_stuff(lev, ba, dm);
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
92
93 if (lev > hires_grid_level) {
94 FillCoarsePatch(lev, time, vec_h[lev].get(), vec_h[lev-1].get(),
96 } else {
98 }
99
100 FillCoarsePatch(lev, time, vec_Zt_avg1[lev].get(), vec_Zt_avg1[lev-1].get(),BCVars::cons_bc);
101 for (int icomp=0; icomp<3; icomp++) {
102 FillCoarsePatch(lev, time, vec_ubar[lev].get(), vec_ubar[lev-1].get(), ubar_bc(),
103 BdyVars::ubar,icomp,false);
104 FillCoarsePatch(lev, time, vec_vbar[lev].get(), vec_vbar[lev-1].get(), vbar_bc(),
105 BdyVars::vbar,icomp,false);
106 }
107 for (int icomp=0; icomp<2; icomp++) {
108 FillCoarsePatch(lev, time, vec_ru[lev].get(), vec_ru[lev-1].get(), xvel_bc(),
109 BdyVars::null,icomp,false);
110 FillCoarsePatch(lev, time, vec_rv[lev].get(), vec_rv[lev-1].get(), yvel_bc(),
111 BdyVars::null,icomp,false);
112 FillCoarsePatch(lev, time, vec_ru2d[lev].get(), vec_ru2d[lev-1].get(), xvel_bc(),
113 BdyVars::null,icomp,false);
114 FillCoarsePatch(lev, time, vec_rv2d[lev].get(), vec_rv2d[lev-1].get(), yvel_bc(),
115 BdyVars::null,icomp,false);
116 }
117
118 // Not totally sure foextrap is right here
119 FillCoarsePatchPC(lev, time, vec_mskr[lev].get(), vec_mskr[lev-1].get(),
120 foextrap_bc());
121
123
124
125 set_grid_scale(lev);
127
128 init_set_vmix(lev);
129 set_hmixcoef(lev);
130 set_coriolis(lev);
132 // Previously set smflux
133
134#ifdef REMORA_USE_NETCDF
137 }
138#endif
139
140 // ********************************************************************************************
141 // If we are making a new level then the FillPatcher for this level hasn't been allocated yet
142 // ********************************************************************************************
143 if (cf_width >= 0) {
146 }
147
148#ifdef REMORA_USE_PARTICLES
149 // particleData.Redistribute();
150#endif
151}
152
153/**
154 * Remake an existing level using provided BoxArray and DistributionMapping and
155 * fill with existing fine and coarse data.
156 * overrides the pure virtual function in AmrCore
157 * @param[in ] lev level to make
158 * @param[in ] time current time
159 * @param[in ] ba BoxArray for the level
160 * @param[in ] dm DistributionMapping for the level
161 */
162void
163REMORA::RemakeLevel (int lev, Real time, const BoxArray& ba, const DistributionMapping& dm)
164{
165 BoxArray ba_old(cons_new[lev]->boxArray());
166 DistributionMapping dm_old(cons_new[lev]->DistributionMap());
167
168 BoxList bl2d = ba.boxList();
169 for (auto& b : bl2d) {
170 b.setRange(2,0);
171 }
172 BoxArray ba2d(std::move(bl2d));
173
174 amrex::Print() << "Remaking level " << lev << std::endl;
175 amrex::Print() << "GRIDS AT LEVEL " << lev << " ARE " << ba << std::endl;
176
177#if (NGROW==2)
178 int ngrow_state = ComputeGhostCells(solverChoice.spatial_order)+1;
179 int ngrow_vels = ComputeGhostCells(solverChoice.spatial_order)+1;
180 int ngrow_zeta = ComputeGhostCells(solverChoice.spatial_order)+1;
182 int ngrow_velbar = ComputeGhostCells(solverChoice.spatial_order);
183#else
184 int ngrow_state = ComputeGhostCells(solverChoice.spatial_order)+2;
185 int ngrow_vels = ComputeGhostCells(solverChoice.spatial_order)+2;
186 int ngrow_zeta = ComputeGhostCells(solverChoice.spatial_order)+2;
188 int ngrow_velbar = ComputeGhostCells(solverChoice.spatial_order)+1;
189#endif
190
191 MultiFab tmp_cons_new(ba, dm, ncons, ngrow_state);
192 MultiFab tmp_cons_old(ba, dm, ncons, ngrow_state);
193
194 MultiFab tmp_xvel_new(convert(ba, IntVect(1,0,0)), dm, 1, ngrow_vels);
195 MultiFab tmp_xvel_old(convert(ba, IntVect(1,0,0)), dm, 1, ngrow_vels);
196
197 MultiFab tmp_yvel_new(convert(ba, IntVect(0,1,0)), dm, 1, ngrow_vels);
198 MultiFab tmp_yvel_old(convert(ba, IntVect(0,1,0)), dm, 1, ngrow_vels);
199
200 MultiFab tmp_zvel_new(convert(ba, IntVect(0,0,1)), dm, 1, IntVect(ngrow_vels,ngrow_vels,0));
201 MultiFab tmp_zvel_old(convert(ba, IntVect(0,0,1)), dm, 1, IntVect(ngrow_vels,ngrow_vels,0));
202
203 MultiFab tmp_Zt_avg1_new(ba2d, dm, 1, IntVect(ngrow_zeta,ngrow_zeta,0));
204 MultiFab tmp_h(ba2d, dm, 2, IntVect(ngrow_h,ngrow_h,0));
205
206 MultiFab tmp_ubar_new(convert(ba2d, IntVect(1,0,0)), dm, 3, IntVect(ngrow_velbar,ngrow_velbar,0));
207
208 MultiFab tmp_vbar_new(convert(ba2d, IntVect(0,1,0)), dm, 3, IntVect(ngrow_velbar,ngrow_velbar,0));
209
210 MultiFab tmp_ru_new(convert(ba, IntVect(1,0,0)),dm,2,IntVect(NGROW,NGROW,0));
211 MultiFab tmp_rv_new(convert(ba, IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0));
212
213 MultiFab tmp_ru2d_new(convert(ba2d, IntVect(1,0,0)),dm,2,IntVect(NGROW,NGROW,0));
214 MultiFab tmp_rv2d_new(convert(ba2d, IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0));
215
216 init_masks(lev, ba, dm);
217
218 tmp_cons_new.setVal(zero);
219 tmp_xvel_new.setVal(zero);
220 tmp_yvel_new.setVal(zero);
221 tmp_zvel_new.setVal(zero);
222
223 tmp_cons_old.setVal(zero);
224 tmp_xvel_old.setVal(zero);
225 tmp_yvel_old.setVal(zero);
226 tmp_zvel_old.setVal(zero);
227
228 tmp_ru_new.setVal(zero);
229 tmp_rv_new.setVal(zero);
230
231 tmp_ru2d_new.setVal(zero);
232 tmp_rv2d_new.setVal(zero);
233
234 tmp_ubar_new.setVal(zero);
235 tmp_vbar_new.setVal(zero);
236
237
238 // This will fill the temporary MultiFabs with data from previous fine data as well as coarse where needed
239 FillPatch(lev, time, tmp_cons_new, cons_new, BCVars::cons_bc, BdyVars::t,0,true,false);
240 FillPatch(lev, time, tmp_xvel_new, xvel_new, xvel_bc(), BdyVars::u,0,true,false,0,0,zero,tmp_xvel_new);
241 FillPatch(lev, time, tmp_yvel_new, yvel_new, yvel_bc(), BdyVars::v,0,true,false,0,0,zero,tmp_yvel_new);
242 FillPatch(lev, time, tmp_zvel_new, zvel_new, zvel_bc(), BdyVars::null,0,true,false);
243 FillPatch(lev, time, tmp_Zt_avg1_new, GetVecOfPtrs(vec_Zt_avg1), zeta_bc(), BdyVars::null,0,true,false);
244
245 for (int icomp=0; icomp<3; icomp++) {
246 FillPatch(lev, time, tmp_ubar_new, GetVecOfPtrs(vec_ubar), ubar_bc(), BdyVars::ubar, icomp,false,false);
247 FillPatch(lev, time, tmp_vbar_new, GetVecOfPtrs(vec_vbar), vbar_bc(), BdyVars::vbar, icomp,false,false);
248 }
249 for (int icomp=0; icomp<2; icomp++) {
250 FillPatch(lev, time, tmp_ru_new, GetVecOfPtrs(vec_ru), xvel_bc(), BdyVars::null, icomp,false,false);
251 FillPatch(lev, time, tmp_rv_new, GetVecOfPtrs(vec_rv), yvel_bc(), BdyVars::null, icomp,false,false);
252 // These might want to have BCVars::ubar_bc and vbar_bc
253 FillPatch(lev, time, tmp_ru2d_new, GetVecOfPtrs(vec_ru2d), xvel_bc(), BdyVars::null, icomp,false,false);
254 FillPatch(lev, time, tmp_rv2d_new, GetVecOfPtrs(vec_rv2d), yvel_bc(), BdyVars::null, icomp,false,false);
255 }
256
257 MultiFab::Copy(tmp_cons_old,tmp_cons_new,0,0,ncons,tmp_cons_new.nGrowVect());
258 MultiFab::Copy(tmp_xvel_old,tmp_xvel_new,0,0, 1,tmp_xvel_new.nGrowVect());
259 MultiFab::Copy(tmp_yvel_old,tmp_yvel_new,0,0, 1,tmp_yvel_new.nGrowVect());
260 MultiFab::Copy(tmp_zvel_old,tmp_zvel_new,0,0, 1,tmp_zvel_new.nGrowVect());
261
262 std::swap(tmp_cons_new, *cons_new[lev]);
263 std::swap(tmp_cons_old, *cons_old[lev]);
264 std::swap(tmp_xvel_new, *xvel_new[lev]);
265 std::swap(tmp_xvel_old, *xvel_old[lev]);
266 std::swap(tmp_yvel_new, *yvel_new[lev]);
267 std::swap(tmp_yvel_old, *yvel_old[lev]);
268 std::swap(tmp_zvel_new, *zvel_new[lev]);
269 std::swap(tmp_zvel_old, *zvel_old[lev]);
270 std::swap(tmp_Zt_avg1_new, *vec_Zt_avg1[lev]);
271 std::swap(tmp_ubar_new, *vec_ubar[lev]);
272 std::swap(tmp_vbar_new, *vec_vbar[lev]);
273 std::swap(tmp_ru_new, *vec_ru[lev]);
274 std::swap(tmp_rv_new, *vec_rv[lev]);
275 std::swap(tmp_ru2d_new, *vec_ru2d[lev]);
276 std::swap(tmp_rv2d_new, *vec_rv2d[lev]);
277
278 // Handle bathymetry separately
279 if (lev > hires_grid_level) {
280 FillPatch(lev, time, tmp_h, GetVecOfPtrs(vec_h), BCVars::cons_bc, BdyVars::null,0,false,false);
281 FillPatch(lev, time, tmp_h, GetVecOfPtrs(vec_h), BCVars::cons_bc, BdyVars::null,1,false,false);
282 std::swap(tmp_h, *vec_h[lev]);
283 } else {
285 }
286
287 t_new[lev] = time;
289
290 init_masks(lev, ba, dm);
291 FillCoarsePatchPC(lev, time, vec_mskr[lev].get(), vec_mskr[lev-1].get(),
292 foextrap_bc());
294
295 init_stuff(lev, ba, dm);
296
297 set_grid_scale(lev);
299
300 init_set_vmix(lev);
301 set_hmixcoef(lev);
302 set_coriolis(lev);
304 // Previously set smflux here
305
306#ifdef REMORA_USE_NETCDF
309 }
310#endif
311
312 // We need to re-define the FillPatcher if the grids have changed
313 if (lev > 0 && cf_width >= 0) {
314 bool ba_changed = (ba != ba_old);
315 bool dm_changed = (dm != dm_old);
316 if (ba_changed || dm_changed) {
318 }
319 }
320
321#ifdef REMORA_USE_PARTICLES
322 particleData.Redistribute();
323#endif
324}
325
326/**
327 * Make a new level from scratch using provided BoxArray and DistributionMapping.
328 * This is called both for initialization and for restart
329 * (overrides the pure virtual function in AmrCore)
330 * main.cpp --> REMORA::InitData --> InitFromScratch --> MakeNewGrids --> MakeNewLevelFromScratch
331 * restart --> MakeNewGrids --> MakeNewLevelFromScratch
332 *
333 * @param[in ] lev level to make
334 * @param[in ] time current time
335 * @param[in ] ba BoxArray for the level
336 * @param[in ] dm DistributionMapping for the level
337 */
338void REMORA::MakeNewLevelFromScratch (int lev, Real time, const BoxArray& ba,
339 const DistributionMapping& dm)
340{
341 // Set BoxArray grids and DistributionMapping dmap in AMReX_AmrMesh.H class
342 SetBoxArray(lev, ba);
343 SetDistributionMap(lev, dm);
344
345 BoxList bl2d = ba.boxList();
346 for (auto& b : bl2d) {
347 b.setRange(2,0);
348 }
349 BoxArray ba2d(std::move(bl2d));
350
351 amrex::Print() << "Making level " << lev << " from scratch" << std::endl;
352 amrex::Print() << "GRIDS AT LEVEL " << lev << " ARE " << ba << std::endl;
353
354 // The number of ghost cells for density must be 1 greater than that for velocity
355 // so that we can go back in forth between velocity and momentum on all faces
356#if NGROW==2
357 int ngrow_state = ComputeGhostCells(solverChoice.spatial_order)+1;
358 int ngrow_vels = ComputeGhostCells(solverChoice.spatial_order)+1;
359#else
360 int ngrow_state = ComputeGhostCells(solverChoice.spatial_order)+2;
361 int ngrow_vels = ComputeGhostCells(solverChoice.spatial_order)+2;
362#endif
363
364 cons_old[lev] = new MultiFab(ba, dm, ncons, ngrow_state);
365 cons_new[lev] = new MultiFab(ba, dm, ncons, ngrow_state);
366
367 xvel_new[lev] = new MultiFab(convert(ba, IntVect(1,0,0)), dm, 1, ngrow_vels);
368 xvel_old[lev] = new MultiFab(convert(ba, IntVect(1,0,0)), dm, 1, ngrow_vels);
369
370 yvel_new[lev] = new MultiFab(convert(ba, IntVect(0,1,0)), dm, 1, ngrow_vels);
371 yvel_old[lev] = new MultiFab(convert(ba, IntVect(0,1,0)), dm, 1, ngrow_vels);
372
373 zvel_new[lev] = new MultiFab(convert(ba, IntVect(0,0,1)), dm, 1, IntVect(ngrow_vels,ngrow_vels,0));
374 zvel_old[lev] = new MultiFab(convert(ba, IntVect(0,0,1)), dm, 1, IntVect(ngrow_vels,ngrow_vels,0));
375
376 resize_stuff(lev);
377
378 vec_Zt_avg1[lev].reset(new MultiFab(ba2d ,dm,1,IntVect(NGROW+1,NGROW+1,0))); //2d, average of the free surface (zeta)
379 vec_h[lev].reset(new MultiFab(ba2d ,dm,2,IntVect(NGROW+1,NGROW+1,0))); //2d, bathymetry
380 vec_ubar[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,3,IntVect(NGROW,NGROW,0)));
381 vec_vbar[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,3,IntVect(NGROW,NGROW,0)));
382
383 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)
384 vec_rv[lev].reset(new MultiFab(convert(ba,IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0))); // RHS v
385
386 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)
387 vec_rv2d[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0))); // RHS v
388
389 init_masks(lev, ba, dm);
390 init_stuff(lev, ba, dm);
391
392 init_only(lev, time);
393
394#ifdef REMORA_USE_PARTICLES
395 if (restart_chkfile.empty()) {
396 if (lev == 0) {
397 initializeTracers((ParGDBBase*)GetParGDB(),vec_z_phys_nd);
398 } else {
399 particleData.Redistribute();
400 }
401 }
402#endif
403}
404
405/**
406 * @param[in ] lev level do operate on
407 */
409{
410 vec_z_phys_nd.resize(lev+1);
411
413
414 vec_h.resize(lev+1);
415 vec_Zt_avg1.resize(lev+1);
416 vec_z_w.resize(lev+1);
417 vec_z_r.resize(lev+1);
418 vec_Hz.resize(lev+1);
419 vec_Huon.resize(lev+1);
420 vec_Hvom.resize(lev+1);
421 vec_Akv.resize(lev+1);
422 vec_Akt.resize(lev+1);
423 vec_visc2_p.resize(lev+1);
424 vec_visc2_r.resize(lev+1);
425 vec_diff2.resize(lev+1);
426 vec_ru.resize(lev+1);
427 vec_rv.resize(lev+1);
428 vec_ru2d.resize(lev+1);
429 vec_rv2d.resize(lev+1);
430 vec_rufrc.resize(lev+1);
431 vec_rvfrc.resize(lev+1);
432 vec_sustr.resize(lev+1);
433 vec_svstr.resize(lev+1);
434 vec_btflx.resize(lev+1);
435 vec_stflx.resize(lev+1);
436 vec_btflux.resize(lev+1);
437 vec_stflux.resize(lev+1);
438 vec_lrflx.resize(lev+1);
439 vec_longwave_down.resize(lev+1);
440 vec_lhflx.resize(lev+1);
441 vec_shflx.resize(lev+1);
442 vec_rain.resize(lev+1);
443 vec_evap.resize(lev+1);
444 vec_rdrag.resize(lev+1);
445 vec_rdrag2.resize(lev+1);
446 vec_ZoBot.resize(lev+1);
447 vec_bustr.resize(lev+1);
448 vec_bvstr.resize(lev+1);
449 vec_uwind.resize(lev+1);
450 vec_vwind.resize(lev+1);
451 vec_Tair.resize(lev+1);
452 vec_qair.resize(lev+1);
453 vec_Pair.resize(lev+1);
454 vec_srflx.resize(lev+1);
455 vec_cloud.resize(lev+1);
456 vec_EminusP.resize(lev+1);
457 vec_alpha.resize(lev+1);
458 vec_beta.resize(lev+1);
459
460 vec_DU_avg1.resize(lev+1);
461 vec_DU_avg2.resize(lev+1);
462 vec_DV_avg1.resize(lev+1);
463 vec_DV_avg2.resize(lev+1);
464 vec_rubar.resize(lev+1);
465 vec_rvbar.resize(lev+1);
466 vec_rzeta.resize(lev+1);
467 vec_ubar.resize(lev+1);
468 vec_vbar.resize(lev+1);
469 vec_zeta.resize(lev+1);
471 vec_mskr.resize(lev+1);
472 vec_msku.resize(lev+1);
473 vec_mskv.resize(lev+1);
474 vec_mskp.resize(lev+1);
475 vec_mskr3d.resize(lev+1);
476 vec_sstore.resize(lev+1);
477
481
482 vec_pm.resize(lev+1);
483 vec_pn.resize(lev+1);
484 vec_fcor.resize(lev+1);
487
488 vec_xr.resize(lev+1);
489 vec_yr.resize(lev+1);
490 vec_xu.resize(lev+1);
491 vec_yu.resize(lev+1);
492 vec_xv.resize(lev+1);
493 vec_yv.resize(lev+1);
494 vec_xp.resize(lev+1);
495 vec_yp.resize(lev+1);
496 vec_lonp.resize(lev+1);
497 vec_latp.resize(lev+1);
498
499 vec_dndx.resize(lev+1);
500 vec_dmde.resize(lev+1);
501
502 vec_rhoS.resize(lev+1);
503 vec_rhoA.resize(lev+1);
504 vec_bvf.resize(lev+1);
505
506 vec_tke.resize(lev+1);
507 vec_gls.resize(lev+1);
508 vec_Lscale.resize(lev+1);
509 vec_Akk.resize(lev+1);
510 vec_Akp.resize(lev+1);
511
512 vec_river_position.resize(lev+1);
513
514 if (lev==0) vec_nudg_coeff.resize(BdyVars::NumTypes);
515
516 vec_nudg_coeff[BdyVars::u].resize(lev+1);
517 vec_nudg_coeff[BdyVars::v].resize(lev+1);
518 vec_nudg_coeff[BdyVars::t].resize(lev+1);
519 vec_nudg_coeff[BdyVars::s].resize(lev+1);
520 vec_nudg_coeff[BdyVars::ubar].resize(lev+1);
521 vec_nudg_coeff[BdyVars::vbar].resize(lev+1);
522 vec_nudg_coeff[BdyVars::zeta].resize(lev+1);
523}
524
525/**
526 * @param[in ] lev level to operate on
527 * @param[in ] ba BoxArray for the level
528 * @param[in ] dm DistributionMapping for the level
529 */
530void REMORA::init_masks (int lev, const BoxArray& ba, const DistributionMapping& dm)
531{
532 BoxList bl2d = ba.boxList();
533 for (auto& b : bl2d) {
534 b.setRange(2,0);
535 }
536
537 BoxArray ba2d(std::move(bl2d));
538 vec_mskr[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
539 vec_msku[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW+1,NGROW+1,0)));
540 vec_mskv[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW+1,NGROW+1,0)));
541 vec_mskp[lev].reset(new MultiFab(convert(ba2d,IntVect(1,1,0)),dm,1,IntVect(NGROW+1,NGROW+1,0)));
542
543 vec_mskr3d[lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,0)));
544
545 vec_mskr[lev]->setVal(one);
546 vec_msku[lev]->setVal(one);
547 vec_mskv[lev]->setVal(one);
548 vec_mskp[lev]->setVal(one);
549
550 vec_mskr3d[lev]->setVal(one);
551}
552
553/**
554 * @param[in ] lev level to operate on
555 * @param[in ] ba BoxArray for the level
556 * @param[in ] dm DistributionMapping for the level
557 */
558void REMORA::init_stuff (int lev, const BoxArray& ba, const DistributionMapping& dm)
559{
560 // ********************************************************************************************
561 // Initialize the boundary conditions
562 // ********************************************************************************************
563 physbcs[lev] = std::make_unique<REMORAPhysBCFunct> (lev, geom[lev], domain_bcs_type, domain_bcs_type_d,
565
566 BoxList bl2d = ba.boxList();
567 for (auto& b : bl2d) {
568 b.setRange(2,0);
569 }
570 BoxArray ba2d(std::move(bl2d));
571
572 BoxList bl1d = ba.boxList();
573 for (auto& b : bl1d) {
574 b.setRange(0,0);
575 b.setRange(1,0);
576 }
577 BoxArray ba1d(std::move(bl1d));
578
579 BoxArray ba_nd(ba);
580 ba_nd.surroundingNodes();
581 BoxArray ba_w(ba);
582 ba_w.surroundingNodes(2);
583
584 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
585 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)
586 vec_z_r[lev].reset (new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,0))); // z at r points (cell center)
587 vec_Hz[lev].reset (new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,NGROW+1))); // like in ROMS, thickness of cell in z
588
589 vec_Huon[lev].reset (new MultiFab(convert(ba,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0))); // mass flux for u component
590 vec_Hvom[lev].reset (new MultiFab(convert(ba,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0))); // mass flux for v component
591
592 vec_Akv[lev].reset (new MultiFab(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW,NGROW,0))); // vertical mixing coefficient (.in)
593 vec_Akt[lev].reset (new MultiFab(convert(ba,IntVect(0,0,1)),dm,ncons,IntVect(NGROW,NGROW,0))); // vertical mixing coefficient (.in)
594
595 // check dimensionality
596 vec_visc2_p[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); // harmonic viscosity at psi points -- difference to 3d?
597 vec_visc2_r[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); // harmonic viscosity at rho points
598 vec_diff2[lev].reset(new MultiFab(ba2d,dm,ncons,IntVect(NGROW,NGROW,0))); // harmonic diffusivity temperature/salt
599
600 //2d, (incl advection terms and surface/bottom stresses, integral over the whole column, k=0)
601 vec_rufrc[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,2,IntVect(NGROW,NGROW,0)));
602 vec_rvfrc[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,2,IntVect(NGROW,NGROW,0))); //2d, same as above but v
603
604 vec_sustr[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0))); //2d, surface stress
605 vec_svstr[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0))); //2d
606
608 //2d, linear drag coefficient [m/s], defined at rho, somehow related to rdrg
609 vec_rdrag[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
611 vec_rdrag2[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
612 }
613
616 vec_ZoBot[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
617 }
618
619 vec_bustr[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0))); //2d, bottom stress
620 vec_bvstr[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
621
622 //all 2d -- all associated with the 2D advance
623 //2d DU: sum(height[incl free surface?] * u)
624 vec_DU_avg1[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
625
626 //2d like above, but correct(or)?
627 vec_DU_avg2[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
628
629 vec_DV_avg1[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
630 vec_DV_avg2[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
631
632 vec_rubar[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,4,IntVect(NGROW,NGROW,0))); // 2d RHS ubar
633 vec_rvbar[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,4,IntVect(NGROW,NGROW,0)));
634 vec_rzeta[lev].reset(new MultiFab(ba2d,dm,4,IntVect(NGROW,NGROW,0))); // 2d RHS zeta
635
636 // 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
637 vec_zeta[lev].reset(new MultiFab(ba2d,dm,3,IntVect(NGROW+1,NGROW+1,0))); // 2d free surface
638
639 vec_pm[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+2,0)));
640 vec_pn[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+2,NGROW+1,0)));
641 vec_fcor[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
642
643 vec_xr[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
644 vec_yr[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
645
646 vec_xu[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
647 vec_yu[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
648 vec_xv[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
649 vec_yv[lev].reset(new MultiFab(convert(ba2d,IntVect(0,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
650 vec_xp[lev].reset(new MultiFab(convert(ba2d,IntVect(1,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
651 vec_yp[lev].reset(new MultiFab(convert(ba2d,IntVect(1,1,0)),dm,1,IntVect(NGROW,NGROW,0)));
652
654 vec_dndx[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
655 vec_dmde[lev].reset(new MultiFab(convert(ba2d,IntVect(1,0,0)),dm,1,IntVect(NGROW,NGROW,0)));
656 }
657
658 // tempstore, saltstore, etc
659 vec_sstore[lev].reset(new MultiFab(ba,dm,ncons,IntVect(NGROW,NGROW,0)));
660
661 vec_rhoS[lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW,NGROW,0)));
662 vec_rhoA[lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW,NGROW,0)));
663 vec_bvf[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW,NGROW,0)));
664
665 vec_tke[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,3,IntVect(NGROW,NGROW,0)));
666 vec_gls[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,3,IntVect(NGROW,NGROW,0)));
667 vec_Lscale[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW,NGROW,0)));
668 vec_Akk[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW,NGROW,0)));
669 vec_Akp[lev].reset(new MultiFab(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW,NGROW,0)));
670
671 // surface/bottom tracer fluxes for update
672 vec_stflx[lev].reset(new MultiFab(ba2d,dm,ncons,IntVect(NGROW,NGROW,0)));
673 vec_btflx[lev].reset(new MultiFab(ba2d,dm,ncons,IntVect(NGROW,NGROW,0)));
674 // surface/bottom tracer fluxes to be filled by inputs
675 vec_stflux[lev].reset(new MultiFab(ba2d,dm,ncons,IntVect(NGROW,NGROW,0)));
676 vec_btflux[lev].reset(new MultiFab(ba2d,dm,ncons,IntVect(NGROW,NGROW,0)));
677
679 vec_uwind[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, surface wind u
680 vec_vwind[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, surface wind v
681 vec_Tair[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, air temperature
682 vec_qair[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, specific humidity
683 vec_Pair[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, air pressure
684 vec_srflx[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, shortwave radiation flux
685 vec_longwave_down[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, external longwave radiation flux
686 vec_cloud[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, cloud cover fraction
687 vec_EminusP[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0))); //2d, evaporation minus precipitation
688 vec_alpha[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
689 vec_beta[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
690 vec_lrflx[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
691 vec_lhflx[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
692 vec_shflx[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
693 vec_rain[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
694 vec_evap[lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
695
696 vec_uwind[lev]->setVal(solverChoice.Uwind);
697 vec_vwind[lev]->setVal(solverChoice.Vwind);
698 vec_Tair[lev]->setVal(solverChoice.Tair);
699 vec_qair[lev]->setVal(solverChoice.Hair); // Hair can be specific humidity or RH
700 vec_Pair[lev]->setVal(solverChoice.Pair);
701 vec_srflx[lev]->setVal(solverChoice.srflux);
703 vec_cloud[lev]->setVal(solverChoice.cloud);
704 vec_EminusP[lev]->setVal(solverChoice.EminusP);
705 vec_rain[lev]->setVal(solverChoice.rain);
706
707 // Set flux vars that will be computed in bulk_fluxes to zero so initial plotting works
708 vec_stflx[lev]->setVal(zero);
709 vec_sustr[lev]->setVal(zero);
710 vec_svstr[lev]->setVal(zero);
711 vec_lhflx[lev]->setVal(zero);
712 vec_shflx[lev]->setVal(zero);
713 vec_lrflx[lev]->setVal(zero); // possibly this should be set to longwave_rad like longwave_down
714 }
715
717 vec_river_position[lev].reset(new iMultiFab(ba2d,dm,1,IntVect(NGROW,NGROW,0)));
718 vec_river_position[lev]->setVal(-1);
719 }
720
721 vec_nudg_coeff[BdyVars::u][lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,0)));
722 vec_nudg_coeff[BdyVars::v][lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,0)));
723 vec_nudg_coeff[BdyVars::t][lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,0)));
724 vec_nudg_coeff[BdyVars::s][lev].reset(new MultiFab(ba,dm,1,IntVect(NGROW+1,NGROW+1,0)));
725 vec_nudg_coeff[BdyVars::ubar][lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
726 vec_nudg_coeff[BdyVars::vbar][lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
727 vec_nudg_coeff[BdyVars::zeta][lev].reset(new MultiFab(ba2d,dm,1,IntVect(NGROW+1,NGROW+1,0)));
728
729 set_weights(lev);
730
731 vec_DU_avg1[lev]->setVal(zero);
732 vec_DU_avg2[lev]->setVal(zero);
733 vec_DV_avg1[lev]->setVal(zero);
734 vec_DV_avg2[lev]->setVal(zero);
735 vec_rubar[lev]->setVal(zero);
736 vec_rvbar[lev]->setVal(zero);
737 vec_rzeta[lev]->setVal(zero);
738
739 // Initialize these vars even if we aren't using GLS to
740 // avoid issues on e.g. checkpoint
741 vec_tke[lev]->setVal(solverChoice.gls_Kmin);
742 vec_gls[lev]->setVal(solverChoice.gls_Pmin);
743 vec_Lscale[lev]->setVal(zero);
744 vec_Akk[lev]->setVal(solverChoice.Akk_bak);
745 vec_Akp[lev]->setVal(solverChoice.Akp_bak);
746
747 vec_stflx[lev]->setVal(zero);
748 vec_btflx[lev]->setVal(zero);
749 vec_stflux[lev]->setVal(zero);
750 vec_btflux[lev]->setVal(zero);
751
752 // NOTE: Used to set vec_pm and vec_pn to 1e34 here to make foextrap work
753 // when init_type = real. However, this does not appear to be necessary so removing
754
755 // Set initial linear drag coefficient
757 vec_rdrag[lev]->setVal(solverChoice.rdrag);
759 vec_rdrag2[lev]->setVal(solverChoice.rdrag2);
760 }
761
764 vec_ZoBot[lev]->setVal(solverChoice.Zob);
765 }
766
767
768 // ********************************************************************************************
769 // Create the REMORAFillPatcher object
770 // ********************************************************************************************
771 if (lev > 0 && cf_width >= 0) {
774 }
775}
776
777/**
778 * Delete level data. Overrides the pure virtual function in AmrCore
779 *
780 * @param[in ] lev level to operate on
781 */
782void
784{
785 delete cons_new[lev]; delete xvel_new[lev]; delete yvel_new[lev]; delete zvel_new[lev];
786 delete cons_old[lev]; delete xvel_old[lev]; delete yvel_old[lev]; delete zvel_old[lev];
787}
788
789/**
790 * @param[in ] lev level to operate on
791 */
792void
794{
795 // Even if we're using high-resolution grid initialization, don't set it up with average-down
798 const auto dxi = Geom(lev).InvCellSize();
799 vec_pm[lev]->setVal(dxi[0]); vec_pm[lev]->FillBoundary(geom[lev].periodicity());
800 vec_pn[lev]->setVal(dxi[1]); vec_pn[lev]->FillBoundary(geom[lev].periodicity());
802 prob->init_analytic_grid_scale(lev, Geom(lev), solverChoice, *this, *vec_pm[lev].get(), *vec_pn[lev].get());
803 vec_pm[lev]->FillBoundary(geom[lev].periodicity());
804 vec_pn[lev]->FillBoundary(geom[lev].periodicity());
805 }
807#ifdef REMORA_USE_NETCDF
808 } else if (solverChoice.ic_type == IC_Type::netcdf) {
809 if (lev == 0 && hires_grid_level < 0) {
811 } else if (lev > hires_grid_level) {
812 Real dummy_time = zero;
813 FillCoarsePatch(lev,dummy_time,vec_pm[lev].get(), vec_pm[lev-1].get(), foextrap_bc());
814 FillCoarsePatch(lev,dummy_time,vec_pn[lev].get(), vec_pn[lev-1].get(), foextrap_bc());
815
816 int rrx = ref_ratio[lev-1][0];
817 int rry = ref_ratio[lev-1][1];
818 // pm and pn need to be rescaled by the refinement ratio
819 for ( MFIter mfi(*cons_new[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
820 {
821 Array4<Real> const& pm = vec_pm[lev]->array(mfi);
822 Array4<Real> const& pn = vec_pn[lev]->array(mfi);
823 Box ubx = mfi.growntilebox(IntVect(NGROW+1,NGROW+2,0));
824 Box vbx = mfi.growntilebox(IntVect(NGROW+2,NGROW+1,0));
825 ParallelFor(makeSlab(ubx,2,0), [=] AMREX_GPU_DEVICE (int i, int j, int ) {
826 pm(i,j,0) = pm(i,j,0) * (rrx);
827 });
828 ParallelFor(makeSlab(vbx,2,0), [=] AMREX_GPU_DEVICE (int i, int j, int ) {
829 pn(i,j,0) = pn(i,j,0) * (rry);
830 });
831 }
833 } else {
836 }
837#endif
838 }
841 }
842}
843
844/**
845 * @param[in ]lev level to operate on
846 */
847void
849 for ( MFIter mfi(*vec_xr[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
850 {
851 Array4<const Real> const& pm = vec_pm[lev]->const_array(mfi);
852 Array4<const Real> const& pn = vec_pn[lev]->const_array(mfi);
853 Array4<Real> const& xr = vec_xr[lev]->array(mfi);
854 Array4<Real> const& yr = vec_yr[lev]->array(mfi);
855 Array4<Real> const& xu = vec_xu[lev]->array(mfi);
856 Array4<Real> const& yu = vec_yu[lev]->array(mfi);
857 Array4<Real> const& xv = vec_xv[lev]->array(mfi);
858 Array4<Real> const& yv = vec_yv[lev]->array(mfi);
859 Array4<Real> const& xp = vec_xp[lev]->array(mfi);
860 Array4<Real> const& yp = vec_yp[lev]->array(mfi);
861
862 Box bx = mfi.growntilebox(IntVect(NGROW,NGROW,0));
863 ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int)
864 {
865 xr(i,j,0) = (i + Real(0.5)) / pm(i,j,0);
866 yr(i,j,0) = (j + Real(0.5)) / pn(i,j,0);
867 });
868
869 ParallelFor(grow(convert(bx,IntVect(1,0,0)),IntVect(-1,0,0)), [=] AMREX_GPU_DEVICE (int i, int j, int)
870 {
871 xu(i,j,0) = i / pm(i,j,0);
872 yu(i,j,0) = (j + Real(0.5)) / pn(i,j,0);
873 });
874
875 ParallelFor(grow(convert(bx,IntVect(0,1,0)),IntVect(0,-1,0)), [=] AMREX_GPU_DEVICE (int i, int j, int)
876 {
877 xv(i,j,0) = (i + Real(0.5)) / pm(i,j,0);
878 yv(i,j,0) = j / pn(i,j,0);
879 });
880
881 ParallelFor(grow(convert(bx,IntVect(1,1,0)),IntVect(-1,-1,0)), [=] AMREX_GPU_DEVICE (int i, int j, int)
882 {
883 xp(i,j,0) = i / pm(i,j,0);
884 yp(i,j,0) = j / pn(i,j,0);
885 });
886 }
887}
888
889/**
890 * @param[in ]lev level to operate on
891 */
892void
894 for ( MFIter mfi(*vec_dndx[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
895 {
896 Array4<const Real> const& pm = vec_pm[lev]->const_array(mfi);
897 Array4<const Real> const& pn = vec_pn[lev]->const_array(mfi);
898 Array4<Real> const& dndx = vec_dndx[lev]->array(mfi);
899 Array4<Real> const& dmde = vec_dmde[lev]->array(mfi);
900
901 Box bx = mfi.growntilebox(IntVect(NGROW,NGROW,0));
902 ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int)
903 {
904 dndx(i,j,0) = Real(0.5) * (one / pn(i+1,j ,0) - one / pn(i-1,j ,0));
905 dmde(i,j,0) = Real(0.5) * (one / pm(i ,j+1,0) - one / pn(i ,j-1,0));
906 });
907 }
908}
909
910/**
911 * @param[in ] lev level to operate on
912 */
913void
915{
916 BL_PROFILE("REMORA::set_zeta_to_Ztavg()");
917 std::unique_ptr<MultiFab>& mf_zeta = vec_zeta[lev];
918 std::unique_ptr<MultiFab>& mf_Zt_avg1 = vec_Zt_avg1[lev];
920 for ( MFIter mfi(*vec_zeta[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
921 {
922 Array4<Real> const& Zt_avg1 = (mf_Zt_avg1)->array(mfi);
923 Array4<const Real> const& evap = vec_evap[lev]->const_array(mfi);
924 Array4<const Real> const& rain = vec_rain[lev]->const_array(mfi);
925 Array4<const Real> const& EminusP = vec_EminusP[lev]->const_array(mfi);
926 bool use_EminusP_from_input = solverChoice.eminusp &&
928
929 Box bx2 = mfi.growntilebox(IntVect(NGROW,NGROW,0));// bx2.grow(IntVect(NGROW,NGROW,0));
930
931 Real cff = dt[lev] / rhow;
932 Real dt_lev = dt[lev];
933
934 ParallelFor(bx2, [=] AMREX_GPU_DEVICE (int i, int j, int )
935 {
936 if (use_EminusP_from_input) {
937 // EminusP is treated as a kinematic freshwater flux (m/s).
938 Zt_avg1(i,j,0) = Zt_avg1(i,j,0) - EminusP(i,j,0) * dt_lev;
939 } else {
940 Zt_avg1(i,j,0) = Zt_avg1(i,j,0) - (evap(i,j,0) - rain(i,j,0)) * cff;
941 }
942 });
943 }
944 }
945 Gpu::streamSynchronize();
946
947 vec_Zt_avg1[lev]->FillBoundary(geom[lev].periodicity());
948
949 for ( MFIter mfi(*vec_zeta[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
950 {
951 Box bx3 = mfi.tilebox(); bx3.grow(IntVect(NGROW+1,NGROW+1,0));
952 Array4<Real> const& zeta = mf_zeta->array(mfi);
953 Array4<Real> const& Zt_avg1 = (mf_Zt_avg1)->array(mfi);
954
955 ParallelFor(bx3, 3, [=] AMREX_GPU_DEVICE (int i, int j, int , int n)
956 {
957 zeta(i,j,0,n) = Zt_avg1(i,j,0);
958 });
959 }
960}
961
962/**
963 * @param[in ] lev level to operate on
964 */
965void
967{
968 for ( MFIter mfi(*vec_mskr[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
969 {
970 Array4<const Real> const& mskr = vec_mskr[lev]->const_array(mfi);
971 Array4< Real> const& mskp = vec_mskp[lev]->array(mfi);
972
973 Box bx = mfi.tilebox(); bx.grow(IntVect(1,1,0)); bx.makeSlab(2,0);
974
975 Real cff1 = one;
976 Real cff2 = two;
977
978 ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int)
979 {
980 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))) {
981 mskp(i,j,0) = one;
982 } 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))) {
983 mskp(i,j,0) = cff1;
984 } 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))) {
985 mskp(i,j,0) = cff1;
986 } 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))) {
987 mskp(i,j,0) = cff1;
988 } 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))) {
989 mskp(i,j,0) = cff1;
990 } 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))) {
991 mskp(i,j,0) = cff2;
992 } 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))) {
993 mskp(i,j,0) = cff2;
994 } 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))) {
995 mskp(i,j,0) = cff2;
996 } 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))) {
997 mskp(i,j,0) = cff2;
998 } else {
999 mskp(i,j,0) = zero;
1000 }
1001
1002 });
1003 }
1004}
1005
1006/**
1007 * @param[in ] lev level to operate on
1008 */
1009void
1011{
1012 for ( MFIter mfi(*vec_mskr[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
1013 {
1014 Array4<const Real> const& mskr = vec_mskr[lev]->const_array(mfi);
1015 Array4< Real> const& msku = vec_msku[lev]->array(mfi);
1016 Array4< Real> const& mskv = vec_mskv[lev]->array(mfi);
1017 Array4< Real> const& mskp = vec_mskp[lev]->array(mfi);
1018
1019 Box bx = mfi.tilebox(); bx.grow(IntVect(1,1,0)); bx.makeSlab(2,0);
1020
1021 ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int)
1022 {
1023 msku(i,j,0) = mskr(i-1,j ,0) * mskr(i,j,0);
1024 mskv(i,j,0) = mskr(i ,j-1,0) * mskr(i,j,0);
1025 mskp(i,j,0) = mskr(i-1,j-1,0) * mskr(i,j,0) * mskr(i-1,j,0) * mskr(i,j-1,0);
1026 });
1027 }
1028}
1029
1030/**
1031 * @param[in ] lev level to operate on
1032 */
1033void
1035{
1036 for ( MFIter mfi(*vec_mskr3d[lev], TilingIfNotGPU()); mfi.isValid(); ++mfi )
1037 {
1038 Array4<const Real> const& mskr = vec_mskr[lev]->const_array(mfi);
1039 Array4< Real> const& mskr3d = vec_mskr3d[lev]->array(mfi);
1040
1041 Box bx = mfi.tilebox(); bx.grow(IntVect(1,1,0));
1042
1043 ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k)
1044 {
1045 mskr3d(i,j,k) = mskr(i,j,0);
1046 });
1047 }
1048}
constexpr amrex::Real two
constexpr amrex::Real bogus_large_value
constexpr amrex::Real one
constexpr amrex::Real zero
constexpr amrex::Real rhow
#define NGROW
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_EminusP
evaporation minus precipitation [kg/m^2/s], defined at rho-points
Definition REMORA.H:491
void set_grid_vars_averaged_down(int lev)
Set pm/pn by averaging down from higher-resolution grid.
Definition REMORA.cpp:718
int ncons
Number of conserved scalars in the state (temperature + salt + passive scalars)
Definition REMORA.H:1546
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta_full_domain
high resolution initial free surface height (2D)
Definition REMORA.H:536
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv2d
v velocity RHS (2D, includes horizontal and vertical advection)
Definition REMORA.H:406
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_evap
evaporation rate [kg/m^2/s]
Definition REMORA.H:487
int zvel_bc() const noexcept
Definition REMORA.H:1249
int xvel_bc() const noexcept
Definition REMORA.H:1247
amrex::Vector< amrex::BCRec > domain_bcs_type
vector (over BCVars) of BCRecs
Definition REMORA.H:1495
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:559
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_btflux
Bottom tracer flux; input arrays.
Definition REMORA.H:482
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rubar
barotropic x velocity for the RHS (2D)
Definition REMORA.H:523
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:379
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:388
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pm
horizontal scaling factor: 1 / dx (2D)
Definition REMORA.H:550
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ZoBot
Bottom roughness length [m], defined at rho points.
Definition REMORA.H:507
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DU_avg2
correct time average of barotropic x velocity flux for coupling (2D)
Definition REMORA.H:517
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_lrflx
longwave radiation
Definition REMORA.H:467
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yv
y_grid on v-points (2D)
Definition REMORA.H:574
amrex::Vector< amrex::MultiFab * > cons_new
multilevel data container for current step's scalar data: temperature, salinity, passive tracer
Definition REMORA.H:368
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 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:456
std::unique_ptr< ProblemBase > prob
Pointer to container of analytical functions for problem definition.
Definition REMORA.H:1459
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr
land/sea mask at cell centers (2D)
Definition REMORA.H:539
void Construct_REMORAFillPatchers(int lev)
Construct FillPatchers.
Definition REMORA.cpp:500
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:485
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_tke
Turbulent kinetic energy.
Definition REMORA.H:614
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_stflx
Surface tracer flux; working arrays.
Definition REMORA.H:476
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_gls
Turbulent generic length scale.
Definition REMORA.H:616
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_sustr
Surface stress in the u direction.
Definition REMORA.H:449
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yp
y_grid on psi-points (2D)
Definition REMORA.H:579
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xr
x_grid on rho points (2D)
Definition REMORA.H:562
int yvel_bc() const noexcept
Definition REMORA.H:1248
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru2d
u velocity RHS (2D, includes horizontal and vertical advection)
Definition REMORA.H:404
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:374
AMREX_FORCE_INLINE int ComputeGhostCells(const int &spatial_order)
Helper function to determine number of ghost cells.
Definition REMORA.H:1726
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_sstore
additional scratch space for calculations on temp, salt, etc
Definition REMORA.H:594
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xv
x_grid on v-points (2D)
Definition REMORA.H:572
void init_only(int lev, amrex::Real time)
Init (NOT restart or regrid)
Definition REMORA.cpp:1303
void init_set_vmix(int lev)
Initialize vertical mixing coefficients from file or analytic.
Definition REMORA.cpp:793
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:764
int foextrap_bc() const noexcept
Definition REMORA.H:1255
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Lscale
Vertical mixing turbulent length scale.
Definition REMORA.H:618
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Hz
Width of cells in the vertical (z-) direction (3D, Hz in ROMS)
Definition REMORA.H:394
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akt
Vertical diffusion coefficient (3D)
Definition REMORA.H:414
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_msku
land/sea mask at x-faces (2D)
Definition REMORA.H:541
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rvfrc
v velocity RHS, integrated, including advection and bottom/surface stresses (2D)
Definition REMORA.H:410
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pm_full_domain
horizontal scaling factor: 1 / dx (2D) on whole domain
Definition REMORA.H:554
amrex::Vector< amrex::MultiFab * > xvel_old
multilevel data container for last step's x velocities (u in ROMS)
Definition REMORA.H:361
amrex::Vector< amrex::MultiFab * > yvel_new
multilevel data container for current step's y velocities (v in ROMS)
Definition REMORA.H:372
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_uwind
Wind in the u direction, defined at rho-points.
Definition REMORA.H:454
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rufrc
u velocity RHS, integrated, including advection and bottom/surface stresses (2D)
Definition REMORA.H:408
int zeta_bc() const noexcept
Definition REMORA.H:1252
void Define_REMORAFillPatchers(int lev)
Define FillPatchers.
Definition REMORA.cpp:549
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_shflx
sensible heat flux
Definition REMORA.H:473
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:416
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_dmde
d(1/m)/d(eta)
Definition REMORA.H:591
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rvbar
barotropic y velocity for the RHS (2D)
Definition REMORA.H:525
amrex::Vector< amrex::MultiFab * > zvel_old
multilevel data container for last step's z velocities (largely unused; W stored separately)
Definition REMORA.H:365
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_z_r
z coordinates at rho points (cell centers)
Definition REMORA.H:423
amrex::Vector< amrex::MultiFab * > xvel_new
multilevel data container for current step's x velocities (u in ROMS)
Definition REMORA.H:370
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_lhflx
latent heat flux
Definition REMORA.H:471
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskp
land/sea mask at cell corners (2D)
Definition REMORA.H:545
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_bvf
Brunt-Vaisala frequency (3D)
Definition REMORA.H:601
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:583
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskv
land/sea mask at y-faces (2D)
Definition REMORA.H:543
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:1483
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:597
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:418
void update_mskp(int lev)
Set psi-point mask to be consistent with rho-point mask.
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:381
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_svstr
Surface stress in the v direction.
Definition REMORA.H:451
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Huon
u-volume flux (3D)
Definition REMORA.H:396
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_h_full_domain
Bathymetry data on the whole domain at each potential level.
Definition REMORA.H:391
amrex::Vector< amrex::MultiFab * > yvel_old
multilevel data container for last step's y velocities (v in ROMS)
Definition REMORA.H:363
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:599
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DV_avg1
time average of barotropic y velocity flux
Definition REMORA.H:519
int hires_init_level
Which level the high resolution initialization data is at.
Definition REMORA.H:1673
amrex::Vector< amrex::Real > t_new
new time at each level
Definition REMORA.H:1473
static SolverChoice solverChoice
Container for algorithmic choices.
Definition REMORA.H:1603
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:1411
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akk
Turbulent kinetic energy vertical diffusion coefficient.
Definition REMORA.H:620
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rdrag2
Quadratic drag coefficient [unitless], defined at rho points.
Definition REMORA.H:505
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru
u velocity RHS (3D, includes horizontal and vertical advection)
Definition REMORA.H:400
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xp
x_grid on psi-points (2D)
Definition REMORA.H:577
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_longwave_down
Downward longwave radiation.
Definition REMORA.H:469
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta
free surface height (2D)
Definition REMORA.H:533
int ubar_bc() const noexcept
Definition REMORA.H:1250
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vbar
barotropic y velocity (2D)
Definition REMORA.H:531
void FillCoarsePatchPC(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 using the piecewise constant interpol...
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DU_avg1
time average of barotropic x velocity flux (2D)
Definition REMORA.H:515
void set_zeta_to_Ztavg(int lev)
Set zeta components to be equal to time-averaged Zt_avg1.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_alpha
Thermal expansion coefficient (3D)
Definition REMORA.H:603
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ubar
barotropic x velocity (2D)
Definition REMORA.H:529
amrex::Vector< amrex::MultiFab * > cons_old
multilevel data container for last step's scalar data: temperature, salinity, passive tracer
Definition REMORA.H:359
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_bustr
Bottom stress in the u direction.
Definition REMORA.H:510
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:377
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())
Fill a new MultiFab by copying in phi from valid region and filling ghost cells.
int vbar_bc() const noexcept
Definition REMORA.H:1251
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_DV_avg2
correct time average of barotropic y velocity flux for coupling (2D)
Definition REMORA.H:521
void set_hmixcoef(int lev)
Initialize horizontal mixing coefficients.
Definition REMORA.cpp:852
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yu
y_grid on u-points (2D)
Definition REMORA.H:569
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_dndx
d(1/n)/d(xi)
Definition REMORA.H:589
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_bvstr
Bottom stress in the v direction.
Definition REMORA.H:512
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rzeta
free surface height for the RHS (2D)
Definition REMORA.H:527
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_z_phys_nd
z coordinates at psi points (cell nodes)
Definition REMORA.H:443
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_xu
x_grid on u-points (2D)
Definition REMORA.H:567
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pn_full_domain
horizontal scaling factor: 1 / dy (2D) on whole domain
Definition REMORA.H:556
amrex::Vector< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > vec_nudg_coeff
Climatology nudging coefficients.
Definition REMORA.H:625
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:552
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akv
Vertical viscosity coefficient (3D)
Definition REMORA.H:412
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_stflux
Surface tracer flux; input arrays.
Definition REMORA.H:478
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rdrag
Linear drag coefficient [m/s], defined at rho points.
Definition REMORA.H:503
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_cloud
cloud cover fraction [0-1], defined at rho-points
Definition REMORA.H:489
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Zt_avg1
Average of the free surface, zeta (2D)
Definition REMORA.H:446
std::string restart_chkfile
If set, restart from this checkpoint file.
Definition REMORA.H:1541
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv
v velocity RHS (3D, includes horizontal and vertical advection)
Definition REMORA.H:402
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_btflx
Bottom tracer flux; working arrays.
Definition REMORA.H:480
int cf_width
Nudging width at coarse-fine interface.
Definition REMORA.H:1421
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_beta
Saline contraction coefficient (3D)
Definition REMORA.H:605
amrex::Vector< amrex::Real > t_old
old time at each level
Definition REMORA.H:1475
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr3d
land/sea mask at cell centers, copied to all z levels (3D)
Definition REMORA.H:547
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:1503
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_srflx
Shortwave radiation flux [W/m²], defined at rho-points.
Definition REMORA.H:465
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:701
amrex::Vector< amrex::Real > dt
time step at each level
Definition REMORA.H:1477
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Pair
Air pressure [mb], defined at rho-points.
Definition REMORA.H:462
amrex::Gpu::DeviceVector< amrex::BCRec > domain_bcs_type_d
GPU vector (over BCVars) of BCRecs.
Definition REMORA.H:1497
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_qair
Specific humidity [kg/kg], defined at rho-points.
Definition REMORA.H:460
int hires_grid_level
Which level the high resolution bathymetry is at.
Definition REMORA.H:1666
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_z_w
z coordinates at w points (faces between z-cells)
Definition REMORA.H:426
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Tair
Air temperature [°C], defined at rho-points.
Definition REMORA.H:458
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_yr
y_grid on rho points (2D)
Definition REMORA.H:564
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Hvom
v-volume flux (3D)
Definition REMORA.H:398
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akp
Turbulent length scale vertical diffusion coefficient.
Definition REMORA.H:622
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_diff2
Harmonic diffusivity for temperature / salinity.
Definition REMORA.H:420
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:586
static constexpr int cons_bc
static constexpr int Temp_bc_comp
@ EminusP
evaporation minus precipitation [m/s]
amrex::Real cloud
amrex::Real rdrag2
amrex::Real Vwind
amrex::Real Akk_bak
amrex::Real Uwind
amrex::Real EminusP
BottomStressType bottom_stress_type
amrex::Real longwave_rad
amrex::Real srflux
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