SNOWPACK  SNOWPACK-3.6.0
ReSolver1d.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 */
25 #ifndef RESOLVER1D_H
26 #define RESOLVER1D_H
27 
28 #include <snowpack/DataClasses.h>
30 #include <meteoio/MeteoIO.h>
31 
32 #include <string.h>
40 class ReSolver1d {
41 
42  public:
43  ReSolver1d(const SnowpackConfig& cfg); // Class constructor
44  void SolveRichardsEquation(SnowStation& Xdata, SurfaceFluxes& Sdata);
45 
46  double surfacefluxrate; // Surfacefluxrate for solving RE. It is either surface of snow, in case of snowpack and solving RE for snow, or surface of soil, when no snowpack and/or solving RE only for soil.
47  double soilsurfacesourceflux; // Soilsurfacesourceflux for solving RE. This is used when we use RE for snow AND there is a snowpack AND the lowest snow element is removed.
48 
49 
50  private:
51  std::string variant;
52 
53  //To prevent string comparisons, we define an enumerated list:
54  enum watertransportmodels{UNDEFINED, BUCKET, NIED, RICHARDSEQUATION};
55  //Soil types
56  enum SoilTypes{ORGANIC, CLAY, CLAYLOAM, LOAM, LOAMYSAND, SAND, SANDYCLAY, SANDYCLAYLOAM, SANDYLOAM, SILT, SILTYCLAY, SILTYCLAYLOAM, SILTLOAM, WFJGRAVELSAND};
57  //Hydraulic conductivity parameterizations
58  enum K_Parameterizations{SHIMIZU, CALONNE};
59  //K_Average types
60  enum K_AverageTypes{ARITHMETICMEAN, GEOMETRICMEAN, HARMONICMEAN, MINIMUMVALUE, UPSTREAM};
61  //Van genuchten model types
62  enum VanGenuchten_ModelTypesSnow{YAMAGUCHI2012, YAMAGUCHI2010, YAMAGUCHI2010_ADAPTED, DAANEN};
63  //Solvers
64  enum SOLVERS{DGESVD, DGTSV, TDMA};
65  //Boundary conditions
66  enum BoundaryConditions{DIRICHLET, NEUMANN, LIMITEDFLUXEVAPORATION, LIMITEDFLUXINFILTRATION, LIMITEDFLUX, WATERTABLE, FREEDRAINAGE, GRAVITATIONALDRAINAGE, SEEPAGEBOUNDARY};
67 
68 
69  watertransportmodels iwatertransportmodel_snow, iwatertransportmodel_soil;
70 
71  std::string watertransportmodel_snow;
72  std::string watertransportmodel_soil;
73  BoundaryConditions BottomBC; //Bottom boundary condition (recommended choice either DIRICHLET with saturation (lower boundary in water table) or FREEDRAINAGE (lower boundary not in water table))
74  K_AverageTypes K_AverageType; //Implemented choices: ARITHMETICMEAN (recommended), HARMONICMEAN, GEOMETRICMEAN, MINIMUMVALUE, UPSTREAM
75 
76  double sn_dt;
77  bool useSoilLayers, water_layer;
78 
79 
80  // Van Genuchten functions
81  double fromTHETAtoH(double theta, double theta_r, double theta_s, double alpha, double m, double n, double Sc, double h_e, double h_d);
82  double fromTHETAtoHforICE(double theta, double theta_r, double theta_s, double alpha, double m, double n, double Sc, double h_e, double h_d, double theta_i);
83  double fromHtoTHETA(double h, double theta_r, double theta_s, double alpha, double m, double n, double Sc, double h_e);
84  double fromHtoTHETAforICE(double h, double theta_r, double theta_s, double alpha, double m, double n, double Sc, double h_e, double theta_i);
85  double AirEntryPressureHead(double MaximumPoreSize, double Temperature);
86  void SetSoil(SoilTypes type, double *theta_r, double *theta_s, double *alpha, double *m, double *n, double *ksat, double *he);
87 
88  // Solvers
89  int TDMASolver (int n, double *a, double *b, double *c, double *v, double *x);
90  int pinv(int m, int n, int lda, double *a);
91 };
92 #endif //End of WaterTransport.h
Definition: SnowpackConfig.h:28
double surfacefluxrate
Definition: ReSolver1d.h:46
Definition: DataClasses.h:589
ReSolver1d(const SnowpackConfig &cfg)
Definition: ReSolver1d.cc:56
This module contains the solver for the 1d Richards Equation for the 1d snowpack model.
Definition: ReSolver1d.h:40
Station data including all information on snowpack layers (elements and nodes) and on canopy This is...
Definition: DataClasses.h:468
double soilsurfacesourceflux
Definition: ReSolver1d.h:47
void SolveRichardsEquation(SnowStation &Xdata, SurfaceFluxes &Sdata)
Solve Richards Equation Solve Richards Equation .
Definition: ReSolver1d.cc:593