24 #include "pism/coupler/surface/Cache.hh"
25 #include "pism/util/Time.hh"
26 #include "pism/util/Grid.hh"
27 #include "pism/util/error_handling.hh"
28 #include "pism/util/MaxTimestep.hh"
33 Cache::Cache(std::shared_ptr<const Grid> grid, std::shared_ptr<SurfaceModel> in)
45 "surface.cache.update_interval has to be strictly positive.");
63 m_log->message(2,
"* Initializing the 'caching' surface model modifier...\n");
73 double time_resolution =
m_config->get_number(
"time_stepping.resolution",
"seconds");
78 update_dt = one_year_from_now - t;
80 assert(update_dt > 0.0);
102 double time_resolution =
m_config->get_number(
"time_stepping.resolution",
"seconds");
106 if (dt < time_resolution) {
119 if (input_max_timestep.
finite()) {
120 return std::min(input_max_timestep, cache_dt);
const Time & time() const
std::shared_ptr< const Grid > grid() const
const Config::ConstPtr m_config
configuration database used by this component
const Logger::ConstPtr m_log
logger (for easy access)
bool finite() const
Convert to bool to check if a time step restriction is "active".
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
double increment_date(double T, double years) const
double convert_time_interval(double T, const std::string &units) const
Convert time interval from seconds to given units. Handle 'years' using the year length corresponding...
double current() const
Current time, in seconds.
virtual const array::Scalar & runoff_impl() const
std::shared_ptr< array::Scalar > m_temperature
const array::Scalar & layer_thickness_impl() const
void update_impl(const Geometry &geometry, double t, double dt)
MaxTimestep max_timestep_impl(double t) const
const array::Scalar & liquid_water_fraction_impl() const
const array::Scalar & layer_mass_impl() const
double m_update_interval_years
std::shared_ptr< array::Scalar > m_mass_flux
Cache(std::shared_ptr< const Grid > g, std::shared_ptr< SurfaceModel > in)
const array::Scalar & temperature_impl() const
double m_next_update_time
virtual const array::Scalar & melt_impl() const
const array::Scalar & mass_flux_impl() const
void init_impl(const Geometry &geometry)
virtual const array::Scalar & accumulation_impl() const
static std::shared_ptr< array::Scalar > allocate_runoff(std::shared_ptr< const Grid > grid)
static std::shared_ptr< array::Scalar > allocate_mass_flux(std::shared_ptr< const Grid > grid)
std::shared_ptr< array::Scalar > m_melt
std::shared_ptr< array::Scalar > m_layer_thickness
static std::shared_ptr< array::Scalar > allocate_temperature(std::shared_ptr< const Grid > grid)
static std::shared_ptr< array::Scalar > allocate_accumulation(std::shared_ptr< const Grid > grid)
static std::shared_ptr< array::Scalar > allocate_melt(std::shared_ptr< const Grid > grid)
std::shared_ptr< array::Scalar > m_runoff
static std::shared_ptr< array::Scalar > allocate_layer_thickness(std::shared_ptr< const Grid > grid)
std::shared_ptr< SurfaceModel > m_input_model
static std::shared_ptr< array::Scalar > allocate_layer_mass(std::shared_ptr< const Grid > grid)
std::shared_ptr< array::Scalar > m_layer_mass
std::shared_ptr< array::Scalar > m_accumulation
std::shared_ptr< array::Scalar > m_liquid_water_fraction
static std::shared_ptr< array::Scalar > allocate_liquid_water_fraction(std::shared_ptr< const Grid > grid)
The interface of PISM's surface models.
#define PISM_ERROR_LOCATION
double min(const array::Scalar &input)
Finds minimum over all the values in an array::Scalar object. Ignores ghosts.