PISM, A Parallel Ice Sheet Model stable 0.4.1779

src/coupler/localMassBalance.hh

Go to the documentation of this file.
00001 // Copyright (C) 2009, 2010, 2011 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 #ifndef __localMassBalance_hh
00020 #define __localMassBalance_hh
00021 
00022 #include <petsc.h>
00023 #include <gsl/gsl_rng.h>
00024 #include "NCVariable.hh"
00025 #include "iceModelVec.hh"  // only needed for FaustoGrevePDDObject
00026 
00027 
00029 
00032 struct DegreeDayFactors {
00033   PetscScalar  snow, 
00034                ice,  
00035                refreezeFrac;  
00036 };
00037 
00038 
00041 
00065 class LocalMassBalance {
00066 public:
00067   LocalMassBalance(const NCConfigVariable &myconfig)
00068     : config(myconfig) {}
00069   virtual ~LocalMassBalance() {}
00070   virtual PetscErrorCode init() { return 0; };
00071 
00075   virtual PetscErrorCode getNForTemperatureSeries(
00076                 PetscScalar t, PetscScalar dt, PetscInt &N) = 0;
00077 
00079 
00081   virtual PetscScalar getPDDSumFromTemperatureTimeSeries(
00082                  PetscScalar pddStdDev, PetscScalar pddThresholdTemp,
00083                  PetscScalar t, PetscScalar dt_series, PetscScalar *T, PetscInt N) = 0;
00084 
00088   virtual PetscScalar getSnowFromPrecipAndTemperatureTimeSeries(
00089                  PetscScalar precip_rate,
00090                  PetscScalar t, PetscScalar dt_series, PetscScalar *T, PetscInt N) = 0;
00091 
00097   virtual PetscErrorCode getMassFluxesFromPDDs(const DegreeDayFactors &ddf,
00098                                                PetscScalar dt, PetscScalar pddsum,
00099                                                PetscScalar snow,
00100                                                PetscScalar &accumulation_rate,
00101                                                PetscScalar &melt_rate,
00102                                                PetscScalar &runoff_rate,
00103                                                PetscScalar &smb_rate) = 0;
00104 
00105 protected:
00106   const NCConfigVariable& config;
00107 };
00108 
00109 
00111 
00116 class PDDMassBalance : public LocalMassBalance {
00117 
00118 public:
00119   PDDMassBalance(const NCConfigVariable& myconfig);
00120   virtual ~PDDMassBalance() {}
00121 
00122   virtual PetscErrorCode getNForTemperatureSeries(
00123              PetscScalar t, PetscScalar dt, PetscInt &N);
00124 
00125   virtual PetscScalar getPDDSumFromTemperatureTimeSeries(
00126                  PetscScalar pddStdDev, PetscScalar pddThresholdTemp,
00127                  PetscScalar t, PetscScalar dt_series, PetscScalar *T, PetscInt N);
00128 
00129   virtual PetscScalar getSnowFromPrecipAndTemperatureTimeSeries(
00130                  PetscScalar precip_rate,
00131                  PetscScalar t, PetscScalar dt_series, PetscScalar *T, PetscInt N);
00132 
00133   virtual PetscErrorCode getMassFluxesFromPDDs(const DegreeDayFactors &ddf,
00134                                                PetscScalar dt, PetscScalar pddsum,
00135                                                PetscScalar snow,
00136                                                PetscScalar &accumulation_rate,
00137                                                PetscScalar &melt_rate,
00138                                                PetscScalar &runoff_rate,
00139                                                PetscScalar &smb_rate);
00140 
00141 protected:
00142   PetscScalar CalovGreveIntegrand(PetscScalar sigma, PetscScalar TacC);
00143 
00144   bool precip_as_snow;          
00145   PetscScalar Tmin,             
00146               Tmax;             
00147 };
00148 
00149 
00151 
00162 class PDDrandMassBalance : public PDDMassBalance {
00163 
00164 public:
00165   PDDrandMassBalance(const NCConfigVariable& myconfig, bool repeatable); 
00166   virtual ~PDDrandMassBalance();
00167 
00168   virtual PetscErrorCode getNForTemperatureSeries(
00169                 PetscScalar t, PetscScalar dt, PetscInt &N);
00170 
00171   virtual PetscScalar getPDDSumFromTemperatureTimeSeries(
00172                PetscScalar pddStdDev, PetscScalar pddThresholdTemp,
00173                PetscScalar t, PetscScalar dt_series, PetscScalar *T, PetscInt N);
00174 
00175 protected:
00176   gsl_rng *pddRandGen;
00177 };
00178 
00179 
00194 class FaustoGrevePDDObject {
00195 
00196 public:
00197   FaustoGrevePDDObject(IceGrid &g, const NCConfigVariable &myconfig);
00198   virtual ~FaustoGrevePDDObject() {}
00199 
00200   virtual PetscErrorCode update_temp_mj(IceModelVec2S *surfelev, IceModelVec2S *lat, IceModelVec2S *lon);
00201 
00204   virtual PetscErrorCode setDegreeDayFactors(
00205               PetscInt i, PetscInt j,
00206               PetscScalar /* usurf */, PetscScalar lat, PetscScalar /* lon */,
00207               DegreeDayFactors &ddf);
00208 
00209 protected:
00210   IceGrid &grid;
00211   const NCConfigVariable &config;
00212   PetscScalar beta_ice_w, beta_snow_w, T_c, T_w, beta_ice_c, beta_snow_c,
00213               fresh_water_density, ice_density, pdd_fausto_latitude_beta_w;
00214   IceModelVec2S temp_mj;
00215 };
00216 
00217 
00218 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines