PISM, A Parallel Ice Sheet Model stable 0.4.1779

src/base/basal_strength/PISMConstantYieldStress.cc

Go to the documentation of this file.
00001 // Copyright (C) 2011 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 "PISMYieldStress.hh"
00020 
00021 PetscErrorCode PISMConstantYieldStress::init(PISMVars &/*vars*/) {
00022   PetscErrorCode ierr;
00023   bool i_set, bootstrap, tauc_set;
00024   PetscReal constant_tauc;
00025   string filename;
00026   int start;
00027 
00028   ierr = verbPrintf(2, grid.com, "* Initializing the constant basal yield stress model...\n"); CHKERRQ(ierr);
00029 
00030   ierr = PetscOptionsBegin(grid.com, "", "PISMConstantYieldStress options", ""); CHKERRQ(ierr);
00031   {
00032     ierr = PISMOptionsIsSet("-i", "PISM input file", i_set); CHKERRQ(ierr);
00033     ierr = PISMOptionsIsSet("-boot_file", "PISM bootstrapping file",
00034                             bootstrap); CHKERRQ(ierr);
00035     ierr = PISMOptionsReal("-tauc", "set basal yield stress to a constant (units of Pa)",
00036                            constant_tauc, tauc_set); CHKERRQ(ierr);
00037   }
00038   ierr = PetscOptionsEnd(); CHKERRQ(ierr);
00039 
00040   // if -tauc was set we just use that value
00041   if (tauc_set) {
00042     ierr = tauc.set(constant_tauc); CHKERRQ(ierr);
00043   } else if (i_set || bootstrap) {
00044     ierr = find_pism_input(filename, bootstrap, start); CHKERRQ(ierr);
00045 
00046     if (i_set) {
00047       ierr = tauc.read(filename, start); CHKERRQ(ierr);
00048     } else {
00049       ierr = tauc.regrid(filename, config.get("default_tauc")); CHKERRQ(ierr);
00050     }
00051   } else {
00052     ierr = tauc.set(config.get("default_tauc")); CHKERRQ(ierr);
00053   }
00054 
00055   ierr = regrid(); CHKERRQ(ierr);
00056 
00057   return 0;
00058 }
00059 
00060 
00061 void PISMConstantYieldStress::add_vars_to_output(string /*keyword*/, set<string> &result) {
00062   result.insert("tauc");
00063 }
00064 
00065 
00066 PetscErrorCode PISMConstantYieldStress::define_variables(set<string> vars, const NCTool &nc,
00067                                                          nc_type nctype) {
00068   if (set_contains(vars, "tauc")) {
00069     PetscErrorCode ierr = tauc.define(nc, nctype); CHKERRQ(ierr);
00070   }
00071   return 0;
00072 }
00073 
00074 
00075 PetscErrorCode PISMConstantYieldStress::write_variables(set<string> vars, string filename) {
00076   if (set_contains(vars, "tauc")) {
00077     PetscErrorCode ierr = tauc.write(filename); CHKERRQ(ierr);
00078   }
00079   return 0;
00080 }
00081 
00082 
00083 PetscErrorCode PISMConstantYieldStress::update(PetscReal t_years, PetscReal dt_years) {
00084   t = t_years; dt = dt_years;
00085   return 0;
00086 }
00087 
00088 
00089 PetscErrorCode PISMConstantYieldStress::basal_material_yield_stress(IceModelVec2S &result) {
00090   PetscErrorCode ierr = tauc.copy_to(result); CHKERRQ(ierr);
00091   return 0;
00092 }
00093 
00094 PetscErrorCode PISMConstantYieldStress::allocate() {
00095   PetscErrorCode ierr;
00096 
00097   ierr = tauc.create(grid, "tauc", true, grid.max_stencil_width); CHKERRQ(ierr);
00098   // PROPOSED standard_name = land_ice_basal_material_yield_stress
00099   ierr = tauc.set_attrs("model_state", 
00100                         "yield stress for basal till (plastic or pseudo-plastic model)",
00101                         "Pa", ""); CHKERRQ(ierr);
00102   return 0;
00103 }
00104 
00105 PetscErrorCode PISMConstantYieldStress::regrid() {
00106   PetscErrorCode ierr;
00107   bool regrid_file_set, regrid_vars_set;
00108   string regrid_file;
00109   vector<string> regrid_vars;
00110 
00111   ierr = PetscOptionsBegin(grid.com, "", "PISMDefaultYieldStress regridding options", ""); CHKERRQ(ierr);
00112   {
00113     ierr = PISMOptionsString("-regrid_file", "regridding file name",
00114                              regrid_file, regrid_file_set); CHKERRQ(ierr);
00115     ierr = PISMOptionsStringArray("-regrid_vars", "comma-separated list of regridding variables",
00116                                   "", regrid_vars, regrid_vars_set); CHKERRQ(ierr);
00117   }
00118   ierr = PetscOptionsEnd(); CHKERRQ(ierr);
00119 
00120   if (! regrid_file_set) return 0;
00121 
00122   set<string> vars;
00123   for (unsigned int i = 0; i < regrid_vars.size(); ++i)
00124     vars.insert(regrid_vars[i]);
00125 
00126   // stop if the user did not ask to regrid tillphi
00127   if (!set_contains(vars, tauc.string_attr("short_name")))
00128     return 0;
00129 
00130   ierr = tauc.regrid(regrid_file, true); CHKERRQ(ierr);
00131 
00132   return 0;
00133 }
00134 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines