|
PISM, A Parallel Ice Sheet Model
stable v0.5
|
00001 // Copyright (C) 2004-2011 Jed Brown, Ed Bueler and Constantine Khroulev 00002 // 00003 // This file is part of Pism. 00004 // 00005 // Pism is free software; you can redistribute it and/or modify it under the 00006 // terms of the GNU General Public License as published by the Free Software 00007 // Foundation; either version 2 of the License, or (at your option) any later 00008 // version. 00009 // 00010 // Pism is distributed in the hope that it will be useful, but WITHOUT ANY 00011 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Pism; if not, write to the Free Software 00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 #include <petsc.h> 00020 #include "pism_const.hh" 00021 #include "flowlaw_factory.hh" 00022 #include "NCVariable.hh" 00023 #include "enthalpyConverter.hh" 00024 #include "pism_options.hh" 00025 00026 static char help[] = 00027 "Calls IceFlowLaw with various values of arguments and prints results.\n" 00028 "Used for software tests. Tests the flow() method but prints\n" 00029 "temperature and liquid fraction as inputs and flow coefficient as output.\n" 00030 "Thus also tests methods getPressureFromDepth(), getMeltingTemp(), and\n" 00031 "getEnth() methods of EnthalpyConverter. Nonetheless a change to the\n" 00032 "enthalpy normalization only should not affect the outcome. Only physically-\n" 00033 "meaningful inputs and output appear at stdout.\n"; 00034 00035 int main(int argc, char *argv[]) { 00036 PetscErrorCode ierr; 00037 00038 MPI_Comm com; 00039 PetscMPIInt rank, size; 00040 00041 ierr = PetscInitialize(&argc, &argv, PETSC_NULL, help); CHKERRQ(ierr); 00042 00043 com = PETSC_COMM_WORLD; 00044 ierr = MPI_Comm_rank(com, &rank); CHKERRQ(ierr); 00045 ierr = MPI_Comm_size(com, &size); CHKERRQ(ierr); 00046 00047 /* This explicit scoping forces destructors to be called before PetscFinalize() */ 00048 { 00049 NCConfigVariable config, overrides; 00050 ierr = init_config(com, rank, config, overrides); CHKERRQ(ierr); 00051 00052 EnthalpyConverter EC(config); 00053 00054 IceFlowLaw *flow_law = NULL; 00055 IceFlowLawFactory ice_factory(com, NULL, config, &EC); 00056 00057 string flow_law_name = ICE_GPBLD; 00058 ice_factory.setType(ICE_GPBLD); // set the default type 00059 00060 ierr = ice_factory.setFromOptions(); CHKERRQ(ierr); 00061 ice_factory.create(&flow_law); 00062 00063 bool dummy; 00064 ierr = PISMOptionsString("-flow_law", "Selects the flow law", 00065 flow_law_name, dummy); CHKERRQ(ierr); 00066 00067 double TpaC[] = {-30.0, -5.0, 0.0, 0.0}, // pressure-adjusted, deg C 00068 depth = 2000.0, 00069 gs = 1.0e-3, // some laws use grain size; fixed 00070 omega0 = 0.005, // some laws use liquid fraction; used w TpaC[3] 00071 sigma[] = {1e4, 5e4, 1e5, 1.5e5}; 00072 00073 double p = EC.getPressureFromDepth(depth), 00074 Tm = EC.getMeltingTemp(p); 00075 00076 printf("flow law: \"%s\"\n", flow_law_name.c_str()); 00077 printf("pressure = %9.3e Pa = (hydrostatic at depth %7.2f m)\n", 00078 p,depth); 00079 printf("flowtable:\n"); 00080 printf(" (dev stress) (abs temp) (liq frac) = (flow)\n"); 00081 00082 for (int i=0; i<4; ++i) { 00083 for (int j=0; j<4; ++j) { 00084 00085 double T = Tm + TpaC[j], 00086 omega = (j == 3) ? omega0 : 0.0; 00087 00088 double E, flowcoeff; 00089 EC.getEnth(T, omega, p, E); 00090 flowcoeff = flow_law->flow(sigma[i], E, p, gs); 00091 00092 printf(" %10.2e %10.3f %9.3f = %10.6e\n", 00093 sigma[i], T, omega, flowcoeff); 00094 00095 } 00096 } 00097 00098 delete flow_law; 00099 } // end explicit scope 00100 00101 ierr = PetscFinalize(); CHKERRQ(ierr); 00102 return 0; 00103 }
1.7.5.1