ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
StructureModel Class Referenceabstract

A model of structures in the flow, behind ERF's structure coupling. More...

#include <ERF_StructureModel.H>

Public Member Functions

virtual ~StructureModel ()=default
 
virtual const char * name () const =0
 Name of the model, as erf.structures.model selects it. More...
 
virtual int level (int finest_level) const =0
 The level the model couples to. More...
 
virtual std::vector< amrex::RealBox > support () const =0
 Where the model's force can be nonzero this step. More...
 
virtual bool wants_immersed_terrain_surface () const
 The model wants StructureInit::immersed_terrain_surface (ERF builds it only on request). More...
 
virtual void initialize (const StructureInit &init)=0
 Set the model up once the mesh and the initial state exist. More...
 
virtual void fixed_dt_changed (int lev, double fixed_dt)
 ERF lowered the fixed step after initialize() More...
 
virtual void advance (const StructureStep &step)=0
 Advance the structures over one step of level() More...
 
virtual void add_momentum_sources (int lev, amrex::MultiFab &xmom_src, amrex::MultiFab &ymom_src, amrex::MultiFab &zmom_src) const =0
 Add the structures' force on the air to the momentum sources. More...
 
virtual void write_checkpoint (const std::string &checkpointname) const
 Write the model's state under the checkpoint directory. More...
 
virtual bool supports_restart () const
 The model restores its state in initialize() on a restart. More...
 
virtual void finalize ()
 The run has ended normally. More...
 
virtual std::vector< std::string > plot_var_names () const
 Fields the ERF plotfile can carry, by name. More...
 
virtual void fill_plot_var (const std::string &name, int lev, amrex::MultiFab &dst, int comp) const
 Fill the field plot_var_names() lists as name on level lev. More...
 

Detailed Description

A model of structures in the flow, behind ERF's structure coupling.

Constructor & Destructor Documentation

◆ ~StructureModel()

virtual StructureModel::~StructureModel ( )
virtualdefault

Member Function Documentation

◆ add_momentum_sources()

virtual void StructureModel::add_momentum_sources ( int  lev,
amrex::MultiFab &  xmom_src,
amrex::MultiFab &  ymom_src,
amrex::MultiFab &  zmom_src 
) const
pure virtual

Add the structures' force on the air to the momentum sources.

Face-centered sources on level lev [N/m^3, i.e. kg/(m^2 s^2)], added (not set), held fixed over the step. Called at every Runge-Kutta stage, after ERF's own sources. ERF applies no mask to them: the model keeps its kernels clear of embedded boundaries, immersed terrain and buildings.

