19#ifndef PISM_ICEMODEL_H
20#define PISM_ICEMODEL_H
43#include "pism/util/array/Vector.hh"
44#include "pism/util/Config.hh"
45#include "pism/util/Context.hh"
46#include "pism/util/Logger.hh"
47#include "pism/util/Time.hh"
48#include "pism/util/Diagnostic.hh"
49#include "pism/util/MaxTimestep.hh"
50#include "pism/geometry/Geometry.hh"
51#include "pism/geometry/GeometryEvolution.hh"
52#include "pism/stressbalance/StressBalance.hh"
53#include "pism/basalstrength/YieldStress.hh"
54#include "pism/util/ScalarForcing.hh"
79class CalvingAtThickness;
88class EnergyModelStats;
92namespace frontalmelt {
110class PrescribedRetreat;
123 IceModel(std::shared_ptr<Grid>
grid,
const std::shared_ptr<Context> &context);
128 std::shared_ptr<Grid>
grid()
const;
129 std::shared_ptr<Context>
ctx()
const;
209 virtual std::set<VariableMetadata>
222 std::set<VariableMetadata>
243 virtual double step(
bool do_mass_continuity,
bool do_skip);
253 virtual void restart_2d(
const File &input_file,
unsigned int record);
265 const std::set<std::string> &variable_names)
const;
270 const std::set<std::string> &variable_names)
const;
273 const std::set<std::string> &additional_variables);
304 std::shared_ptr<energy::BedThermalUnit>
m_btu;
381 virtual unsigned int skip_counter(
double input_dt,
double input_dt_diffusivity);
427 double volume,
double area,
428 double meltfrac,
double max_diffusivity);
437 mutable std::vector<std::shared_ptr<array::Scalar2>>
m_work2d;
520 std::map<std::string,
521 std::vector<std::shared_ptr<petsc::Viewer> > >
m_viewers;
530 const std::string &description);
High-level PISM I/O class.
std::string m_adaptive_timestep_reason
unsigned int m_current_snapshot
std::map< std::string, const Component * > m_submodels
the list of sub-models, for writing model states and obtaining diagnostics
virtual energy::Inputs energy_model_inputs()
std::set< std::string > m_snapshot_vars
virtual int process_signals()
Catch signals -USR1, -USR2 and -TERM.
virtual void hydrology_step(double t, double dt)
void enforce_consistency_of_geometry(ConsistencyFlag flag)
Update the surface elevation and the flow-type mask when the geometry has changed.
virtual double compute_temperate_base_fraction(double ice_area)
virtual void allocate_bed_deformation()
MaxTimestep scalar_diagnostics_max_timestep(double t)
Computes the maximum time-step we can take and still hit all -scalar_times.
std::string m_snapshots_filename
const Geometry & geometry() const
void compute_geometry_change(const array::Scalar &thickness, const array::Scalar &Href, const array::Scalar &thickness_old, const array::Scalar &Href_old, bool add_values, array::Scalar &output)
void init_checkpoints()
Initialize checkpointing (snapshot-on-wallclock-time) mechanism.
std::shared_ptr< stressbalance::StressBalance > m_stress_balance
std::shared_ptr< Isochrones > m_isochrones
IceModelTerminationReason run()
virtual void init_calving()
Initialize calving mechanisms.
std::shared_ptr< ocean::OceanModel > m_ocean
virtual void post_step_hook()
Virtual. Does nothing in IceModel. Derived classes can do more computation in each time step.
const ocean::OceanModel * ocean_model() const
virtual void view_field(const array::Array *field)
std::shared_ptr< surface::SurfaceModel > m_surface
void define_variables(const OutputFile &file, const std::set< VariableMetadata > &variables) const
virtual void compute_lat_lon()
void write_snapshot()
Writes a snapshot of the model state (if necessary)
unsigned int m_step_counter
std::set< std::string > m_spatial_vars
virtual stressbalance::Inputs stress_balance_inputs()
std::shared_ptr< FractureDensity > m_fracture
std::shared_ptr< Config > m_config
Configuration flags and parameters.
virtual void bootstrap_2d(const File &input_file)
virtual std::map< std::string, Diagnostic::Ptr > allocate_spatial_diagnostics()
ThicknessChanges m_thickness_change
double m_dt_TempAge
enthalpy/temperature and age time-steps
MaxTimestep spatial_diagnostics_max_timestep(double t)
Computes the maximum time-step we can take and still hit all -spatial_times.
virtual void update_fracture_density(double dt)
const GeometryEvolution & geometry_evolution() const
void define_time(const OutputFile &file, bool with_bounds=false) const
const stressbalance::StressBalance * stress_balance() const
void write_run_stats(const OutputFile &file) const
std::vector< double > m_snapshot_times
static const int m_n_work2d
std::shared_ptr< YieldStress > m_basal_yield_stress_model
std::shared_ptr< calving::IcebergRemover > m_iceberg_remover
MaxTimestep snapshots_max_timestep(double my_t)
Computes the maximum time-step we can take and still hit all -save_times.
virtual void initialize_2d()
double m_timestep_hit_multiples_last_time
virtual double compute_original_ice_fraction(double ice_volume)
std::shared_ptr< Context > m_ctx
Execution context.
std::shared_ptr< frontalmelt::FrontalMelt > m_frontal_melt
std::shared_ptr< Logger > m_log
Logger.
std::set< VariableMetadata > m_spatial_file_contents
set of variables that will be written to extra files
array::Scalar m_basal_melt_rate
rate of production of basal meltwater (ice-equivalent); no ghosts
std::shared_ptr< Grid > grid() const
Return the grid used by this model.
double m_last_checkpoint_time
virtual unsigned int skip_counter(double input_dt, double input_dt_diffusivity)
Compute the skip counter using "long" (usually determined using the CFL stability criterion) and "sho...
std::set< std::string > m_scalar_vars
virtual std::set< VariableMetadata > diagnostic_variables(const std::set< std::string > &variable_names) const
virtual MaxTimestep max_timestep_diffusivity()
Compute the maximum time step allowed by the diffusive SIA.
std::shared_ptr< OutputFile > m_snapshot_file
std::shared_ptr< array::Forcing > m_surface_input_for_hydrology
unsigned int m_next_spatial_index
std::set< VariableMetadata > m_output_file_contents
Set of variables that will be written to the output file.
std::shared_ptr< std::vector< double > > m_scalar_times
requested times for scalar time-series
double m_t_TempAge
time of last update for enthalpy/temperature
void list_diagnostics(DiagnosticReport report_type) const
array::Scalar m_bedtoptemp
temperature at the top surface of the bedrock thermal layer
virtual void allocate_stressbalance()
Decide which stress balance model to use.
std::set< VariableMetadata > state_variables_diagnostics(const std::set< std::string > &variable_names) const
const energy::EnergyModel * energy_balance_model() const
virtual std::set< VariableMetadata > state_variables() const
std::shared_ptr< calving::EigenCalving > m_eigen_calving
virtual void update_diagnostics(double t, double dt)
std::unique_ptr< ScalarForcing > m_calving_rate_factor
std::shared_ptr< OutputWriter > m_snapshot_writer
std::string save_state_on_error(const std::string &suffix, const std::set< std::string > &additional_variables)
void init_outputs(InputOptions options, DiagnosticReport report_type)
VariableMetadata m_output_global_attributes
stores global attributes saved in a PISM output file
std::shared_ptr< OutputWriter > m_spatial_writer
std::shared_ptr< Time > m_time
Time manager.
const array::Scalar & frontal_melt() const
virtual void allocate_iceberg_remover()
const array::Scalar & forced_retreat() const
std::vector< std::shared_ptr< array::Scalar2 > > m_work2d
std::shared_ptr< calving::CalvingAtThickness > m_thickness_threshold_calving
std::shared_ptr< calving::FloatKill > m_float_kill_calving
virtual void allocate_subglacial_hydrology()
Decide which subglacial hydrology model to use.
std::shared_ptr< PrescribedRetreat > m_prescribed_retreat
void write_spatial_diagnostics()
Write spatially-variable diagnostic quantities.
bool write_checkpoint()
Write a checkpoint (i.e. an intermediate result of a run).
virtual void allocate_storage()
Allocate all Arrays defined in IceModel.
std::set< std::string > m_checkpoint_vars
array::Scalar2 m_velocity_bc_mask
mask to determine Dirichlet boundary locations for the sliding velocity
void init_scalar_diagnostics()
Initializes the code writing scalar time-series.
std::shared_ptr< calving::HayhurstCalving > m_hayhurst_calving
std::vector< double > m_spatial_times
virtual void allocate_basal_yield_stress()
Decide which basal yield stress model to use.
std::string m_stdout_flags
std::unique_ptr< GeometryEvolution > m_geometry_evolution
virtual void energy_step(double t, double dt)
Manage the solution of the energy equation, and related parallel communication.
std::map< std::string, Diagnostic::Ptr > m_available_spatial_diagnostics
Available spatially-variable diagnostics.
std::set< VariableMetadata > common_metadata() const
void write_state_diagnostics(const OutputFile &file, const std::set< std::string > &variable_names) const
virtual void combine_basal_melt_rate(const Geometry &geometry, const array::Scalar &shelf_base_mass_flux, const array::Scalar &grounded_basal_melt_rate, array::Scalar &result)
Combine basal melt rate in grounded and floating areas.
virtual std::map< std::string, TSDiagnostic::Ptr > allocate_scalar_diagnostics()
std::shared_ptr< OutputFile > m_spatial_file
void write_diagnostics(const OutputFile &file, const std::set< std::string > &variable_names) const
Writes variables listed in variable_names to file.
virtual void allocate_energy_model()
std::set< VariableMetadata > m_snapshot_file_contents
set of variables that will be written to snapshot files
virtual void restart_2d(const File &input_file, unsigned int record)
Initialize 2D model state fields managed by IceModel from a file (for re-starting).
virtual void front_retreat_step(double t, double dt)
void init(DiagnosticReport report_type=DIAG_NONE)
Manage the initialization of the IceModel object.
std::shared_ptr< energy::BedThermalUnit > m_btu
std::string m_spatial_filename
virtual void model_state_setup(InputOptions input_options)
Sets the starting values of model state variables.
std::set< array::Array * > m_model_state
array::Scalar1 m_ice_thickness_bc_mask
Mask prescribing locations where ice thickness is held constant.
std::shared_ptr< AgeModel > m_age_model
virtual void init_front_retreat()
std::map< std::string, std::vector< std::shared_ptr< petsc::Viewer > > > m_viewers
const bed::BedDef * bed_deformation_model() const
virtual void allocate_bedrock_thermal_unit()
Decide which bedrock thermal unit to use.
virtual void bedrock_thermal_model_step(double t, double dt)
virtual std::set< std::string > output_variables(const std::string &keyword)
Assembles a list of diagnostics corresponding to an output file size.
std::string m_checkpoint_filename
void init_spatial_diagnostics()
Initialize the code saving spatially-variable diagnostic quantities.
virtual void regrid()
Manage regridding based on user options.
const units::System::Ptr m_sys
Unit system.
std::map< std::string, TSDiagnostic::Ptr > m_available_scalar_diagnostics
Available scalar diagnostics.
array::Vector2 m_velocity_bc_values
Dirichlet boundary velocities.
virtual void allocate_geometry_evolution()
void write_final_output()
Save model state in NetCDF format.
void init_snapshots()
Initializes the snapshot-saving mechanism.
std::shared_ptr< ocean::sea_level::SeaLevel > m_sea_level
virtual void print_summary_line(bool printPrototype, bool tempAndAge, double delta_t, double volume, double area, double meltfrac, double max_diffusivity)
Print a line to stdout which summarizes the state of the modeled ice sheet at the end of the time ste...
virtual void allocate_age_model()
std::shared_ptr< OutputWriter > m_output_writer
void scalar_diagnostics_flush_buffers()
Flush scalar time-series.
virtual double step(bool do_mass_continuity, bool do_skip)
The contents of the main PISM time-step.
virtual void update_viewers()
Update the runtime graphical viewers.
const array::Scalar & calving() const
std::string m_output_filename
Name of the output file.
virtual void pre_step_hook()
Virtual. Does nothing in IceModel. Derived classes can do more computation in each time step.
unsigned int m_skip_countdown
IceModelTerminationReason run_to(double run_end)
std::shared_ptr< Context > ctx() const
Return the context this model is running in.
std::string m_output_history
virtual YieldStressInputs yield_stress_inputs()
virtual void misc_setup(InputOptions input_options, DiagnosticReport report_type)
Miscellaneous initialization tasks plus tasks that need the fields that can come from regridding.
virtual void write_state(const OutputFile &file) const
virtual void allocate_couplers()
virtual void append_history(const std::string &string)
Get time and user/host name and add it to the given string.
const YieldStress * basal_yield_stress_model() const
std::unique_ptr< hydrology::Hydrology > m_subglacial_hydrology
std::shared_ptr< calving::vonMisesCalving > m_vonmises_calving
std::shared_ptr< OutputFile > m_scalar_file
file to write scalar time-series to
std::set< std::string > m_output_vars
const energy::BedThermalUnit * bedrock_thermal_model() const
std::set< VariableMetadata > m_checkpoint_file_contents
set of variables that will be written to checkpoint files
virtual void print_summary(bool tempAndAge, double dt)
void set_python_ocean_model(std::shared_ptr< ocean::PyOceanModel > model)
virtual void allocate_isochrones()
virtual void init_frontal_melt()
double m_dt
mass continuity time step, s
std::shared_ptr< energy::EnergyModel > m_energy_model
const std::shared_ptr< Grid > m_grid
Computational grid.
void identify_open_ocean(const array::CellType &cell_type, array::Scalar1 &result)
std::shared_ptr< bed::BedDef > m_beddef
double m_last_spatial_time
virtual TimesteppingInfo max_timestep(unsigned int counter)
Use various stability criteria to determine the time step for an evolution run.
virtual void allocate_submodels()
Allocate PISM's sub-models implementing some physical processes.
std::shared_ptr< FrontRetreat > m_front_retreat
array::Scalar2 m_basal_yield_stress
ghosted
void deallocate_unused_diagnostics()
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
The PISM basal yield stress model interface (virtual base class)
Abstract class for reading, writing, allocating, and accessing a DA-based PETSc Vec (2D and 3D fields...
"Cell type" mask. Adds convenience methods to array::Scalar.
PISM bed deformation model (base class).
Given the temperature of the top of the bedrock, for the duration of one time-step,...
A very rudimentary PISM ocean model.
The class defining PISM's interface to the shallow stress balance code.
std::shared_ptr< System > Ptr
bool ocean(int M)
An ocean cell (floating ice or ice-free).
MaxTimestep reporting_max_timestep(const std::vector< double > ×, double t, double eps, const std::string &description)
double ice_area(const Geometry &geometry, double thickness_threshold)
Computes ice area, in m^2.
IceModelTerminationReason
double ice_volume(const Geometry &geometry, double thickness_threshold)
Computes the ice volume, in m^3.
void bedrock_surface_temperature(const array::Scalar &sea_level, const array::CellType &cell_type, const array::Scalar &bed_topography, const array::Scalar &ice_thickness, const array::Scalar &basal_enthalpy, const array::Scalar &ice_surface_temperature, array::Scalar &result)
Compute the temperature seen by the top of the bedrock thermal layer.
array::Scalar forced_retreat
array::Scalar frontal_melt
unsigned int skip_counter