21 #include "pism/energy/CHSystem.hh"
22 #include "pism/energy/enthSystem.hh"
23 #include "pism/energy/utilities.hh"
24 #include "pism/util/Context.hh"
25 #include "pism/util/EnthalpyConverter.hh"
26 #include "pism/util/array/CellType.hh"
27 #include "pism/util/io/File.hh"
58 std::shared_ptr<const stressbalance::StressBalance> stress_balance)
68 m_log->message(2,
"* Restarting the cryo-hydrologic system from %s...\n",
82 m_log->message(2,
"* Bootstrapping the cryo-hydrologic warming model from %s...\n",
101 m_log->message(2,
"* Bootstrapping the cryo-hydrologic warming model...\n");
131 const auto &cell_type = *inputs.
cell_type;
145 const size_t Mz_fine = system.
z().size();
146 const double dz = system.
dz();
147 std::vector<double> Enthnew(Mz_fine);
149 array::AccessScope list{&ice_surface_temp, &shelf_base_temp, &surface_liquid_fraction,
150 &ice_thickness, &basal_frictional_heating, &basal_heat_flux,
155 margin_threshold =
m_config->get_number(
"energy.margin_ice_thickness_limit"),
156 T_pm =
m_config->get_number(
"constants.fresh_water.melting_point_temperature"),
157 residual_water_fraction =
m_config->get_number(
"energy.ch_warming.residual_water_fraction");
159 const std::vector<double> &z =
m_grid->z();
160 const unsigned int Mz =
m_grid->Mz();
164 for (
auto pt =
m_grid->points(); pt; pt.next()) {
165 const int i = pt.i(), j = pt.j();
167 const double H = ice_thickness(i, j);
169 if (ice_surface_temp(i, j) >= T_pm) {
174 for (
unsigned int k = 0;
k < Mz; ++
k) {
177 P = EC->pressure(depth);
178 column[
k] = EC->enthalpy(EC->melting_temperature(P),
179 residual_water_fraction,
187 depth_ks = H - system.
ks() * dz,
188 p_ks = EC->pressure(depth_ks);
190 const double Enth_ks = EC->enthalpy_permissive(ice_surface_temp(i, j),
191 surface_liquid_fraction(i, j), p_ks);
194 marginal(ice_thickness, i, j, margin_threshold),
197 const bool ice_free_column = (system.
ks() == 0);
200 if (ice_free_column) {
205 if (system.
lambda() < 1.0) {
213 if (cell_type.ocean(i, j)) {
216 double Enth0 = EC->enthalpy_permissive(shelf_base_temp(i, j), 0.0, EC->pressure(H));
224 system.
solve(Enthnew);
258 auto grid = result.
grid();
260 const auto &z = grid->z();
261 auto Mz = grid->Mz();
263 auto EC = grid->ctx()->enthalpy_converter();
267 double C =
k / (R * R);
271 for (
auto p = grid->points(); p; p.next()) {
272 const int i = p.i(), j = p.j();
279 for (
unsigned int m = 0; m < Mz; ++m) {
281 depth = ice_thickness(i, j) - z[m];
284 double P = EC->pressure(depth);
285 Q[m] =
std::max(
C * (EC->temperature(E_ch[m], P) - EC->temperature(E_ice[m], P)),
const Config::ConstPtr m_config
configuration database used by this component
const Logger::ConstPtr m_log
logger (for easy access)
const std::shared_ptr< const Grid > m_grid
grid used by this component
static Ptr wrap(const T &input)
std::shared_ptr< EnthalpyConverter > Ptr
std::string filename() const
High-level PISM I/O class.
void failed()
Indicates a failure of a parallel section.
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
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 set_name(const std::string &name)
Sets the variable name to name.
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
int state_counter() const
Get the object state counter.
std::shared_ptr< const Grid > grid() const
SpatialVariableMetadata & metadata(unsigned int N=0)
Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N.
const std::vector< double > & z() const
void fine_to_coarse(const std::vector< double > &fine, int i, int j, array::Array3D &coarse) const
CHSystem(std::shared_ptr< const Grid > grid, std::shared_ptr< const stressbalance::StressBalance > stress_balance)
void restart_impl(const File &input_file, int record)
void update_impl(double t, double dt, const Inputs &inputs)
Update the enthalpy of the cryo-hydrologic system.
DiagnosticList diagnostics_impl() const
void initialize_impl(const array::Scalar &basal_melt_rate, const array::Scalar &ice_thickness, const array::Scalar &surface_temperature, const array::Scalar &climatic_mass_balance, const array::Scalar &basal_heat_flux)
void define_model_state_impl(const File &output) const
The default (empty implementation).
void bootstrap_impl(const File &input_file, const array::Scalar &ice_thickness, const array::Scalar &surface_temperature, const array::Scalar &climatic_mass_balance, const array::Scalar &basal_heat_flux)
void write_model_state_impl(const File &output) const
The default (empty implementation).
unsigned int reduced_accuracy_counter
void init_enthalpy(const File &input_file, bool regrid, int record)
Initialize enthalpy by reading it from a file, or by reading temperature and liquid water fraction,...
const array::Scalar & basal_melt_rate() const
Basal melt rate in grounded areas. (It is set to zero elsewhere.)
array::Array3D m_ice_enthalpy
void regrid_enthalpy()
Regrid enthalpy from the -regrid_file.
void init(int i, int j, bool ismarginal, double ice_thickness)
void set_basal_heat_flux(double heat_flux)
Set coefficients in discrete equation for Neumann condition at base of ice.
void solve(std::vector< double > &result)
Solve the tridiagonal system, in a single column, which determines the new values of the ice enthalpy...
void set_basal_dirichlet_bc(double E_basal)
Set coefficients in discrete equation for at base of ice.
void set_surface_dirichlet_bc(double E_surface)
Tridiagonal linear system for conservation of energy in vertical column of ice enthalpy.
double max(const array::Scalar &input)
Finds maximum over all the values in an array::Scalar object. Ignores ghosts.
void cryo_hydrologic_warming_flux(double k, double R, const array::Scalar &ice_thickness, const array::Array3D &ice_enthalpy, const array::Array3D &ch_enthalpy, array::Array3D &result)
bool marginal(const array::Scalar1 &thickness, int i, int j, double threshold)
void bootstrap_ice_enthalpy(const array::Scalar &ice_thickness, const array::Scalar &ice_surface_temp, const array::Scalar &surface_mass_balance, const array::Scalar &basal_heat_flux, array::Array3D &result)
static Vector3 column(const double A[3][3], size_t k)
std::map< std::string, Diagnostic::Ptr > DiagnosticList