SNOWPACK  SNOWPACK-3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
32 #include <meteoio/MeteoIO.h>
33 #include <vector>
34 #include <string>
35 
37 #define N_OF_INCIDENCES 2
38 
39 class Snowpack {
40 
41  public:
42  Snowpack(const SnowpackConfig& i_cfg);
43 
44  void runSnowpackModel(CurrentMeteo Mdata, SnowStation& Xdata, double& cumu_precip,
45  BoundCond& Bdata, SurfaceFluxes& Sdata);
46 
47  void setUseSoilLayers(const bool& value);
48  const static double new_snow_albedo, min_ice_content;
49 
50  private:
56  enum BoundaryCondition {
57  NEUMANN_BC,
58  DIRICHLET_BC
59  };
60 
61  static void EL_INCID(const size_t &e, int Ie[]);
62  static void EL_TEMP( const int Ie[], double Te0[], double Tei[], const std::vector<NodeData> &T0, const double Ti[] );
63  static void EL_RGT_ASSEM(double F[], const int Ie[], const double Fe[]);
64 
65  void compSnowCreep(const CurrentMeteo& Mdata, SnowStation& Xdata);
66 
67  bool sn_ElementKtMatrix(ElementData &Edata, double dt, const double dvdz, double T0[ N_OF_INCIDENCES ],
68  double Se[ N_OF_INCIDENCES ][ N_OF_INCIDENCES ], double Fe[ N_OF_INCIDENCES ],
69  const double VaporEnhance);
70 
71  void updateBoundHeatFluxes(BoundCond& Bdata, SnowStation& Xdata, const CurrentMeteo& Mdata);
72 
73  void neumannBoundaryConditions(const CurrentMeteo& Mdata, BoundCond& Bdata, const SnowStation& Xdata,
74  const double& T_snow, const double& T_iter,
75  double Se[ N_OF_INCIDENCES ][ N_OF_INCIDENCES ],
76  double Fe[ N_OF_INCIDENCES ]);
77 
78  void neumannBoundaryConditionsSoil(const double& flux, const double& T_snow,
79  double Se[ N_OF_INCIDENCES ][ N_OF_INCIDENCES ],
80  double Fe[ N_OF_INCIDENCES ]);
81 
82  double getParameterizedAlbedo(const SnowStation& Xdata, const CurrentMeteo& Mdata) const;
83  double getModelAlbedo(const SnowStation& Xdata, CurrentMeteo& Mdata) const;
84 
85  bool compTemperatureProfile(const CurrentMeteo& Mdata, SnowStation& Xdata, BoundCond& Bdata, const bool& ThrowAtNoConvergence);
86 
87  void assignSomeFluxes(SnowStation& Xdata, const CurrentMeteo& Mdata, const double& mAlb,
88  SurfaceFluxes& Sdata);
89 
90  void setHydrometeorMicrostructure(const CurrentMeteo& Mdata, const bool& is_surface_hoar, ElementData &EMS);
91 
92  void fillNewSnowElement(const CurrentMeteo& Mdata, const double& length, const double& density,
93  const bool& is_surface_hoar, const unsigned short& number_of_solutes, ElementData &elem);
94 
95  void compSnowFall(const CurrentMeteo& Mdata, SnowStation& Xdata, double& cumu_precip,
96  SurfaceFluxes& Sdata);
97 
98  const SnowpackConfig& cfg;
99  BoundaryCondition surfaceCode;
100  std::string variant, viscosity_model, watertransportmodel_snow, watertransportmodel_soil;
101  std::string hn_density, hn_density_parameterization;
102  std::string sw_mode, snow_albedo, albedo_parameterization, albedo_average_schmucki, sw_absorption_scheme;
103  Meteo::ATM_STABILITY atm_stability_model;
104  bool allow_adaptive_timestepping;
105  double albedo_fixedValue, hn_density_fixedValue;
106  double meteo_step_length;
107  double thresh_change_bc, geo_heat, height_of_meteo_values, height_new_elem, sn_dt;
108  double t_crazy_min, t_crazy_max, thresh_rh, thresh_dtempAirSnow;
109  double new_snow_dd, new_snow_sp, new_snow_dd_wind, new_snow_sp_wind, rh_lowlim, bond_factor_rh;
110  double new_snow_grain_size, new_snow_bond_size;
111  double hoar_density_buried, hoar_density_surf, hoar_min_size_buried;
112  double minimum_l_element;
113  double t_surf;
114  static const double min_snow_albedo;
115  bool research_mode, useCanopyModel, enforce_measured_snow_heights, detect_grass;
116  bool soil_flux, useSoilLayers;
117  bool combine_elements, reduce_n_elements, change_bc, meas_tss;
118  bool vw_dendricity;
119  bool enhanced_wind_slab;
120  bool alpine3d;
121  bool ageAlbedo;
122 
123  const static bool hydrometeor;
124  const static double snowfall_warning;
125  const static unsigned int new_snow_marker;
126  bool adjust_height_of_meteo_values;
127  bool advective_heat;
128  double heat_begin, heat_end;
129  double temp_index_degree_day, temp_index_swr_factor;
130  bool forestfloor_alb;
131 }; //end class Snowpack
132 
133 #endif
Snowpack(const SnowpackConfig &i_cfg)
Definition: Snowpack.cc:86
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:580
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:48
Definition: Snowpack.h:39
#define N_OF_INCIDENCES
The number of element incidences.
Definition: Snowpack.h:37
ATM_STABILITY
Definition: Meteo.h:39
void setUseSoilLayers(const bool &value)
Definition: Snowpack.cc:274
static const double min_ice_content
Min volumetric ice content allowed.
Definition: Snowpack.h:48
Station data including all information on snowpack layers (elements and nodes) and on canopy This is...
Definition: DataClasses.h:463
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:1640
BoundCond is used to set Neumann boundary conditions.
Definition: DataClasses.h:561