Alamo
Integrator.H
Go to the documentation of this file.
1//
2// Pure abstract class for managing data structures, time integration (with substepping),
3// mesh refinement, and I/O.
4//
5// Native input file parameters:
6//
7// .. code-block:: make
8//
9// max_step = [maximum number of timesteps]
10// stop_time = [maximum simulation time]
11// timestep = [time step for coarsest level]
12//
13// amr.regrid_int = [number of timesteps between regridding]
14// amr.plot_int = [number of timesteps between dumping output]
15// amr.plot_file = [base name of output directory]
16//
17// amr.nsubsteps = [number of temporal substeps at each level. This can be
18// either a single int (which is then applied to every refinement
19// level) or an array of ints (equal to amr.max_level)
20// corresponding to the refinement for each level.]
21//
22// Inherited input file parameters (from amrex AmrMesh class):
23//
24// .. code-block:: make
25//
26// amr.v = [verbosity level]
27// amr.max_level = [maximum level of refinement]
28// amr.n_proper =
29// amr.grid_eff =
30// amr.n_error_buff =
31// amr.ref_ratio_vect = [refinement ratios in each direction]
32// amr.ref_ratio = [refinement ratio in all directions (cannot be used with ref_ratio_vect)]
33// amr.max_grid_x =
34// amr.blocking_factor =
35// amr.n_cell = [number of cells on coarsest level]
36// amr.refine_grid_layout =
37// amr.check_input =
38//
39
40#ifndef INTEGRATOR_INTEGRATOR_H
41#define INTEGRATOR_INTEGRATOR_H
42
43#include <chrono>
44#include <ctime>
45#include <string>
46#include <limits>
47#include <memory>
48
49#ifdef _OPENMP
50#include <omp.h>
51#endif
52
53#include <AMReX_ParallelDescriptor.H>
54#include <AMReX_ParmParse.H>
55#include <AMReX_MultiFabUtil.H>
56#include <AMReX_FillPatchUtil.H>
57#include <AMReX_BC_TYPES.H>
58#include <AMReX_AmrCore.H>
59#include <AMReX_FluxRegister.H>
60#include <AMReX_Utility.H>
61#include <AMReX_PlotFileUtil.H>
62
63#include "Set/Set.H"
64#include "BC/BC.H"
65#include "BC/Nothing.H"
66#include "IO/WriteMetaData.H"
67#include "BaseField.H"
68
69/// \brief Collection of numerical integrator objects
70namespace Integrator
71{
72
74 : public amrex::AmrCore
75{
76public:
77
78 /// This is the constructor for the intetgrator class, which reads timestep information,
79 /// simulation output and AMR, initialized time substep, and creates a new directory.
80 Integrator();
81
82 /// Virtual destructure; make sure delete any pointers that you create here.
83 virtual ~Integrator();
84
85 /// Front-end method to initialize simulation on all levels
86 void InitData();
87
88 /// Read in output from previous simulation and start simulation at that point -
89 /// Not currently tested
90 void Restart(std::string restartfile, bool a_node = false);
91
92 /// Front-end method to start simulation
93 void Evolve();
94
95 /// Simple setter to set filename
96 void SetFilename(std::string _plot_file) { plot_file = _plot_file; };
97
98 /// Simple getter to get filename
99 std::string GetFilename() { return plot_file; };
100
101 /// This overrides an AMReX method just to allow for explicit meshing when
102 /// desired.
103 void regrid(int lbase, Set::Scalar time, bool initial = false) override
104 {
105 if (!explicitmesh.on)
106 AmrCore::regrid(lbase, time, initial);
107 }
108
109 /// This creates a new levels that have not previously been
110 /// used.
112 {
113 if (!explicitmesh.on) AmrCore::InitFromScratch(time);
114 else
115 {
116 // Generate the coarse level mesh.
117 {
118 finest_level = 0;
119 const amrex::BoxArray& ba = MakeBaseGrids();
120 amrex::DistributionMapping dm(ba);
121 const auto old_num_setdm = num_setdm;
122 const auto old_num_setba = num_setba;
123 MakeNewLevelFromScratch(0, time, ba, dm);
124 if (old_num_setba == num_setba) SetBoxArray(0, ba);
125 if (old_num_setdm == num_setdm) SetDistributionMap(0, dm);
126 }
127 // Generate subsequent level meshes based on user input
128 for (int ilev = 0; ilev < maxLevel(); ++ilev)
129 {
130 finest_level = ilev + 1;
131 amrex::BoxArray grids(explicitmesh.box[ilev]);
132 ChopGrids(ilev + 1, grids, amrex::ParallelDescriptor::NProcs());
133 amrex::DistributionMapping dmap(grids);
134 SetBoxArray(ilev + 1, grids);
135 SetDistributionMap(ilev + 1, dmap);
136 MakeNewLevelFromScratch(ilev + 1, time, grids, dmap);
137 }
138
139 }
140 }
141
142protected:
143
144 /// You must override this function to inherit this class;
145 /// this function is called before the simulation begins, and is where
146 /// initial conditions should be applied.
147 virtual void Initialize(int lev ///<[in] AMR Level
148 ) = 0;
149
150 /// You must override this function to inherit this class;
151 /// Advance is called every time(sub)step, and implements the evolution of
152 /// the system in time.
153 virtual void Advance(int lev, ///<[in] AMR Level
154 amrex::Real time, ///< [in] System time
155 amrex::Real dt ///< [in] Timestep for this level
156 ) = 0;
157
158 /// You must override this function to inherit this class;
159 /// Advance is called every time(sub)step, and implements the evolution of
160 /// the system in time.
161 virtual void TagCellsForRefinement(int lev, amrex::TagBoxArray& tags, amrex::Real time,
162 int ngrow) = 0;
163
164 /// This optional function is called at the beginning of every timestep, and can be used
165 /// to complete additional global solves, e.g. a MLMG implicit solve.
166 virtual void TimeStepBegin(Set::Scalar /*time*/, int /*iter*/) {};
167
168 /// This optional function is called at the end of every timestep, and can be used
169 /// to complete additional global solves, e.g. a MLMG implicit solve.
170 virtual void TimeStepComplete(Set::Scalar /*time*/, int /*iter*/) {};
171
172 /// This is a function that is called by `Integrator` to update the variables registered in
173 /// RegisterIntegratedVariable; you can override this to do your integration.
174 virtual void Integrate( int /*amrlev*/,
175 Set::Scalar /*time*/,
176 int /*iter*/,
177 const amrex::MFIter&/*mfi*/,
178 const amrex::Box&/*box*/
179 )
180 {
181 if (thermo.number > 0)
182 Util::Warning(INFO, "integrated variables registered, but no integration implemented!");
183 }
184
185 /// An optionally overridable method to trigger behavior whenver a regrid occurs.
186 virtual void Regrid(int /* amrlev */, Set::Scalar /* time */)
187 {}
188
189
190 /// Add a new cell-based scalar field.
191 void RegisterNewFab(Set::Field<Set::Scalar>& new_fab, BC::BC<Set::Scalar>* new_bc, int ncomp, int nghost, std::string name, bool writeout,std::vector<std::string> suffix = {});
192 /// Add a new cell-based scalar field (with additional arguments).
193 void RegisterNewFab(Set::Field<Set::Scalar>& new_fab, int ncomp, std::string name, bool writeout,std::vector<std::string> suffix = {});
194 /// Add a new node-based scalar field
195 void RegisterNodalFab(Set::Field<Set::Scalar>& new_fab, int ncomp, int nghost, std::string name, bool writeout,std::vector<std::string> suffix = {});
196 /// Add a new node-based scalar field (wtih additional arguments)
197 void RegisterNodalFab(Set::Field<Set::Scalar>& new_fab, BC::BC<Set::Scalar>* new_bc, int ncomp, int nghost, std::string name, bool writeout,std::vector<std::string> suffix = {});
198 template<class T>
199 /// Add a templated nodal field
200 void RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, bool evolving = true);
201 template<class T>
202 /// Add a templated nodal field (additional arguments)
203 void RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, std::string a_name, bool evolving = true);
204 template<class T>
205 /// Add a templated nodal field (additional arguments)
206 void RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, bool writeout, std::string a_name, bool evolving = true);
207
208 /// Add a field with arbitrary type (templated with T) and grid location (templated with d).
209 template<class T, int d>
210 void AddField( Set::Field<T>& new_field, BC::BC<T>* new_bc, int ncomp, int nghost,
211 std::string, bool writeout, bool evolving, std::vector<std::string> suffix = {});
212
213 /// Utility to ensure that all fields know what the finest level is
214 void SetFinestLevel(const int a_finestlevel)
215 {
216 for (unsigned int i = 0; i < cell.fab_array.size(); i++)
217 cell.fab_array[i]->finest_level = a_finestlevel;
218 for (unsigned int i = 0; i < node.fab_array.size(); i++)
219 node.fab_array[i]->finest_level = a_finestlevel;
220 for (unsigned int i = 0; i < m_basefields_cell.size(); i++)
221 m_basefields_cell[i]->SetFinestLevel(finest_level);
222 for (unsigned int i = 0; i < m_basefields.size(); i++)
223 m_basefields[i]->SetFinestLevel(finest_level);
224 }
225
226 /// Register a variable to be integrated over the spatial domain using
227 /// the Integrate function.
228 void RegisterIntegratedVariable(Set::Scalar* integrated_variable, std::string name, bool extensive=true);
229
230 /// Utility to set the coarse-grid timestep
231 void SetTimestep(Set::Scalar _timestep);
232
233 /// Utility to set the frequency (in timesteps) of plotfile dumping
234 void SetPlotInt(int plot_int);
235
236 /// Utility to set the frequency (in timesteps) of thermo data calculation
237 void SetThermoInt(int a_thermo_int) { thermo.interval = a_thermo_int; }
238 /// Utility to set the frequency (in timesteps) of thermo data writing to file
239 void SetThermoPlotInt(int a_thermo_plot_int) { thermo.plot_int = a_thermo_plot_int; }
240 /// Utility to set the global stop time.
241 void SetStopTime(Set::Scalar a_stop_time) { stop_time = a_stop_time; }
242
243
244 // Dynamic timestep adjustment
245
246 struct {
247 // user params
248 bool on = false;
249 int verbose = -1;
250 int nprevious = -1;
251 Set::Scalar cfl = NAN;
252 Set::Scalar min = NAN;
253 Set::Scalar max = NAN;
254 // internal variables
255 std::vector<Set::Scalar> dt_limit_min;
256 std::vector<Set::Scalar> previous_timesteps;
257 } dynamictimestep; /// Params for the dynamic timestp
259 {
260 if (!dynamictimestep.on) return;
261 if (!dynamictimestep.dt_limit_min.size())
262 {
263 dynamictimestep.dt_limit_min.resize(max_level+1,
264 std::numeric_limits<Set::Scalar>::max());
265 }
266 dynamictimestep.dt_limit_min[lev] = std::min(dt_min,
267 dynamictimestep.dt_limit_min[lev]);
268
269 amrex::ParallelDescriptor::ReduceRealMin(dynamictimestep.dt_limit_min[lev]);
270 }
272 {
273 if (!dynamictimestep.on) return;
274 dynamictimestep.previous_timesteps.clear();
275 }
277 {
278 if (!dynamictimestep.on) return;
279 if (!dynamictimestep.dt_limit_min.size()) return;
280
281 Set::Scalar final_timestep = NAN;
282
283 if (amrex::ParallelDescriptor::IOProcessor())
284 {
285 Set::Scalar timestep_average = this->dt[0];
286 if (dynamictimestep.previous_timesteps.size() > 0)
287 {
288 timestep_average = 0.0;
289 for (unsigned int d = 0; d < dynamictimestep.previous_timesteps.size(); d++)
290 timestep_average += dynamictimestep.previous_timesteps[d];
291 timestep_average /= dynamictimestep.previous_timesteps.size();
292 }
293
294 Set::Scalar new_timestep = std::numeric_limits<Set::Scalar>::max();
295 for (int lev = 0; lev <= this->max_level; lev++)
296 {
297 //const Set::Scalar* DX = this->geom[lev].CellSize();
298 Set::Scalar dt_lev = dynamictimestep.dt_limit_min[lev];
299
300 Util::Message(INFO,"lev=",lev," ",dt_lev, " (",this->nsubsteps[lev],")");
301
302 for (int ilev = lev; ilev > 0; ilev--) dt_lev *= (Set::Scalar)(this->nsubsteps[ilev]);
303
304 Util::Message(INFO,"lev=",lev," --> ",dt_lev);
305
306 new_timestep = std::min(new_timestep,dt_lev);
307 }
308
309 if (new_timestep < timestep_average)
310 {
311 dynamictimestep.previous_timesteps.clear();
312
313 final_timestep = new_timestep;
314 final_timestep = std::max(final_timestep,dynamictimestep.min);
315 final_timestep = std::min(final_timestep,dynamictimestep.max);
316
317 dynamictimestep.previous_timesteps.push_back(new_timestep);
318 }
319 else
320 {
321 final_timestep = timestep_average;
322 final_timestep = std::max(final_timestep,dynamictimestep.min);
323 final_timestep = std::min(final_timestep,dynamictimestep.max);
324
325 if ((int)(dynamictimestep.previous_timesteps.size()) > dynamictimestep.nprevious)
326 dynamictimestep.previous_timesteps.erase(dynamictimestep.previous_timesteps.begin()); // pop first
327 dynamictimestep.previous_timesteps.push_back(new_timestep); // push back new timestep
328 }
329
330 }
331 amrex::ParallelDescriptor::Bcast(&final_timestep,1);
332 this->SetTimestep(final_timestep);
333 dynamictimestep.dt_limit_min.clear();
334 }
335
336
337
338 amrex::Vector<amrex::Real> t_new; ///< Keep track of current old simulation time on each level
339 amrex::Vector<int> istep; ///< Keep track of where each level is
340 // PLOT FILES
341 std::string plot_file{ "plt" }; ///< Plotfile name
342
343private:
344 virtual void MakeNewLevelFromScratch(int lev, amrex::Real time, const amrex::BoxArray& ba,
345 const amrex::DistributionMapping& dm) override;
346 virtual void MakeNewLevelFromCoarse(int lev, amrex::Real time, const amrex::BoxArray& ba,
347 const amrex::DistributionMapping& dm) override;
348 virtual void RemakeLevel(int lev, amrex::Real time, const amrex::BoxArray& ba,
349 const amrex::DistributionMapping& dm) override;
350 virtual void ClearLevel(int lev) override;
351 virtual void ErrorEst(int lev, amrex::TagBoxArray& tags, amrex::Real time, int ngrow) override;
352
353
354 /// This is the function that is responsible for updating patch data.
355 void FillPatch(int lev, amrex::Real time,
356 amrex::Vector<std::unique_ptr<amrex::MultiFab>>& source_mf,
357 amrex::MultiFab& destination_multifab,
358 BC::BC<Set::Scalar>& physbc,
359 int icomp);
360 /// Simple utility to count cells
361 long CountCells(int lev);
362 /// Timestep marching
363 void TimeStep(int lev, amrex::Real time, int iteration);
364 void FillCoarsePatch(int lev, amrex::Real time, Set::Field<Set::Scalar>& mf, BC::BC<Set::Scalar>& physbc, int icomp, int ncomp);
365 void GetData(const int lev, const amrex::Real time, amrex::Vector<amrex::MultiFab*>& data, amrex::Vector<amrex::Real>& datatime);
366
367 std::vector<std::string> PlotFileName(int lev, std::string prefix = "") const;
368protected:
369 void IntegrateVariables(Set::Scalar cur_time, int step);
370 void WritePlotFile(bool initial = false) const;
371 void WritePlotFile(std::string prefix, Set::Scalar time, int step) const;
372 void WritePlotFile(Set::Scalar time, amrex::Vector<int> iter, bool initial = false, std::string prefix = "") const;
373
374 //
375 // MEMBER VARIABLES
376 //
377
378 // TIME (STEP) KEEPINGamrex::Vector<std::unique_ptr<amrex::MultiFab> >
379protected:
380 amrex::Real timestep = NAN; ///< Timestep for the base level of refinement
381 amrex::Vector<amrex::Real> dt; ///< Timesteps for each level of refinement
382 amrex::Vector<int> nsubsteps; ///< how many substeps on each level?
383private:
384 int max_plot_level = -1;
385
386 amrex::Vector<amrex::Real> t_old;///< Keep track of current old simulation time on each level
387 int max_step = std::numeric_limits<int>::max(); ///< Maximum allowable timestep
388 amrex::Real tstart = 0; ///< Default start time (default: 0)
389 amrex::Real stop_time = NAN; ///< Default stop time
390
391protected:
392 bool integrate_variables_before_advance = true;
393 bool integrate_variables_after_advance = false;
394
395protected:
396 struct {
397 int number_of_fabs = 0;
398 std::vector<Set::Field<Set::Scalar>*> fab_array;
399 std::vector<int> ncomp_array;
400 std::vector<int> nghost_array;
401 std::vector<std::vector<std::string>> name_array;
402 std::vector<BC::BC<Set::Scalar>*> physbc_array;
403 std::vector<bool> writeout_array;
404 bool any = true;
405 bool all = false;
406 } node;
407
408 struct {
409 int number_of_fabs = 0;
410 std::vector<Set::Field<Set::Scalar>*> fab_array;
411 std::vector<int> ncomp_array;
412 std::vector<int> nghost_array;
413 std::vector<std::vector<std::string>> name_array;
414 std::vector<BC::BC<Set::Scalar>*> physbc_array;
415 std::vector<bool> writeout_array;
416 bool any = true;
417 bool all = false;
418 } cell;
419
420 std::vector<BaseField*> m_basefields;
421 std::vector<BaseField*> m_basefields_cell;
422
424
425 // KEEP TRACK OF ALL INTEGRATED VARIABLES
426 struct {
427 int interval = -1;
428 Set::Scalar dt = NAN;
429 int plot_int = -1;
430 Set::Scalar plot_dt = NAN;
431 int number = 0;
432 std::vector<Set::Scalar*> vars;
433 std::vector<std::string> names;
434 std::vector<bool> extensives;
435 } thermo;
436
437 // REGRIDDING
438 int regrid_int = -1; ///< Determine how often to regrid (default: 2)
439 int base_regrid_int = -1; ///< Determine how often to regrid based on coarse level only (default: 0)
440
441 std::string restart_file_cell = "";
442 std::string restart_file_node = "";
443
444 struct {
445 int on = 0;
446 std::vector<amrex::Box> box;
447 } explicitmesh;
448
449protected:
450 int plot_int = -1; ///< How frequently to dump plot file (default: never)
451 Set::Scalar plot_dt = -1.0;
452
453 int abort_on_nan = true;
454};
455
456
457template<>
460( Set::Field<Set::Scalar>& new_field,
461 BC::BC<Set::Scalar>* new_bc,
462 int ncomp,
463 int nghost,
464 std::string name,
465 bool writeout,
466 bool /*evolving*/,
467 std::vector<std::string> suffix)
468{
469 int nlevs_max = maxLevel() + 1;
470 new_field.resize(nlevs_max);
471 cell.fab_array.push_back(&new_field);
472 if (new_bc != nullptr) cell.physbc_array.push_back(new_bc);
473 else cell.physbc_array.push_back(&bcnothing);
474 cell.ncomp_array.push_back(ncomp);
475 cell.nghost_array.push_back(nghost);
476 //cell.name_array.push_back(name);
477 cell.writeout_array.push_back(writeout);
478 cell.number_of_fabs++;
479
480 Util::Assert(INFO,TEST((int)suffix.size() == 0 || (int)suffix.size() == ncomp));
481 std::vector<std::string> names;
482 if (ncomp == 1)
483 names.push_back(name);
484 else
485 {
486 if (suffix.size() == 0)
487 for (int j = 0; j < ncomp; j++)
488 names.push_back(amrex::Concatenate(name,j+1,3));
489 else
490 for (int j = 0; j < ncomp; j++)
491 names.push_back(name + suffix[j]);
492 }
493 cell.name_array.push_back(names);
494}
495
496template<>
499( Set::Field<Set::Scalar>& new_field,
500 BC::BC<Set::Scalar>* new_bc,
501 int ncomp,
502 int nghost,
503 std::string name,
504 bool writeout,
505 bool /*evolving*/,
506 std::vector<std::string> suffix)
507{
508 BL_PROFILE("Integrator::RegisterNodalFab");
509 Util::Assert(INFO, TEST(new_bc == nullptr));
510 int nlevs_max = maxLevel() + 1;
511 new_field.resize(nlevs_max);
512 node.fab_array.push_back(&new_field);
513 node.physbc_array.push_back(&bcnothing);
514 node.ncomp_array.push_back(ncomp);
515 node.nghost_array.push_back(nghost);
516 //node.name_array.push_back(name);
517 node.writeout_array.push_back(writeout);
518 node.number_of_fabs++;
519
520 Util::Assert(INFO,TEST((int)suffix.size() == 0 || (int)suffix.size() == ncomp));
521 std::vector<std::string> names;
522 if (ncomp == 1)
523 names.push_back(name);
524 else
525 {
526 if (suffix.size() == 0)
527 for (int j = 0; j < ncomp; j++)
528 names.push_back(amrex::Concatenate(name,j+1,3));
529 else
530 for (int j = 0; j < ncomp; j++)
531 names.push_back(name + suffix[j]);
532 }
533 node.name_array.push_back(names);
534}
535
536template<class T, int d>
539( Set::Field<T>& new_field, BC::BC<T>* new_bc, int ncomp,
540 int nghost, std::string name, bool writeout, bool evolving,
541 std::vector<std::string> /*suffix*/)
542{
543 if (d == Set::Hypercube::Node)
544 {
545 Util::Assert(INFO, TEST(new_bc == nullptr));
546 int nlevs_max = maxLevel() + 1;
547 new_field.resize(nlevs_max);
548 m_basefields.push_back(new Field<T>(new_field, geom, refRatio(), ncomp, nghost));
549 m_basefields.back()->evolving = evolving;
550 m_basefields.back()->writeout = writeout;
551 m_basefields.back()->setName(name);
552 m_basefields.back()->evolving = evolving;
553 m_basefields.back()->m_gridtype = Set::Hypercube::Node;
554 }
555 else if (d == Set::Hypercube::Cell)
556 {
557 int nlevs_max = maxLevel() + 1;
558 new_field.resize(nlevs_max);
559 m_basefields_cell.push_back(new Field<T>(new_field, geom, refRatio(), ncomp, nghost));
560 m_basefields_cell.back()->evolving = evolving;
561 m_basefields_cell.back()->writeout = writeout;
562 m_basefields_cell.back()->setName(name);
563 m_basefields_cell.back()->evolving = evolving;
564 if (new_bc) m_basefields_cell.back()->setBC(new_bc);
565 else m_basefields_cell.back()->setBC(&bcnothing);
566 m_basefields_cell.back()->m_gridtype = Set::Hypercube::Cell;
567 }
568 else
569 {
570 Util::Abort(INFO, "Only node and cell based fields can be added at this time");
571 }
572}
573
574
575
576template<class T>
578void Integrator::RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, bool evolving)
579{
580 //Util::Warning(INFO, "RegisterGeneralFab is depricated. Please replace with AddField");
581 AddField<T, Set::Hypercube::Node>(new_fab, nullptr, ncomp, nghost, "", true, evolving);
582}
583template<class T>
585void Integrator::RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, std::string a_name, bool evolving)
586{
587 //Util::Warning(INFO, "RegisterGeneralFab is depricated. Please replace with AddField");
588 AddField<T, Set::Hypercube::Node>(new_fab, nullptr, ncomp, nghost, a_name, true, evolving);
589}
590template<class T>
591AMREX_ATTRIBUTE_WEAK
592void Integrator::RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, bool writeout, std::string a_name, bool evolving)
593{
594 //Util::Warning(INFO, "RegisterGeneralFab is depricated. Please replace with AddField");
595 AddField<T, Set::Hypercube::Node>(new_fab, nullptr, ncomp, nghost, a_name, writeout, evolving);
596}
597
598}
599#endif
#define TEST(x)
Definition Util.H:21
#define ALAMO_SINGLE_DEFINITION
Definition Util.H:25
#define INFO
Definition Util.H:20
Definition BC.H:42
std::vector< BaseField * > m_basefields
Definition Integrator.H:420
virtual void Initialize(int lev)=0
You must override this function to inherit this class; this function is called before the simulation ...
void SetFinestLevel(const int a_finestlevel)
Utility to ensure that all fields know what the finest level is.
Definition Integrator.H:214
void SetStopTime(Set::Scalar a_stop_time)
Utility to set the global stop time.
Definition Integrator.H:241
std::string GetFilename()
Simple getter to get filename.
Definition Integrator.H:99
void DynamicTimestep_SyncTimeStep(int lev, Set::Scalar dt_min)
Params for the dynamic timestp.
Definition Integrator.H:258
void RegisterGeneralFab(Set::Field< T > &new_fab, int ncomp, int nghost, bool writeout, std::string a_name, bool evolving=true)
Add a templated nodal field (additional arguments)
std::vector< int > nghost_array
Definition Integrator.H:400
void regrid(int lbase, Set::Scalar time, bool initial=false) override
This overrides an AMReX method just to allow for explicit meshing when desired.
Definition Integrator.H:103
void SetThermoInt(int a_thermo_int)
Utility to set the frequency (in timesteps) of thermo data calculation.
Definition Integrator.H:237
std::vector< bool > extensives
Definition Integrator.H:434
virtual void TimeStepBegin(Set::Scalar, int)
This optional function is called at the beginning of every timestep, and can be used to complete addi...
Definition Integrator.H:166
std::vector< Set::Scalar * > vars
Definition Integrator.H:432
void RegisterGeneralFab(Set::Field< T > &new_fab, int ncomp, int nghost, std::string a_name, bool evolving=true)
Add a templated nodal field (additional arguments)
std::vector< amrex::Box > box
Definition Integrator.H:446
std::vector< BaseField * > m_basefields_cell
Definition Integrator.H:421
std::vector< BC::BC< Set::Scalar > * > physbc_array
Definition Integrator.H:402
virtual void Advance(int lev, amrex::Real time, amrex::Real dt)=0
You must override this function to inherit this class; Advance is called every time(sub)step,...
std::vector< int > ncomp_array
Definition Integrator.H:399
amrex::Vector< amrex::Real > dt
Timesteps for each level of refinement.
Definition Integrator.H:381
virtual void TagCellsForRefinement(int lev, amrex::TagBoxArray &tags, amrex::Real time, int ngrow)=0
You must override this function to inherit this class; Advance is called every time(sub)step,...
amrex::Vector< amrex::Real > t_old
Keep track of current old simulation time on each level.
Definition Integrator.H:386
virtual void Integrate(int, Set::Scalar, int, const amrex::MFIter &, const amrex::Box &)
This is a function that is called by Integrator to update the variables registered in RegisterIntegra...
Definition Integrator.H:174
std::vector< Set::Scalar > previous_timesteps
Definition Integrator.H:256
void AddField(Set::Field< T > &new_field, BC::BC< T > *new_bc, int ncomp, int nghost, std::string, bool writeout, bool evolving, std::vector< std::string > suffix={})
Add a field with arbitrary type (templated with T) and grid location (templated with d).
amrex::Vector< int > nsubsteps
how many substeps on each level?
Definition Integrator.H:382
std::vector< std::vector< std::string > > name_array
Definition Integrator.H:401
std::vector< std::string > names
Definition Integrator.H:433
void SetThermoPlotInt(int a_thermo_plot_int)
Utility to set the frequency (in timesteps) of thermo data writing to file.
Definition Integrator.H:239
amrex::Vector< amrex::Real > t_new
Keep track of current old simulation time on each level.
Definition Integrator.H:338
amrex::Vector< int > istep
Keep track of where each level is.
Definition Integrator.H:339
std::vector< Set::Scalar > dt_limit_min
Definition Integrator.H:255
void GetData(const int lev, const amrex::Real time, amrex::Vector< amrex::MultiFab * > &data, amrex::Vector< amrex::Real > &datatime)
void InitFromScratch(Set::Scalar time)
This creates a new levels that have not previously been used.
Definition Integrator.H:111
void RegisterGeneralFab(Set::Field< T > &new_fab, int ncomp, int nghost, bool evolving=true)
Add a templated nodal field.
virtual void Regrid(int, Set::Scalar)
An optionally overridable method to trigger behavior whenver a regrid occurs.
Definition Integrator.H:186
std::vector< bool > writeout_array
Definition Integrator.H:403
std::vector< Set::Field< Set::Scalar > * > fab_array
Definition Integrator.H:398
void SetFilename(std::string _plot_file)
Simple setter to set filename.
Definition Integrator.H:96
virtual void TimeStepComplete(Set::Scalar, int)
This optional function is called at the end of every timestep, and can be used to complete additional...
Definition Integrator.H:170
Collection of numerical integrator objects.
Definition AllenCahn.H:41
ALAMO_SINGLE_DEFINITION void Integrator::AddField< Set::Scalar, Set::Hypercube::Cell >(Set::Field< Set::Scalar > &new_field, BC::BC< Set::Scalar > *new_bc, int ncomp, int nghost, std::string name, bool writeout, bool, std::vector< std::string > suffix)
Definition Integrator.H:460
ALAMO_SINGLE_DEFINITION void Integrator::AddField< Set::Scalar, Set::Hypercube::Node >(Set::Field< Set::Scalar > &new_field, BC::BC< Set::Scalar > *new_bc, int ncomp, int nghost, std::string name, bool writeout, bool, std::vector< std::string > suffix)
Definition Integrator.H:499
amrex::Real Scalar
Definition Base.H:19
@ Cell
Definition Set.H:32
@ Node
Definition Set.H:32
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
Definition Base.H:20
void Abort(const char *msg)
Definition Util.cpp:170
AMREX_FORCE_INLINE void Assert(std::string file, std::string func, int line, std::string smt, bool pass, Args const &... args)
Definition Util.H:70
void Warning(std::string file, std::string func, int line, Args const &... args)
Definition Util.H:181
void Message(std::string file, std::string func, int line, Args const &... args)
Definition Util.H:141