REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA_setup_step.cpp
Go to the documentation of this file.
1#include <REMORA.H>
2
3using namespace amrex;
4
5/**
6 * @param[in ] lev level to operate on
7 * @param[in ] time time at start of step
8 * @param[in ] dt_lev time step at level
9 */
10void
12{
13 BL_PROFILE("REMORA::setup_step()");
14
15 MultiFab& S_old = *cons_old[lev];
16 MultiFab& S_new = *cons_new[lev];
17
18 MultiFab& U_old = *xvel_old[lev];
19 MultiFab& V_old = *yvel_old[lev];
20 MultiFab& W_old = *zvel_old[lev];
21
22 MultiFab& U_new = *xvel_new[lev];
23 MultiFab& V_new = *yvel_new[lev];
24 MultiFab& W_new = *zvel_new[lev];
25
26 [[maybe_unused]] int nvars = S_old.nComp();
27
28 // Fill ghost cells/faces at old time
33 amrex::MultiFab(), zvel_old, zvel_new);
34
35 ////////// //pre_step3d corrections to boundaries
36
37 const BoxArray& ba = S_old.boxArray();
38 const DistributionMapping& dm = S_old.DistributionMap();
39
40 const int nrhs = 0;
41 int nstp = 0;
42
43 //-----------------------------------------------------------------------
44 // Time step momentum equation
45 //-----------------------------------------------------------------------
46
47 //Only used locally, probably should be rearranged into FArrayBox declaration
48
49 MultiFab mf_DC(ba,dm,1,IntVect(NGROW,NGROW,NGROW-1)); //2d missing j coordinate
50 MultiFab mf_logdrg_tmp(ba,dm,1,IntVect(NGROW,NGROW,0));
51 MultiFab mf_rho(ba,dm,1,IntVect(NGROW,NGROW,0));
52
53 MultiFab* mf_z_r = vec_z_r[lev].get();
54 MultiFab* mf_z_w = vec_z_w[lev].get();
55 MultiFab* mf_h = vec_h[lev].get();
56 MultiFab* mf_pm = vec_pm[lev].get();
57 MultiFab* mf_pn = vec_pn[lev].get();
58 MultiFab* mf_fcor = vec_fcor[lev].get();
59
60 MultiFab* mf_gls = vec_gls[lev].get();
61 MultiFab* mf_tke = vec_tke[lev].get();
62
63 //Consider passing these into the advance function or renaming relevant things
64
65 std::unique_ptr<MultiFab>& mf_rhoS = vec_rhoS[lev];
66 std::unique_ptr<MultiFab>& mf_rhoA = vec_rhoA[lev];
67 std::unique_ptr<MultiFab>& mf_bvf = vec_bvf[lev];
68 std::unique_ptr<MultiFab>& mf_ru = vec_ru[lev];
69 std::unique_ptr<MultiFab>& mf_rv = vec_rv[lev];
70 std::unique_ptr<MultiFab>& mf_rufrc = vec_rufrc[lev];
71 std::unique_ptr<MultiFab>& mf_rvfrc = vec_rvfrc[lev];
72 std::unique_ptr<MultiFab>& mf_sustr = vec_sustr[lev];
73 std::unique_ptr<MultiFab>& mf_svstr = vec_svstr[lev];
74 std::unique_ptr<MultiFab>& mf_rdrag = vec_rdrag[lev];
75 std::unique_ptr<MultiFab>& mf_rdrag2 = vec_rdrag2[lev];
76 std::unique_ptr<MultiFab>& mf_ZoBot = vec_ZoBot[lev];
77 std::unique_ptr<MultiFab>& mf_bustr = vec_bustr[lev];
78 std::unique_ptr<MultiFab>& mf_bvstr = vec_bvstr[lev];
79
80 std::unique_ptr<MultiFab>& mf_mskr = vec_mskr[lev];
81 std::unique_ptr<MultiFab>& mf_msku = vec_msku[lev];
82 std::unique_ptr<MultiFab>& mf_mskv = vec_mskv[lev];
83 std::unique_ptr<MultiFab>& mf_mskp = vec_mskp[lev];
84
85 std::unique_ptr<MultiFab>& mf_visc2_p = vec_visc2_p[lev];
86 std::unique_ptr<MultiFab>& mf_visc2_r = vec_visc2_r[lev];
87
88 // We need to set these because otherwise in the first call to remora_advance we may
89 // read uninitialized data on ghost values in setting the bc's on the velocities
90 mf_rho.setVal(zero,IntVect(AMREX_D_DECL(NGROW-1,NGROW-1,0)));
91 mf_rhoS->setVal(zero,IntVect(AMREX_D_DECL(NGROW-1,NGROW-1,0)));
92 mf_rhoA->setVal(zero,IntVect(AMREX_D_DECL(NGROW-1,NGROW-1,0)));
93 mf_DC.setVal(zero);
94
98
99 mf_rufrc->setVal(zero);
100 mf_rvfrc->setVal(zero);
101
102 int iic = istep[lev];
103 int ntfirst = 0;
104 if(iic==ntfirst) {
105 MultiFab::Copy(S_new,S_old,0,0,S_new.nComp(),S_new.nGrowVect());
106 MultiFab::Copy(U_new,U_old,0,0,U_new.nComp(),U_new.nGrowVect());
107 MultiFab::Copy(V_new,V_old,0,0,V_new.nComp(),V_new.nGrowVect());
108 MultiFab::Copy(W_new,W_old,0,0,W_new.nComp(),W_new.nGrowVect());
109 }
110
111 // Refresh the atmospheric forcing fields feeding the bulk-flux path.
112 //
113 // A coupled run needs this too, and used to skip it entirely. The driver
114 // supplies only the lanes its atmosphere can fill and withholds the rest,
115 // expecting those to keep this deck's own forcing - NetCDF series included.
116 // set_surface_state is already per-lane, so the supplied ones are left
117 // alone; skipping it wholesale froze every withheld lane at its
118 // level-creation constant.
119 //
120 // The gate mirrors the bulk_fluxes() call below: in driver flux mode these
121 // fields are never read.
127 set_smflux(lev); // uncoupled, no bulk fluxes: set surface fluxes directly
128 }
129
130 auto N = Geom(lev).Domain().size()[2]-1; // Number of vertical "levs" aka, NZ
131
132 for ( MFIter mfi(S_new, TilingIfNotGPU()); mfi.isValid(); ++mfi )
133 {
134 Array4<Real const> const& h = vec_h[lev]->const_array(mfi);
135 Array4<Real const> const& Hz = vec_Hz[lev]->const_array(mfi);
136 Array4<Real > const& Huon = vec_Huon[lev]->array(mfi);
137 Array4<Real > const& Hvom = vec_Hvom[lev]->array(mfi);
138
139 Array4<Real const> const& z_w = mf_z_w->const_array(mfi);
140 Array4<Real const> const& z_r = mf_z_r->const_array(mfi);
141 Array4<Real const> const& uold = U_old.const_array(mfi);
142 Array4<Real const> const& vold = V_old.const_array(mfi);
143 Array4<Real > const& rho = mf_rho.array(mfi);
144 Array4<Real > const& rhoA = mf_rhoA->array(mfi);
145 Array4<Real > const& rhoS = mf_rhoS->array(mfi);
146 Array4<Real > const& bvf = mf_bvf->array(mfi);
150 ? vec_alpha[lev]->array(mfi) : Array4<Real>();
154 ? vec_beta[lev]->array(mfi) : Array4<Real>();
155
156 Array4<Real const> const& pm = mf_pm->const_array(mfi);
157 Array4<Real const> const& pn = mf_pn->const_array(mfi);
158
159 Array4<Real const> const& mskr = mf_mskr->const_array(mfi);
160
161 Box bx = mfi.tilebox();
162 Box gbx1 = mfi.growntilebox(IntVect(NGROW-1,NGROW-1,0));
163 Box gbx2 = mfi.growntilebox(IntVect(NGROW,NGROW,0));
164 Box ugbx2 = mfi.grownnodaltilebox(0,IntVect(NGROW,NGROW,0));
165 Box vgbx2 = mfi.grownnodaltilebox(1,IntVect(NGROW,NGROW,0));
166
167 Box bxD = bx;
168 bxD.makeSlab(2,0);
169 Box gbx1D = gbx1;
170 gbx1D.makeSlab(2,0);
171 Box gbx2D = gbx2;
172 gbx2D.makeSlab(2,0);
173
174 //
175 //-----------------------------------------------------------------------
176 // Compute horizontal mass fluxes, Hz*u/n and Hz*v/m (set_massflux_3d)
177 //-----------------------------------------------------------------------
178 //
179 ParallelFor(ugbx2, [=] AMREX_GPU_DEVICE (int i, int j, int k)
180 {
181 Real on_u = two / (pn(i-1,j,0)+pn(i,j,0));
182 Huon(i,j,k)=Real(0.5)*(Hz(i,j,k)+Hz(i-1,j,k))*uold(i,j,k)* on_u;
183 });
184
185 ParallelFor(vgbx2, [=] AMREX_GPU_DEVICE (int i, int j, int k)
186 {
187 Real om_v= two / (pm(i,j-1,0)+pm(i,j,0));
188 Hvom(i,j,k)=Real(0.5)*(Hz(i,j,k)+Hz(i,j-1,k))*vold(i,j,k)* om_v;
189 });
190
191 Array4<Real const> const& state_old = S_old.const_array(mfi);
193 }
194
195 const Real Cdb_min = solverChoice.Cdb_min;
196 const Real Cdb_max = solverChoice.Cdb_max;
197
198 MultiFab* lw_ptr = nullptr;
199
202 }
207 vec_Tair[lev].get(),vec_qair[lev].get(),vec_Pair[lev].get(),
208 vec_srflx[lev].get(),
209 lw_ptr,
210 vec_evap[lev].get(),
211 vec_sustr[lev].get(),vec_svstr[lev].get(),vec_stflux[lev].get(),
212 vec_lrflx[lev].get(),vec_lhflx[lev].get(),vec_shflx[lev].get(),N);
213 vec_evap[lev]->FillBoundary(geom[lev].periodicity());
214 }
215
217 for ( MFIter mfi(S_new, TilingIfNotGPU()); mfi.isValid(); ++mfi )
218 {
219 Array4<Real > const& stflx = vec_stflx[lev]->array(mfi);
220 Array4<Real > const& btflx = vec_btflx[lev]->array(mfi);
221 Array4<Real const> const& stflux = vec_stflux[lev]->array(mfi);
222 Array4<Real const> const& btflux = vec_btflux[lev]->array(mfi);
223 Box gbx2 = mfi.growntilebox(IntVect(NGROW,NGROW,0));
224 Box gbx2D = gbx2;
225 gbx2D.makeSlab(2,0);
226 ParallelFor(gbx2D, [=] AMREX_GPU_DEVICE (int i, int j, int ) {
229 });
230 }
231 }
233 for ( MFIter mfi(S_new, TilingIfNotGPU()); mfi.isValid(); ++mfi )
234 {
235 Array4<Real > const& stflx = vec_stflx[lev]->array(mfi);
236 Array4<Real > const& btflx = vec_btflx[lev]->array(mfi);
237 Array4<Real const> const& stflux = vec_stflux[lev]->const_array(mfi);
238 Array4<Real const> const& salt_old = S_old.const_array(mfi,Salt_comp);
239 Box gbx2 = mfi.growntilebox(IntVect(NGROW,NGROW,0));
240 Box gbx2D = gbx2;
241 gbx2D.makeSlab(2,0);
242 ParallelFor(gbx2D, [=] AMREX_GPU_DEVICE (int i, int j, int ) {
244 // The fact that this is btflx on the RHS matches what's in ROMS even though
245 // it's weird -- if it's non-zero, does that mean that it will run away since
246 // it's always getting multiplied by salt?
247 btflx(i,j,0,Salt_comp) = btflx(i,j,0,Salt_comp) * salt_old(i,j,0);
248 });
249 }
250 }
251
252 for ( MFIter mfi(S_new, TilingIfNotGPU()); mfi.isValid(); ++mfi )
253 {
254 Array4<Real > const& bustr = mf_bustr->array(mfi);
255 Array4<Real > const& bvstr = mf_bvstr->array(mfi);
256 Array4<Real const> const& uold = U_old.const_array(mfi);
257 Array4<Real const> const& vold = V_old.const_array(mfi);
259 Array4<Real const> const& z_r = mf_z_r->const_array(mfi);
260 Array4<Real const> const& z_w = mf_z_w->const_array(mfi);
261
262 Box gbx2 = mfi.growntilebox(IntVect(NGROW,NGROW,0));
263 Box gbx2D = gbx2;
264 gbx2D.makeSlab(2,0);
265 Box ubx1 = mfi.grownnodaltilebox(0,IntVect(NGROW-1,NGROW-1,0));
266 Box ubx1D = ubx1;
267 ubx1D.makeSlab(2,0);
268 Box vbx1 = mfi.grownnodaltilebox(1,IntVect(NGROW-1,NGROW-1,0));
269 Box vbx1D = vbx1;
270 vbx1D.makeSlab(2,0);
271 // Set bottom stress as defined in set_vbx.F
273 Array4<Real const> const& rdrag = mf_rdrag->const_array(mfi);
274 ParallelFor(ubx1D, [=] AMREX_GPU_DEVICE (int i, int j, int )
275 {
276 bustr(i,j,0) = Real(0.5) * (rdrag(i-1,j,0)+rdrag(i,j,0))*(uold(i,j,0));
277 });
278 ParallelFor(vbx1D, [=] AMREX_GPU_DEVICE (int i, int j, int )
279 {
280 bvstr(i,j,0) = Real(0.5) * (rdrag(i,j-1,0)+rdrag(i,j,0))*(vold(i,j,0));
281 });
283 Array4<Real const> const& rdrag2 = mf_rdrag2->const_array(mfi);
284 ParallelFor(ubx1D, [=] AMREX_GPU_DEVICE (int i, int j, int )
285 {
286 Real avg_v = Real(0.25) * (vold(i,j,0) + vold(i,j+1,0) + vold(i-1,j,0) + vold(i-1,j+1,0));
287 Real vel_mag = std::sqrt(uold(i,j,0)*uold(i,j,0) + avg_v * avg_v);
288 bustr(i,j,0) = Real(0.5) * (rdrag2(i-1,j,0) + rdrag2(i,j,0)) * uold(i,j,0) * vel_mag;
289 });
290 ParallelFor(vbx1D, [=] AMREX_GPU_DEVICE (int i, int j, int )
291 {
292 Real avg_u = Real(0.25) * (uold(i,j,0) + uold(i+1,j,0) + uold(i,j-1,0) + uold(i+1,j-1,0));
293 Real vel_mag = std::sqrt(avg_u * avg_u + vold(i,j,0) * vold(i,j,0));
294 bvstr(i,j,0) = Real(0.5) * (rdrag2(i,j-1,0) + rdrag2(i,j,0)) * vold(i,j,0) * vel_mag;
295 });
297 Array4<Real const> const& ZoBot = mf_ZoBot->const_array(mfi);
298 ParallelFor(gbx2D, [=] AMREX_GPU_DEVICE (int i, int j, int )
299 {
300 Real logz = one / (std::log((z_r(i,j,0) - z_w(i,j,0)) / ZoBot(i,j,0)));
301 Real cff = vonKar * vonKar * logz * logz;
302 logdrg_tmp(i,j,0) = std::min(Cdb_max,std::max(Cdb_min,cff));
303 });
304 ParallelFor(ubx1D, [=] AMREX_GPU_DEVICE (int i, int j, int )
305 {
306 Real avg_v = Real(0.25) * (vold(i,j,0) + vold(i,j+1,0) + vold(i-1,j,0) + vold(i-1,j+1,0));
307 Real vel_mag = std::sqrt(uold(i,j,0)*uold(i,j,0) + avg_v * avg_v);
308 bustr(i,j,0) = Real(0.5) * (logdrg_tmp(i-1,j,0)+logdrg_tmp(i,j,0)) * uold(i,j,0) * vel_mag;
309 });
310 ParallelFor(vbx1D, [=] AMREX_GPU_DEVICE (int i, int j, int )
311 {
312 Real avg_u = Real(0.25) * (uold(i,j,0) + uold(i+1,j,0) + uold(i,j-1,0) + uold(i+1,j-1,0));
313 Real vel_mag = std::sqrt(avg_u * avg_u + vold(i,j,0) * vold(i,j,0));
314 bvstr(i,j,0) = Real(0.5) * (logdrg_tmp(i,j-1,0) + logdrg_tmp(i,j,0)) * vold(i,j,0) * vel_mag;
315 });
316 }
317 }
320
322 // Update Akv if using analytic mixing
324 }
325
327
328 MultiFab mf_W(convert(ba,IntVect(0,0,1)),dm,1,IntVect(NGROW+1,NGROW+1,0));
329 mf_W.setVal(zero);
330
331
333 const int nnew = 0;
335 mf_ru.get(), mf_rv.get(),
336 S_old, S_new, mf_W,
338 mf_sustr.get(), mf_svstr.get(), mf_bustr.get(), mf_bvstr.get(),
339 mf_msku.get(), mf_mskv.get(),
340 iic, ntfirst, nnew, nstp, nrhs, N, dt_lev);
341 }
342
343 // We use FillBoundary not FillPatch here since mf_W is single-level scratch space
344 mf_W.FillBoundary(geom[lev].periodicity());
345 (*physbcs[lev])(mf_W,*mf_mskr.get(),0,1,mf_W.nGrowVect(),t_new[lev],zvel_bc());
346
347#ifdef REMORA_USE_NETCDF
348 // Get u and v climatology if we're going to do nudging
350 u_clim_data_from_file->update_interpolated_to_time(model_time(t_new[lev]), lev, xvel_new[lev], geom, ref_ratio);
351 v_clim_data_from_file->update_interpolated_to_time(model_time(t_new[lev]), lev, yvel_new[lev], geom, ref_ratio);
352 }
353#endif
354
355 for ( MFIter mfi(S_old, TilingIfNotGPU()); mfi.isValid(); ++mfi )
356 {
357 Array4<Real const> const& Hz = vec_Hz[lev]->const_array(mfi);
358 Array4<Real> const& Huon = vec_Huon[lev]->array(mfi);
359 Array4<Real> const& Hvom = vec_Hvom[lev]->array(mfi);
360 Array4<Real> const& z_r = (mf_z_r)->array(mfi);
361 Array4<Real> const& z_w = (mf_z_w)->array(mfi);
362 Array4<Real const> const& uold = U_old.const_array(mfi);
363 Array4<Real const> const& vold = V_old.const_array(mfi);
364 Array4<Real> const& u = U_new.array(mfi);
365 Array4<Real> const& v = V_new.array(mfi);
366 Array4<Real> const& rho = (mf_rho).array(mfi);
367 Array4<Real> const& ru = (mf_ru)->array(mfi);
368 Array4<Real> const& rv = (mf_rv)->array(mfi);
369 Array4<Real> const& rufrc = (mf_rufrc)->array(mfi);
370 Array4<Real> const& rvfrc = (mf_rvfrc)->array(mfi);
371 Array4<Real> const& W = (mf_W).array(mfi);
372 Array4<Real> const& sustr = (mf_sustr)->array(mfi);
373 Array4<Real> const& svstr = (mf_svstr)->array(mfi);
374 Array4<Real> const& bustr = (mf_bustr)->array(mfi);
375 Array4<Real> const& bvstr = (mf_bvstr)->array(mfi);
376 Array4<Real> const& visc2_p = (mf_visc2_p)->array(mfi);
377 Array4<Real> const& visc2_r = (mf_visc2_r)->array(mfi);
378
379 Array4<Real const> const& pm = mf_pm->const_array(mfi);
380 Array4<Real const> const& pn = mf_pn->const_array(mfi);
381 Array4<Real const> const& fcor = mf_fcor->const_array(mfi);
382
383 Array4<Real const> const& msku = mf_msku->const_array(mfi);
384 Array4<Real const> const& mskv = mf_mskv->const_array(mfi);
385 Array4<Real const> const& mskp = mf_mskp->const_array(mfi);
386
387 Box bx = mfi.tilebox();
388
389 Box tbxp1 = bx;
390 Box tbxp2 = bx;
391 Box xbx = mfi.nodaltilebox(0);
392 Box ybx = mfi.nodaltilebox(1);
393
394 Box gbx1 = mfi.growntilebox(IntVect(NGROW-1,NGROW-1,0));
395 Box gbx2 = mfi.growntilebox(IntVect(NGROW,NGROW,0));
396
397 Box utbx = mfi.nodaltilebox(0);
398 Box vtbx = mfi.nodaltilebox(1);
399
400 tbxp1.grow(IntVect(NGROW-1,NGROW-1,0));
401 tbxp2.grow(IntVect(NGROW,NGROW,0));
402
403 Box bxD = bx;
404 bxD.makeSlab(2,0);
405 Box gbx1D = gbx1;
406 gbx1D.makeSlab(2,0);
407 Box gbx2D = gbx2;
408 gbx2D.makeSlab(2,0);
409
410 Box tbxp1D = tbxp1;
411 tbxp1D.makeSlab(2,0);
412 Box tbxp2D = tbxp2;
413 tbxp2D.makeSlab(2,0);
414
415 FArrayBox fab_FC(surroundingNodes(tbxp2,2),1,amrex::The_Async_Arena()); //3D
416 auto FC=fab_FC.array();
417
418 FArrayBox fab_fomn(tbxp2D,1,amrex::The_Async_Arena());
419 auto fomn=fab_fomn.array();
420
422 ParallelFor(tbxp2D, [=] AMREX_GPU_DEVICE (int i, int j, int )
423 {
424 fomn(i,j,0) = fcor(i,j,0)*(one/(pm(i,j,0)*pn(i,j,0)));
425 });
426 }
427
428 ParallelFor(gbx2, [=] AMREX_GPU_DEVICE (int i, int j, int k)
429 {
430 FC(i,j,k)=zero;
431 });
432
434
435 // Apply mixing to temperature and, if use_salt, salt
436 int ncomp = solverChoice.use_salt ? 2 : 1;
437 Array4<Real> const& s_arr = S_new.array(mfi);
438 Array4<Real> const& s_arr_rhs = S_old.array(mfi);
439 Array4<Real> const& diff2_arr = vec_diff2[lev]->array(mfi);
440
442
443 for (int itrac = Tracer_comp; itrac < ncons; ++itrac) {
445 t3dmix2(bx, S_new.array(mfi,itrac), S_old.array(mfi,itrac), diff2_arr_scalar, Hz, z_r, pm, pn, msku, mskv, dt_lev, 1, N);
446 }
447
449 //-----------------------------------------------------------------------
450 // coriolis
451 //-----------------------------------------------------------------------
452 //
453 // ru, rv updated
454 // In ROMS, coriolis is the first (un-ifdefed) thing to happen in rhs3d_tile, which gets called after t3dmix
456 }
457
459 Array4<Real const> const& dndx = vec_dndx[lev]->const_array(mfi);
460 Array4<Real const> const& dmde = vec_dmde[lev]->const_array(mfi);
462 }
463
464#ifdef REMORA_USE_NETCDF
466 Array4<const Real> const& uclim = u_clim_data_from_file->get_interpolated_mf(lev)->const_array(mfi);
467 Array4<const Real> const& vclim = v_clim_data_from_file->get_interpolated_mf(lev)->const_array(mfi);
470 // These boxes are set to match the ROMS loops i=IstrU..Iend, j=JstrV..Jend, which
471 // exclude the u-face on the west/east domain edges and the v-face on south/north
472 const Box xbx_adj = clim_nudg_momentum_box(mfi.nodaltilebox(0), 0,
473 Geom(lev).Domain(), Geom(lev).isPeriodic(0));
474 const Box ybx_adj = clim_nudg_momentum_box(mfi.nodaltilebox(1), 1,
475 Geom(lev).Domain(), Geom(lev).isPeriodic(1));
478 }
479#endif
480
481 ////rufrc from 3d is set to ru, then the wind stress (and bottom stress) is added, then the mixing is added
482 //rufrc=ru+sustr*om_u*on_u
483
485 sustr, svstr, bustr, bvstr, Huon, Hvom,
486 pm, pn, W, FC, nrhs, N);
487
489 const int nnew = 0;
490 uv3dmix(xbx, ybx, u, v, uold, vold, rufrc, rvfrc, visc2_p, visc2_r, Hz, pm, pn, mskp, nrhs, nnew, dt_lev);
491 }
492 } // MFIter
493
494 int nnew = (iic +1)% 2;
495 nstp = iic % 2;
498 nstp, nnew, iic, ntfirst, N, dt_lev);
499 }
500 nstp = 0;
501
502 // Commenting out for now, but not sure it's necessary
503 //FillPatch(lev, time, *cons_old[lev], cons_old, BCVars::cons_bc, BdyVars::t);
504 //FillPatch(lev, time, *cons_new[lev], cons_new, BCVars::cons_bc, BdyVars::t);
506
507 // Don't actually want to apply boundary conditions here
508 vec_Huon[lev]->FillBoundary(geom[lev].periodicity());
509 vec_Hvom[lev]->FillBoundary(geom[lev].periodicity());
510}
constexpr amrex::Real two
constexpr amrex::Real one
constexpr amrex::Real zero
constexpr amrex::Real vonKar
#define NGROW
#define Temp_comp
#define Tracer_comp
#define Salt_comp
mf_h setVal(geomdata.ProbHi(2))
int ncons
Number of conserved scalars in the state (temperature + salt + passive scalars + biology tracers)
Definition REMORA.H:1797
void prsgrd(const amrex::Box &bx, const amrex::Box &gbx, const amrex::Box &utbx, const amrex::Box &vtbx, const amrex::Array4< amrex::Real > &ru, const amrex::Array4< amrex::Real > &rv, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &rho, const amrex::Array4< amrex::Real > &FC, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &z_r, const amrex::Array4< amrex::Real const > &z_w, const amrex::Array4< amrex::Real const > &msku, const amrex::Array4< amrex::Real const > &mskv, const int nrhs, const int N)
Calculate pressure gradient.
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:1450
bool running_with_coupling_driver
True once REMORA has received forcing through the coupling driver.
Definition REMORA.H:526
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_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_lrflx
longwave radiation
Definition REMORA.H:497
amrex::Vector< amrex::MultiFab * > cons_new
multilevel data container for current step's scalar data: temperature, salinity, passive tracer
Definition REMORA.H:393
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vwind
Wind in the v direction, defined at rho-points.
Definition REMORA.H:486
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr
land/sea mask at cell centers (2D)
Definition REMORA.H:584
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_tke
Turbulent kinetic energy.
Definition REMORA.H:667
void rho_eos(const amrex::Box &bx, const amrex::Array4< amrex::Real const > &state, const amrex::Array4< amrex::Real > &rho, const amrex::Array4< amrex::Real > &rhoA, const amrex::Array4< amrex::Real > &rhoS, const amrex::Array4< amrex::Real > &bvf, const amrex::Array4< amrex::Real > &alpha, const amrex::Array4< amrex::Real > &beta, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &z_w, const amrex::Array4< amrex::Real const > &z_r, const amrex::Array4< amrex::Real const > &h, const amrex::Array4< amrex::Real const > &mskr, const int N)
Wrapper around equation of state calculation.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_stflx
Surface tracer flux; working arrays.
Definition REMORA.H:506
void t3dmix2(const amrex::Box &bx, const amrex::Array4< amrex::Real > &state, const amrex::Array4< amrex::Real > &state_rhs, const amrex::Array4< amrex::Real const > &diff2, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &z_r, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &msku, const amrex::Array4< amrex::Real const > &mskv, const amrex::Real dt_lev, const int ncomp, const int N)
Wrapper for harmonic diffusivity for tracers.
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< amrex::MultiFab * > zvel_new
multilevel data container for current step's z velocities (largely unused; W stored separately)
Definition REMORA.H:399
void set_surface_state(int lev)
Initialize or calculate wind speed and other surface state vars from file or analytic.
Definition REMORA.cpp:1621
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_sstore
additional scratch space for calculations on temp, salt, etc
Definition REMORA.H:647
std::unique_ptr< NCTimeSeries > v_clim_data_from_file
Data container for v-velocity climatology data read from file.
Definition REMORA.H:1609
void rhs_uv_3d(int lev, const amrex::Box &xbx, const amrex::Box &ybx, const amrex::Array4< amrex::Real const > &uold, const amrex::Array4< amrex::Real const > &vold, const amrex::Array4< amrex::Real > &ru, const amrex::Array4< amrex::Real > &rv, const amrex::Array4< amrex::Real > &rufrc, const amrex::Array4< amrex::Real > &rvfrc, const amrex::Array4< amrex::Real const > &sustr, const amrex::Array4< amrex::Real const > &svstr, const amrex::Array4< amrex::Real const > &bustr, const amrex::Array4< amrex::Real const > &bvstr, const amrex::Array4< amrex::Real const > &Huon, const amrex::Array4< amrex::Real const > &Hvom, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &W, const amrex::Array4< amrex::Real > &FC, int nrhs, int N)
RHS terms for 3D momentum.
static amrex::Box clim_nudg_momentum_box(const amrex::Box &nodal_bx, int dir, const amrex::Box &domain, bool is_periodic)
Shrink an x- or y-nodal momentum tilebox to the faces ROMS nudges.
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_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
int v2d_simple_bc() const noexcept
Definition REMORA.H:1458
std::unique_ptr< NCTimeSeries > u_clim_data_from_file
Data container for u-velocity climatology data read from file.
Definition REMORA.H:1607
amrex::Vector< amrex::MultiFab * > xvel_old
multilevel data container for last step's x velocities (u in ROMS)
Definition REMORA.H:386
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
DriverAtmosForcingMode driver_atmos_forcing_mode
Active atmosphere-to-ocean forcing contract on the most recent driver apply.
Definition REMORA.H:530
void gls_prestep(int lev, amrex::MultiFab *mf_gls, amrex::MultiFab *mf_tke, amrex::MultiFab &mf_W, amrex::MultiFab *mf_msku, amrex::MultiFab *mf_mskv, const int nstp, const int nnew, const int iic, const int ntfirst, const int N, const amrex::Real dt_lev)
Prestep for GLS calculation.
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< 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
int u2d_simple_bc() const noexcept
Definition REMORA.H:1457
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskp
land/sea mask at cell corners (2D)
Definition REMORA.H:590
void prestep(int lev, amrex::MultiFab &mf_uold, amrex::MultiFab &mf_vold, amrex::MultiFab &mf_u, amrex::MultiFab &mf_v, amrex::MultiFab *mf_ru, amrex::MultiFab *mf_rv, amrex::MultiFab &S_old, amrex::MultiFab &S_new, amrex::MultiFab &mf_W, amrex::MultiFab &mf_DC, const amrex::MultiFab *mf_z_r, const amrex::MultiFab *mf_z_w, const amrex::MultiFab *mf_h, const amrex::MultiFab *mf_pm, const amrex::MultiFab *mf_pn, const amrex::MultiFab *mf_sustr, const amrex::MultiFab *mf_svstr, const amrex::MultiFab *mf_bustr, const amrex::MultiFab *mf_bvstr, const amrex::MultiFab *mf_msku, const amrex::MultiFab *mf_mskv, const int iic, const int nfirst, const int nnew, int nstp, int nrhs, int N, const amrex::Real dt_lev)
Wrapper function for prestep.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_bvf
Brunt-Vaisala frequency (3D)
Definition REMORA.H:654
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskv
land/sea mask at y-faces (2D)
Definition REMORA.H:588
amrex::Vector< std::unique_ptr< REMORAPhysBCFunct > > physbcs
Vector (over level) of functors to apply physical boundary conditions.
Definition REMORA.H:1710
amrex::Vector< int > istep
which step?
Definition REMORA.H:1689
void uv3dmix(const amrex::Box &xbx, const amrex::Box &ybx, const amrex::Array4< amrex::Real > &u, const amrex::Array4< amrex::Real > &v, const amrex::Array4< amrex::Real const > &uold, const amrex::Array4< amrex::Real const > &vold, const amrex::Array4< amrex::Real > &rufrc, const amrex::Array4< amrex::Real > &rvfrc, const amrex::Array4< amrex::Real const > &visc2_p, const amrex::Array4< amrex::Real const > &visc2_r, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &mskp, int nrhs, int nnew, const amrex::Real dt_lev)
Harmonic viscosity.
void set_analytic_vmix(int lev)
Set vertical mixing coefficients from analytic.
Definition REMORA.cpp:919
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rhoS
density perturbation
Definition REMORA.H:650
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_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< amrex::MultiFab * > yvel_old
multilevel data container for last step's y velocities (v in ROMS)
Definition REMORA.H:388
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rhoA
vertically-averaged density
Definition REMORA.H:652
void apply_clim_nudg(const amrex::Box &bx, int ioff, int joff, const amrex::Array4< amrex::Real > &var, const amrex::Array4< amrex::Real const > &var_old, const amrex::Array4< amrex::Real const > &var_clim, const amrex::Array4< amrex::Real const > &clim_coeff, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Real dt_lev=zero)
Apply climatology nudging.
amrex::Vector< amrex::Real > t_new
new time at each level, in seconds since start_time
Definition REMORA.H:1700
static SolverChoice solverChoice
Container for algorithmic choices.
Definition REMORA.H:1949
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
void FillPatchNoBC(int lev, amrex::Real time, amrex::MultiFab &mf_to_be_filled, amrex::Vector< amrex::MultiFab * > const &mfs, const int bdy_var_type=BdyVars::null, const int icomp=0, const bool fill_all=true, const bool fill_set=false, 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 without applying boun...
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_alpha
Thermal expansion coefficient (3D)
Definition REMORA.H:656
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
static constexpr bool DriverUsesStateForcing(DriverAtmosForcingMode mode) noexcept
Definition REMORA.H:100
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< amrex::Vector< std::unique_ptr< amrex::MultiFab > > > vec_nudg_coeff
Climatology nudging coefficients.
Definition REMORA.H:678
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_pn
horizontal scaling factor: 1 / dy (2D)
Definition REMORA.H:605
void curvilinear(const amrex::Box &bx, const amrex::Box &xbx, const amrex::Box &ybx, const amrex::Array4< amrex::Real const > &uold, const amrex::Array4< amrex::Real const > &vold, const amrex::Array4< amrex::Real > &ru, const amrex::Array4< amrex::Real > &rv, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &dndx, const amrex::Array4< amrex::Real const > &dmde, int nrhs, int nr)
Calculate curvilinear advection terms.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_stflux
Surface tracer flux; input arrays.
Definition REMORA.H:508
void setup_step(int lev, amrex::Real time, amrex::Real dt_lev)
Set everything up for a step on a level.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rdrag
Linear drag coefficient [m/s], defined at rho points.
Definition REMORA.H:533
void set_smflux(int lev)
Initialize or calculate surface momentum flux from file or analytic.
Definition REMORA.cpp:1602
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
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_beta
Saline contraction coefficient (3D)
Definition REMORA.H:658
void bulk_fluxes(int lev, amrex::MultiFab *mf_cons, amrex::MultiFab *mf_uwind, amrex::MultiFab *mf_vwind, amrex::MultiFab *mf_Tair, amrex::MultiFab *mf_qair, amrex::MultiFab *mf_Pair, amrex::MultiFab *mf_srflx, amrex::MultiFab *mf_longwave_down, amrex::MultiFab *mf_evap, amrex::MultiFab *mf_sustr, amrex::MultiFab *mf_svstr, amrex::MultiFab *mf_stflux, amrex::MultiFab *mf_lrflx, amrex::MultiFab *mf_lhflx, amrex::MultiFab *mf_shflx, const int N)
Calculate bulk temperature, salinity, wind fluxes.
double model_time(amrex::Real elapsed) const noexcept
Time on the model clock, in seconds, of an elapsed time such as t_new.
Definition REMORA.H:2170
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_srflx
Shortwave radiation flux [W/m²], defined at rho-points.
Definition REMORA.H:495
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Pair
Air pressure [mb], defined at rho-points.
Definition REMORA.H:492
void coriolis(const amrex::Box &xbx, const amrex::Box &ybx, const amrex::Array4< amrex::Real const > &uold, const amrex::Array4< amrex::Real const > &vold, const amrex::Array4< amrex::Real > &ru, const amrex::Array4< amrex::Real > &rv, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &fomn, int nrhs, int nr)
Calculate Coriolis terms.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_qair
Specific humidity [kg/kg], defined at rho-points.
Definition REMORA.H:490
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_Hvom
v-volume flux (3D)
Definition REMORA.H:428
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_diff2
Harmonic diffusivity for temperature / salinity.
Definition REMORA.H:450
static constexpr int cons_bc
static constexpr int t
cons component Temp_comp
static constexpr int u
static constexpr int v
static constexpr int null
@ LWrad
longwave radiation [W/m^2]
amrex::Real Cdb_min
BottomStressType bottom_stress_type
VertMixingType vert_mixing_type
std::array< BulkForcingType, BulkFlux::NumTypes > bulk_flux_type
amrex::Real Cdb_max