21 " Testing program for PISM's implementations of the SSA.\n"
22 " Does a time-independent calculation. Does not run IceModel or a derived\n"
23 " class thereof. Uses the van der Veen flow-line shelf geometry. Also may be\n"
24 " used in a PISM software (regression) test.\n\n";
26 #include "pism/basalstrength/basal_resistance.hh"
27 #include "pism/stressbalance/ssa/SSAFD.hh"
28 #include "pism/stressbalance/ssa/SSAFD_diagnostics.hh"
29 #include "pism/stressbalance/ssa/SSATestCase.hh"
30 #include "pism/stressbalance/ssa/SSAFEM.hh"
31 #include "pism/util/Mask.hh"
32 #include "pism/util/Context.hh"
33 #include "pism/util/VariableMetadata.hh"
34 #include "pism/util/error_handling.hh"
35 #include "pism/util/io/File.hh"
36 #include "pism/util/petscwrappers/PetscInitializer.hh"
37 #include "pism/util/pism_utilities.hh"
38 #include "pism/util/pism_options.hh"
41 namespace stressbalance {
44 static double H_exact(
double V0,
double H0,
double C,
double x) {
45 const double Q0 = V0*
H0;
46 return pow(4 *
C / Q0 * x + 1/pow(
H0, 4), -0.25);
50 static double u_exact(
double V0,
double H0,
double C,
double x) {
51 const double Q0 = V0*
H0;
63 m_config->set_number(
"flow_law.isothermal_Glen.ice_softness",
64 pow(1.9e8, -
m_config->get_number(
"stress_balance.ssa.Glen_exponent")));
65 m_config->set_flag(
"stress_balance.ssa.compute_surface_gradient_inward",
false);
66 m_config->set_flag(
"stress_balance.calving_front_stress_bc",
true);
67 m_config->set_flag(
"stress_balance.ssa.fd.flow_line_mode",
true);
68 m_config->set_flag(
"stress_balance.ssa.fd.extrapolate_at_margins",
false);
69 m_config->set_string(
"stress_balance.ssa.flow_law",
"isothermal_glen");
76 virtual void write_nuH(
const std::string &filename);
82 double x,
double y,
double *u,
double *v);
108 const double x_min =
m_grid->x(0);
110 for (
auto p =
m_grid->points(); p; p.next()) {
111 const int i = p.i(), j = p.j();
113 const double x =
m_grid->x(i);
115 if (i != (
int)
m_grid->Mx() - 1) {
139 double *u,
double *v) {
140 const double x_min =
m_grid->x(0);
142 if (i != (
int)
m_grid->Mx() - 1) {
154 int main(
int argc,
char *argv[]) {
156 using namespace pism;
159 MPI_Comm com = MPI_COMM_WORLD;
162 com = PETSC_COMM_WORLD;
169 std::string usage =
"\n"
170 "usage of SSA_TEST_CFBC:\n"
171 " run ssa_test_cfbc -Mx <number> -My <number>\n"
181 unsigned int Mx = config->get_number(
"grid.Mx");
182 unsigned int My = config->get_number(
"grid.My");
184 auto method = config->get_string(
"stress_balance.ssa.method");
185 auto output_file = config->get_string(
"output.file");
187 bool write_output = config->get_string(
"output.size") !=
"none";
191 if (method ==
"fem") {
193 }
else if (method ==
"fd") {
204 testcase.
write(output_file);
std::shared_ptr< Config > Ptr
std::shared_ptr< array::Array > compute() const
Compute a diagnostic quantity and return a pointer to a newly-allocated Array.
std::shared_ptr< EnthalpyConverter > Ptr
Converts between specific enthalpy and temperature or liquid content.
void ensure_consistency(double ice_free_thickness_threshold)
array::Scalar2 ice_surface_elevation
array::CellType2 cell_type
array::Scalar2 ice_thickness
array::Scalar2 bed_elevation
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
void set(double c)
Result: v[j] <- c for all j.
void update_ghosts()
Updates ghost points.
Reports the nuH (viscosity times thickness) product on the staggered grid.
PISM's SSA solver: the finite difference implementation.
double H0
grounding line thickness (meters)
SSATestCaseCFBC(std::shared_ptr< Context > ctx, int Mx, int My, SSAFactory ssafactory)
virtual void exactSolution(int i, int j, double x, double y, double *u, double *v)
double C
"typical constant ice parameter"
virtual void initializeSSACoefficients()
Set up the coefficient variables as appropriate for the test case.
double V0
grounding line vertically-averaged velocity
virtual void write_nuH(const std::string &filename)
virtual void init()
Initialize the test case at the start of a run.
EnthalpyConverter::Ptr m_enthalpyconverter
array::Array3D m_ice_enthalpy
std::shared_ptr< Grid > m_grid
array::Vector2 m_bc_values
virtual void report(const std::string &testname)
Report on the generated solution.
virtual void run()
Solve the SSA.
const Config::Ptr m_config
virtual void write(const std::string &filename)
Save the computation and data to a file.
SSA * SSAFDFactory(std::shared_ptr< const Grid > g)
Constructs a new SSAFD.
SSA *(* SSAFactory)(std::shared_ptr< const Grid >)
static double H_exact(double V0, double H0, double C, double x)
SSA * SSAFEMFactory(std::shared_ptr< const Grid > g)
Factory function for constructing a new SSAFEM.
static double u_exact(double V0, double H0, double C, double x)
Stress balance models and related diagnostics.
double convert(System::Ptr system, double input, const std::string &spec1, const std::string &spec2)
Convert a quantity from unit1 to unit2.
std::shared_ptr< Context > context_from_options(MPI_Comm com, const std::string &prefix, bool print)
Create a default context using options.
void handle_fatal_errors(MPI_Comm com)
bool show_usage_check_req_opts(const Logger &log, const std::string &execname, const std::vector< std::string > &required_options, const std::string &usage)
In a single call a driver program can provide a usage string to the user and check if required option...
int main(int argc, char *argv[])