Line data Source code
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
70 : namespace Integrator
71 : {
72 :
73 : class Integrator
74 : : public amrex::AmrCore
75 : {
76 : public:
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 20168 : void regrid(int lbase, Set::Scalar time, bool initial = false) override
104 : {
105 20168 : if (!explicitmesh.on)
106 20160 : AmrCore::regrid(lbase, time, initial);
107 20168 : }
108 :
109 : /// This creates a new levels that have not previously been
110 : /// used.
111 40 : void InitFromScratch(Set::Scalar time)
112 : {
113 40 : if (!explicitmesh.on) AmrCore::InitFromScratch(time);
114 : else
115 : {
116 : // Generate the coarse level mesh.
117 : {
118 7 : finest_level = 0;
119 7 : const amrex::BoxArray& ba = MakeBaseGrids();
120 7 : amrex::DistributionMapping dm(ba);
121 7 : const auto old_num_setdm = num_setdm;
122 7 : const auto old_num_setba = num_setba;
123 7 : MakeNewLevelFromScratch(0, time, ba, dm);
124 7 : if (old_num_setba == num_setba) SetBoxArray(0, ba);
125 7 : if (old_num_setdm == num_setdm) SetDistributionMap(0, dm);
126 7 : }
127 : // Generate subsequent level meshes based on user input
128 13 : for (int ilev = 0; ilev < maxLevel(); ++ilev)
129 : {
130 6 : finest_level = ilev + 1;
131 6 : amrex::BoxArray grids(explicitmesh.box[ilev]);
132 6 : ChopGrids(ilev + 1, grids, amrex::ParallelDescriptor::NProcs());
133 6 : amrex::DistributionMapping dmap(grids);
134 6 : SetBoxArray(ilev + 1, grids);
135 6 : SetDistributionMap(ilev + 1, dmap);
136 6 : MakeNewLevelFromScratch(ilev + 1, time, grids, dmap);
137 6 : }
138 :
139 : }
140 40 : }
141 :
142 : protected:
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 7302 : 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 7728 : 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 0 : 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 0 : if (thermo.number > 0)
182 0 : Util::Warning(INFO, "integrated variables registered, but no integration implemented!");
183 0 : }
184 :
185 : /// An optionally overridable method to trigger behavior whenver a regrid occurs.
186 972 : virtual void Regrid(int /* amrlev */, Set::Scalar /* time */)
187 972 : {}
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 114652 : void SetFinestLevel(const int a_finestlevel)
225 : {
226 439751 : for (unsigned int i = 0; i < cell.fab_array.size(); i++)
227 325099 : cell.fab_array[i]->finest_level = a_finestlevel;
228 123591 : for (unsigned int i = 0; i < node.fab_array.size(); i++)
229 8939 : node.fab_array[i]->finest_level = a_finestlevel;
230 114652 : for (unsigned int i = 0; i < m_basefields_cell.size(); i++)
231 0 : m_basefields_cell[i]->SetFinestLevel(finest_level);
232 118472 : for (unsigned int i = 0; i < m_basefields.size(); i++)
233 3820 : m_basefields[i]->SetFinestLevel(finest_level);
234 114652 : }
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 1 : 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
268 0 : void DynamicTimestep_SyncTimeStep(int lev, Set::Scalar dt_min)
269 : {
270 0 : if (!dynamictimestep.on) return;
271 0 : if (!dynamictimestep.dt_limit_min.size())
272 : {
273 0 : dynamictimestep.dt_limit_min.resize(max_level+1,
274 0 : std::numeric_limits<Set::Scalar>::max());
275 : }
276 0 : dynamictimestep.dt_limit_min[lev] = std::min(dt_min,
277 0 : dynamictimestep.dt_limit_min[lev]);
278 :
279 0 : amrex::ParallelDescriptor::ReduceRealMin(dynamictimestep.dt_limit_min[lev]);
280 : }
281 : void DynamicTimestep_Reset()
282 : {
283 : if (!dynamictimestep.on) return;
284 : dynamictimestep.previous_timesteps.clear();
285 : }
286 44 : void DynamicTimestep_Update()
287 : {
288 44 : if (!dynamictimestep.on) return;
289 0 : if (!dynamictimestep.dt_limit_min.size()) return;
290 :
291 0 : Set::Scalar final_timestep = NAN;
292 :
293 0 : if (amrex::ParallelDescriptor::IOProcessor())
294 : {
295 0 : Set::Scalar timestep_average = this->dt[0];
296 0 : if (dynamictimestep.previous_timesteps.size() > 0)
297 : {
298 0 : timestep_average = 0.0;
299 0 : for (unsigned int d = 0; d < dynamictimestep.previous_timesteps.size(); d++)
300 0 : timestep_average += dynamictimestep.previous_timesteps[d];
301 0 : timestep_average /= dynamictimestep.previous_timesteps.size();
302 : }
303 :
304 0 : Set::Scalar new_timestep = std::numeric_limits<Set::Scalar>::max();
305 0 : for (int lev = 0; lev <= this->max_level; lev++)
306 : {
307 : //const Set::Scalar* DX = this->geom[lev].CellSize();
308 0 : Set::Scalar dt_lev = dynamictimestep.dt_limit_min[lev];
309 :
310 0 : Util::Message(INFO,"lev=",lev," ",dt_lev, " (",this->nsubsteps[lev],")");
311 :
312 0 : for (int ilev = lev; ilev > 0; ilev--) dt_lev *= (Set::Scalar)(this->nsubsteps[ilev]);
313 :
314 0 : Util::Message(INFO,"lev=",lev," --> ",dt_lev);
315 :
316 0 : new_timestep = std::min(new_timestep,dt_lev);
317 : }
318 :
319 0 : if (new_timestep < timestep_average)
320 : {
321 0 : dynamictimestep.previous_timesteps.clear();
322 :
323 0 : final_timestep = new_timestep;
324 0 : final_timestep = std::max(final_timestep,dynamictimestep.min);
325 0 : final_timestep = std::min(final_timestep,dynamictimestep.max);
326 :
327 0 : dynamictimestep.previous_timesteps.push_back(new_timestep);
328 : }
329 : else
330 : {
331 0 : final_timestep = timestep_average;
332 0 : final_timestep = std::max(final_timestep,dynamictimestep.min);
333 0 : final_timestep = std::min(final_timestep,dynamictimestep.max);
334 :
335 0 : if ((int)(dynamictimestep.previous_timesteps.size()) > dynamictimestep.nprevious)
336 0 : dynamictimestep.previous_timesteps.erase(dynamictimestep.previous_timesteps.begin()); // pop first
337 0 : dynamictimestep.previous_timesteps.push_back(new_timestep); // push back new timestep
338 : }
339 :
340 : }
341 0 : amrex::ParallelDescriptor::Bcast(&final_timestep,1);
342 0 : this->SetTimestep(final_timestep);
343 0 : 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 :
353 : private:
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;
378 : protected:
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> >
389 : protected:
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?
393 : private:
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 :
401 : protected:
402 : bool integrate_variables_before_advance = true;
403 : bool integrate_variables_after_advance = false;
404 :
405 : bool clock_running = true;
406 :
407 : protected:
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 :
437 : BC::Nothing bcnothing;
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 :
463 : protected:
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 :
471 : template<>
472 : ALAMO_SINGLE_DEFINITION
473 175 : void Integrator::AddField<Set::Scalar, Set::Hypercube::Cell>
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 175 : int nlevs_max = maxLevel() + 1;
484 175 : new_field.resize(nlevs_max);
485 175 : cell.fab_array.push_back(&new_field);
486 175 : if (new_bc != nullptr) cell.physbc_array.push_back(new_bc);
487 0 : else cell.physbc_array.push_back(&bcnothing);
488 175 : cell.ncomp_array.push_back(ncomp);
489 175 : cell.nghost_array.push_back(nghost);
490 : //cell.name_array.push_back(name);
491 175 : cell.writeout_array.push_back(writeout);
492 175 : cell.evolving_array.push_back(evolving);
493 175 : cell.number_of_fabs++;
494 :
495 1225 : Util::Assert(INFO,TEST((int)suffix.size() == 0 || (int)suffix.size() == ncomp));
496 175 : std::vector<std::string> names;
497 175 : if (ncomp == 1)
498 120 : names.push_back(name);
499 : else
500 : {
501 55 : if (suffix.size() == 0)
502 90 : for (int j = 0; j < ncomp; j++)
503 70 : names.push_back(amrex::Concatenate(name,j+1,3));
504 : else
505 105 : for (int j = 0; j < ncomp; j++)
506 70 : names.push_back(name + suffix[j]);
507 : }
508 175 : cell.name_array.push_back(names);
509 175 : }
510 :
511 : template<>
512 : ALAMO_SINGLE_DEFINITION
513 21 : void Integrator::AddField<Set::Scalar, Set::Hypercube::Node>
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 147 : Util::Assert(INFO, TEST(new_bc == nullptr));
525 21 : int nlevs_max = maxLevel() + 1;
526 21 : new_field.resize(nlevs_max);
527 21 : node.fab_array.push_back(&new_field);
528 21 : node.physbc_array.push_back(&bcnothing);
529 21 : node.ncomp_array.push_back(ncomp);
530 21 : node.nghost_array.push_back(nghost);
531 21 : node.evolving_array.push_back(evolving);
532 21 : node.writeout_array.push_back(writeout);
533 21 : node.number_of_fabs++;
534 :
535 147 : Util::Assert(INFO,TEST((int)suffix.size() == 0 || (int)suffix.size() == ncomp));
536 21 : std::vector<std::string> names;
537 21 : if (ncomp == 1)
538 18 : names.push_back(name);
539 : else
540 : {
541 3 : if (suffix.size() == 0)
542 9 : for (int j = 0; j < ncomp; j++)
543 6 : names.push_back(amrex::Concatenate(name,j+1,3));
544 : else
545 0 : for (int j = 0; j < ncomp; j++)
546 0 : names.push_back(name + suffix[j]);
547 : }
548 21 : node.name_array.push_back(names);
549 21 : }
550 :
551 : template<class T, int d>
552 : ALAMO_SINGLE_DEFINITION
553 98 : void Integrator::AddField
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 686 : Util::Assert(INFO, TEST(new_bc == nullptr));
561 98 : int nlevs_max = maxLevel() + 1;
562 98 : new_field.resize(nlevs_max);
563 98 : m_basefields.push_back(new Field<T>(new_field, geom, refRatio(), ncomp, nghost));
564 98 : m_basefields.back()->evolving = evolving;
565 98 : m_basefields.back()->writeout = writeout;
566 98 : m_basefields.back()->setName(name);
567 98 : m_basefields.back()->evolving = evolving;
568 98 : 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 98 : }
588 :
589 :
590 :
591 : template<class T>
592 : ALAMO_SINGLE_DEFINITION
593 19 : void 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 57 : AddField<T, Set::Hypercube::Node>(new_fab, nullptr, ncomp, nghost, "", true, evolving);
597 19 : }
598 : template<class T>
599 : ALAMO_SINGLE_DEFINITION
600 3 : void 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 3 : AddField<T, Set::Hypercube::Node>(new_fab, nullptr, ncomp, nghost, a_name, true, evolving);
604 3 : }
605 : template<class T>
606 : AMREX_ATTRIBUTE_WEAK
607 76 : void 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 76 : AddField<T, Set::Hypercube::Node>(new_fab, nullptr, ncomp, nghost, a_name, writeout, evolving);
611 76 : }
612 :
613 : }
614 : #endif
|