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),BCVars::foextrap_periodic_bc,BdyVars::null,0,false);
727 FillPatch(lev, t_old[lev], *vec_vwind[lev], GetVecOfPtrs(vec_vwind),BCVars::foextrap_periodic_bc,BdyVars::null,0,false);
728#endif
729 }
730}
731
732/**
733 * @param[in ] lev level to operate on
734 */
735void
737{
739 prob->init_analytic_masks(lev,geom[lev], solverChoice, *this, *vec_mskr[lev]);
742#ifdef REMORA_USE_NETCDF
743 if (lev == 0) {
744 amrex::Print() << "Calling init_masks_from_netcdf level " << lev << std::endl;
746 amrex::Print() << "Masks loaded from netcdf file \n " << std::endl;
747 } else {
748 Real dummy_time = 0.0_rt;
749 FillCoarsePatchPC(lev, dummy_time, vec_mskr[lev].get(), vec_mskr[lev-1].get(),
752 }
753#endif
754 }
755 fill_3d_masks(lev);
756}
757
758/**
759 * @param[in ] lev level to operate on
760 * @param[in ] time current time for initialization
761 */
762void
763REMORA::init_only (int lev, Real time)
764{
765 BL_PROFILE("REMORA::init_only()");
766 t_new[lev] = time;
767 t_old[lev] = time - 1.e200_rt;
768
769 cons_new[lev]->setVal(0.0_rt);
770 xvel_new[lev]->setVal(0.0_rt);
771 yvel_new[lev]->setVal(0.0_rt);
772 zvel_new[lev]->setVal(0.0_rt);
773
774 xvel_old[lev]->setVal(0.0_rt);
775 yvel_old[lev]->setVal(0.0_rt);
776 zvel_old[lev]->setVal(0.0_rt);
777
778 vec_ru[lev]->setVal(0.0_rt);
779 vec_rv[lev]->setVal(0.0_rt);
780
781 vec_ru2d[lev]->setVal(0.0_rt);
782 vec_rv2d[lev]->setVal(0.0_rt);
783
785 set_grid_scale(lev);
786 }
787 set_masks(lev);
788
789#ifdef REMORA_USE_NETCDF
792
794 if (nc_clim_his_file.empty()) {
795 amrex::Error("NetCDF climatology file name must be provided via input");
796 }
798 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);
799 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);
802 }
804 u_clim_data_from_file = new NCTimeSeries(nc_clim_his_file, "u", clim_u_time_varname, geom[lev].Domain(),xvel_new[lev],false,true);
805 v_clim_data_from_file = new NCTimeSeries(nc_clim_his_file, "v", clim_v_time_varname, geom[lev].Domain(),yvel_new[lev],false,true);
808 }
809 // Since the NCTimeSeries object isn't filling the cons_new MultiFab directly, we don't have to specify a component.
810 // It just needs to know the shape of the MultiFab
812 temp_clim_data_from_file = new NCTimeSeries(nc_clim_his_file, "temp", clim_temp_time_varname,geom[lev].Domain(),cons_new[lev],false,true);
814 }
816 salt_clim_data_from_file = new NCTimeSeries(nc_clim_his_file, "salt", clim_salt_time_varname,geom[lev].Domain(),cons_new[lev],false,true);
818 }
819 }
820 }
821
823 amrex::Print() << "Calling init_bdry_from_netcdf at level " << lev << std::endl;
825 amrex::Print() << "Boundary data loaded from netcdf file \n " << std::endl;
826 }
827
828 // This will be a non-op if forcings specified analytically
830 if (nc_frc_file.empty()) {
831 amrex::Error("NetCDF forcing file name must be provided via input for winds");
832 }
833 Uwind_data_from_file = new NCTimeSeries(nc_frc_file, "Uwind", frc_time_varname, geom[lev].Domain(),vec_uwind[lev].get(), true, false);
834 Vwind_data_from_file = new NCTimeSeries(nc_frc_file, "Vwind", frc_time_varname, geom[lev].Domain(),vec_vwind[lev].get(), true, false);
838 if (nc_frc_file.empty()) {
839 amrex::Error("NetCDF forcing file name must be provided via input for surface momentum fluxes");
840 }
841 sustr_data_from_file = new NCTimeSeries(nc_frc_file, "sustr", frc_time_varname, geom[lev].Domain(),vec_sustr[lev].get(), true, false);
842 svstr_data_from_file = new NCTimeSeries(nc_frc_file, "svstr", frc_time_varname, geom[lev].Domain(),vec_svstr[lev].get(), true, false);
845 }
846
848 auto dom = geom[0].Domain();
849 int nz = dom.length(2);
850 river_source_cons.resize(NCONS);
851 Print() << solverChoice.do_rivers_cons[0] << std::endl;
854 river_source_cons[Salt_comp]->Initialize();
855 }
858 river_source_cons[Temp_comp]->Initialize();
859 }
862 river_source_cons[Scalar_comp]->Initialize();
863 }
869 }
870#else
872 Abort("Not compiled with NetCDF, but selected boundary conditions require NetCDF");
873 }
875 Abort("Not compiled with NetCDF, but using river sources requires NetCDF");
876 }
877#endif
878
879 set_bathymetry(lev);
880 set_zeta(lev);
882
884 if (lev==0) {
886 {
887 init_analytic(lev);
888#ifdef REMORA_USE_NETCDF
889 } else if (solverChoice.ic_type == IC_Type::netcdf) {
890 amrex::Print() << "Calling init_data_from_netcdf " << std::endl;
893 amrex::Print() << "Initial data loaded from netcdf file \n " << std::endl;
894
895#endif
896 } else {
897 Abort("Need to specify ic_type");
898 }
899 } else {
904 }
907 {
908 init_analytic(lev);
909#ifdef REMORA_USE_NETCDF
910 } else if (solverChoice.ic_type == IC_Type::netcdf) {
911 amrex::Print() << "Calling init_data_from_netcdf on level " << lev << std::endl;
914 amrex::Print() << "Initial data loaded from netcdf file on level " << lev << std::endl;
915
916#endif
917 } else {
918 Abort("Need to specify ic_type");
919 }
920 } else {
921 amrex::Abort("Need to specify T init procedure");
922 }
923
924 // Ensure that the face-based data are the same on both sides of a periodic domain.
925 // The data associated with the lower grid ID is considered the correct value.
926 xvel_new[lev]->OverrideSync(geom[lev].periodicity());
927 yvel_new[lev]->OverrideSync(geom[lev].periodicity());
928 zvel_new[lev]->OverrideSync(geom[lev].periodicity());
929
930 set_2darrays(lev);
931
932 init_set_vmix(lev);
933 set_hmixcoef(lev);
934 set_coriolis(lev);
935
936 // Previously set smflux here with OverrideSync:
937// set_smflux(lev);
938// prob->init_analytic_smflux(lev, geom[lev], solverChoice, *this, *vec_sustr[lev], *vec_svstr[lev]);
939// vec_sustr[lev]->OverrideSync(geom[lev].periodicity());
940// vec_svstr[lev]->OverrideSync(geom[lev].periodicity());
941
942}
943
944void
946{
947 BL_PROFILE("REMORA::ReadParameters()");
948 {
949 ParmParse pp; // Traditionally, max_step and stop_time do not have prefix, so allow it for now.
950 bool noprefix_max_step = pp.queryAdd("max_step", max_step);
951 bool noprefix_stop_time = pp.queryAdd("stop_time", stop_time);
952 bool remora_max_step = pp.queryAdd("remora.max_step", max_step);
953 bool remora_stop_time = pp.queryAdd("remora.stop_time", stop_time);
954 if (remora_max_step and noprefix_max_step) {
955 Abort("remora.max_step and max_step are both specified. Please use only one!");
956 }
957 if (remora_stop_time and noprefix_stop_time) {
958 Abort("remora.stop_time and stop_time are both specified. Please use only one!");
959 }
960 }
961
962 ParmParse pp(pp_prefix);
963 ParmParse pp_amr("amr");
964 {
965 pp_amr.queryAdd("regrid_int", regrid_int);
966 pp.queryAdd("check_file", check_file);
967 pp.queryAdd("check_int", check_int);
968 pp_amr.queryAdd("check_int", check_int);
969 pp.queryAdd("check_int_time", check_int_time);
970 pp_amr.queryAdd("check_int_time", check_int_time);
971
972 pp.queryAdd("expand_plotvars_to_unif_rr", expand_plotvars_to_unif_rr);
973
974 pp.queryAdd("restart", restart_chkfile);
975 pp_amr.queryAdd("restart", restart_chkfile);
976 pp.queryAdd("start_time",start_time);
977
978 if (pp.contains("data_log"))
979 {
980 int num_datalogs = pp.countval("data_log");
981 datalog.resize(num_datalogs);
982 datalogname.resize(num_datalogs);
983 pp.queryarr("data_log",datalogname,0,num_datalogs);
984 for (int i = 0; i < num_datalogs; i++)
986 }
987
988 // Verbosity
989 pp.queryAdd("v", verbose);
990
991 // Frequency of diagnostic output
992 pp.queryAdd("sum_interval", sum_interval);
993 pp.queryAdd("sum_period" , sum_per);
994 pp.queryAdd("file_min_digits", file_min_digits);
995
996 if (file_min_digits < 0) {
997 amrex::Abort("remora.file_min_digits must be non-negative");
998 }
999
1000 // Time step controls
1001 pp.queryAdd("cfl", cfl);
1002 pp.queryAdd("change_max", change_max);
1003
1004 pp.queryAdd("fixed_dt", fixed_dt);
1005 pp.queryAdd("fixed_fast_dt", fixed_fast_dt);
1006
1007 pp.queryAdd("fixed_ndtfast_ratio", fixed_ndtfast_ratio);
1008
1009 // If all three are specified, they must be consistent
1010 if (fixed_dt > 0. && fixed_fast_dt > 0. && fixed_ndtfast_ratio > 0)
1011 {
1013 {
1014 amrex::Abort("Dt is over-specfied");
1015 }
1016 }
1017 // If two are specified, initialize fixed_ndtfast_ratio
1018 else if (fixed_dt > 0. && fixed_fast_dt > 0. && fixed_ndtfast_ratio <= 0)
1019 {
1020 fixed_ndtfast_ratio = static_cast<int>(fixed_dt / fixed_fast_dt);
1021 }
1022
1023 AMREX_ASSERT(cfl > 0. || fixed_dt > 0.);
1024
1025 pp_amr.queryAdd("do_substep", do_substep);
1026 if (do_substep) {
1027 amrex::Abort("Time substepping is not yet implemented. amr.do_substep must be 0");
1028 }
1029
1030 // We use this to keep track of how many boxes we read in from WRF initialization
1031 num_files_at_level.resize(max_level+1,0);
1032
1033 // We use this to keep track of how many boxes are specified thru the refinement indicators
1034 num_boxes_at_level.resize(max_level+1,0);
1035 boxes_at_level.resize(max_level+1);
1036
1037 // We always have exactly one file at level 0
1038 num_boxes_at_level[0] = 1;
1039 boxes_at_level[0].resize(1);
1040 boxes_at_level[0][0] = geom[0].Domain();
1041
1042 // Plotfile name and frequency
1043 pp.queryAdd("plot_file", plot_file_name);
1044 pp.queryAdd("plot_int", plot_int);
1045 pp.queryAdd("plot_int_time", plot_int_time);
1046
1047 // Should we plot the staggered face velocities (without averaging to cell centers)
1048 pp.queryAdd("plot_staggered_vels", plot_staggered_vels);
1049
1050 // Output format
1051 std::string plotfile_type_str = "amrex";
1052 pp.queryAdd("plotfile_type", plotfile_type_str);
1053 if (plotfile_type_str == "amrex") {
1055 } else if (plotfile_type_str == "netcdf" || plotfile_type_str == "NetCDF") {
1057#ifdef REMORA_USE_NETCDF
1058 pp.queryAdd("write_history_file",write_history_file);
1059 pp.queryAdd("chunk_history_file",chunk_history_file);
1060 pp.queryAdd("steps_per_history_file",steps_per_history_file);
1061 // Estimate size of domain for one timestep of netcdf
1062 auto dom = geom[0].Domain();
1063 int nx = dom.length(0) + 2;
1064 int ny = dom.length(1) + 2;
1065 int nz = dom.length(2);
1067 // Estimate number of steps that will fit into a 2GB file.
1068 steps_per_history_file = int((1.6e10 - NCH2D * nx * ny * 64.0_rt)
1069 / (nx * ny * 64.0_rt * (NC3D*nz + NC2D)));
1070 // If we calculate that a single step will exceed 2GB and the user has
1071 // requested automatic history file sizing, warn about a possible impending
1072 // error, and set steps_per_history_file = 1 to attempt output anyway.
1073 if (steps_per_history_file == 0) {
1074 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.");
1076 }
1077 } else if (write_history_file and !chunk_history_file) {
1078 // Estimate number of output steps we'll need
1079 int nt_out = int((max_step) / plot_int) + 1;
1080 Real est_hist_file_size = NCH2D * nx * ny * 64.0_rt + nt_out * nx * ny * 64.0_rt * (NC3D*nz + NC2D);
1081 if (est_hist_file_size > 1.6e10) {
1082 amrex::Warning("WARNING: NetCDF history file may be larger than 2GB limit. Consider setting remora.chunk_history_file=true");
1083 }
1084 }
1086 Print() << "NetCDF history files will have " << steps_per_history_file << " steps per file." << std::endl;
1087 }
1088#endif
1089 } else {
1090 amrex::Print() << "User selected plotfile_type = " << plotfile_type_str << std::endl;
1091 amrex::Abort("Dont know this plotfile_type");
1092 }
1093#ifndef REMORA_USE_NETCDF
1095 {
1096 amrex::Abort("Please compile with NetCDF in order to enable NetCDF plotfiles");
1097 }
1098
1099#endif
1100
1101#ifdef REMORA_USE_NETCDF
1102 nc_init_file.resize(max_level+1);
1103 nc_grid_file.resize(max_level+1);
1104
1105 boundary_series.resize(max_level+1);
1106
1107 // NetCDF initialization files -- possibly multiple files at each of multiple levels
1108 // but we always have exactly one file at level 0
1109 for (int lev = 0; lev <= max_level; lev++)
1110 {
1111 const std::string nc_file_names = amrex::Concatenate("nc_init_file_",lev,1);
1112 const std::string nc_bathy_file_names = amrex::Concatenate("nc_grid_file_",lev,1);
1113
1114 if (pp.contains(nc_file_names.c_str()))
1115 {
1116 int num_files = pp.countval(nc_file_names.c_str());
1117 int num_bathy_files = pp.countval(nc_bathy_file_names.c_str());
1118 if (num_files != num_bathy_files) {
1119 amrex::Error("Must have same number of netcdf files for grid info as for solution");
1120 }
1121
1122 num_files_at_level[lev] = num_files;
1123 nc_init_file[lev].resize(num_files);
1124 nc_grid_file[lev].resize(num_files);
1125
1126 pp.queryarr(nc_file_names.c_str() , nc_init_file[lev] ,0,num_files);
1127 pp.queryarr(nc_bathy_file_names.c_str(), nc_grid_file[lev],0,num_files);
1128 }
1129 }
1130 // We only read boundary data at level 0
1131 pp.queryarr("nc_bdry_file", nc_bdry_file);
1132
1133 // Also only read forcings at level 0 (for now)
1134 pp.queryAdd("nc_frc_file", nc_frc_file);
1135
1136 // Get river file
1137 pp.queryAdd("nc_river_file", nc_riv_file);
1138
1139 // Read in file names for climatology history and nudging weights
1140 pp.queryAdd("nc_clim_his_file", nc_clim_his_file);
1141 pp.queryAdd("nc_clim_coeff_file", nc_clim_coeff_file);
1142
1143 for (int i=0; i<BdyVars::NumTypes; i++) {
1144 bdry_time_name_byvar.push_back("");
1145 }
1146 pp.queryAdd("bdy_time_varname",bdry_time_varname);
1147 pp.queryAdd("bdy_temp_time_varname",bdry_time_name_byvar[BdyVars::t]);
1148 pp.queryAdd("bdy_salt_time_varname",bdry_time_name_byvar[BdyVars::s]);
1149 pp.queryAdd("bdy_u_time_varname",bdry_time_name_byvar[BdyVars::u]);
1150 pp.queryAdd("bdy_v_time_varname",bdry_time_name_byvar[BdyVars::v]);
1151 pp.queryAdd("bdy_ubar_time_varname",bdry_time_name_byvar[BdyVars::ubar]);
1152 pp.queryAdd("bdy_vbar_time_varname",bdry_time_name_byvar[BdyVars::vbar]);
1153 pp.queryAdd("bdy_zeta_time_varname",bdry_time_name_byvar[BdyVars::zeta]);
1154
1155 // If not specified per variable, populate with the default
1156 for (int i=0; i<BdyVars::NumTypes; i++) {
1157 if (bdry_time_name_byvar[i] == "") {
1159 }
1160 }
1161
1162 pp.queryAdd("frc_time_varname",frc_time_varname);
1163
1164 pp.queryAdd("riv_time_varname",riv_time_varname);
1165
1166 pp.queryAdd("clim_ubar_time_varname",clim_ubar_time_varname);
1167 pp.queryAdd("clim_vbar_time_varname",clim_vbar_time_varname);
1168 pp.queryAdd("clim_u_time_varname",clim_u_time_varname);
1169 pp.queryAdd("clim_v_time_varname",clim_v_time_varname);
1170 pp.queryAdd("clim_salt_time_varname",clim_salt_time_varname);
1171 pp.queryAdd("clim_temp_time_varname",clim_temp_time_varname);
1172
1173#endif
1174
1175#ifdef REMORA_USE_PARTICLES
1176 readTracersParams();
1177#endif
1178 }
1179
1181}
1182
1183void
1185{
1186 BL_PROFILE("REMORA::AverageDown()");
1187 for (int lev = finest_level-1; lev >= 0; --lev)
1188 {
1189 AverageDownTo(lev);
1190 }
1191}
1192
1193/**
1194 * @param[in ] crse_lev level to average down to
1195 */
1196void
1198{
1199 BL_PROFILE("REMORA::AverageDownTo()");
1200 average_down(*cons_new[crse_lev+1], *cons_new[crse_lev],
1201 0, cons_new[crse_lev]->nComp(), refRatio(crse_lev));
1202 average_down(*vec_Zt_avg1[crse_lev+1].get(), *vec_Zt_avg1[crse_lev].get(),
1203 0, vec_Zt_avg1[crse_lev]->nComp(), refRatio(crse_lev));
1204
1205 Array<MultiFab*,AMREX_SPACEDIM> faces_crse;
1206 Array<MultiFab*,AMREX_SPACEDIM> faces_fine;
1207 faces_crse[0] = xvel_new[crse_lev];
1208 faces_crse[1] = yvel_new[crse_lev];
1209 faces_crse[2] = zvel_new[crse_lev];
1210
1211 faces_fine[0] = xvel_new[crse_lev+1];
1212 faces_fine[1] = yvel_new[crse_lev+1];
1213 faces_fine[2] = zvel_new[crse_lev+1];
1214
1215 average_down_faces(GetArrOfConstPtrs(faces_fine), faces_crse,
1216 refRatio(crse_lev),geom[crse_lev]);
1217 stretch_transform(crse_lev);
1218}
1219
1220/**
1221 * @param[in ] lev level at which to get time
1222 */
1223amrex::Real REMORA::get_t_old(int lev) const
1224{
1225 return t_old[lev];
1226}
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:1343
NCTimeSeriesRiver * river_source_transportbar
Data container for vertically integrated momentum transport in rivers.
Definition REMORA.H:1105
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...
std::string riv_time_varname
Name of time field for river time.
Definition REMORA.H:1379
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:1250
amrex::Real last_plot_file_time
Simulation time when we last output a plotfile.
Definition REMORA.H:1221
amrex::Vector< NCTimeSeriesRiver * > river_source_cons
Vector of data containers for scalar data in rivers.
Definition REMORA.H:1101
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.
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:1446
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_fcor
coriolis factor (2D)
Definition REMORA.H:391
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:1131
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:1076
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:1160
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_mskr
land/sea mask at cell centers (2D)
Definition REMORA.H:375
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:1332
int history_count
Counter for which time index we are writing to in the netcdf history file.
Definition REMORA.H:1286
amrex::Real stop_time
Time to stop.
Definition REMORA.H:1236
int do_substep
Whether to substep fine levels in time.
Definition REMORA.H:1259
NCTimeSeries * vbar_clim_data_from_file
Data container for vbar climatology data read from file.
Definition REMORA.H:1090
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:1083
std::string bdry_time_varname
Default name of time field for boundary data.
Definition REMORA.H:1362
void ReadCheckpointFile()
read checkpoint file from disk
bool chunk_history_file
Whether to chunk netcdf history file.
Definition REMORA.H:1279
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:1223
NCTimeSeries * v_clim_data_from_file
Data container for v-velocity climatology data read from file.
Definition REMORA.H:1094
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:1478
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:763
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:1371
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:1129
std::string clim_temp_time_varname
Name of time field for temperature climatology data.
Definition REMORA.H:1377
amrex::Vector< amrex::Vector< amrex::Box > > boxes_at_level
the boxes specified at each level by tagging criteria
Definition REMORA.H:1167
static amrex::Vector< amrex::AMRErrorTag > ref_tags
Holds info for dynamically generated tagging criteria.
Definition REMORA.H:1388
std::string nc_frc_file
NetCDF forcing file.
Definition REMORA.H:1353
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:1367
void WriteNCPlotFile(int istep)
Write plotfile using NetCDF (wrapper)
std::string check_file
Checkpoint file prefix.
Definition REMORA.H:1272
static amrex::Real startCPUTime
Variable for CPU timing.
Definition REMORA.H:1444
NCTimeSeries * u_clim_data_from_file
Data container for u-velocity climatology data read from file.
Definition REMORA.H:1092
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:1239
NCTimeSeries * ubar_clim_data_from_file
Data container for ubar climatology data read from file.
Definition REMORA.H:1088
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:1252
int regrid_int
how often each level regrids the higher levels of refinement (after a level advances that many time s...
Definition REMORA.H:1262
amrex::Real check_int_time
Checkpoint output interval in seconds.
Definition REMORA.H:1276
NCTimeSeries * sustr_data_from_file
Data container for u-component surface momentum flux read from file.
Definition REMORA.H:1079
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:1270
amrex::Vector< int > num_files_at_level
how many netcdf input files specified at each level
Definition REMORA.H:1165
amrex::Vector< REMORAFillPatcher > FPr_vbar
Vector over levels of FillPatchers for vbar (2D)
Definition REMORA.H:1139
void AverageDownTo(int crse_lev)
more flexible version of AverageDown() that lets you average down across multiple levels
Definition REMORA.cpp:1197
int steps_per_history_file
Number of time steps per netcdf history file.
Definition REMORA.H:1284
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:1234
amrex::Vector< amrex::MultiFab * > zvel_old
multilevel data container for last step's z velocities (largely unused; W stored separately)
Definition REMORA.H:238
amrex::Vector< int > num_boxes_at_level
how many boxes specified at each level by tagging criteria
Definition REMORA.H:1163
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:1224
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:1369
amrex::Vector< int > nsubsteps
How many substeps on each level?
Definition REMORA.H:1172
amrex::Vector< std::unique_ptr< REMORAPhysBCFunct > > physbcs
Vector (over level) of functors to apply physical boundary conditions.
Definition REMORA.H:1184
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:1268
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:1170
void WriteCheckpointFile()
write checkpoint file to disk
std::string nc_clim_coeff_file
NetCDF climatology coefficient file.
Definition REMORA.H:1359
void setRecordDataInfo(int i, const std::string &filename)
Definition REMORA.H:1464
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:1364
static int file_min_digits
Minimum number of digits in plotfile name or chunked history file.
Definition REMORA.H:1337
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:1354
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:1248
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.
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
amrex::Vector< REMORAFillPatcher > FPr_c
Vector over levels of FillPatchers for scalars.
Definition REMORA.H:1127
std::string clim_v_time_varname
Name of time field for v climatology data.
Definition REMORA.H:1373
amrex::Vector< REMORAFillPatcher > FPr_w
Vector over levels of FillPatchers for w.
Definition REMORA.H:1133
amrex::Vector< amrex::YAFluxRegister * > advflux_reg
array of flux registers for refluxing in multilevel
Definition REMORA.H:1187
std::string clim_salt_time_varname
Name of time field for salinity climatology data.
Definition REMORA.H:1375
NCTimeSeries * Vwind_data_from_file
Data container for v-direction wind read from file.
Definition REMORA.H:1085
amrex::Vector< amrex::Real > t_new
new time at each level
Definition REMORA.H:1174
NCTimeSeriesRiver * river_source_transport
Data container for momentum transport in rivers.
Definition REMORA.H:1103
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:1096
static SolverChoice solverChoice
Container for algorithmic choices.
Definition REMORA.H:1299
void set_masks(int lev)
Initialize land-sea masks from file or analytic.
Definition REMORA.cpp:736
int cf_set_width
Width for fixing values at coarse-fine interface.
Definition REMORA.H:1124
NCTimeSeries * salt_clim_data_from_file
Data container for salinity climatology data read from file.
Definition REMORA.H:1098
void ReadParameters()
read in some parameters from inputs file
Definition REMORA.cpp:945
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:1081
void sum_integrated_quantities(amrex::Real time)
Integrate conserved quantities for diagnostics.
static int total_nc_plot_file_step
Definition REMORA.H:989
static int plot_staggered_vels
Whether to write the staggered velocities (not averaged to cell centers)
Definition REMORA.H:1340
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:1108
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_zeta
free surface height (2D)
Definition REMORA.H:372
amrex::Vector< std::unique_ptr< amrex::MultiFab > > vec_vbar
barotropic y velocity (2D)
Definition REMORA.H:370
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:1302
int plot_file_on_restart
Whether to output a plotfile on restart from checkpoint.
Definition REMORA.H:1228
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:368
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:1381
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:1137
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:1357
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:1184
static int fixed_ndtfast_ratio
User specified, number of barotropic steps per baroclinic step.
Definition REMORA.H:1254
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:1477
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:1246
void append3DPlotVariables(const std::string &pp_plot_var_names_3d)
static int verbose
Verbosity level of output.
Definition REMORA.H:1329
std::string plot_file_name
Plotfile prefix.
Definition REMORA.H:1266
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:1274
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:1242
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:1122
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:1219
amrex::Vector< amrex::Real > t_old
old time at each level
Definition REMORA.H:1176
amrex::Real last_check_file_time
Simulation time when we last output a checkpoint file.
Definition REMORA.H:1226
void append2DPlotVariables(const std::string &pp_plot_var_names_2d)
amrex::Vector< amrex::Real > dt
time step at each level
Definition REMORA.H:1178
static amrex::Real sum_per
Diagnostic sum output interval in time.
Definition REMORA.H:1334
virtual ~REMORA()
Definition REMORA.cpp:141
void restart()
Definition REMORA.cpp:472
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