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 inline void StopClock()
191 {
192 clock_running = false;
193 }
194 inline void RestartClock()
195 {
196 clock_running = true;
197 }
198
199
200 /// Add a new cell-based scalar field.
201 void RegisterNewFab(Set::Field<Set::Scalar>& new_fab, BC::BC<Set::Scalar>* new_bc, int ncomp, int nghost, std::string name, bool writeout,bool evolving = true,std::vector<std::string> suffix = {});
202 /// Add a new cell-based scalar field (with additional arguments).
203 void RegisterNewFab(Set::Field<Set::Scalar>& new_fab, int ncomp, std::string name, bool writeout,bool evolving=true, std::vector<std::string> suffix = {});
204 /// Add a new node-based scalar field
205 void RegisterNodalFab(Set::Field<Set::Scalar>& new_fab, int ncomp, int nghost, std::string name, bool writeout,bool evolving=true,std::vector<std::string> suffix = {});
206 /// Add a new node-based scalar field (wtih additional arguments)
207 void RegisterNodalFab(Set::Field<Set::Scalar>& new_fab, BC::BC<Set::Scalar>* new_bc, int ncomp, int nghost, std::string name, bool writeout,bool evolving=true, std::vector<std::string> suffix = {});
208 template<class T>
209 /// Add a templated nodal field
210 void RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, bool evolving = true);
211 template<class T>
212 /// Add a templated nodal field (additional arguments)
213 void RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, std::string a_name, bool evolving = true);
214 template<class T>
215 /// Add a templated nodal field (additional arguments)
216 void RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, bool writeout, std::string a_name, bool evolving = true);
217
218 /// Add a field with arbitrary type (templated with T) and grid location (templated with d).
219 template<class T, int d>
220 void AddField( Set::Field<T>& new_field, BC::BC<T>* new_bc, int ncomp, int nghost,
221 std::string, bool writeout, bool evolving, std::vector<std::string> suffix = {});
222
223 /// Utility to ensure that all fields know what the finest level is
224 void SetFinestLevel(const int a_finestlevel)
225 {
226 for (unsigned int i = 0; i < cell.fab_array.size(); i++)
227 cell.fab_array[i]->finest_level = a_finestlevel;
228 for (unsigned int i = 0; i < node.fab_array.size(); i++)
229 node.fab_array[i]->finest_level = a_finestlevel;
230 for (unsigned int i = 0; i < m_basefields_cell.size(); i++)
231 m_basefields_cell[i]->SetFinestLevel(finest_level);
232 for (unsigned int i = 0; i < m_basefields.size(); i++)
233 m_basefields[i]->SetFinestLevel(finest_level);
234 }
235
236 /// Register a variable to be integrated over the spatial domain using
237 /// the Integrate function.
238 void RegisterIntegratedVariable(Set::Scalar* integrated_variable, std::string name, bool extensive=true);
239
240 /// Utility to set the coarse-grid timestep
241 void SetTimestep(Set::Scalar _timestep);
242
243 /// Utility to set the frequency (in timesteps) of plotfile dumping
244 void SetPlotInt(int plot_int);
245
246 /// Utility to set the frequency (in timesteps) of thermo data calculation
247 void SetThermoInt(int a_thermo_int) { thermo.interval = a_thermo_int; }
248 /// Utility to set the frequency (in timesteps) of thermo data writing to file
249 void SetThermoPlotInt(int a_thermo_plot_int) { thermo.plot_int = a_thermo_plot_int; }
250 /// Utility to set the global stop time.
251 void SetStopTime(Set::Scalar a_stop_time) { stop_time = a_stop_time; }
252
253
254 // Dynamic timestep adjustment
255
256 struct {
257 // user params
258 bool on = false;
259 int verbose = -1;
260 int nprevious = -1;
261 Set::Scalar cfl = NAN;
262 Set::Scalar min = NAN;
263 Set::Scalar max = NAN;
264 // internal variables
265 std::vector<Set::Scalar> dt_limit_min;
266 std::vector<Set::Scalar> previous_timesteps;
267 } dynamictimestep; /// Params for the dynamic timestp
269 {
270 if (!dynamictimestep.on) return;
271 if (!dynamictimestep.dt_limit_min.size())
272 {
273 dynamictimestep.dt_limit_min.resize(max_level+1,
274 std::numeric_limits<Set::Scalar>::max());
275 }
276 dynamictimestep.dt_limit_min[lev] = std::min(dt_min,
277 dynamictimestep.dt_limit_min[lev]);
278
279 amrex::ParallelDescriptor::ReduceRealMin(dynamictimestep.dt_limit_min[lev]);
280 }
282 {
283 if (!dynamictimestep.on) return;
284 dynamictimestep.previous_timesteps.clear();
285 }
287 {
288 if (!dynamictimestep.on) return;
289 if (!dynamictimestep.dt_limit_min.size()) return;
290
291 Set::Scalar final_timestep = NAN;
292
293 if (amrex::ParallelDescriptor::IOProcessor())
294 {
295 Set::Scalar timestep_average = this->dt[0];
296 if (dynamictimestep.previous_timesteps.size() > 0)
297 {
298 timestep_average = 0.0;
299 for (unsigned int d = 0; d < dynamictimestep.previous_timesteps.size(); d++)
300 timestep_average += dynamictimestep.previous_timesteps[d];
301 timestep_average /= dynamictimestep.previous_timesteps.size();
302 }
303
304 Set::Scalar new_timestep = std::numeric_limits<Set::Scalar>::max();
305 for (int lev = 0; lev <= this->max_level; lev++)
306 {
307 //const Set::Scalar* DX = this->geom[lev].CellSize();
308 Set::Scalar dt_lev = dynamictimestep.dt_limit_min[lev];
309
310 Util::Message(INFO,"lev=",lev," ",dt_lev, " (",this->nsubsteps[lev],")");
311
312 for (int ilev = lev; ilev > 0; ilev--) dt_lev *= (Set::Scalar)(this->nsubsteps[ilev]);
313
314 Util::Message(INFO,"lev=",lev," --> ",dt_lev);
315
316 new_timestep = std::min(new_timestep,dt_lev);
317 }
318
319 if (new_timestep < timestep_average)
320 {
321 dynamictimestep.previous_timesteps.clear();
322
323 final_timestep = new_timestep;
324 final_timestep = std::max(final_timestep,dynamictimestep.min);
325 final_timestep = std::min(final_timestep,dynamictimestep.max);
326
327 dynamictimestep.previous_timesteps.push_back(new_timestep);
328 }
329 else
330 {
331 final_timestep = timestep_average;
332 final_timestep = std::max(final_timestep,dynamictimestep.min);
333 final_timestep = std::min(final_timestep,dynamictimestep.max);
334
335 if ((int)(dynamictimestep.previous_timesteps.size()) > dynamictimestep.nprevious)
336 dynamictimestep.previous_timesteps.erase(dynamictimestep.previous_timesteps.begin()); // pop first
337 dynamictimestep.previous_timesteps.push_back(new_timestep); // push back new timestep
338 }
339
340 }
341 amrex::ParallelDescriptor::Bcast(&final_timestep,1);
342 this->SetTimestep(final_timestep);
343 dynamictimestep.dt_limit_min.clear();
344 }
345
346
347
348 amrex::Vector<amrex::Real> t_new; ///< Keep track of current old simulation time on each level
349 amrex::Vector<int> istep; ///< Keep track of where each level is
350 // PLOT FILES
351 std::string plot_file{ "plt" }; ///< Plotfile name
352
353private:
354 virtual void MakeNewLevelFromScratch(int lev, amrex::Real time, const amrex::BoxArray& ba,
355 const amrex::DistributionMapping& dm) override;
356 virtual void MakeNewLevelFromCoarse(int lev, amrex::Real time, const amrex::BoxArray& ba,
357 const amrex::DistributionMapping& dm) override;
358 virtual void RemakeLevel(int lev, amrex::Real time, const amrex::BoxArray& ba,
359 const amrex::DistributionMapping& dm) override;
360 virtual void ClearLevel(int lev) override;
361 virtual void ErrorEst(int lev, amrex::TagBoxArray& tags, amrex::Real time, int ngrow) override;
362
363
364 /// This is the function that is responsible for updating patch data.
365 void FillPatch(int lev, amrex::Real time,
366 amrex::Vector<std::unique_ptr<amrex::MultiFab>>& source_mf,
367 amrex::MultiFab& destination_multifab,
368 BC::BC<Set::Scalar>& physbc,
369 int icomp);
370 /// Simple utility to count cells
371 long CountCells(int lev);
372 /// Timestep marching
373 void TimeStep(int lev, amrex::Real time, int iteration);
374 void FillCoarsePatch(int lev, amrex::Real time, Set::Field<Set::Scalar>& mf, BC::BC<Set::Scalar>& physbc, int icomp, int ncomp);
375 void GetData(const int lev, const amrex::Real time, amrex::Vector<amrex::MultiFab*>& data, amrex::Vector<amrex::Real>& datatime);
376
377 std::vector<std::string> PlotFileName(int lev, std::string prefix = "") const;
378protected:
379 void IntegrateVariables(Set::Scalar cur_time, int step);
380 void WritePlotFile(bool initial = false) const;
381 void WritePlotFile(std::string prefix, Set::Scalar time, int step) const;
382 void WritePlotFile(Set::Scalar time, amrex::Vector<int> iter, bool initial = false, std::string prefix = "") const;
383
384 //
385 // MEMBER VARIABLES
386 //
387
388 // TIME (STEP) KEEPINGamrex::Vector<std::unique_ptr<amrex::MultiFab> >
389protected:
390 amrex::Real timestep = NAN; ///< Timestep for the base level of refinement
391 amrex::Vector<amrex::Real> dt; ///< Timesteps for each level of refinement
392 amrex::Vector<int> nsubsteps; ///< how many substeps on each level?
393private:
394 int max_plot_level = -1;
395
396 amrex::Vector<amrex::Real> t_old;///< Keep track of current old simulation time on each level
397 int max_step = std::numeric_limits<int>::max(); ///< Maximum allowable timestep
398 amrex::Real tstart = 0; ///< Default start time (default: 0)
399 amrex::Real stop_time = NAN; ///< Default stop time
400
401protected:
402 bool integrate_variables_before_advance = true;
403 bool integrate_variables_after_advance = false;
404
405 bool clock_running = true;
406
407protected:
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 std::vector<bool> evolving_array;
417 bool any = true;
418 bool all = false;
419 } node;
420
421 struct {
422 int number_of_fabs = 0;
423 std::vector<Set::Field<Set::Scalar>*> fab_array;
424 std::vector<int> ncomp_array;
425 std::vector<int> nghost_array;
426 std::vector<std::vector<std::string>> name_array;
427 std::vector<BC::BC<Set::Scalar>*> physbc_array;
428 std::vector<bool> writeout_array;
429 std::vector<bool> evolving_array;
430 bool any = true;
431 bool all = false;
432 } cell;
433
434 std::vector<BaseField*> m_basefields;
435 std::vector<BaseField*> m_basefields_cell;
436
438
439 // KEEP TRACK OF ALL INTEGRATED VARIABLES
440 struct {
441 int interval = -1;
442 Set::Scalar dt = NAN;
443 int plot_int = -1;
444 Set::Scalar plot_dt = NAN;
445 int number = 0;
446 std::vector<Set::Scalar*> vars;
447 std::vector<std::string> names;
448 std::vector<bool> extensives;
449 } thermo;
450
451 // REGRIDDING
452 int regrid_int = -1; ///< Determine how often to regrid (default: 2)
453 int base_regrid_int = -1; ///< Determine how often to regrid based on coarse level only (default: 0)
454
455 std::string restart_file_cell = "";
456 std::string restart_file_node = "";
457
458 struct {
459 int on = 0;
460 std::vector<amrex::Box> box;
461 } explicitmesh;
462
463protected:
464 int plot_int = -1; ///< How frequently to dump plot file (default: never)
465 Set::Scalar plot_dt = -1.0;
466
467 int abort_on_nan = true;
468};
469
470
471template<>
474( Set::Field<Set::Scalar>& new_field,
475 BC::BC<Set::Scalar>* new_bc,
476 int ncomp,
477 int nghost,
478 std::string name,
479 bool writeout,
480 bool evolving,
481 std::vector<std::string> suffix)
482{
483 int nlevs_max = maxLevel() + 1;
484 new_field.resize(nlevs_max);
485 cell.fab_array.push_back(&new_field);
486 if (new_bc != nullptr) cell.physbc_array.push_back(new_bc);
487 else cell.physbc_array.push_back(&bcnothing);
488 cell.ncomp_array.push_back(ncomp);
489 cell.nghost_array.push_back(nghost);
490 //cell.name_array.push_back(name);
491 cell.writeout_array.push_back(writeout);
492 cell.evolving_array.push_back(evolving);
493 cell.number_of_fabs++;
494
495 Util::Assert(INFO,TEST((int)suffix.size() == 0 || (int)suffix.size() == ncomp));
496 std::vector<std::string> names;
497 if (ncomp == 1)
498 names.push_back(name);
499 else
500 {
501 if (suffix.size() == 0)
502 for (int j = 0; j < ncomp; j++)
503 names.push_back(amrex::Concatenate(name,j+1,3));
504 else
505 for (int j = 0; j < ncomp; j++)
506 names.push_back(name + suffix[j]);
507 }
508 cell.name_array.push_back(names);
509}
510
511template<>
514( Set::Field<Set::Scalar>& new_field,
515 BC::BC<Set::Scalar>* new_bc,
516 int ncomp,
517 int nghost,
518 std::string name,
519 bool writeout,
520 bool evolving,
521 std::vector<std::string> suffix)
522{
523 BL_PROFILE("Integrator::RegisterNodalFab");
524 Util::Assert(INFO, TEST(new_bc == nullptr));
525 int nlevs_max = maxLevel() + 1;
526 new_field.resize(nlevs_max);
527 node.fab_array.push_back(&new_field);
528 node.physbc_array.push_back(&bcnothing);
529 node.ncomp_array.push_back(ncomp);
530 node.nghost_array.push_back(nghost);
531 node.evolving_array.push_back(evolving);
532 node.writeout_array.push_back(writeout);
533 node.number_of_fabs++;
534
535 Util::Assert(INFO,TEST((int)suffix.size() == 0 || (int)suffix.size() == ncomp));
536 std::vector<std::string> names;
537 if (ncomp == 1)
538 names.push_back(name);
539 else
540 {
541 if (suffix.size() == 0)
542 for (int j = 0; j < ncomp; j++)
543 names.push_back(amrex::Concatenate(name,j+1,3));
544 else
545 for (int j = 0; j < ncomp; j++)
546 names.push_back(name + suffix[j]);
547 }
548 node.name_array.push_back(names);
549}
550
551template<class T, int d>
554( Set::Field<T>& new_field, BC::BC<T>* new_bc, int ncomp,
555 int nghost, std::string name, bool writeout, bool evolving,
556 std::vector<std::string> /*suffix*/)
557{
558 if (d == Set::Hypercube::Node)
559 {
560 Util::Assert(INFO, TEST(new_bc == nullptr));
561 int nlevs_max = maxLevel() + 1;
562 new_field.resize(nlevs_max);
563 m_basefields.push_back(new Field<T>(new_field, geom, refRatio(), ncomp, nghost));
564 m_basefields.back()->evolving = evolving;
565 m_basefields.back()->writeout = writeout;
566 m_basefields.back()->setName(name);
567 m_basefields.back()->evolving = evolving;
568 m_basefields.back()->m_gridtype = Set::Hypercube::Node;
569 }
570 else if (d == Set::Hypercube::Cell)
571 {
572 int nlevs_max = maxLevel() + 1;
573 new_field.resize(nlevs_max);
574 m_basefields_cell.push_back(new Field<T>(new_field, geom, refRatio(), ncomp, nghost));
575 m_basefields_cell.back()->evolving = evolving;
576 m_basefields_cell.back()->writeout = writeout;
577 m_basefields_cell.back()->setName(name);
578 m_basefields_cell.back()->evolving = evolving;
579 if (new_bc) m_basefields_cell.back()->setBC(new_bc);
580 else m_basefields_cell.back()->setBC(&bcnothing);
581 m_basefields_cell.back()->m_gridtype = Set::Hypercube::Cell;
582 }
583 else
584 {
585 Util::Abort(INFO, "Only node and cell based fields can be added at this time");
586 }
587}
588
589
590
591template<class T>
593void Integrator::RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, bool evolving)
594{
595 //Util::Warning(INFO, "RegisterGeneralFab is depricated. Please replace with AddField");
596 AddField<T, Set::Hypercube::Node>(new_fab, nullptr, ncomp, nghost, "", true, evolving);
597}
598template<class T>
600void Integrator::RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, std::string a_name, bool evolving)
601{
602 //Util::Warning(INFO, "RegisterGeneralFab is depricated. Please replace with AddField");
603 AddField<T, Set::Hypercube::Node>(new_fab, nullptr, ncomp, nghost, a_name, true, evolving);
604}
605template<class T>
606AMREX_ATTRIBUTE_WEAK
607void Integrator::RegisterGeneralFab(Set::Field<T>& new_fab, int ncomp, int nghost, bool writeout, std::string a_name, bool evolving)
608{
609 //Util::Warning(INFO, "RegisterGeneralFab is depricated. Please replace with AddField");
610 AddField<T, Set::Hypercube::Node>(new_fab, nullptr, ncomp, nghost, a_name, writeout, evolving);
611}
612
613}
614#endif
#define TEST(x)
Definition Util.H:22
#define ALAMO_SINGLE_DEFINITION
Definition Util.H:26
#define INFO
Definition Util.H:21
Definition BC.H:43
std::vector< bool > evolving_array
Definition Integrator.H:416
std::vector< BaseField * > m_basefields
Definition Integrator.H:434
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:224
void SetStopTime(Set::Scalar a_stop_time)
Utility to set the global stop time.
Definition Integrator.H:251
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:268
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:412
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:247
std::vector< bool > extensives
Definition Integrator.H:448
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:446
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:460
std::vector< BaseField * > m_basefields_cell
Definition Integrator.H:435
std::vector< BC::BC< Set::Scalar > * > physbc_array
Definition Integrator.H:414
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:411
amrex::Vector< amrex::Real > dt
Timesteps for each level of refinement.
Definition Integrator.H:391
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:396
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:266
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:392
std::vector< std::vector< std::string > > name_array
Definition Integrator.H:413
std::vector< std::string > names
Definition Integrator.H:447
void SetThermoPlotInt(int a_thermo_plot_int)
Utility to set the frequency (in timesteps) of thermo data writing to file.
Definition Integrator.H:249
amrex::Vector< amrex::Real > t_new
Keep track of current old simulation time on each level.
Definition Integrator.H:348
amrex::Vector< int > istep
Keep track of where each level is.
Definition Integrator.H:349
std::vector< Set::Scalar > dt_limit_min
Definition Integrator.H:265
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:415
std::vector< Set::Field< Set::Scalar > * > fab_array
Definition Integrator.H:410
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:42
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 evolving, std::vector< std::string > suffix)
Definition Integrator.H:514
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 evolving, std::vector< std::string > suffix)
Definition Integrator.H:474
amrex::Real Scalar
Definition Base.H:18
@ Cell
Definition Set.H:32
@ Node
Definition Set.H:32
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
Definition Base.H:19
void Abort(const char *msg)
Definition Util.cpp:243
AMREX_FORCE_INLINE void Assert(std::string file, std::string func, int line, std::string smt, bool pass, Args const &... args)
Definition Util.H:55
void Warning(std::string file, std::string func, int line, Args const &... args)
Definition Util.H:199
void Message(std::string file, std::string func, int line, Args const &... args)
Definition Util.H:126