PISM, A Parallel Ice Sheet Model stable 0.4.1779

src/coupler/PISMSurface.hh

Go to the documentation of this file.
00001 // Copyright (C) 2008-2011 Ed Bueler, Constantine Khroulev, Ricarda Winkelmann,
00002 // Gudfinna Adalgeirsdottir and Andy Aschwanden
00003 //
00004 // This file is part of PISM.
00005 //
00006 // PISM is free software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the Free Software
00008 // Foundation; either version 2 of the License, or (at your option) any later
00009 // version.
00010 //
00011 // PISM is distributed in the hope that it will be useful, but WITHOUT ANY
00012 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013 // FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00014 // details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with PISM; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 #ifndef __PISMSurfaceModel_hh
00021 #define __PISMSurfaceModel_hh
00022 
00023 #include "PISMComponent.hh"
00024 #include "iceModelVec.hh"
00025 #include "PISMAtmosphere.hh"
00026 #include "localMassBalance.hh"
00027 
00028 class PISMSurfaceModel : public PISMComponent_TS {
00029 public:
00030   PISMSurfaceModel(IceGrid &g, const NCConfigVariable &conf)
00031     : PISMComponent_TS(g, conf)
00032   { atmosphere = NULL; };
00033 
00034   virtual ~PISMSurfaceModel()
00035   { delete atmosphere; };
00036 
00037   virtual void get_diagnostics(map<string, PISMDiagnostic*> &dict)
00038   { if (atmosphere)  atmosphere->get_diagnostics(dict); }
00039 
00040   virtual PetscErrorCode init(PISMVars &vars);
00041   virtual void attach_atmosphere_model(PISMAtmosphereModel *input);
00042   virtual PetscErrorCode ice_surface_mass_flux(IceModelVec2S &result) = 0;
00043   virtual PetscErrorCode ice_surface_temperature(IceModelVec2S &result) = 0;
00044   virtual PetscErrorCode ice_surface_liquid_water_fraction(IceModelVec2S &result);
00045   virtual PetscErrorCode mass_held_in_surface_layer(IceModelVec2S &result);
00046   virtual PetscErrorCode surface_layer_thickness(IceModelVec2S &result);
00047 
00048   virtual PetscErrorCode define_variables(set<string> vars, const NCTool &nc, nc_type nctype);
00049   virtual PetscErrorCode write_variables(set<string> vars, string filename);
00050 protected:
00051   PISMAtmosphereModel *atmosphere;
00052 };
00053 
00054 
00056 
00061 class PSDummy : public PISMSurfaceModel {
00062 public:
00063   PSDummy(IceGrid &g, const NCConfigVariable &conf)
00064     : PISMSurfaceModel(g, conf)
00065   {};
00066 
00067   virtual void attach_atmosphere_model(PISMAtmosphereModel *input)
00068   { delete input; }
00069 
00070   virtual PetscErrorCode init(PISMVars &) { return 0; };
00071   virtual PetscErrorCode update(PetscReal t_years, PetscReal dt_years)
00072   { t = t_years; dt = dt_years; return 0; } // do nothing
00073   virtual PetscErrorCode ice_surface_mass_flux(IceModelVec2S&)
00074   { return 0; }
00075 
00076   virtual PetscErrorCode ice_surface_temperature(IceModelVec2S &)
00077   { return 0; }
00078   virtual void add_vars_to_output(string /*keyword*/, set<string> &/*result*/) {}
00079   virtual PetscErrorCode define_variables(set<string> /*vars*/, const NCTool &/*nc*/, nc_type /*nctype*/)
00080   { return 0; }
00081   virtual PetscErrorCode write_variables(set<string>, string)
00082   { return 0; }
00083 
00084   // Does not have an atmosphere model.
00085   virtual void get_diagnostics(map<string, PISMDiagnostic*> &/*dict*/) {}
00086 };
00087 
00088 
00090 
00102 class PSSimple : public PISMSurfaceModel {
00103 public:
00104   PSSimple(IceGrid &g, const NCConfigVariable &conf)
00105     : PISMSurfaceModel(g, conf) {};
00106   virtual PetscErrorCode init(PISMVars &vars);
00107   virtual PetscErrorCode update(PetscReal t_years, PetscReal dt_years)
00108   {
00109     t = t_years; dt = dt_years;
00110     if (atmosphere) {
00111       PetscErrorCode ierr = atmosphere->update(t_years, dt_years); CHKERRQ(ierr);
00112     }
00113     return 0;
00114   }
00115   virtual PetscErrorCode ice_surface_mass_flux(IceModelVec2S &result);
00116   virtual PetscErrorCode ice_surface_temperature(IceModelVec2S &result);
00117   virtual void add_vars_to_output(string keyword, set<string> &result);
00118 };
00119 
00120 
00123 
00143 class PSConstant : public PISMSurfaceModel {
00144 public:
00145   PSConstant(IceGrid &g, const NCConfigVariable &conf)
00146     : PISMSurfaceModel(g, conf)
00147   {};
00148 
00149   virtual PetscErrorCode init(PISMVars &vars);
00150   virtual PetscErrorCode update(PetscReal t_years, PetscReal dt_years)
00151   { t = t_years; dt = dt_years; return 0; } // do nothing
00153   virtual void attach_atmosphere_model(PISMAtmosphereModel *input)
00154   { delete input; }
00155 
00156   // Does not have an atmosphere model.
00157   virtual void get_diagnostics(map<string, PISMDiagnostic*> &/*dict*/) {}
00158 
00159   virtual PetscErrorCode ice_surface_mass_flux(IceModelVec2S &result);
00160   virtual PetscErrorCode ice_surface_temperature(IceModelVec2S &result);
00161   virtual PetscErrorCode define_variables(set<string> vars, const NCTool &nc, nc_type nctype);
00162   virtual PetscErrorCode write_variables(set<string> vars, string filename);
00163   virtual void add_vars_to_output(string keyword, set<string> &result);
00164 protected:
00165   string input_file;
00166   IceModelVec2S acab, artm;
00167 };
00168 
00169 
00173 
00190 class PSTemperatureIndex : public PISMSurfaceModel {
00191 public:
00192   PSTemperatureIndex(IceGrid &g, const NCConfigVariable &conf);
00193   virtual ~PSTemperatureIndex();
00194   virtual PetscErrorCode update(PetscReal t_years, PetscReal dt_years);
00195   virtual PetscErrorCode init(PISMVars &vars);
00196   virtual PetscErrorCode max_timestep(PetscReal t_years, PetscReal &dt_years);
00197   virtual PetscErrorCode ice_surface_mass_flux(IceModelVec2S &result);
00198   virtual PetscErrorCode ice_surface_temperature(IceModelVec2S &result);
00199   virtual void add_vars_to_output(string keyword, set<string> &result);
00200   virtual PetscErrorCode define_variables(set<string> vars, const NCTool &nc, nc_type nctype);  
00201   virtual PetscErrorCode write_variables(set<string> vars, string filename);
00202 protected:
00203   virtual PetscErrorCode update_internal(PetscReal t_years, PetscReal dt_years);
00204   LocalMassBalance *mbscheme;         
00205 
00206   FaustoGrevePDDObject *faustogreve;  
00207 
00208   DegreeDayFactors base_ddf;          
00209   PetscScalar  base_pddStdDev,        
00210                base_pddThresholdTemp; 
00211   IceModelVec2S
00212     acab,               
00213     accumulation_rate,  
00214     melt_rate,          
00215 
00216     runoff_rate;        
00217 
00218   IceModelVec2S *lat, *lon, *usurf;  
00219 
00220 
00221 
00222   bool pdd_annualize;
00223   PetscReal next_pdd_update_year;
00224 };
00225 
00228 
00237 class PSModifier : public Modifier<PISMSurfaceModel>
00238 {
00239 public:
00240   PSModifier(IceGrid &g, const NCConfigVariable &conf, PISMSurfaceModel* in)
00241     : Modifier<PISMSurfaceModel>(g, conf, in) {}
00242   virtual ~PSModifier() {}
00243 
00244   virtual void attach_atmosphere_model(PISMAtmosphereModel *in) {
00245     input_model->attach_atmosphere_model(in);
00246   }
00247 
00248   virtual PetscErrorCode ice_surface_mass_flux(IceModelVec2S &result)
00249   {
00250     PetscErrorCode ierr = input_model->ice_surface_mass_flux(result); CHKERRQ(ierr);
00251     return 0;
00252   }
00253 
00254   virtual PetscErrorCode ice_surface_temperature(IceModelVec2S &result)
00255   {
00256     PetscErrorCode ierr = input_model->ice_surface_temperature(result); CHKERRQ(ierr);
00257     return 0;
00258   }
00259 
00260   virtual PetscErrorCode ice_surface_liquid_water_fraction(IceModelVec2S &result)
00261   {
00262     PetscErrorCode ierr = input_model->ice_surface_liquid_water_fraction(result); CHKERRQ(ierr);
00263     return 0;
00264   }
00265 
00266   virtual PetscErrorCode mass_held_in_surface_layer(IceModelVec2S &result)
00267   {
00268     PetscErrorCode ierr = input_model->mass_held_in_surface_layer(result); CHKERRQ(ierr);
00269     return 0;
00270   }
00271 
00272   virtual PetscErrorCode surface_layer_thickness(IceModelVec2S &result)
00273   {
00274     PetscErrorCode ierr = input_model->surface_layer_thickness(result); CHKERRQ(ierr);
00275     return 0;
00276   }
00277 };
00278 
00281 class PSForceThickness : public PSModifier {
00282 public:
00283   PSForceThickness(IceGrid &g, const NCConfigVariable &conf, PISMSurfaceModel *input)
00284     : PSModifier(g, conf, input)
00285   {
00286     ice_thickness = NULL;
00287     alpha = config.get("force_to_thickness_alpha");
00288   }
00289 
00290   virtual ~PSForceThickness() {}
00291   PetscErrorCode init(PISMVars &vars);
00292   virtual void attach_atmosphere_model(PISMAtmosphereModel *input);
00293   virtual PetscErrorCode ice_surface_mass_flux(IceModelVec2S &result);
00294   virtual PetscErrorCode ice_surface_temperature(IceModelVec2S &result);
00295   virtual PetscErrorCode max_timestep(PetscReal t_years, PetscReal &dt_years);
00296   virtual void add_vars_to_output(string keyword, set<string> &result);
00297   virtual PetscErrorCode define_variables(set<string> vars, const NCTool &nc, nc_type nctype);
00298   virtual PetscErrorCode write_variables(set<string> vars, string filename);
00299 protected:
00300   string input_file;
00301   PetscReal alpha;
00302   IceModelVec2S *ice_thickness; 
00303   IceModelVec2S target_thickness, ftt_mask, ftt_modified_acab;
00304 };
00305 
00309 
00310 class PSConstantPIK : public PISMSurfaceModel {
00311 public:
00312   PSConstantPIK(IceGrid &g, const NCConfigVariable &conf)
00313     : PISMSurfaceModel(g, conf)
00314   {};
00315 
00316   virtual PetscErrorCode init(PISMVars &vars);
00318   virtual void attach_atmosphere_model(PISMAtmosphereModel *input)
00319   { delete input; }
00320 
00321   // Does not have an atmosphere model.
00322   virtual void get_diagnostics(map<string, PISMDiagnostic*> &/*dict*/) {}
00323 
00324   virtual PetscErrorCode update(PetscReal t_years, PetscReal dt_years)
00325   { t = t_years; dt = dt_years; return 0; } // do nothing
00326   virtual PetscErrorCode ice_surface_mass_flux(IceModelVec2S &result);
00327   virtual PetscErrorCode ice_surface_temperature(IceModelVec2S &result);
00328   virtual PetscErrorCode define_variables(set<string> vars, const NCTool &nc, nc_type nctype);
00329   virtual PetscErrorCode write_variables(set<string> vars, string filename);
00330   virtual void add_vars_to_output(string keyword, set<string> &result);
00331 protected:
00332   string input_file;
00333   IceModelVec2S acab, artm;
00334   IceModelVec2S *lat, *usurf;
00335 
00336 };
00337 
00338 
00339 #endif  // __PISMSurfaceModel_hh
00340 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines