19 #ifndef PISM_ICEMODEL_H
20 #define PISM_ICEMODEL_H
43 #include "pism/util/array/Vector.hh"
44 #include "pism/util/ConfigInterface.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"
55 #include "pism/util/petscwrappers/Vec.hh"
77 class vonMisesCalving;
79 class HayhurstCalving;
80 class CalvingAtThickness;
84 class FractureDensity;
89 class EnergyModelStats;
93 namespace frontalmelt {
111 class PrescribedRetreat;
120 IceModel(std::shared_ptr<Grid>
grid,
const std::shared_ptr<Context> &context);
125 std::shared_ptr<Grid>
grid()
const;
126 std::shared_ptr<Context>
ctx()
const;
197 virtual void step(
bool do_mass_continuity,
bool do_skip);
213 virtual void restart_2d(
const File &input_file,
unsigned int record);
219 const std::set<std::string> &variables,
232 const std::set<std::string> &variables,
235 const std::set<std::string> &variables)
const;
238 const std::set<std::string> &additional_variables);
245 const std::shared_ptr<Context>
m_ctx;
266 std::shared_ptr<energy::BedThermalUnit>
m_btu;
343 virtual unsigned int skip_counter(
double input_dt,
double input_dt_diffusivity);
382 double volume,
double area,
383 double meltfrac,
double max_diffusivity);
393 mutable std::vector<std::shared_ptr<array::Scalar2>>
m_work2d;
472 std::map<std::string,
473 std::vector<std::shared_ptr<petsc::Viewer> > >
m_viewers;
486 const std::string &description);
std::shared_ptr< Config > Ptr
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.
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 extras_max_timestep(double my_t)
Computes the maximum time-step we can take and still hit all -extra_times.
std::string m_snapshots_filename
virtual void define_diagnostics(const File &file, const std::set< std::string > &variables, io::Type default_type) const
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)
virtual void model_state_setup()
Sets the starting values of model state variables.
void init_checkpoints()
Initialize checkpointing (snapshot-on-wallclock-time) mechanism.
double ice_volume_temperate(double thickness_threshold) const
Computes the temperate ice volume, in m^3.
std::shared_ptr< stressbalance::StressBalance > m_stress_balance
std::shared_ptr< Isochrones > m_isochrones
VariableMetadata m_timestamp
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
VariableMetadata run_stats() const
std::map< std::string, TSDiagnostic::Ptr > m_ts_diagnostics
Requested scalar diagnostics.
virtual void energy_step()
Manage the solution of the energy equation, and related parallel communication.
std::shared_ptr< petsc::Vec > m_work2d_proc0
unsigned int m_next_extra
virtual void view_field(const array::Array *field)
std::unique_ptr< File > m_extra_file
std::shared_ptr< surface::SurfaceModel > m_surface
const Config::Ptr m_config
Configuration flags and parameters.
void write_extras()
Write spatially-variable diagnostic quantities.
virtual void compute_lat_lon()
void write_snapshot()
Writes a snapshot of the model state (if necessary)
double cold_base_area(double thickness_threshold) const
Computes area of basal ice which is cold, in m^2.
unsigned int m_step_counter
virtual stressbalance::Inputs stress_balance_inputs()
std::shared_ptr< FractureDensity > m_fracture
virtual void bootstrap_2d(const File &input_file)
ThicknessChanges m_thickness_change
void init()
Manage the initialization of the IceModel object.
const Time::Ptr m_time
Time manager.
const GeometryEvolution & geometry_evolution() const
const stressbalance::StressBalance * stress_balance() const
std::vector< double > m_snapshot_times
virtual void reset_diagnostics()
static const int m_n_work2d
std::shared_ptr< YieldStress > m_basal_yield_stress_model
std::shared_ptr< calving::IcebergRemover > m_iceberg_remover
double temperate_base_area(double thickness_threshold) const
Computes area of basal ice which is temperate, in m^2.
std::shared_ptr< std::vector< double > > m_ts_times
requested times for scalar time-series
virtual void initialize_2d()
double m_timestep_hit_multiples_last_time
virtual double compute_original_ice_fraction(double ice_volume)
std::shared_ptr< frontalmelt::FrontalMelt > m_frontal_melt
void init_extras()
Initialize the code saving spatially-variable diagnostic quantities.
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.
virtual void front_retreat_step()
double m_last_checkpoint_time
const std::shared_ptr< Context > m_ctx
Execution context.
virtual void save_results()
Save model state in NetCDF format.
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...
virtual void misc_setup()
Miscellaneous initialization tasks plus tasks that need the fields that can come from regridding.
const Logger::Ptr m_log
Logger.
virtual MaxTimestep max_timestep_diffusivity()
Compute the maximum time step allowed by the diffusive SIA.
MaxTimestep ts_max_timestep(double my_t)
Computes the maximum time-step we can take and still hit all -ts_times.
std::shared_ptr< array::Forcing > m_surface_input_for_hydrology
virtual void print_summary(bool tempAndAge)
virtual void update_diagnostics(double dt)
array::Scalar m_bedtoptemp
temperature at the top surface of the bedrock thermal layer
double ice_volume_cold(double thickness_threshold) const
Computes the cold ice volume, in m^3.
virtual void allocate_stressbalance()
Decide which stress balance model to use.
const energy::EnergyModel * energy_balance_model() const
std::shared_ptr< calving::EigenCalving > m_eigen_calving
std::unique_ptr< ScalarForcing > m_calving_rate_factor
std::string save_state_on_error(const std::string &suffix, const std::set< std::string > &additional_variables)
VariableMetadata m_output_global_attributes
stores global attributes saved in a PISM output file
void flush_timeseries()
Flush scalar time-series.
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
virtual void process_options()
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.
void identify_open_ocean(const array::CellType &cell_type, array::Scalar &result)
std::shared_ptr< PrescribedRetreat > m_prescribed_retreat
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
virtual void prepend_history(const std::string &string)
Get time and user/host name and add it to the given string.
std::shared_ptr< calving::HayhurstCalving > m_hayhurst_calving
virtual void write_model_state(const File &file) const
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 step(bool do_mass_continuity, bool do_skip)
The contents of the main PISM time-step.
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 void allocate_energy_model()
virtual void hydrology_step()
virtual void bedrock_thermal_model_step()
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 time_setup()
Initialize time from an input file or command-line options.
std::shared_ptr< energy::BedThermalUnit > m_btu
virtual void save_variables(const File &file, OutputKind kind, const std::set< std::string > &variables, double time, io::Type default_diagnostics_type=io::PISM_FLOAT) const
virtual void define_model_state(const File &file) const
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 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
virtual void write_diagnostics(const File &file, const std::set< std::string > &variables) const
Writes variables listed in vars to filename, using nctype to write fields stored in dedicated Arrays.
virtual void regrid()
Manage regridding based on user options.
const units::System::Ptr m_sys
Unit system.
double t_TempAge
time of last update for enthalpy/temperature
array::Vector2 m_velocity_bc_values
Dirichlet boundary velocities.
virtual void prune_diagnostics()
virtual void allocate_geometry_evolution()
void list_diagnostics(const std::string &list_type) const
std::string m_ts_filename
file to write scalar time-series to
MaxTimestep save_max_timestep(double my_t)
Computes the maximum time-step we can take and still hit all -save_times.
virtual void update_fracture_density()
std::map< std::string, Diagnostic::Ptr > m_diagnostics
Requested spatially-variable diagnostics.
IceModel(std::shared_ptr< Grid > grid, const std::shared_ptr< Context > &context)
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()
virtual void update_viewers()
Update the runtime graphical viewers.
const array::Scalar & calving() const
virtual void pre_step_hook()
Virtual. Does nothing in IceModel. Derived classes can do more computation in each time step.
std::set< std::string > m_ts_vars
unsigned int m_skip_countdown
IceModelTerminationReason run_to(double run_end)
std::set< std::string > m_extra_vars
std::shared_ptr< Context > ctx() const
Return the context this model is running in.
virtual YieldStressInputs yield_stress_inputs()
virtual void init_diagnostics()
virtual void allocate_couplers()
virtual void write_metadata(const File &file, MappingTreatment mapping_flag, HistoryTreatment history_flag) const
Write time-independent metadata to a file.
const YieldStress * basal_yield_stress_model() const
std::unique_ptr< hydrology::Hydrology > m_subglacial_hydrology
std::string m_extra_filename
std::shared_ptr< calving::vonMisesCalving > m_vonmises_calving
void init_timeseries()
Initializes the code writing scalar time-series.
std::set< std::string > m_output_vars
bool m_snapshots_file_is_ready
bool m_extra_file_is_ready
std::vector< double > m_extra_times
const energy::BedThermalUnit * bedrock_thermal_model() const
void set_python_ocean_model(std::shared_ptr< ocean::PyOceanModel > model)
virtual void allocate_isochrones()
double dt_TempAge
enthalpy/temperature and age time-steps
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.
std::shared_ptr< bed::BedDef > m_beddef
virtual TimesteppingInfo max_timestep(unsigned int counter)
Use various stability criteria to determine the time step for an evolution run.
VariableMetadata m_extra_bounds
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
std::shared_ptr< Logger > Ptr
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
std::shared_ptr< Time > Ptr
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.
void write_mapping(const File &file, const pism::MappingInfo &info)
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.
void write_run_stats(const File &file, const pism::VariableMetadata &stats)
array::Scalar forced_retreat
ThicknessChanges(const std::shared_ptr< const Grid > &grid)
array::Scalar frontal_melt
unsigned int skip_counter