33 " Testing program for the finite element implementation of the SSA.\n"
34 " Does a time-independent calculation. Does not run IceModel or a derived\n"
35 " class thereof.Also may be used in a PISM\n"
36 " software (regression) test.\n\n";
40 #include "pism/basalstrength/basal_resistance.hh"
41 #include "pism/stressbalance/ssa/SSAFD.hh"
42 #include "pism/stressbalance/ssa/SSAFEM.hh"
43 #include "pism/stressbalance/ssa/SSATestCase.hh"
44 #include "pism/util/Mask.hh"
45 #include "pism/util/Context.hh"
46 #include "pism/util/VariableMetadata.hh"
47 #include "pism/util/error_handling.hh"
48 #include "pism/util/io/File.hh"
49 #include "pism/util/petscwrappers/PetscInitializer.hh"
50 #include "pism/util/pism_utilities.hh"
51 #include "pism/util/pism_options.hh"
52 #include "pism/verification/tests/exactTestsIJ.h"
55 namespace stressbalance {
71 m_config->set_flag(
"basal_resistance.pseudo_plastic.enabled",
true);
75 m_config->set_flag(
"basal_resistance.pseudo_plastic.enabled",
true);
87 double x,
double y,
double *u,
double *v);
100 m_config->set_flag(
"stress_balance.ssa.compute_surface_gradient_inward",
true);
110 for (
auto p =
m_grid->points(); p; p.next()) {
111 const int i = p.i(), j = p.j();
119 bool edge = ((j == 0) || (j == (
int)
m_grid->My() - 1) ||
120 (i == 0) || (i == (int)
m_grid->Mx() - 1));
138 double *u,
double *v) {
139 double earth_grav =
m_config->get_number(
"constants.standard_gravity"),
140 tauc_threshold_velocity =
m_config->get_number(
"basal_resistance.pseudo_plastic.u_threshold",
142 ice_rho =
m_config->get_number(
"constants.ice.density");
144 *u = pow(ice_rho * earth_grav *
H0 *
dhdx /
tauc0, 1./
basal_q)*tauc_threshold_velocity;
151 int main(
int argc,
char *argv[]) {
153 using namespace pism;
156 MPI_Comm com = MPI_COMM_WORLD;
159 com = PETSC_COMM_WORLD;
166 std::string usage =
"\n"
167 "usage of SSA_TEST_CONST:\n"
168 " run ssa_test_const -Mx <number> -My <number> -ssa_method <fd|fem>\n"
178 unsigned int Mx = config->get_number(
"grid.Mx");
179 unsigned int My = config->get_number(
"grid.My");
181 config->set_number(
"basal_resistance.pseudo_plastic.q", 1.0);
182 double basal_q = config->get_number(
"basal_resistance.pseudo_plastic.q");
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< EnthalpyConverter > Ptr
Converts between specific enthalpy and temperature or liquid content.
array::Scalar2 ice_surface_elevation
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.
void set_min_thickness(double my_min_thickness)
Set minimum thickness to trigger use of extension.
void set_notional_strength(double my_nuH)
Set strength = (viscosity times thickness).
virtual void initializeSSACoefficients()
Set up the coefficient variables as appropriate for the test case.
virtual void exactSolution(int i, int j, double x, double y, double *u, double *v)
SSATestCaseConst(std::shared_ptr< Context > ctx, int Mx, int My, double q, SSAFactory ssafactory)
virtual void init()
Initialize the test case at the start of a run.
EnthalpyConverter::Ptr m_enthalpyconverter
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.
SSAStrengthExtension * strength_extension
SSA * SSAFDFactory(std::shared_ptr< const Grid > g)
Constructs a new SSAFD.
SSA *(* SSAFactory)(std::shared_ptr< const Grid >)
SSA * SSAFEMFactory(std::shared_ptr< const Grid > g)
Factory function for constructing a new SSAFEM.
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[])