SNOWPACK  SNOWPACK-3.6.0
Snowpack.h
Go to the documentation of this file.
1 /*
2  * SNOWPACK stand-alone
3  *
4  * Copyright WSL Institute for Snow and Avalanche Research SLF, DAVOS, SWITZERLAND
5 */
6 /* This file is part of Snowpack.
7  Snowpack is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  Snowpack is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Snowpack. If not, see <http://www.gnu.org/licenses/>.
19 */
26 #ifndef SNOWPACK_H
27 #define SNOWPACK_H
28 
29 #include <snowpack/Meteo.h>
30 #include <snowpack/DataClasses.h>
31 #include <snowpack/SnowDrift.h>
32 #include <snowpack/TechnicalSnow.h>
35 
36 #include <meteoio/MeteoIO.h>
37 #include <vector>
38 #include <string>
39 
41 #define N_OF_INCIDENCES 2
42 
43 class Snowpack {
44 
45  public:
46  Snowpack(const SnowpackConfig& i_cfg);
47 
48  void runSnowpackModel(CurrentMeteo Mdata, SnowStation& Xdata, double& cumu_precip,
49  BoundCond& Bdata, SurfaceFluxes& Sdata);
50 
56  void snowPreparation(const mio::Date& currentDate, SnowStation& Xdata) const;
57 
58  void setUseSoilLayers(const bool& value);
59  const static double new_snow_albedo, min_ice_content;
60 
61  private:
67  enum BoundaryCondition {
68  NEUMANN_BC,
69  DIRICHLET_BC
70  };
71 
72  static void EL_INCID(const size_t &e, int Ie[]);
73  static void EL_TEMP( const int Ie[], double Te0[], double Tei[], const std::vector<NodeData> &T0, const double Ti[] );
74  static void EL_RGT_ASSEM(double F[], const int Ie[], const double Fe[]);
75 
76  void compSnowCreep(const CurrentMeteo& Mdata, SnowStation& Xdata);
77 
78  bool sn_ElementKtMatrix(ElementData &Edata, double dt, const double dvdz, double T0[ N_OF_INCIDENCES ],
79  double Se[ N_OF_INCIDENCES ][ N_OF_INCIDENCES ], double Fe[ N_OF_INCIDENCES ],
80  const double VaporEnhance);
81 
82  void updateBoundHeatFluxes(BoundCond& Bdata, SnowStation& Xdata, const CurrentMeteo& Mdata);
83 
84  void neumannBoundaryConditions(const CurrentMeteo& Mdata, BoundCond& Bdata, const SnowStation& Xdata,
85  const double& T_snow, const double& T_iter,
86  double Se[ N_OF_INCIDENCES ][ N_OF_INCIDENCES ],
87  double Fe[ N_OF_INCIDENCES ]);
88 
89  void neumannBoundaryConditionsSoil(const double& flux, const double& T_snow,
90  double Se[ N_OF_INCIDENCES ][ N_OF_INCIDENCES ],
91  double Fe[ N_OF_INCIDENCES ]);
92 
93  double getParameterizedAlbedo(const SnowStation& Xdata, const CurrentMeteo& Mdata) const;
94  double getModelAlbedo(const SnowStation& Xdata, CurrentMeteo& Mdata) const;
95 
96  bool compTemperatureProfile(const CurrentMeteo& Mdata, SnowStation& Xdata, BoundCond& Bdata, const bool& ThrowAtNoConvergence);
97 
98  void assignSomeFluxes(SnowStation& Xdata, const CurrentMeteo& Mdata, const double& mAlb,
99  SurfaceFluxes& Sdata);
100 
101  void setHydrometeorMicrostructure(const CurrentMeteo& Mdata, const bool& is_surface_hoar, ElementData &EMS);
102 
103  void fillNewSnowElement(const CurrentMeteo& Mdata, const double& length, const double& density,
104  const bool& is_surface_hoar, const unsigned short& number_of_solutes, ElementData &elem);
105 
106  void compTechnicalSnow(const CurrentMeteo& Mdata, SnowStation& Xdata, double& cumu_precip);
107 
108  void compSnowFall(const CurrentMeteo& Mdata, SnowStation& Xdata, double& cumu_precip,
109  SurfaceFluxes& Sdata);
110 
111  const SnowpackConfig& cfg;
112  const Metamorphism metamorphism;
113  PhaseChange phasechange;
114  const SnowDrift snowdrift;
115  BoundaryCondition surfaceCode;
116  TechSnow techsnow;
117  std::string variant, viscosity_model, watertransportmodel_snow, watertransportmodel_soil;
118  std::string hn_density, hn_density_parameterization;
119  std::string sw_mode, snow_albedo, albedo_parameterization, albedo_average_schmucki, sw_absorption_scheme;
120  Meteo::ATM_STABILITY atm_stability_model;
121  bool allow_adaptive_timestepping;
122  double albedo_fixedValue, hn_density_fixedValue;
123  double meteo_step_length;
124  double thresh_change_bc, geo_heat, height_of_meteo_values, height_new_elem, sn_dt;
125  double t_crazy_min, t_crazy_max, thresh_rh, thresh_dtempAirSnow;
126  double new_snow_dd, new_snow_sp, new_snow_dd_wind, new_snow_sp_wind, rh_lowlim, bond_factor_rh;
127  double new_snow_grain_size, new_snow_bond_size;
128  double hoar_density_buried, hoar_density_surf, hoar_min_size_buried;
129  double minimum_l_element;
130  double t_surf;
131  static const double min_snow_albedo;
132  bool research_mode, useCanopyModel, enforce_measured_snow_heights, detect_grass;
133  bool soil_flux, useSoilLayers;
134  bool combine_elements, reduce_n_elements, change_bc, meas_tss;
135  bool vw_dendricity;
136  bool enhanced_wind_slab;
137  bool alpine3d;
138  bool ageAlbedo;
139 
140  static const bool hydrometeor;
141  static const double snowfall_warning;
142  static const unsigned int new_snow_marker;
143  bool adjust_height_of_meteo_values;
144  bool advective_heat;
145  double heat_begin, heat_end;
146  double temp_index_degree_day, temp_index_swr_factor;
147  bool forestfloor_alb;
148  std::string soil_evaporation,soil_thermal_conductivity;
149 }; //end class Snowpack
150 
151 #endif
Snowpack(const SnowpackConfig &i_cfg)
Definition: Snowpack.cc:84
Definition: SnowpackConfig.h:28
ELEMENT DATA used as a pointer in the SnowStation structure NOTE on M below: this is the mass of an e...
Definition: DataClasses.h:251
Definition: DataClasses.h:589
This class contains the computation of local snow drift and the associated erosion.
Definition: SnowDrift.h:37
This class contains the phase change routines for the 1d snowpack model It also updates the volumetri...
Definition: PhaseChange.h:33
CurrentMeteo is the class of interpolated meteo data for the current calculation time step It contai...
Definition: DataClasses.h:81
static const double new_snow_albedo
Definition: Snowpack.h:59
Definition: Snowpack.h:43
#define N_OF_INCIDENCES
The number of element incidences.
Definition: Snowpack.h:41
Definition: Metamorphism.h:40
ATM_STABILITY
Definition: Meteo.h:39
Implementation of snow grooming.
Definition: TechnicalSnow.h:42
void setUseSoilLayers(const bool &value)
Definition: Snowpack.cc:284
static const double min_ice_content
Min volumetric ice content allowed.
Definition: Snowpack.h:59
void snowPreparation(const mio::Date &currentDate, SnowStation &Xdata) const
Perform snow preparation (grooming, etc) on a given snowpack.
Definition: Snowpack.cc:1940
Station data including all information on snowpack layers (elements and nodes) and on canopy This is...
Definition: DataClasses.h:468
void runSnowpackModel(CurrentMeteo Mdata, SnowStation &Xdata, double &cumu_precip, BoundCond &Bdata, SurfaceFluxes &Sdata)
The near future (s. below) has arrived on Wednesday Feb. 6, when it was finally snowing in Davos and ...
Definition: Snowpack.cc:1761
BoundCond is used to set Neumann boundary conditions.
Definition: DataClasses.h:569