34 " Testing program for the finite element implementation of the SSA.\n"
35 " Does a time-independent calculation. Does not run IceModel or a derived\n"
36 " class thereof.Also may be used in a PISM\n"
37 " software (regression) test.\n\n";
41#include "pism/basalstrength/basal_resistance.hh"
42#include "pism/stressbalance/ssa/SSAFD.hh"
43#include "pism/stressbalance/ssa/SSAFEM.hh"
44#include "pism/stressbalance/ssa/SSATestCase.hh"
45#include "pism/util/Mask.hh"
46#include "pism/util/Context.hh"
47#include "pism/util/VariableMetadata.hh"
48#include "pism/util/error_handling.hh"
49#include "pism/util/io/File.hh"
50#include "pism/util/petscwrappers/PetscInitializer.hh"
51#include "pism/util/pism_utilities.hh"
52#include "pism/util/pism_options.hh"
53#include "pism/verification/tests/exactTestsIJ.h"
56namespace stressbalance {
72 auto config = ctx->config();
73 m_basal_q = config->get_number(
"basal_resistance.pseudo_plastic.q");
79 void exactSolution(
int i,
int j,
double x,
double y,
double *u,
double *v);
93 m_ssa->strength_extension->set_min_thickness(0.5*
m_H0);
103 for (
auto p =
m_grid->points(); p; p.next()) {
104 const int i = p.i(), j = p.j();
112 bool edge = ((j == 0) || (j == (
int)
m_grid->My() - 1) ||
113 (i == 0) || (i == (
int)
m_grid->Mx() - 1));
131 double *u,
double *v) {
132 double earth_grav =
m_config->get_number(
"constants.standard_gravity"),
133 tauc_threshold_velocity =
m_config->get_number(
"basal_resistance.pseudo_plastic.u_threshold",
135 ice_rho =
m_config->get_number(
"constants.ice.density");
144int main(
int argc,
char *argv[]) {
146 using namespace pism;
149 MPI_Comm com = MPI_COMM_WORLD;
152 com = PETSC_COMM_WORLD;
156 std::shared_ptr<Context> ctx = context_from_options(com,
"ssa_test_const");
159 std::string usage =
"\n"
160 "usage of SSA_TEST_CONST:\n"
161 " run ssa_test_const -Mx <number> -My <number> -ssa_method <fd|fem>\n"
164 bool stop = show_usage_check_req_opts(*ctx->log(),
"ssa_test_const", {}, usage);
171 unsigned int Mx = config->get_number(
"grid.Mx");
172 unsigned int My = config->get_number(
"grid.My");
174 double basal_q = 1.0;
176 auto method = config->get_string(
"stress_balance.ssa.method");
177 auto output_file = config->get_string(
"output.file");
179 bool write_output = config->get_string(
"output.size") !=
"none";
181 config->set_flag(
"basal_resistance.pseudo_plastic.enabled",
true);
182 config->set_number(
"basal_resistance.pseudo_plastic.q", basal_q);
185 config->set_flag(
"basal_resistance.pseudo_plastic.enabled",
true);
188 config->set_flag(
"stress_balance.ssa.compute_surface_gradient_inward",
true);
190 auto grid = ssa_test_const_grid(ctx, Mx, My);
196 testcase.
write(output_file);
200 handle_fatal_errors(com);
std::shared_ptr< Config > Ptr
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 initializeSSACoefficients()
Set up the coefficient variables as appropriate for the test case.
SSATestCaseConst(std::shared_ptr< Context > ctx, std::shared_ptr< SSA > ssa)
void exactSolution(int i, int j, double x, double y, double *u, double *v)
std::shared_ptr< const pism::Grid > m_grid
virtual void init()
Initialize the test case at the start of a run.
const units::System::Ptr m_sys
static std::shared_ptr< Grid > grid(std::shared_ptr< Context > ctx, int Mx, int My, double Lx, double Ly, grid::Registration registration, grid::Periodicity periodicity)
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::ConstPtr m_config
std::shared_ptr< SSA > m_ssa
virtual void write(const std::string &filename)
Save the computation and data to a file.
std::shared_ptr< Grid > ssa_test_const_grid(std::shared_ptr< Context > ctx, int Mx, int My)
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.
int main(int argc, char *argv[])