20 #include "pism/age/AgeModel.hh"
21 #include "pism/age/AgeColumnSystem.hh"
22 #include "pism/util/error_handling.hh"
23 #include "pism/util/io/File.hh"
32 : ice_thickness(thickness), u3(u), v3(v), w3(w) {
46 "ice age model input %s was not provided", name);
58 std::shared_ptr<const stressbalance::StressBalance> stress_balance)
61 m_ice_age(m_grid,
"age", array::
WITH_GHOSTS, m_grid->z(), m_config->get_number(
"grid.max_stencil_width")),
63 m_stress_balance(stress_balance) {
126 size_t Mz_fine = system.
z().size();
127 std::vector<double> x(Mz_fine);
131 unsigned int Mz =
m_grid->Mz();
135 for (
auto p =
m_grid->points(); p; p.next()) {
136 const int i = p.i(), j = p.j();
138 system.
init(i, j, ice_thickness(i, j));
140 if (system.
ks() == 0) {
157 for (
unsigned int k = 0;
k < Mz; ++
k) {
180 "AgeModel: no stress balance provided."
181 " Cannot compute max. time step.");
189 m_log->message(2,
"* Initializing the age model...\n");
192 double initial_age_years =
m_config->get_number(
"age.initial_value",
"years");
201 "PISM WARNING: input file '%s' does not have the 'age' variable.\n"
202 " Setting it to %f years...\n",
203 opts.
filename.c_str(), initial_age_years);
207 m_log->message(2,
" - setting initial age to %.4f years\n", initial_age_years);
void init(int i, int j, double thickness)
void solve(std::vector< double > &x)
First-order upwind scheme with implicit in the vertical: one column solve.
Tridiagonal linear system for vertical column of age (pure advection) problem.
void define_model_state_impl(const File &output) const
The default (empty implementation).
AgeModel(std::shared_ptr< const Grid > grid, std::shared_ptr< const stressbalance::StressBalance > stress_balance)
std::shared_ptr< const stressbalance::StressBalance > m_stress_balance
MaxTimestep max_timestep_impl(double t) const
const array::Array3D & age() const
void write_model_state_impl(const File &output) const
The default (empty implementation).
void init(const InputOptions &opts)
void update(double t, double dt, const AgeModelInputs &inputs)
const Config::ConstPtr m_config
configuration database used by this component
const Logger::ConstPtr m_log
logger (for easy access)
@ REGRID_WITHOUT_REGRID_VARS
const std::shared_ptr< const Grid > m_grid
grid used by this component
void regrid(const std::string &module_name, array::Array &variable, RegriddingFlag flag=NO_REGRID_WITHOUT_REGRID_VARS)
A class defining a common interface for most PISM sub-models.
VariableLookupData find_variable(const std::string &short_name, const std::string &std_name) const
Find a variable using its standard name and/or short name.
High-level PISM I/O class.
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
void failed()
Indicates a failure of a parallel section.
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
void copy_from(const Array3D &input)
void set_column(int i, int j, double c)
Set all values of scalar quantity to given a single value in a particular column.
double * get_column(int i, int j)
A virtual class collecting methods common to ice and bedrock 3D fields.
void read(const std::string &filename, unsigned int time)
void define(const File &file, io::Type default_type) const
Define variables corresponding to an Array in a file opened using file.
void write(const std::string &filename) const
void set(double c)
Result: v[j] <- c for all j.
SpatialVariableMetadata & metadata(unsigned int N=0)
Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N.
Abstract class for reading, writing, allocating, and accessing a DA-based PETSc Vec (2D and 3D fields...
const std::vector< double > & z() const
void fine_to_coarse(const std::vector< double > &fine, int i, int j, array::Array3D &coarse) const
#define PISM_ERROR_LOCATION
static Vector3 column(const double A[3][3], size_t k)
@ PISM_READONLY
open an existing file for reading only
static void check_input(const array::Array *ptr, const char *name)