28 " Testing program for the finite element implementation of the SSA.\n"
29 " Does a time-independent calculation. Does not run IceModel or a derived\n"
30 " class thereof.\n\n";
34 #include "pism/basalstrength/basal_resistance.hh"
35 #include "pism/stressbalance/ssa/SSAFD.hh"
36 #include "pism/stressbalance/ssa/SSAFEM.hh"
37 #include "pism/stressbalance/ssa/SSATestCase.hh"
38 #include "pism/util/Context.hh"
39 #include "pism/util/VariableMetadata.hh"
40 #include "pism/util/error_handling.hh"
41 #include "pism/util/io/File.hh"
42 #include "pism/util/petscwrappers/PetscInitializer.hh"
43 #include "pism/util/pism_utilities.hh"
44 #include "pism/util/pism_options.hh"
45 #include "pism/verification/tests/exactTestsIJ.h"
48 namespace stressbalance {
71 m_config->set_string(
"stress_balance.ssa.flow_law",
"isothermal_glen");
72 m_config->set_number(
"flow_law.isothermal_Glen.ice_softness", pow(
B0, -
glen_n));
81 double x,
double y,
double *u,
double *v);
98 m_config->set_flag(
"stress_balance.ssa.compute_surface_gradient_inward",
true);
99 m_config->set_number(
"stress_balance.ssa.epsilon", 0.0);
113 for (
auto p =
m_grid->points(); p; p.next()) {
114 const int i = p.i(), j = p.j();
122 bool edge = ((j == 0) || (j == (
int)
m_grid->My() - 1) ||
123 (i == 0) || (i == (int)
m_grid->Mx() - 1));
140 double *u,
double *v) {
141 double earth_grav =
m_config->get_number(
"constants.standard_gravity"),
142 ice_rho =
m_config->get_number(
"constants.ice.density");
143 double f = ice_rho * earth_grav *
H0*
dhdx;
146 *u = 0.5*pow(f,3)*pow(
L,4)/pow(
B0*
H0,3)*(1-pow(ynd,4));
153 int main(
int argc,
char *argv[]) {
155 using namespace pism;
158 MPI_Comm com = MPI_COMM_WORLD;
161 com = PETSC_COMM_WORLD;
168 std::string usage =
"\n"
169 "usage of SSA_TEST_PLUG:\n"
170 " run ssa_test_plug -Mx <number> -My <number> -ssa_method <fd|fem>\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");
186 auto glen_n = config->get_number(
"stress_balance.ssa.Glen_exponent");
188 bool write_output = config->get_string(
"output.size") !=
"none";
192 if (method ==
"fem") {
194 }
else if (method ==
"fd") {
205 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.
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)
SSATestCasePlug(std::shared_ptr< Context > ctx, int Mx, int My, double n, 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.
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[])