REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA.cpp
Go to the documentation of this file.
1/**
2 * \file REMORA.cpp
3 */
4
6#include <REMORA.H>
7
8#include <AMReX_buildInfo.H>
9
10using namespace amrex;
11
12amrex::Real REMORA::startCPUTime = 0.0_rt;
13amrex::Real REMORA::previousCPUTimeUsed = 0.0_rt;
14
15Vector<AMRErrorTag> REMORA::ref_tags;
16
18
19// Time step control
20amrex::Real REMORA::cfl = 0.8_rt;
21amrex::Real REMORA::fixed_dt = -1.0_rt;
22amrex::Real REMORA::fixed_fast_dt = -1.0_rt;
23amrex::Real REMORA::change_max = 1.1_rt;
24
26
27// Dictate verbosity in screen output
28int REMORA::verbose = 0;
29
30// Frequency of diagnostic output
32amrex::Real REMORA::sum_per = -1.0_rt;
33
34// Minimum number of digits in plotfile name
36
37// Do we include staggered velocities in the plotfile?
39
40// Native AMReX vs NetCDF
42
43#ifdef REMORA_USE_NETCDF
44
46
47// Do we write one file per timestep (false) or one file for all timesteps (true)
49
50// NetCDF initialization file
51amrex::Vector<std::string> REMORA::nc_bdry_file = {""}; // Must provide via input
52amrex::Vector<amrex::Vector<std::string>> REMORA::nc_init_file = {{""}}; // Must provide via input
53amrex::Vector<amrex::Vector<std::string>> REMORA::nc_grid_file = {{""}}; // Must provide via input
54#endif
55
56amrex::Vector<std::string> BCNames = {"xlo", "ylo", "zlo", "xhi", "yhi", "zhi"};
57
58/**
59 * constructor:
60 * - reads in parameters from inputs file
61 * - sizes multilevel arrays and data structures
62 * - initializes BCRec boundary condition object
63 */
65{
66 BL_PROFILE("REMORA::REMORA()");
67 if (ParallelDescriptor::IOProcessor()) {
68 const char* remora_hash = amrex::buildInfoGetGitHash(1);
69 const char* amrex_hash = amrex::buildInfoGetGitHash(2);
70 const char* buildgithash = amrex::buildInfoGetBuildGitHash();
71 const char* buildgitname = amrex::buildInfoGetBuildGitName();
72
73 if (strlen(remora_hash) > 0) {
74 amrex::Print() << "\n"
75 << "REMORA git hash: " << remora_hash << "\n";
76 }
77 if (strlen(amrex_hash) > 0) {
78 amrex::Print() << "AMReX git hash: " << amrex_hash << "\n";
79 }
80 if (strlen(buildgithash) > 0) {
81 amrex::Print() << buildgitname << " git hash: " << buildgithash << "\n";
82 }
83
84 amrex::Print() << "\n";
85 }
86
88
89 const std::string& pv3d = "plot_vars_3d"; set3DPlotVariables(pv3d);
90 const std::string& pv2d = "plot_vars_2d"; set2DPlotVariables(pv2d);
91
92 prob = amrex_probinit(geom[0].ProbLo(),geom[0].ProbHi());
93
94 // Geometry on all levels has been defined already.
95
96 // No valid BoxArray and DistributionMapping have been defined.
97 // But the arrays for them have been resized.
98
99 int nlevs_max = max_level + 1;
100
101 istep.resize(nlevs_max, 0);
102 nsubsteps.resize(nlevs_max, 1);
103 for (int lev = 1; lev <= max_level; ++lev) {
104 nsubsteps[lev] = do_substep ? MaxRefRatio(lev-1) : 1;
105 }
106
107 physbcs.resize(nlevs_max);
108
109 t_new.resize(nlevs_max, 0.0_rt);
110 t_old.resize(nlevs_max, -1.e100_rt);
111 dt.resize(nlevs_max, 1.e100_rt);
112
113 cons_new.resize(nlevs_max);
114 cons_old.resize(nlevs_max);
115 xvel_new.resize(nlevs_max);
116 xvel_old.resize(nlevs_max);
117 yvel_new.resize(nlevs_max);
118 yvel_old.resize(nlevs_max);
119 zvel_new.resize(nlevs_max);
120 zvel_old.resize(nlevs_max);
121
122 advflux_reg.resize(nlevs_max);
123
124 // Initialize tagging criteria for mesh refinement
126
127 // We have already read in the ref_Ratio (via amr.ref_ratio =) but we need to enforce
128 // that there is no refinement in the vertical so we test on that here.
129 for (int lev = 0; lev < max_level; ++lev)
130 {
131 amrex::Print() << "Refinement ratio at level " << lev << " set to be " <<
132 ref_ratio[lev][0] << " " << ref_ratio[lev][1] << " " << ref_ratio[lev][2] << std::endl;
133
134 if (ref_ratio[lev][2] != 1)
135 {
136 amrex::Error("We don't allow refinement in the vertical -- make sure to set ref_ratio = 1 in z");
137 }
138 }
139}
140
142{
143}
144
145void
147{
148 BL_PROFILE("REMORA::Evolve()");
149 Real cur_time = t_new[0];
150
151 // Take one coarse timestep by calling timeStep -- which recursively calls timeStep
152 // for finer levels (with or without subcycling)
153 for (int step = istep[0]; step < max_step && cur_time < stop_time; ++step)
154 {
155 amrex::Print() << "\nCoarse STEP " << step+1 << " starts ..." << std::endl;
156
157 ComputeDt();
158
159 int lev = 0;
160 int iteration = 1;
161
162 if (max_level == 0) {
163 timeStep(lev, cur_time, iteration);
164 }
165 else {
166 timeStepML(cur_time, iteration);
167 }
168
169 cur_time += dt[0];
170
171 amrex::Print() << "Coarse STEP " << step+1 << " ends." << " TIME = " << cur_time
172 << " DT = " << dt[0] << std::endl;
173
174 if ((plot_int > 0 && (step+1 - last_plot_file_step) == plot_int)
175 || (plot_int_time > 0 && cur_time >= (last_plot_file_time + plot_int_time))) {
176 last_plot_file_step = step+1;
177 last_plot_file_time = cur_time;
179
181 }
182#ifdef REMORA_USE_NETCDF
184 WriteNCPlotFile(step+1);
186 }
187#endif
188 }
189
190 if ((check_int > 0 && (step+1 - last_check_file_step) == check_int)
191 || (check_int_time > 0 && cur_time >= (last_check_file_time + check_int_time))) {
192 last_check_file_step = step+1;
193 last_check_file_time = cur_time;
195 }
196
197 post_timestep(step, cur_time, dt[0]);
198
199#ifdef AMREX_MEM_PROFILING
200 {
201 std::ostringstream ss;
202 ss << "[STEP " << step+1 << "]";
203 MemProfiler::report(ss.str());
204 }
205#endif
206
207 if (cur_time >= stop_time - 1.e-6*dt[0]) break;
208 }
209
210 if ((plot_int > 0 || plot_int_time > 0.0) && istep[0] > last_plot_file_step) {
213 }
214#ifdef REMORA_USE_NETCDF
218 }
219#endif
220 }
221
222 if ((check_int > 0 || check_int_time > 0.0) && istep[0] > last_check_file_step) {
224 }
225}
226
227/**
228 * @param[in ] nstep which step we're on
229 * @param[in ] time current time
230 * @param[in ] dt_lev0 time step on level 0
231 */
232void
233REMORA::post_timestep (int nstep, Real time, Real dt_lev0)
234{
235 BL_PROFILE("REMORA::post_timestep()");
236
237#ifdef REMORA_USE_PARTICLES
238 particleData.Redistribute();
239#endif
240
242 {
243 for (int lev = finest_level-1; lev >= 0; lev--)
244 {
245 // This call refluxes from the lev/lev+1 interface onto lev
246 //getAdvFluxReg(lev+1)->Reflux(*cons_new[lev], 0, 0, NCONS);
247
248 // We need to do this before anything else because refluxing changes the
249 // values of coarse cells underneath fine grids with the assumption they'll
250 // be over-written by averaging down
251 //
252 AverageDownTo(lev);
253 }
254 }
255
256 if (is_it_time_for_action(nstep, time, dt_lev0, sum_interval, sum_per)) {
258 }
259}
260
261/**
262 * This is called from main.cpp and handles all initialization, whether from start or restart
263 */
264void
266{
267 BL_PROFILE("REMORA::InitData()");
268 // Initialize the start time for our CPU-time tracker
269 startCPUTime = Real(ParallelDescriptor::second());
270
271 // Map the words in the inputs file to BC types, then translate
272 // those types into what they mean for each variable
273 init_bcs();
274
275 // Init vertical stretching coeffs
277
280 last_plot_file_time = -1.0_rt;
281 last_check_file_time = -1.0_rt;
282
283 if (restart_chkfile == "") {
284 // start simulation from the beginning
285
286 InitFromScratch(start_time);
287
289 AverageDown();
290 }
291
292 } else { // Restart from a checkpoint
293
294 restart();
295
296 }
297#ifdef REMORA_USE_MOAB
298 InitMOABMesh();
299#endif
300 // Initialize flux registers (whether we start from scratch or restart)
302 advflux_reg[0] = nullptr;
303 for (int lev = 1; lev <= finest_level; lev++)
304 {
305 advflux_reg[lev] = new YAFluxRegister(grids[lev], grids[lev-1],
306 dmap[lev], dmap[lev-1],
307 geom[lev], geom[lev-1],
308 ref_ratio[lev-1], lev, NCONS);
309 }
310 }
311
312 // Fill ghost cells/faces
313 for (int lev = 0; lev <= finest_level; ++lev)
314 {
315 if (lev > 0 && cf_width >= 0) {
317 }
318
319 if (restart_chkfile == "") {
320 FillPatch(lev, t_new[lev], *cons_new[lev], cons_new, BCVars::cons_bc, BdyVars::t, 0, true, false,0,0,0.0,*cons_new[lev]);
321 FillPatch(lev, t_new[lev], *xvel_new[lev], xvel_new, BCVars::xvel_bc, BdyVars::u, 0, true, false,0,0,0.0,*xvel_new[lev]);
322 FillPatch(lev, t_new[lev], *yvel_new[lev], yvel_new, BCVars::yvel_bc, BdyVars::v, 0, true, false,0,0,0.0,*yvel_new[lev]);
323 FillPatch(lev, t_new[lev], *zvel_new[lev], zvel_new, BCVars::zvel_bc, BdyVars::null, 0, true, false);
324
325 // Copy from new into old just in case when initializing from scratch
326 int ngs = cons_new[lev]->nGrow();
327 int ngvel = xvel_new[lev]->nGrow();
328 MultiFab::Copy(*cons_old[lev],*cons_new[lev],0,0,NCONS,ngs);
329 MultiFab::Copy(*xvel_old[lev],*xvel_new[lev],0,0,1,ngvel);
330 MultiFab::Copy(*yvel_old[lev],*yvel_new[lev],0,0,1,ngvel);
331 MultiFab::Copy(*zvel_old[lev],*zvel_new[lev],0,0,1,IntVect(ngvel,ngvel,0));
332 }
333 } // lev
334
335 // Check for additional plotting variables that are available after
336 // particle containers are setup.
337 const std::string& pv3d = "plot_vars_3d"; append3DPlotVariables(pv3d);
338 const std::string& pv2d = "plot_vars_2d"; append2DPlotVariables(pv2d);
339
340 if (restart_chkfile == "" && (check_int > 0 || check_int_time > 0.0_rt))
341 {
344 }
345
346 if ( (restart_chkfile == "") ||
348 {
349 if (plot_int > 0 || plot_int_time > 0.0)
350 {
353#ifdef REMORA_USE_NETCDF
355 int step0 = 0;
356 WriteNCPlotFile(step0);
358 }
359#endif
361 }
362 }
363
366 }
367
368 ComputeDt();
369
370}
371
372/**
373 * @param[in ] lev level to operate on
374 */
375void
377{
378 BL_PROFILE("REMORA::Construct_REMORAFillPatchers()");
379 amrex::Print() << ":::Construct_REMORAFillPatchers " << lev << std::endl;
380
381 auto& ba_fine = cons_new[lev ]->boxArray();
382 auto& ba_crse = cons_new[lev-1]->boxArray();
383 auto& dm_fine = cons_new[lev ]->DistributionMap();
384 auto& dm_crse = cons_new[lev-1]->DistributionMap();
385
386 BoxList bl2d_fine = ba_fine.boxList();
387 for (auto& b : bl2d_fine) {
388 b.setRange(2,0);
389 }
390 BoxArray ba2d_fine(std::move(bl2d_fine));
391
392 BoxList bl2d_crse = ba_crse.boxList();
393 for (auto& b : bl2d_crse) {
394 b.setRange(2,0);
395 }
396 BoxArray ba2d_crse(std::move(bl2d_crse));
397
398 int ncomp = cons_new[lev]->nComp();
399
400 FPr_c.emplace_back(ba_fine, dm_fine, geom[lev] ,
401 ba_crse, dm_crse, geom[lev-1],
402 -cf_width, -cf_set_width, ncomp, &cell_cons_interp);
403 FPr_u.emplace_back(convert(ba_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
404 convert(ba_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
405 -cf_width, -cf_set_width, 1, &face_cons_linear_interp);
406 FPr_v.emplace_back(convert(ba_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
407 convert(ba_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
408 -cf_width, -cf_set_width, 1, &face_cons_linear_interp);
409 FPr_w.emplace_back(convert(ba_fine, IntVect(0,0,1)), dm_fine, geom[lev] ,
410 convert(ba_crse, IntVect(0,0,1)), dm_crse, geom[lev-1],
411 -cf_width, -cf_set_width, 1, &face_cons_linear_interp);
412
413 FPr_ubar.emplace_back(convert(ba2d_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
414 convert(ba2d_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
415 -cf_width, -cf_set_width, 3, &face_cons_linear_interp);
416 FPr_vbar.emplace_back(convert(ba2d_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
417 convert(ba2d_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
418 -cf_width, -cf_set_width, 3, &face_cons_linear_interp);
419}
420
421/**
422 * @param[in ] lev level to operate on
423 */
424void
426{
427 BL_PROFILE("REMORA::Define_REMORAFillPatchers()");
428 amrex::Print() << ":::Define_REMORAFillPatchers " << lev << std::endl;
429
430 auto& ba_fine = cons_new[lev ]->boxArray();
431 auto& ba_crse = cons_new[lev-1]->boxArray();
432 auto& dm_fine = cons_new[lev ]->DistributionMap();
433 auto& dm_crse = cons_new[lev-1]->DistributionMap();
434
435 BoxList bl2d_fine = ba_fine.boxList();
436 for (auto& b : bl2d_fine) {
437 b.setRange(2,0);
438 }
439 BoxArray ba2d_fine(std::move(bl2d_fine));
440
441 BoxList bl2d_crse = ba_crse.boxList();
442 for (auto& b : bl2d_crse) {
443 b.setRange(2,0);
444 }
445 BoxArray ba2d_crse(std::move(bl2d_crse));
446
447
448 int ncomp = cons_new[lev]->nComp();
449
450 FPr_c[lev-1].Define(ba_fine, dm_fine, geom[lev] ,
451 ba_crse, dm_crse, geom[lev-1],
452 -cf_width, -cf_set_width, ncomp, &cell_cons_interp);
453 FPr_u[lev-1].Define(convert(ba_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
454 convert(ba_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
455 -cf_width, -cf_set_width, 1, &face_cons_linear_interp);
456 FPr_v[lev-1].Define(convert(ba_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
457 convert(ba_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
458 -cf_width, -cf_set_width, 1, &face_cons_linear_interp);
459 FPr_w[lev-1].Define(convert(ba_fine, IntVect(0,0,1)), dm_fine, geom[lev] ,
460 convert(ba_crse, IntVect(0,0,1)), dm_crse, geom[lev-1],
461 -cf_width, -cf_set_width, 1, &face_cons_linear_interp);
462
463 FPr_ubar[lev-1].Define(convert(ba2d_fine, IntVect(1,0,0)), dm_fine, geom[lev] ,
464 convert(ba2d_crse, IntVect(1,0,0)), dm_crse, geom[lev-1],
465 -cf_width, -cf_set_width, 3, &face_cons_linear_interp);
466 FPr_vbar[lev-1].Define(convert(ba2d_fine, IntVect(0,1,0)), dm_fine, geom[lev] ,
467 convert(ba2d_crse, IntVect(0,1,0)), dm_crse, geom[lev-1],
468 -cf_width, -cf_set_width, 3, &face_cons_linear_interp);
469}
470
471void
473{
474 BL_PROFILE("REMORA::restart()");
476
477 // We set this here so that we don't over-write the checkpoint file we just started from
479}
480
481/**
482 * @param[in ] lev level to operate on
483 */
484void
486{
487 BL_PROFILE("REMORA::set_zeta()");
489 prob->init_analytic_zeta(lev, geom[lev], solverChoice, *this, *vec_zeta[lev]);
490
491#ifdef REMORA_USE_NETCDF
492 } else if (solverChoice.ic_type == IC_Type::netcdf) {
493 if (lev == 0) {
494 amrex::Print() << "Calling init_zeta_from_netcdf on level " << lev << std::endl;
496 amrex::Print() << "Sea surface height loaded from netcdf file \n " << std::endl;
497 } else {
498 Real dummy_time = 0.0_rt;
499 FillCoarsePatch(lev,dummy_time,vec_zeta[lev].get(), vec_zeta[lev-1].get(),BCVars::cons_bc);
500 }
501#endif
502 } else {
503 Abort("Don't know this ic_type!");
504 }
505 vec_zeta[lev]->FillBoundary(geom[lev].periodicity());
506 set_zeta_average(lev);
507}
508
509/**
510 * @param[in ] lev level to operate on
511 */
512void
514{
515 BL_PROFILE("REMORA::bathymetry()");
516 // Only set bathymetry on level 0, and interpolate for finer levels
518 if (lev==0) {
521 prob->init_analytic_bathymetry(lev, geom[lev], solverChoice, *this, *vec_h[lev]);
522 } else {
524 }
525#ifdef REMORA_USE_NETCDF
526 } else if (solverChoice.ic_type == IC_Type::netcdf) {
528 amrex::Print() << "Calling init_bathymetry_from_netcdf " << std::endl;
530 amrex::Print() << "Bathymetry loaded from netcdf file \n " << std::endl;
531 } else {
533 }
534#endif
535 } else {
536 Abort("Don't know this ic_type!");
537 }
538 // Need FillBoundary to fill at grid-grid boundaries, and EnforcePeriodicity
539 // to make sure ghost cells in the domain corners are consistent.
540 vec_h[lev]->FillBoundary(geom[lev].periodicity());
541 vec_h[lev]->EnforcePeriodicity(geom[lev].periodicity());
542 } else {
543 Real dummy_time = 0.0_rt;
544 FillCoarsePatch(lev,dummy_time,vec_h[lev].get(), vec_h[lev-1].get(),BCVars::cons_bc);
546 set_grid_scale(lev);
547 }
548 }
549 } else if (solverChoice.init_ana_h) {
552 prob->init_analytic_bathymetry(lev, geom[lev], solverChoice, *this,*vec_h[lev]);
553 } else {
555 }
556#ifdef REMORA_USE_NETCDF
557 } else if (solverChoice.ic_type == IC_Type::netcdf) {
558 amrex::Print() << "Calling init_bathymetry_from_netcdf level " << lev << std::endl;
560 amrex::Print() << "Bathymetry loaded from netcdf file \n " << std::endl;
561#endif
562 } else {
563 Abort("Don't know this ic_type!");
564 }
565 // Need FillBoundary to fill at grid-grid boundaries, and EnforcePeriodicity
566 // to make sure ghost cells in the domain corners are consistent.
567 vec_h[lev]->FillBoundary(geom[lev].periodicity());
568 vec_h[lev]->EnforcePeriodicity(geom[lev].periodicity());
569 } else if (solverChoice.init_l1ad_h) {
572 prob->init_analytic_bathymetry(lev, geom[lev], solverChoice, *this, *vec_h[lev]);
573 } else {
575 }
576#ifdef REMORA_USE_NETCDF
577 } else if (solverChoice.ic_type == IC_Type::netcdf) {
579 amrex::Print() << "Calling init_bathymetry_from_netcdf " << std::endl;
581 amrex::Print() << "Bathymetry loaded from netcdf file \n " << std::endl;
582 } else {
584 }
585#endif
586 } else {
587 Abort("Don't know this ic_type!");
588 }
589 // Need FillBoundary to fill at grid-grid boundaries, and EnforcePeriodicity
590 // to make sure ghost cells in the domain corners are consistent.
591 vec_h[lev]->FillBoundary(geom[lev].periodicity());
592 vec_h[lev]->EnforcePeriodicity(geom[lev].periodicity());
593 } else {
594 amrex::Abort("Don't know this h init type");
595 }
596}
597
598/**
599 * @param[in ] lev level to operate on
600 */
601void
603 BL_PROFILE("REMORA::set_coriolis()");
606 prob->init_analytic_coriolis(lev, geom[lev], solverChoice, *this, *vec_fcor[lev]);
609#ifdef REMORA_USE_NETCDF
611 if (lev == 0) {
612 amrex::Print() << "Calling init_coriolis_from_netcdf " << std::endl;
614 amrex::Print() << "Coriolis loaded from netcdf file \n" << std::endl;
615 } else {
616 Real dummy_time = 0.0_rt;
617 FillCoarsePatch(lev,dummy_time,vec_fcor[lev].get(), vec_fcor[lev-1].get(),BCVars::cons_bc);
618 }
619#endif
620 } else {
621 Abort("Don't know this coriolis_type!");
622 }
623
624 Real time = 0.0_rt;
625 FillPatch(lev, time, *vec_fcor[lev], GetVecOfPtrs(vec_fcor),BCVars::foextrap_bc);
626 vec_fcor[lev]->EnforcePeriodicity(geom[lev].periodicity());
627 }
628}
629
630void
632 BL_PROFILE("REMORA::init_set_vmix()");
637 // The GLS initialization just sets the multifab to a value, so there's
638 // no need to call FillPatch here
639 } else {
640 Abort("Don't know this vertical mixing type");
641 }
642}
643
644/**
645 * @param[in ] lev level to operate on
646 */
647void
649 BL_PROFILE("REMORA::set_analytic_vmix()");
650 Real time = 0.0_rt;
651 prob->init_analytic_vmix(lev, geom[lev], solverChoice, *this,*vec_Akv[lev], *vec_Akt[lev]);
652 FillPatch(lev, time, *vec_Akv[lev], GetVecOfPtrs(vec_Akv),BCVars::zvel_bc,BdyVars::null,0,true,false);
653 for (int n=0; n<NCONS;n++) {
654 FillPatch(lev, time, *vec_Akt[lev], GetVecOfPtrs(vec_Akt),BCVars::zvel_bc,BdyVars::null,0,false,false);
655 }
656}
657
658/**
659 * @param[in ] lev level to operate on
660 */
661void
663{
664 BL_PROFILE("REMORA::set_hmixcoef()");
666 prob->init_analytic_hmix(lev, geom[lev], solverChoice, *this, *vec_visc2_p[lev], *vec_visc2_r[lev], *vec_diff2[lev]);
668 vec_visc2_p[lev]->setVal(solverChoice.visc2);
669 vec_visc2_r[lev]->setVal(solverChoice.visc2);
670 for (int n=0; n<NCONS; n++) {
671 vec_diff2[lev]->setVal(solverChoice.tnu2[n],n,1);
672 }
673 } else {
674 Abort("Don't know this horizontal mixing type");
675 }
676 Real time = 0.0_rt;
677 FillPatch(lev, time, *vec_visc2_p[lev], GetVecOfPtrs(vec_visc2_p),BCVars::foextrap_periodic_bc);
678 FillPatch(lev, time, *vec_visc2_r[lev], GetVecOfPtrs(vec_visc2_r),BCVars::foextrap_periodic_bc);
679 for (int n=0; n<NCONS; n++) {
680 FillPatch(lev, time, *vec_diff2[lev] , GetVecOfPtrs(vec_diff2),BCVars::foextrap_periodic_bc,BdyVars::null,n,false);
681 }
682}
683
684/**
685 * @param[in ] lev level to operate on
686 */
687void
689{
690 BL_PROFILE("REMORA::init_flat_bathymetry()");
691 vec_h[lev]->setVal(-geom[0].ProbLo()[2]);
692}
693
694/**
695 * @param[in ] lev level to operate on
696 */
697void
699{
700 BL_PROFILE("REMORA::set_smflux()");
702 prob->init_analytic_smflux(lev, geom[lev], solverChoice, *this,*vec_sustr[lev], *vec_svstr[lev]);
704#ifdef REMORA_USE_NETCDF
707 FillPatch(lev, t_old[lev], *vec_sustr[lev], GetVecOfPtrs(vec_sustr),BCVars::foextrap_periodic_bc,BdyVars::null,0,false);
708 FillPatch(lev, t_old[lev], *vec_svstr[lev], GetVecOfPtrs(vec_svstr),BCVars::foextrap_periodic_bc,BdyVars::null,0,false);
709#endif
710 }
711}
712
713/**
714 * @param[in ] lev level to operate on
715 */
716void
718{
719 BL_PROFILE("REMORA::set_wind()");
721 prob->init_analytic_wind(lev,geom[lev], solverChoice, *this, *vec_uwind[lev], *vec_vwind[lev]);
723#ifdef REMORA_USE_NETCDF
726 FillPatch(lev, t_old[lev], *vec_uwind[lev], GetVecOfPtrs(vec_uwind),
728 FillPatch(lev, t_old[lev], *vec_vwind[lev], GetVecOfPtrs(vec_vwind),
730
731 // Conditionally update atmospheric fields if loaded from NetCDF
734 FillPatch(lev, t_old[lev], *vec_Tair[lev], GetVecOfPtrs(vec_Tair),
736 }
739 FillPatch(lev, t_old[lev], *vec_qair[lev], GetVecOfPtrs(vec_qair),
741
742 // Convert qair from percentage (0-100) to specific humidity (0-1) if needed
744 vec_qair[lev]->mult(0.01);
745
746 // Update ghost cells after modification
747 vec_qair[lev]->FillBoundary(geom[lev].periodicity());
748 }
749 }
752 FillPatch(lev, t_old[lev], *vec_Pair[lev], GetVecOfPtrs(vec_Pair),
754 }
757 FillPatch(lev, t_old[lev], *vec_srflx[lev], GetVecOfPtrs(vec_srflx),
759 }
762 FillPatch(lev, t_old[lev], *vec_rain[lev], GetVecOfPtrs(vec_rain),
764 }
767 FillPatch(lev, t_old[lev], *vec_cloud[lev], GetVecOfPtrs(vec_cloud),
769 }
772 FillPatch(lev, t_old[lev], *vec_EminusP[lev], GetVecOfPtrs(vec_EminusP),
774 }
775#endif
776 }
777}
778
779/**
780 * @param[in ] lev level to operate on
781 */
782void
784{
786 prob->init_analytic_masks(lev,geom[lev], solverChoice, *this, *vec_mskr[lev]);
789#ifdef REMORA_USE_NETCDF
790 if (lev == 0) {
791 amrex::Print() << "Calling init_masks_from_netcdf level " << lev << std::endl;
793 amrex::Print() << "Masks loaded from netcdf file \n " << std::endl;
794 } else {
795 Real dummy_time = 0.0_rt;
796 FillCoarsePatchPC(lev, dummy_time, vec_mskr[lev].get(), vec_mskr[lev-1].get(),
799 }
800#endif
801 }
802 fill_3d_masks(lev);
803}
804
805/**
806 * @param[in ] lev level to operate on
807 * @param[in ] time current time for initialization
808 */
809void
810REMORA::init_only (int lev, Real time)
811{
812 BL_PROFILE("REMORA::init_only()");
813 t_new[lev] = time;
814 t_old[lev] = time - 1.e200_rt;
815
816 cons_new[lev]->setVal(0.0_rt);
817 xvel_new[lev]->setVal(0.0_rt);
818 yvel_new[lev]->setVal(0.0_rt);
819 zvel_new[lev]->setVal(0.0_rt);
820
821 xvel_old[lev]->setVal(0.0_rt);
822 yvel_old[lev]->setVal(0.0_rt);
823 zvel_old[lev]->setVal(0.0_rt);
824
825 vec_ru[lev]->setVal(0.0_rt);
826 vec_rv[lev]->setVal(0.0_rt);
827
828 vec_ru2d[lev]->setVal(0.0_rt);
829 vec_rv2d[lev]->setVal(0.0_rt);
830
832 set_grid_scale(lev);
833 }
834 set_masks(lev);
835
836#ifdef REMORA_USE_NETCDF
839
841 if (nc_clim_his_file.empty()) {
842 amrex::Error("NetCDF climatology file name must be provided via input");
843 }
845 ubar_clim_data_from_file = new NCTimeSeries(nc_clim_his_file, "ubar", clim_ubar_time_varname, geom[lev].Domain(),vec_ubar[lev].get(),true,true);
846 vbar_clim_data_from_file = new NCTimeSeries(nc_clim_his_file, "vbar", clim_ubar_time_varname, geom[lev].Domain(),vec_vbar[lev].get(),true,true);
849 }
851 u_clim_data_from_file = new NCTimeSeries(nc_clim_his_file, "u", clim_u_time_varname, geom[lev].Domain(),xvel_new[lev],false,true);
852 v_clim_data_from_file = new NCTimeSeries(nc_clim_his_file, "v", clim_v_time_varname, geom[lev].Domain(),yvel_new[lev],false,true);
855 }
856 // Since the NCTimeSeries object isn't filling the cons_new MultiFab directly, we don't have to specify a component.
857 // It just needs to know the shape of the MultiFab
859 temp_clim_data_from_file = new NCTimeSeries(nc_clim_his_file, "temp", clim_temp_time_varname,geom[lev].Domain(),cons_new[lev],false,true);
861 }
863 salt_clim_data_from_file = new NCTimeSeries(nc_clim_his_file, "salt", clim_salt_time_varname,geom[lev].Domain(),cons_new[lev],false,true);
865 }
866 }
867 }
868
870 amrex::Print() << "Calling init_bdry_from_netcdf at level " << lev << std::endl;
872 amrex::Print() << "Boundary data loaded from netcdf file \n " << std::endl;
873 }
874
875 // This will be a non-op if forcings specified analytically
877 if (nc_frc_file.empty()) {
878 amrex::Error("NetCDF forcing file name must be provided via input for winds");
879 }
880 Uwind_data_from_file = new NCTimeSeries(nc_frc_file, "Uwind", frc_time_varname, geom[lev].Domain(),vec_uwind[lev].get(), true, false);
881 Vwind_data_from_file = new NCTimeSeries(nc_frc_file, "Vwind", frc_time_varname, geom[lev].Domain(),vec_vwind[lev].get(), true, false);
884
885 // Conditionally load atmospheric forcing fields from NetCDF based on user flags
887 Tair_data_from_file = new NCTimeSeries(nc_frc_file, "Tair", frc_time_varname, geom[lev].Domain(),vec_Tair[lev].get(), true, false);
889 }
891 qair_data_from_file = new NCTimeSeries(nc_frc_file, "qair", frc_time_varname, geom[lev].Domain(),vec_qair[lev].get(), true, false);
893 }
895 Pair_data_from_file = new NCTimeSeries(nc_frc_file, "Pair", frc_time_varname, geom[lev].Domain(),vec_Pair[lev].get(), true, false);
897 }
899 srflx_data_from_file = new NCTimeSeries(nc_frc_file, "swrad", frc_time_varname, geom[lev].Domain(),vec_srflx[lev].get(), true, false);
901 }
903 rain_data_from_file = new NCTimeSeries(nc_frc_file, "rain", frc_time_varname, geom[lev].Domain(),vec_rain[lev].get(), true, false);
905 }
907 cloud_data_from_file = new NCTimeSeries(nc_frc_file, "cloud", frc_time_varname, geom[lev].Domain(),vec_cloud[lev].get(), true, false);
909 }
911 EminusP_data_from_file = new NCTimeSeries(nc_frc_file, "EminusP", frc_time_varname, geom[lev].Domain(),vec_EminusP[lev].get(), true, false);
913 }
915 if (nc_frc_file.empty()) {
916 amrex::Error("NetCDF forcing file name must be provided via input for surface momentum fluxes");
917 }
918 sustr_data_from_file = new NCTimeSeries(nc_frc_file, "sustr", frc_time_varname, geom[lev].Domain(),vec_sustr[lev].get(), true, false);
919 svstr_data_from_file = new NCTimeSeries(nc_frc_file, "svstr", frc_time_varname, geom[lev].Domain(),vec_svstr[lev].get(), true, false);
922 }
923
925 auto dom = geom[0].Domain();
926 int nz = dom.length(2);
927 river_source_cons.resize(NCONS);
928 Print() << solverChoice.do_rivers_cons[0] << std::endl;
931 river_source_cons[Salt_comp]->Initialize();
932 }
935 river_source_cons[Temp_comp]->Initialize();
936 }
939 river_source_cons[Scalar_comp]->Initialize();
940 }
946 }
947#else
949 Abort("Not compiled with NetCDF, but selected boundary conditions require NetCDF");
950 }
952 Abort("Not compiled with NetCDF, but using river sources requires NetCDF");
953 }
954#endif
955
956 set_bathymetry(lev);
957 set_zeta(lev);
959
961 if (lev==0) {
963 {
964 init_analytic(lev);
965#ifdef REMORA_USE_NETCDF
966 } else if (solverChoice.ic_type == IC_Type::netcdf) {
967 amrex::Print() << "Calling init_data_from_netcdf " << std::endl;
970 amrex::Print() << "Initial data loaded from netcdf file \n " << std::endl;
971
972#endif
973 } else {
974 Abort("Need to specify ic_type");
975 }
976 } else {
981 }
984 {
985 init_analytic(lev);
986#ifdef REMORA_USE_NETCDF
987 } else if (solverChoice.ic_type == IC_Type::netcdf) {
988 amrex::Print() << "Calling init_data_from_netcdf on level " << lev << std::endl;
991 amrex::Print() << "Initial data loaded from netcdf file on level " << lev << std::endl;
992
993#endif
994 } else {
995 Abort("Need to specify ic_type");
996 }
997 } else {
998 amrex::Abort("Need to specify T init procedure");
999 }
1000
1001 // Ensure that the face-based data are the same on both sides of a periodic domain.
1002 // The data associated with the lower grid ID is considered the correct value.
1003 xvel_new[lev]->OverrideSync(geom[lev].periodicity());
1004 yvel_new[lev]->OverrideSync(geom[lev].periodicity());
1005 zvel_new[lev]->OverrideSync(geom[lev].periodicity());
1006
1007 set_2darrays(lev);
1008
1009 init_set_vmix(lev);
1010 set_hmixcoef(lev);
1011 set_coriolis(lev);
1012
1013 // Previously set smflux here with OverrideSync:
1014// set_smflux(lev);
1015// prob->init_analytic_smflux(lev, geom[lev], solverChoice, *this, *vec_sustr[lev], *vec_svstr[lev]);
1016// vec_sustr[lev]->OverrideSync(geom[lev].periodicity());
1017// vec_svstr[lev]->OverrideSync(geom[lev].periodicity());
1018
1019}
1020
1021void
1023{
1024 BL_PROFILE("REMORA::ReadParameters()");
1025 {
1026 ParmParse pp; // Traditionally, max_step and stop_time do not have prefix, so allow it for now.
1027 bool noprefix_max_step = pp.queryAdd("max_step", max_step);
1028 bool noprefix_stop_time = pp.queryAdd("stop_time", stop_time);
1029 bool remora_max_step = pp.queryAdd("remora.max_step", max_step);
1030 bool remora_stop_time = pp.queryAdd("remora.stop_time", stop_time);
1031 if (remora_max_step and noprefix_max_step) {
1032 Abort("remora.max_step and max_step are both specified. Please use only one!");
1033 }
1034 if (remora_stop_time and noprefix_stop_time) {
1035 Abort("remora.stop_time and stop_time are both specified. Please use only one!");
1036 }
1037 }
1038
1039 ParmParse pp(pp_prefix);
1040 ParmParse pp_amr("amr");
1041 {
1042 pp_amr.queryAdd("regrid_int", regrid_int);
1043 pp.queryAdd("check_file", check_file);
1044 pp.queryAdd("check_int", check_int);
1045 pp_amr.queryAdd("check_int", check_int);
1046 pp.queryAdd("check_int_time", check_int_time);
1047 pp_amr.queryAdd("check_int_time", check_int_time);
1048
1049 pp.queryAdd("expand_plotvars_to_unif_rr", expand_plotvars_to_unif_rr);
1050
1051 pp.queryAdd("restart", restart_chkfile);
1052 pp_amr.queryAdd("restart", restart_chkfile);
1053 pp.queryAdd("start_time",start_time);
1054
1055 if (pp.contains("data_log"))
1056 {
1057 int num_datalogs = pp.countval("data_log");
1058 datalog.resize(num_datalogs);
1059 datalogname.resize(num_datalogs);
1060 pp.queryarr("data_log",datalogname,0,num_datalogs);
1061 for (int i = 0; i < num_datalogs; i++)
1063 }
1064
1065 // Verbosity
1066 pp.queryAdd("v", verbose);
1067
1068 // Frequency of diagnostic output
1069 pp.queryAdd("sum_interval", sum_interval);
1070 pp.queryAdd("sum_period" , sum_per);
1071 pp.queryAdd("file_min_digits", file_min_digits);
1072
1073 if (file_min_digits < 0) {
1074 amrex::Abort("remora.file_min_digits must be non-negative");
1075 }
1076
1077 // Time step controls
1078 pp.queryAdd("cfl", cfl);
1079 pp.queryAdd("change_max", change_max);
1080
1081 pp.queryAdd("fixed_dt", fixed_dt);
1082 pp.queryAdd("fixed_fast_dt", fixed_fast_dt);
1083
1084 pp.queryAdd("fixed_ndtfast_ratio", fixed_ndtfast_ratio);
1085
1086 // If all three are specified, they must be consistent
1087 if (fixed_dt > 0. && fixed_fast_dt > 0. && fixed_ndtfast_ratio > 0)
1088 {
1090 {
1091 amrex::Abort("Dt is over-specfied");
1092 }
1093 }
1094 // If two are specified, initialize fixed_ndtfast_ratio
1095 else if (fixed_dt > 0. && fixed_fast_dt > 0. && fixed_ndtfast_ratio <= 0)
1096 {
1097 fixed_ndtfast_ratio = static_cast<int>(fixed_dt / fixed_fast_dt);
1098 }
1099
1100 AMREX_ASSERT(cfl > 0. || fixed_dt > 0.);
1101
1102 pp_amr.queryAdd("do_substep", do_substep);
1103 if (do_substep) {
1104 amrex::Abort("Time substepping is not yet implemented. amr.do_substep must be 0");
1105 }
1106
1107 // We use this to keep track of how many boxes we read in from WRF initialization
1108 num_files_at_level.resize(max_level+1,0);
1109
1110 // We use this to keep track of how many boxes are specified thru the refinement indicators
1111 num_boxes_at_level.resize(max_level+1,0);
1112 boxes_at_level.resize(max_level+1);
1113
1114 // We always have exactly one file at level 0
1115 num_boxes_at_level[0] = 1;
1116 boxes_at_level[0].resize(1);
1117 boxes_at_level[0][0] = geom[0].Domain();
1118
1119 // Plotfile name and frequency
1120 pp.queryAdd("plot_file", plot_file_name);
1121 pp.queryAdd("plot_int", plot_int);
1122 pp.queryAdd("plot_int_time", plot_int_time);
1123
1124 // Should we plot the staggered face velocities (without averaging to cell centers)
1125 pp.queryAdd("plot_staggered_vels", plot_staggered_vels);
1126
1127 // Output format
1128 std::string plotfile_type_str = "amrex";
1129 pp.queryAdd("plotfile_type", plotfile_type_str);
1130 if (plotfile_type_str == "amrex") {
1132 } else if (plotfile_type_str == "netcdf" || plotfile_type_str == "NetCDF") {
1134#ifdef REMORA_USE_NETCDF
1135 pp.queryAdd("write_history_file",write_history_file);
1136 pp.queryAdd("chunk_history_file",chunk_history_file);
1137 pp.queryAdd("steps_per_history_file",steps_per_history_file);
1138 // Estimate size of domain for one timestep of netcdf
1139 auto dom = geom[0].Domain();
1140 int nx = dom.length(0) + 2;
1141 int ny = dom.length(1) + 2;
1142 int nz = dom.length(2);
1144 // Estimate number of steps that will fit into a 2GB file.
1145 steps_per_history_file = int((1.6e10 - NCH2D * nx * ny * 64.0_rt)
1146 / (nx * ny * 64.0_rt * (NC3D*nz + NC2D)));
1147 // If we calculate that a single step will exceed 2GB and the user has
1148 // requested automatic history file sizing, warn about a possible impending
1149 // error, and set steps_per_history_file = 1 to attempt output anyway.
1150 if (steps_per_history_file == 0) {
1151 amrex::Warning("NetCDF output for a single timestep appears to exceed 2GB. NetCDF output may not work. See Documentation for information about tested MPICH versions.");
1153 }
1154 } else if (write_history_file and !chunk_history_file) {
1155 // Estimate number of output steps we'll need
1156 int nt_out = int((max_step) / plot_int) + 1;
1157 Real est_hist_file_size = NCH2D * nx * ny * 64.0_rt + nt_out * nx * ny * 64.0_rt * (NC3D*nz + NC2D);
1158 if (est_hist_file_size > 1.6e10) {
1159 amrex::Warning("WARNING: NetCDF history file may be larger than 2GB limit. Consider setting remora.chunk_history_file=true");
1160 }
1161 }
1163 Print() << "NetCDF history files will have " << steps_per_history_file << " steps per file." << std::endl;
1164 }
1165#endif
1166 } else {
1167 amrex::Print() << "User selected plotfile_type = " << plotfile_type_str << std::endl;
1168 amrex::Abort("Dont know this plotfile_type");
1169 }
1170#ifndef REMORA_USE_NETCDF
1172 {
1173 amrex::Abort("Please compile with NetCDF in order to enable NetCDF plotfiles");
1174 }
1175
1176#endif
1177
1178#ifdef REMORA_USE_NETCDF
1179 nc_init_file.resize(max_level+1);
1180 nc_grid_file.resize(max_level+1);
1181
1182 boundary_series.resize(max_level+1);
1183
1184 // NetCDF initialization files -- possibly multiple files at each of multiple levels
1185 // but we always have exactly one file at level 0
1186 for (int lev = 0; lev <= max_level; lev++)
1187 {
1188 const std::string nc_file_names = amrex::Concatenate("nc_init_file_",lev,1);
1189 const std::string nc_bathy_file_names = amrex::Concatenate("nc_grid_file_",lev,1);
1190
1191 if (pp.contains(nc_file_names.c_str()))
1192 {
1193 int num_files = pp.countval(nc_file_names.c_str());
1194 int num_bathy_files = pp.countval(nc_bathy_file_names.c_str());
1195 if (num_files != num_bathy_files) {
1196 amrex::Error("Must have same number of netcdf files for grid info as for solution");
1197 }
1198
1199 num_files_at_level[lev] = num_files;
1200 nc_init_file[lev].resize(num_files);
1201 nc_grid_file[lev].resize(num_files);
1202
1203 pp.queryarr(nc_file_names.c_str() , nc_init_file[lev] ,0,num_files);
1204 pp.queryarr(nc_bathy_file_names.c_str(), nc_grid_file[lev],0,num_files);
1205 }
1206 }
1207 // We only read boundary data at level 0
1208 pp.queryarr("nc_bdry_file", nc_bdry_file);
1209
1210 // Also only read forcings at level 0 (for now)
1211 pp.queryAdd("nc_frc_file", nc_frc_file);
1212
1213 // Get river file
1214 pp.queryAdd("nc_river_file", nc_riv_file);
1215
1216 // Read in file names for climatology history and nudging weights
1217 pp.queryAdd("nc_clim_his_file", nc_clim_his_file);
1218 pp.queryAdd("nc_clim_coeff_file", nc_clim_coeff_file);
1219
1220 for (int i=0; i<BdyVars::NumTypes; i++) {
1221 bdry_time_name_byvar.push_back("");
1222 }
1223 pp.queryAdd("bdy_time_varname",bdry_time_varname);
1224 pp.queryAdd("bdy_temp_time_varname",bdry_time_name_byvar[BdyVars::t]);
1225 pp.queryAdd("bdy_salt_time_varname",bdry_time_name_byvar[BdyVars::s]);
1226 pp.queryAdd("bdy_u_time_varname",bdry_time_name_byvar[BdyVars::u]);
1227 pp.queryAdd("bdy_v_time_varname",bdry_time_name_byvar[BdyVars::v]);
1228 pp.queryAdd("bdy_ubar_time_varname",bdry_time_name_byvar[BdyVars::ubar]);
1229 pp.queryAdd("bdy_vbar_time_varname",bdry_time_name_byvar[BdyVars::vbar]);
1230 pp.queryAdd("bdy_zeta_time_varname",bdry_time_name_byvar[BdyVars::zeta]);
1231
1232 // If not specified per variable, populate with the default
1233 for (int i=0; i<BdyVars::NumTypes; i++) {
1234 if (bdry_time_name_byvar[i] == "") {
1236 }
1237 }
1238
1239 pp.queryAdd("frc_time_varname",frc_time_varname);
1240
1241 pp.queryAdd("riv_time_varname",riv_time_varname);
1242
1243 pp.queryAdd("clim_ubar_time_varname",clim_ubar_time_varname);
1244 pp.queryAdd("clim_vbar_time_varname",clim_vbar_time_varname);
1245 pp.queryAdd("clim_u_time_varname",clim_u_time_varname);
1246 pp.queryAdd("clim_v_time_varname",clim_v_time_varname);
1247 pp.queryAdd("clim_salt_time_varname",clim_salt_time_varname);
1248 pp.queryAdd("clim_temp_time_varname",clim_temp_time_varname);
1249
1250#endif
1251
1252#ifdef REMORA_USE_PARTICLES
1253 readTracersParams();
1254#endif
1255 }
1256
1258}
1259
1260void
1262{
1263 BL_PROFILE("REMORA::AverageDown()");
1264 for (int lev = finest_level-1; lev >= 0; --lev)
1265 {
1266 AverageDownTo(lev);
1267 }
1268}
1269
1270/**
1271 * @param[in ] crse_lev level to average down to
1272 */
1273void
1275{
1276 BL_PROFILE("REMORA::AverageDownTo()");
1277 average_down(*cons_new[crse_lev+1], *cons_new[crse_lev],
1278 0, cons_new[crse_lev]->nComp(), refRatio(crse_lev));
1279 average_down(*vec_Zt_avg1[crse_lev+1].get(), *vec_Zt_avg1[crse_lev].get(),
1280 0, vec_Zt_avg1[crse_lev]->nComp(), refRatio(crse_lev));
1281
1282 Array<MultiFab*,AMREX_SPACEDIM> faces_crse;
1283 Array<MultiFab*,AMREX_SPACEDIM> faces_fine;
1284 faces_crse[0] = xvel_new[crse_lev];
1285 faces_crse[1] = yvel_new[crse_lev];
1286 faces_crse[2] = zvel_new[crse_lev];
1287
1288 faces_fine[0] = xvel_new[crse_lev+1];
1289 faces_fine[1] = yvel_new[crse_lev+1];
1290 faces_fine[2] = zvel_new[crse_lev+1];
1291
1292 average_down_faces(GetArrOfConstPtrs(faces_fine), faces_crse,
1293 refRatio(crse_lev),geom[crse_lev]);
1294 stretch_transform(crse_lev);
1295}
1296
1297/**
1298 * @param[in ] lev level at which to get time
1299 */
1300amrex::Real REMORA::get_t_old(int lev) const
1301{
1302 return t_old[lev];
1303}
amrex::Vector< std::string > BCNames
Definition REMORA.cpp:56
PlotfileType
plotfile format
#define Temp_comp
#define Scalar_comp
#define NC3D
#define Salt_comp
#define NC2D
#define NCH2D
#define NCONS
std::unique_ptr< ProblemBase > amrex_probinit(const amrex_real *problo, const amrex_real *probhi) AMREX_ATTRIBUTE_WEAK
Function to init the physical bounds of the domain and instantiate a Problem derived from ProblemBase...
A class to hold and interpolate time series data read from a NetCDF file.
void Initialize()
Read in time array from file and allocate data arrays.
void update_interpolated_to_time(amrex::Real time)
Calculate interpolated values at time, reading in data as necessary.
static PlotfileType plotfile_type
Native or NetCDF plotfile output.
Definition REMORA.H:1373
NCTimeSeriesRiver * river_source_transportbar
Data container for vertically integrated momentum transport in rivers.
Definition REMORA.H:1135
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=amrex::Real(0.0), 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_EminusP
evaporation minus precipitation [kg/m^2/s], defined at rho-points
Definition REMORA.H:351
std::string riv_time_varname
Name of time field for river time.
Definition REMORA.H:1409
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv2d
v velocity RHS (2D, includes horizontal and vertical advection)
Definition REMORA.H:268
static amrex::Real fixed_dt
User specified fixed baroclinic time step.
Definition REMORA.H:1280
amrex::Real last_plot_file_time
Simulation time when we last output a plotfile.
Definition REMORA.H:1251
amrex::Vector< NCTimeSeriesRiver * > river_source_cons
Vector of data containers for scalar data in rivers.
Definition REMORA.H:1131
void init_bathymetry_from_netcdf(int lev)
Bathymetry data initialization from NetCDF file.
void init_bcs()
Read in boundary parameters from input file and set up data structures.
NCTimeSeries * rain_data_from_file
Data container for precipitation rate read from file.
Definition REMORA.H:1111
void calculate_nodal_masks(int lev)
Calculate u-, v-, and psi-point masks based on rho-point masks after analytic initialization.
static amrex::Real previousCPUTimeUsed
Accumulator variable for CPU time used thusfar.
Definition REMORA.H:1476
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_fcor
coriolis factor (2D)
Definition REMORA.H:403
void init_gls_vmix(int lev, SolverChoice solver_choice)
Initialize GLS variables.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_h
Bathymetry data (2D, positive valued, h in ROMS)
Definition REMORA.H:253
void set2DPlotVariables(const std::string &pp_plot_var_names_2d)
amrex::Vector< REMORAFillPatcher > FPr_v
Vector over levels of FillPatchers for v (3D)
Definition REMORA.H:1161
amrex::Vector< amrex::MultiFab * > cons_new
multilevel data container for current step's scalar data: temperature, salinity, passive scalar
Definition REMORA.H:241
static bool write_history_file
Whether to output NetCDF files as a single history file with several time steps.
Definition REMORA.H:1092
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=amrex::Real(0.0), const amrex::MultiFab &mf_calc=amrex::MultiFab())
fill an entire multifab by interpolating from the coarser level
void stretch_transform(int lev)
Calculate vertical stretched coordinates.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vwind
Wind in the v direction, defined at rho-points.
Definition REMORA.H:318
std::unique_ptr< ProblemBase > prob
Pointer to container of analytical functions for problem definition.
Definition REMORA.H:1190
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr
land/sea mask at cell centers (2D)
Definition REMORA.H:387
void Construct_REMORAFillPatchers(int lev)
Construct FillPatchers.
Definition REMORA.cpp:376
static int sum_interval
Diagnostic sum output interval in number of steps.
Definition REMORA.H:1362
int history_count
Counter for which time index we are writing to in the netcdf history file.
Definition REMORA.H:1316
amrex::Real stop_time
Time to stop.
Definition REMORA.H:1266
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rain
precipitation rate [kg/m^2/s]
Definition REMORA.H:345
int do_substep
Whether to substep fine levels in time.
Definition REMORA.H:1289
NCTimeSeries * vbar_clim_data_from_file
Data container for vbar climatology data read from file.
Definition REMORA.H:1120
void Evolve()
Advance solution to final time.
Definition REMORA.cpp:146
NCTimeSeries * Uwind_data_from_file
Data container for u-direction wind read from file.
Definition REMORA.H:1099
std::string bdry_time_varname
Default name of time field for boundary data.
Definition REMORA.H:1392
void ReadCheckpointFile()
read checkpoint file from disk
bool chunk_history_file
Whether to chunk netcdf history file.
Definition REMORA.H:1309
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_sustr
Surface stress in the u direction.
Definition REMORA.H:311
amrex::Real get_t_old(int lev) const
Accessor method for t_old to expose to outside classes.
Definition REMORA.cpp:1300
NCTimeSeries * v_clim_data_from_file
Data container for v-velocity climatology data read from file.
Definition REMORA.H:1124
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru2d
u velocity RHS (2D, includes horizontal and vertical advection)
Definition REMORA.H:266
amrex::Vector< std::string > datalogname
Definition REMORA.H:1508
amrex::Vector< amrex::MultiFab * > zvel_new
multilevel data container for current step's z velocities (largely unused; W stored separately)
Definition REMORA.H:247
void init_only(int lev, amrex::Real time)
Init (NOT restart or regrid)
Definition REMORA.cpp:810
void init_set_vmix(int lev)
Initialize vertical mixing coefficients from file or analytic.
Definition REMORA.cpp:631
std::string clim_u_time_varname
Name of time field for u climatology data.
Definition REMORA.H:1401
void set_grid_scale(int lev)
Set pm and pn arrays on level lev. Only works if using analytic initialization.
void set_coriolis(int lev)
Initialize Coriolis factor from file or analytic.
Definition REMORA.cpp:602
amrex::Vector< REMORAFillPatcher > FPr_u
Vector over levels of FillPatchers for u (3D)
Definition REMORA.H:1159
std::string clim_temp_time_varname
Name of time field for temperature climatology data.
Definition REMORA.H:1407
amrex::Vector< amrex::Vector< amrex::Box > > boxes_at_level
the boxes specified at each level by tagging criteria
Definition REMORA.H:1197
static amrex::Vector< amrex::AMRErrorTag > ref_tags
Holds info for dynamically generated tagging criteria.
Definition REMORA.H:1418
std::string nc_frc_file
NetCDF forcing file.
Definition REMORA.H:1383
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akt
Vertical diffusion coefficient (3D)
Definition REMORA.H:276
std::string clim_ubar_time_varname
Name of time field for ubar climatology data.
Definition REMORA.H:1397
void WriteNCPlotFile(int istep)
Write plotfile using NetCDF (wrapper)
std::string check_file
Checkpoint file prefix.
Definition REMORA.H:1302
static amrex::Real startCPUTime
Variable for CPU timing.
Definition REMORA.H:1474
NCTimeSeries * u_clim_data_from_file
Data container for u-velocity climatology data read from file.
Definition REMORA.H:1122
amrex::Vector< amrex::MultiFab * > xvel_old
multilevel data container for last step's x velocities (u in ROMS)
Definition REMORA.H:234
amrex::Real start_time
Time of the start of the simulation, in seconds.
Definition REMORA.H:1269
NCTimeSeries * ubar_clim_data_from_file
Data container for ubar climatology data read from file.
Definition REMORA.H:1118
NCTimeSeries * Tair_data_from_file
Data container for air temperature read from file.
Definition REMORA.H:1103
void init_data_from_netcdf(int lev)
Problem initialization from NetCDF file.
void init_masks_from_netcdf(int lev)
Mask data initialization from NetCDF file.
amrex::Vector< amrex::MultiFab * > yvel_new
multilevel data container for current step's y velocities (v in ROMS)
Definition REMORA.H:245
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_uwind
Wind in the u direction, defined at rho-points.
Definition REMORA.H:316
static amrex::Real fixed_fast_dt
User specified fixed barotropic time step.
Definition REMORA.H:1282
int regrid_int
how often each level regrids the higher levels of refinement (after a level advances that many time s...
Definition REMORA.H:1292
amrex::Real check_int_time
Checkpoint output interval in seconds.
Definition REMORA.H:1306
NCTimeSeries * sustr_data_from_file
Data container for u-component surface momentum flux read from file.
Definition REMORA.H:1095
void Define_REMORAFillPatchers(int lev)
Define FillPatchers.
Definition REMORA.cpp:425
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:278
amrex::Real plot_int_time
Plotfile output interval in seconds.
Definition REMORA.H:1300
amrex::Vector< int > num_files_at_level
how many netcdf input files specified at each level
Definition REMORA.H:1195
amrex::Vector< REMORAFillPatcher > FPr_vbar
Vector over levels of FillPatchers for vbar (2D)
Definition REMORA.H:1169
void AverageDownTo(int crse_lev)
more flexible version of AverageDown() that lets you average down across multiple levels
Definition REMORA.cpp:1274
int steps_per_history_file
Number of time steps per netcdf history file.
Definition REMORA.H:1314
void post_timestep(int nstep, amrex::Real time, amrex::Real dt_lev)
Called after every level 0 timestep.
Definition REMORA.cpp:233
int max_step
maximum number of steps
Definition REMORA.H:1264
amrex::Vector< amrex::MultiFab * > zvel_old
multilevel data container for last step's z velocities (largely unused; W stored separately)
Definition REMORA.H:238
NCTimeSeries * qair_data_from_file
Data container for specific humidity read from file.
Definition REMORA.H:1105
amrex::Vector< int > num_boxes_at_level
how many boxes specified at each level by tagging criteria
Definition REMORA.H:1193
amrex::Vector< amrex::MultiFab * > xvel_new
multilevel data container for current step's x velocities (u in ROMS)
Definition REMORA.H:243
void refinement_criteria_setup()
Set refinement criteria.
int last_check_file_step
Step when we last output a checkpoint file.
Definition REMORA.H:1254
void init_beta_plane_coriolis(int lev)
Calculate Coriolis parameters from beta plane parametrization.
std::string clim_vbar_time_varname
Name of time field for vbar climatology data.
Definition REMORA.H:1399
NCTimeSeries * cloud_data_from_file
Data container for cloud cover fraction read from file.
Definition REMORA.H:1113
amrex::Vector< int > nsubsteps
How many substeps on each level?
Definition REMORA.H:1202
amrex::Vector< std::unique_ptr< REMORAPhysBCFunct > > physbcs
Vector (over level) of functors to apply physical boundary conditions.
Definition REMORA.H:1214
void ComputeDt()
a wrapper for estTimeStep()
void fill_3d_masks(int lev)
Copy maskr to all z levels.
int plot_int
Plotfile output interval in iterations.
Definition REMORA.H:1298
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=true, const int n_not_fill=0, const int icomp_calc=0, const amrex::Real dt=amrex::Real(0.0), const amrex::MultiFab &mf_calc=amrex::MultiFab())
Fill a new MultiFab by copying in phi from valid region and filling ghost cells.
void InitData()
Initialize multilevel data.
Definition REMORA.cpp:265
void set3DPlotVariables(const std::string &pp_plot_var_names_3d)
amrex::Vector< int > istep
which step?
Definition REMORA.H:1200
void WriteCheckpointFile()
write checkpoint file to disk
std::string nc_clim_coeff_file
NetCDF climatology coefficient file.
Definition REMORA.H:1389
void setRecordDataInfo(int i, const std::string &filename)
Definition REMORA.H:1494
void set_analytic_vmix(int lev)
Set vertical mixing coefficients from analytic.
Definition REMORA.cpp:648
void init_flat_bathymetry(int lev)
Initialize flat bathymetry to value from problo.
Definition REMORA.cpp:688
amrex::Vector< std::string > bdry_time_name_byvar
Name of time fields for boundary data.
Definition REMORA.H:1394
static int file_min_digits
Minimum number of digits in plotfile name or chunked history file.
Definition REMORA.H:1367
void init_riv_pos_from_netcdf(int lev)
static amrex::Vector< std::string > nc_bdry_file
NetCDF boundary data.
Definition REMORA.H:51
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_visc2_r
Harmonic viscosity defined on the rho points (centers)
Definition REMORA.H:280
std::string nc_riv_file
Definition REMORA.H:1384
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_svstr
Surface stress in the v direction.
Definition REMORA.H:313
REMORA()
Definition REMORA.cpp:64
void set_zeta(int lev)
Initialize zeta from file or analytic.
Definition REMORA.cpp:485
static amrex::Real change_max
Fraction maximum change in subsequent time steps.
Definition REMORA.H:1278
void init_zeta_from_netcdf(int lev)
Sea-surface height data initialization from NetCDF file.
void set_zeta_average(int lev)
Set Zt_avg1 to zeta.
void init_coriolis_from_netcdf(int lev)
Coriolis parameter data initialization from NetCDF file.
NCTimeSeries * EminusP_data_from_file
Data container for evaporation minus precipitation read from file.
Definition REMORA.H:1115
std::string pp_prefix
default prefix for input file parameters
Definition REMORA.H:229
void set_bathymetry(int lev)
Initialize bathymetry from file or analytic.
Definition REMORA.cpp:513
amrex::Vector< amrex::MultiFab * > yvel_old
multilevel data container for last step's y velocities (v in ROMS)
Definition REMORA.H:236
NCTimeSeries * srflx_data_from_file
Data container for shortwave radiation flux read from file.
Definition REMORA.H:1109
amrex::Vector< REMORAFillPatcher > FPr_c
Vector over levels of FillPatchers for scalars.
Definition REMORA.H:1157
std::string clim_v_time_varname
Name of time field for v climatology data.
Definition REMORA.H:1403
amrex::Vector< REMORAFillPatcher > FPr_w
Vector over levels of FillPatchers for w.
Definition REMORA.H:1163
amrex::Vector< amrex::YAFluxRegister * > advflux_reg
array of flux registers for refluxing in multilevel
Definition REMORA.H:1217
std::string clim_salt_time_varname
Name of time field for salinity climatology data.
Definition REMORA.H:1405
NCTimeSeries * Vwind_data_from_file
Data container for v-direction wind read from file.
Definition REMORA.H:1101
amrex::Vector< amrex::Real > t_new
new time at each level
Definition REMORA.H:1204
NCTimeSeriesRiver * river_source_transport
Data container for momentum transport in rivers.
Definition REMORA.H:1133
void init_stretch_coeffs()
initialize and calculate stretch coefficients
void init_bdry_from_netcdf(int lev)
Boundary data initialization from NetCDF file.
NCTimeSeries * temp_clim_data_from_file
Data container for temperature climatology data read from file.
Definition REMORA.H:1126
static SolverChoice solverChoice
Container for algorithmic choices.
Definition REMORA.H:1329
void set_masks(int lev)
Initialize land-sea masks from file or analytic.
Definition REMORA.cpp:783
int cf_set_width
Width for fixing values at coarse-fine interface.
Definition REMORA.H:1154
NCTimeSeries * salt_clim_data_from_file
Data container for salinity climatology data read from file.
Definition REMORA.H:1128
void ReadParameters()
read in some parameters from inputs file
Definition REMORA.cpp:1022
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ru
u velocity RHS (3D, includes horizontal and vertical advection)
Definition REMORA.H:262
NCTimeSeries * svstr_data_from_file
Data container for v-component surface momentum flux read from file.
Definition REMORA.H:1097
void sum_integrated_quantities(amrex::Real time)
Integrate conserved quantities for diagnostics.
static int total_nc_plot_file_step
Definition REMORA.H:1005
static int plot_staggered_vels
Whether to write the staggered velocities (not averaged to cell centers)
Definition REMORA.H:1370
static amrex::Vector< amrex::Vector< std::string > > nc_grid_file
NetCDF grid file.
Definition REMORA.H:53
amrex::Vector< amrex::Vector< NCTimeSeriesBoundary * > > boundary_series
Vector over BdyVars of boundary series data containers.
Definition REMORA.H:1138
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta
free surface height (2D)
Definition REMORA.H:384
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vbar
barotropic y velocity (2D)
Definition REMORA.H:382
void set_zeta_to_Ztavg(int lev)
Set zeta components to be equal to time-averaged Zt_avg1.
bool expand_plotvars_to_unif_rr
whether plotfile variables should be expanded to a uniform refinement ratio
Definition REMORA.H:1332
int plot_file_on_restart
Whether to output a plotfile on restart from checkpoint.
Definition REMORA.H:1258
void set_2darrays(int lev)
Set 2D momentum arrays from 3D momentum.
void init_analytic(int lev)
Initialize initial problem data from analytic functions.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_ubar
barotropic x velocity (2D)
Definition REMORA.H:380
amrex::Vector< amrex::MultiFab * > cons_old
multilevel data container for last step's scalar data: temperature, salinity, passive scalar
Definition REMORA.H:232
std::string frc_time_varname
Name of time field for forcing data.
Definition REMORA.H:1411
void set_wind(int lev)
Initialize or calculate wind speed from file or analytic.
Definition REMORA.cpp:717
amrex::Vector< REMORAFillPatcher > FPr_ubar
Vector over levels of FillPatchers for ubar (2D)
Definition REMORA.H:1167
bool is_it_time_for_action(int nstep, amrex::Real time, amrex::Real dt, int action_interval, amrex::Real action_per)
Decide if it is time to take an action.
void set_hmixcoef(int lev)
Initialize horizontal mixing coefficients.
Definition REMORA.cpp:662
std::string nc_clim_his_file
NetCDF climatology history file.
Definition REMORA.H:1387
void timeStep(int lev, amrex::Real time, int iteration)
advance a level by dt, includes a recursive call for finer levels
void AverageDown()
set covered coarse cells to be the average of overlying fine cells
Definition REMORA.cpp:1261
static int fixed_ndtfast_ratio
User specified, number of barotropic steps per baroclinic step.
Definition REMORA.H:1284
void timeStepML(amrex::Real time, int iteration)
advance all levels by dt, loops over finer levels
amrex::Vector< std::unique_ptr< std::fstream > > datalog
Definition REMORA.H:1507
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Akv
Vertical viscosity coefficient (3D)
Definition REMORA.H:274
static amrex::Real cfl
CFL condition.
Definition REMORA.H:1276
void append3DPlotVariables(const std::string &pp_plot_var_names_3d)
static int verbose
Verbosity level of output.
Definition REMORA.H:1359
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_cloud
cloud cover fraction [0-1], defined at rho-points
Definition REMORA.H:349
std::string plot_file_name
Plotfile prefix.
Definition REMORA.H:1296
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Zt_avg1
Average of the free surface, zeta (2D)
Definition REMORA.H:308
int check_int
Checkpoint output interval in iterations.
Definition REMORA.H:1304
void WritePlotFile()
main driver for writing AMReX plotfiles
void set_smflux(int lev)
Initialize or calculate surface momentum flux from file or analytic.
Definition REMORA.cpp:698
std::string restart_chkfile
If set, restart from this checkpoint file.
Definition REMORA.H:1272
void init_clim_nudg_coeff(int lev)
Wrapper to initialize climatology nudging coefficient.
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_rv
v velocity RHS (3D, includes horizontal and vertical advection)
Definition REMORA.H:264
int cf_width
Nudging width at coarse-fine interface.
Definition REMORA.H:1152
static amrex::Vector< amrex::Vector< std::string > > nc_init_file
NetCDF initialization file.
Definition REMORA.H:52
int last_plot_file_step
Step when we last output a plotfile.
Definition REMORA.H:1249
amrex::Vector< amrex::Real > t_old
old time at each level
Definition REMORA.H:1206
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_srflx
Shortwave radiation flux [W/m²], defined at rho-points.
Definition REMORA.H:326
amrex::Real last_check_file_time
Simulation time when we last output a checkpoint file.
Definition REMORA.H:1256
void append2DPlotVariables(const std::string &pp_plot_var_names_2d)
amrex::Vector< amrex::Real > dt
time step at each level
Definition REMORA.H:1208
static amrex::Real sum_per
Diagnostic sum output interval in time.
Definition REMORA.H:1364
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Pair
Air pressure [mb], defined at rho-points.
Definition REMORA.H:324
virtual ~REMORA()
Definition REMORA.cpp:141
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_qair
Specific humidity [kg/kg], defined at rho-points.
Definition REMORA.H:322
void restart()
Definition REMORA.cpp:472
NCTimeSeries * Pair_data_from_file
Data container for air pressure read from file.
Definition REMORA.H:1107
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_Tair
Air temperature [°C], defined at rho-points.
Definition REMORA.H:320
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_diff2
Harmonic diffusivity for temperature / salinity.
Definition REMORA.H:282
const char * buildInfoGetGitHash(int i)
HorizMixingType horiz_mixing_type
amrex::Vector< amrex::Real > tnu2
amrex::Vector< int > do_rivers_cons
void init_params()
read in and initialize parameters
amrex::Real visc2
SMFluxType smflux_type
VertMixingType vert_mixing_type
CouplingType coupling_type