29 " Testing program for the finite element implementation of the SSA.\n"
30 " Does a time-independent calculation. Does not run IceModel or a derived\n"
31 " class thereof.Also may be used in a PISM\n"
32 " software (regression) test.\n\n";
36 #include "pism/basalstrength/basal_resistance.hh"
37 #include "pism/stressbalance/ssa/SSAFD.hh"
38 #include "pism/stressbalance/ssa/SSAFEM.hh"
39 #include "pism/stressbalance/ssa/SSATestCase.hh"
40 #include "pism/util/Context.hh"
41 #include "pism/util/VariableMetadata.hh"
42 #include "pism/util/error_handling.hh"
43 #include "pism/util/io/File.hh"
44 #include "pism/util/petscwrappers/PetscInitializer.hh"
45 #include "pism/util/pism_utilities.hh"
46 #include "pism/util/pism_options.hh"
47 #include "pism/verification/tests/exactTestsIJ.h"
50 namespace stressbalance {
64 m_config->set_flag(
"basal_resistance.pseudo_plastic.enabled",
true);
65 m_config->set_number(
"basal_resistance.pseudo_plastic.q", 1.0);
77 double x,
double y,
double *u,
double *v);
89 m_config->set_flag(
"stress_balance.ssa.compute_surface_gradient_inward",
true);
103 for (
auto p =
m_grid->points(); p; p.next()) {
104 const int i = p.i(), j = p.j();
109 bool edge = ((j == 0) || (j == (
int)
m_grid->My() - 1) ||
110 (i == 0) || (i == (int)
m_grid->Mx() - 1));
125 double *u,
double *v) {
126 double tauc_threshold_velocity =
m_config->get_number(
"basal_resistance.pseudo_plastic.u_threshold",
130 double alpha = sqrt((
tauc0/tauc_threshold_velocity) / (4*
nu0*
H0));
131 *u =
v0*exp(-alpha*(x-
L));
138 int main(
int argc,
char *argv[]) {
140 using namespace pism;
143 MPI_Comm com = MPI_COMM_WORLD;
146 com = PETSC_COMM_WORLD;
153 std::string usage =
"\n"
155 " run ssa_test_linear -Mx <number> -My <number> -ssa_method <fd|fem>\n"
165 unsigned int Mx = config->get_number(
"grid.Mx");
166 unsigned int My = config->get_number(
"grid.My");
168 auto method = config->get_string(
"stress_balance.ssa.method");
169 auto output_file = config->get_string(
"output.file");
171 bool write_output = config->get_string(
"output.size") !=
"none";
175 if (method ==
"fem") {
177 }
else if (method ==
"fd") {
186 testcase.
report(
"linear");
188 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).
SSATestCaseExp(std::shared_ptr< Context > ctx, int Mx, int My, SSAFactory ssafactory)
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)
virtual void init()
Initialize the test case at the start of a run.
EnthalpyConverter::Ptr m_enthalpyconverter
const units::System::Ptr m_sys
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[])