21 #include "pism/verification/tests/exactTestsFG.hh"
22 #include "pism/verification/tests/exactTestK.h"
23 #include "pism/verification/tests/exactTestO.h"
24 #include "pism/verification/iceCompModel.hh"
26 #include "pism/stressbalance/StressBalance.hh"
27 #include "pism/util/Time.hh"
28 #include "pism/util/Grid.hh"
29 #include "pism/util/error_handling.hh"
30 #include "pism/earth/BedDef.hh"
31 #include "pism/util/ConfigInterface.hh"
32 #include "pism/util/pism_utilities.hh"
33 #include "pism/verification/BTU_Verification.hh"
34 #include "pism/energy/TemperatureModel.hh"
35 #include "pism/coupler/SurfaceModel.hh"
36 #include "pism/coupler/OceanModel.hh"
37 #include "pism/hydrology/Hydrology.hh"
107 for (
auto p =
m_grid->points(); p; p.next()) {
108 const int i = p.i(), j = p.j();
124 bed_topography.
set(0.0);
140 bed_topography.
set(0.0);
157 ice_rho =
m_config->get_number(
"constants.ice.density"),
158 ice_c =
m_config->get_number(
"constants.ice.specific_heat_capacity");
167 for (
auto p =
m_grid->points(); p; p.next()) {
168 const int i = p.i(), j = p.j();
187 double maxTerr = 0.0, avTerr = 0.0, avcount = 0.0;
203 for (
auto p =
m_grid->points(); p; p.next()) {
204 const int i = p.i(), j = p.j();
207 const double *T = ice_temperature.get_column(i, j);
211 if ((r >= 1.0) and (r <=
m_LforFG - 1.0)) {
216 for (
int k = 0;
k < ks;
k++) {
217 const double Terr = fabs(T[
k] - P.
T[
k]);
232 gavTerr = gavTerr /
std::max(gavcount, 1.0);
237 double &gmaxTberr,
double &gavTberr) {
243 double maxTerr = 0.0, avTerr = 0.0, avcount = 0.0;
244 double maxTberr = 0.0, avTberr = 0.0, avbcount = 0.0;
246 const double *Tb, *T;
247 std::vector<double> Tex(
m_grid->Mz());
250 if (my_btu == NULL) {
254 const auto &bedrock_temp = my_btu->temperature();
256 auto zblevels = bedrock_temp.levels();
257 auto Mbz = zblevels.size();
258 std::vector<double> Tbex(Mbz);
262 for (
unsigned int k = 0;
k <
m_grid->Mz();
k++) {
266 for (
unsigned int k = 0;
k < Mbz;
k++) {
272 for (
unsigned int k = 0;
k <
m_grid->Mz();
k++) {
275 for (
unsigned int k = 0;
k < Mbz;
k++) {
288 for (
auto p =
m_grid->points(); p; p.next()) {
289 const int i = p.i(), j = p.j();
291 Tb = bedrock_temp.get_column(i, j);
292 for (
unsigned int kb = 0; kb < Mbz; kb++) {
293 const double Tberr = fabs(Tb[kb] - Tbex[kb]);
294 maxTberr =
std::max(maxTberr, Tberr);
298 T = ice_temperature.get_column(i, j);
299 for (
unsigned int k = 0;
k <
m_grid->Mz();
k++) {
300 const double Terr = fabs(T[
k] - Tex[
k]);
310 gavTerr = gavTerr/
std::max(gavcount, 1.0);
315 gavTberr = gavTberr/
std::max(gavbcount, 1.0);
334 std::vector<double> z(1, 0.0);
343 for (
auto p =
m_grid->points(); p; p.next()) {
344 const int i = p.i(), j = p.j();
351 Texact =
exactFG(time, r, z, A).
T[0];
354 const double Tbase = ice_temperature.get_column(i,j)[0];
355 if (i == ((
int)
m_grid->Mx() - 1) / 2 and
356 j == ((
int)
m_grid->My() - 1) / 2) {
361 Terr =
std::max(Terr, fabs(Tbase - Texact));
363 avTerr += fabs(Tbase - Texact);
370 double gdomeT, gdomeTexact;
377 centerTerr = fabs(gdomeT - gdomeTexact);
382 double max_strain_heating_err = 0.0, av_strain_heating_err = 0.0, avcount = 0.0;
389 ice_rho =
m_config->get_number(
"constants.ice.density"),
390 ice_c =
m_config->get_number(
"constants.ice.specific_heat_capacity");
392 const auto &strain_heating3 =
m_stress_balance->volumetric_strain_heating();
401 for (
auto p =
m_grid->points(); p; p.next()) {
402 const int i = p.i(), j = p.j();
405 if ((r >= 1.0) && (r <=
m_LforFG - 1.0)) {
410 for (
unsigned int k = 0;
k <
m_grid->Mz();
k++) {
412 P.
Sig[
k] *= ice_rho * ice_c;
416 const double *strain_heating = strain_heating3.get_column(i, j);
418 for (
unsigned int k = 0;
k < ks;
k++) {
419 const double strain_heating_err = fabs(strain_heating[
k] - P.
Sig[
k]);
420 max_strain_heating_err =
std::max(max_strain_heating_err, strain_heating_err);
422 av_strain_heating_err += strain_heating_err;
431 gmax_strain_heating_err =
GlobalMax(
m_grid->com, max_strain_heating_err);
432 gav_strain_heating_err =
GlobalSum(
m_grid->com, av_strain_heating_err);
434 gav_strain_heating_err = gav_strain_heating_err/
std::max(gavcount, 1.0);
439 double &gmaxWerr,
double &gavWerr) {
458 for (
auto p =
m_grid->points(); p; p.next()) {
459 const int i = p.i(), j = p.j();
462 std::vector<double> z(1, H);
469 if ((r >= 1.0) and (r <=
m_LforFG - 1.0)) {
475 uex = (x/r) * P.
U[0],
476 vex = (y/r) * P.
U[0];
481 v_err = v3.interpolate(i, j, H) - vex,
482 Uerr = sqrt(u_err * u_err + v_err * v_err);
485 const double Werr = fabs(w3.interpolate(i, j, H) - P.
w[0]);
506 maxbmelterr = -9.99e40,
507 minbmelterr = 9.99e40;
520 for (
auto p =
m_grid->points(); p; p.next()) {
521 const int i = p.i(), j = p.j();
523 double err = fabs(basal_melt_rate(i, j) - bmelt);
524 maxbmelterr =
std::max(maxbmelterr, err);
525 minbmelterr =
std::min(minbmelterr, err);
array::Scalar1 sea_level_elevation
array::CellType2 cell_type
array::Scalar2 ice_thickness
array::Scalar2 bed_elevation
void compute_strain_heating_errors(double &gmax_strain_heating_err, double &gav_strain_heating_err)
array::Array3D m_strain_heating3_comp
void computeSurfaceVelocityErrors(double &gmaxUerr, double &gavUerr, double &gmaxWerr, double &gavWerr)
void getCompSourcesTestFG()
bool m_bedrock_is_ice_forK
static const double m_Tmin
void computeIceBedrockTemperatureErrors(double &gmaxTerr, double &gavTerr, double &gmaxTberr, double &gavTberr)
void computeTemperatureErrors(double &gmaxTerr, double &gavTerr)
static const double m_LforFG
void computeBasalMeltRateErrors(double &gmaxbmelterr, double &gminbmelterr)
virtual void energy_step()
Manage the solution of the energy equation, and related parallel communication.
static const double m_ApforG
void computeBasalTemperatureErrors(double &gmaxTerr, double &gavTerr, double ¢erTerr)
std::shared_ptr< stressbalance::StressBalance > m_stress_balance
std::shared_ptr< ocean::OceanModel > m_ocean
std::shared_ptr< surface::SurfaceModel > m_surface
const Config::Ptr m_config
Configuration flags and parameters.
const Time::Ptr m_time
Time manager.
std::vector< std::shared_ptr< array::Scalar2 > > m_work2d
std::string m_stdout_flags
std::shared_ptr< energy::BedThermalUnit > m_btu
double t_TempAge
time of last update for enthalpy/temperature
std::unique_ptr< hydrology::Hydrology > m_subglacial_hydrology
double dt_TempAge
enthalpy/temperature and age time-steps
std::shared_ptr< energy::EnergyModel > m_energy_model
const std::shared_ptr< Grid > m_grid
Computational grid.
std::shared_ptr< bed::BedDef > m_beddef
void failed()
Indicates a failure of a parallel section.
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
double interpolate(int i, int j, double z) const
Return value of scalar quantity at level z (m) above base of ice (by linear interpolation).
void set_column(int i, int j, double c)
Set all values of scalar quantity to given a single value in a particular column.
A virtual class collecting methods common to ice and bedrock 3D fields.
void scale(double alpha)
Result: v <- v * alpha. Calls VecScale.
void set(double c)
Result: v[j] <- c for all j.
void add(double alpha, const Array &x)
Result: v <- v + alpha * x. Calls VecAXPY.
void update_ghosts()
Updates ghost points.
const array::Array3D & temperature() const
#define PISM_ERROR_LOCATION
struct TestKParameters exactK(double t, double z, int bedrock_is_ice)
struct TestOParameters exactO(double z)
void extract_surface(const Array3D &data, double z, Scalar &output)
Copies a horizontal slice at level z of an Array3D into output.
double max(const array::Scalar &input)
Finds maximum over all the values in an array::Scalar object. Ignores ghosts.
double min(const array::Scalar &input)
Finds minimum over all the values in an array::Scalar object. Ignores ghosts.
double radius(const Grid &grid, int i, int j)
Returns the distance from the point (i,j) to the origin.
static double K(double psi_x, double psi_y, double speed, double epsilon)
void GlobalMax(MPI_Comm comm, double *local, double *result, int count)
TestFGParameters exactFG(double t, double r, const std::vector< double > &z, double Cp)
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 GlobalMin(MPI_Comm comm, double *local, double *result, int count)
void GlobalSum(MPI_Comm comm, double *local, double *result, int count)
std::vector< double > Sig
std::vector< double > Sigc