With erf.coupling_type = TwoWay, ERF also calls it at the start of each step of every coarser level, with lev = level() and zeroed MultiFabs on the grids of level() as of the last advance() (they may have ghost faces, which the model leaves alone). It adds the source of its last advance(), as at a stage. ERF restricts that source onto the coarser level, keeping the force it puts on the air (its integral over the faces' control volumes, with the mesh Jacobian on a stretched or terrain-following mesh), and holds it over that level's step: the air under the finer level then feels the force while the coarser level steps, and the coarse/fine faces, which the finer level takes from the coarser one, get the force once. Before the first advance() and after a regrid of level(), until the next advance(), ERF does not call it for the coarser levels. ERF writes the source to its checkpoint, so after a restart, until the first advance(), it restricts the checkpointed source instead: the model need not hold one. ERF also calls it when it writes a checkpoint; being const, it leaves the model as it was.

◆ advance()

virtual void StructureModel::advance ( const StructureStep &  step)
pure virtual

Advance the structures over one step of level()

Samples the flow, advances the structures from step.time to step.time + step.dt, and sets the momentum source add_momentum_sources() returns at the stages of this step.

◆ fill_plot_var()

virtual void StructureModel::fill_plot_var ( const std::string &  name,
int  lev,
amrex::MultiFab &  dst,
int  comp 
) const
inlinevirtual

Fill the field plot_var_names() lists as name on level lev.

One cell-centered component written into dst at component comp, on dst's boxes, with no ghost cells; zero where the model has nothing (for example on levels other than level()).

315  {
316  amrex::ignore_unused(name, lev);
317  dst.setVal(amrex::Real(0.0), comp, 1, 0);
318  }
virtual const char * name() const =0
Name of the model, as erf.structures.model selects it.
Here is the call graph for this function:

◆ finalize()

virtual void StructureModel::finalize ( )
inlinevirtual

The run has ended normally.

Called once, on every rank, after the last step, plotfile and checkpoint: the place to flush and close the model's own files or to shut down a solver it drives. Not called when the run aborts. The default does nothing.

293 {}

◆ fixed_dt_changed()

virtual void StructureModel::fixed_dt_changed ( int  lev,
double  fixed_dt 
)
inlinevirtual

ERF lowered the fixed step after initialize()

With erf.fixed_dt_cfl_limit, ERF lowers the fixed step on all levels when a regrid makes grids on which it exceeds erf.cfl. fixed_dt is the new StructureInit::fixed_dt of level lev (the level the model couples to); a step under way finishes at the old step. The default does nothing.

225 { amrex::ignore_unused(lev, fixed_dt); }

◆ initialize()

virtual void StructureModel::initialize ( const StructureInit &  init)
pure virtual

Set the model up once the mesh and the initial state exist.

On a restart (StructureInit::restart_chkfile not empty) the model restores what write_checkpoint() wrote and continues from it. Aborts, naming the input, on a configuration the model cannot run.

◆ level()

virtual int StructureModel::level ( int  finest_level) const
pure virtual

The level the model couples to.

ERF calls advance() on this level only, and add_momentum_sources() for this level only (see add_momentum_sources() for the coarser levels). Aborts, naming the model's input, when the model cannot couple to a level of this run (for example a level above finest_level).

The level must be the finest level that covers the model's support. On a refined level the model's points and their kernels must lie inside the level's boxes, also after a regrid (erf_actuator::points_covered_by checks it). The force reaches the coarser levels through ERF's averaging down and, with TwoWay coupling, as a source restricted from this level. It never reaches a finer level: averaging down would overwrite the forced cells with that level's unforced data, so ERF stops the run when a finer level's boxes overlap support().

Parameters
[in]finest_levelERF's finest level now

◆ name()

virtual const char* StructureModel::name ( ) const
pure virtual

Name of the model, as erf.structures.model selects it.

Referenced by check_structure_plot_names(), and fill_plot_var().

Here is the caller graph for this function:

◆ plot_var_names()

virtual std::vector<std::string> StructureModel::plot_var_names ( ) const
inlinevirtual

Fields the ERF plotfile can carry, by name.

The names the deck may list in erf.plot_vars_*; they start with the model's own prefix (for example "conductor_") so they never collide with an ERF variable. ERF stops the run on an empty name, a name listed twice, or a name ERF or another model already uses. The answer depends on the model's inputs only. The default lists none.

304 { return {}; }

Referenced by check_structure_plot_names().

Here is the caller graph for this function:

◆ support()

virtual std::vector<amrex::RealBox> StructureModel::support ( ) const
pure virtual

Where the model's force can be nonzero this step.

Boxes in physical coordinates [m] (z as the height of z_phys_nd on a terrain-following mesh) that hold every point together with its kernel's reach, as of the last advance(). The same on every rank. ERF checks them against the next finer level's boxes after each advance() (see level()). The boxes may extend past the domain; a periodic direction wraps. Every box needs its low end at or below its high end in each direction and no NaN (an infinite end is allowed); ERF stops the run otherwise, naming the model.

◆ supports_restart()

virtual bool StructureModel::supports_restart ( ) const
inlinevirtual

The model restores its state in initialize() on a restart.

False by default: ERF then stops a restart instead of letting the model continue from its initial state.

284 { return false; }

◆ wants_immersed_terrain_surface()

virtual bool StructureModel::wants_immersed_terrain_surface ( ) const
inlinevirtual

The model wants StructureInit::immersed_terrain_surface (ERF builds it only on request).

206 { return false; }

◆ write_checkpoint()

virtual void StructureModel::write_checkpoint ( const std::string &  checkpointname) const
inlinevirtual

Write the model's state under the checkpoint directory.

Everything the model carries from one step to the next, under checkpointname/<name()>/ (the model creates that directory on the I/O rank). The default writes nothing, and supports_restart() must then stay false.

274  {
275  amrex::ignore_unused(checkpointname);
276  }

The documentation for this class was generated from the following file: