Alpine3D  Alpine3D-3.2.0
TerrainRadiationHelbig.h
Go to the documentation of this file.
1 /***********************************************************************************/
2 /* Copyright 2009-2015 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3 /***********************************************************************************/
4 /* This file is part of Alpine3D.
5  Alpine3D is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  Alpine3D is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with Alpine3D. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef TERRAINRADIATIONHELBIG_H
19 #define TERRAINRADIATIONHELBIG_H
20 
21 #include <meteoio/MeteoIO.h>
27 
28 #include <ctime>
29 
30 //Optimisation #6 by GS : Function to sort CellList's array by radiation
31 inline int CellsRadComparator_Helbig(const void * cell1, const void * cell2)
32 {
33  const double c1 = ((CellsList *)cell1)->radiation;
34  const double c2 = ((CellsList *)cell2)->radiation;
35  if (c1 > c2) return -1;
36  if (c1 < c2) return 1;
37  return 0;
38 }
39 
75 
76  public:
77  TerrainRadiationHelbig(const mio::Config& i_cfg, const mio::DEMObject& dem_in, const int& i_nbworkers, const std::string& method);
78 
79  void getRadiation(const mio::Array2D<double>& direct, mio::Array2D<double>& diffuse, mio::Array2D<double>& terrain);
80  void setMeteo(const mio::Array2D<double>& albedo, const mio::Array2D<double>& ta,
81  const mio::Array2D<double>& rh, const mio::Array2D<double>& ilwr);
82 
83  private:
84  mio::DEMObject dem;
85  //double iswr_ref;
86  //double ea_ref;
87  double sw_radius;
88 
89  int dimx, dimy;
90  double cellsize;
91 
92  double itEps1_SW;
93  double mean_glob_start; // mean reflectable direct and diffuse sky shortwave radiation
94  int LW_distance_index; //for LW: index of the maximum emitting distance
95  const static int NB_UNROLL = 3; //Define the number of unrolled calculation in loop to LWTerrainRadiationStep
96 
97  mio::Array2D<double> meteo2d_ta, meteo2d_rh;
98  mio::Array2D<double> lw_t,lwi, lw_sky;
99 
100  double lw_eps_stern; //stopping criterion
101  double max_glob_start; // maximum of reflectable direct and diffuse sky shortwave radiation
102 
103  double itEps_SW;
104  double itEps_LW;
105  double max_alb; // max ground albedo
106 
107  mio::Array2D<double> total_diff, tdir, tdiff, sw_t, glob_start, glob_h_isovf, glob_h, t_snowold;
108  //SnowpackInterface *snowpack;
109 
110  double lw_start_l1;
111 
112  //VFSymetricMatrix<float, double> vf; // view factor matrix with dynamic dimension
113 
114  ViewFactorsHelbig viewFactorsHelbigObj;
115  ViewFactorsSectors viewSectorFactorsObj;
116  ViewFactorsCluster viewFactorsClusterObj;
117  //mio::Array2D<double> tdir;
118  //mio::Array2D<double> tdiff;
119 
120  mio::Array2D<double> albedo_grid, meteo2d_ilwr;
121 
122  std::vector<CellsList> lwt_byCell;
123 
124  void Compute();
125  int SWTerrainRadiationStep(const double threshold_itEps_SW, int *c, int *d, unsigned int n, const clock_t t0);
126  int LWTerrainRadiationStep(const double threshold_itEps_LW, const int itMax_LW, const int i_shoot, const int j_shoot, unsigned int n, const clock_t t0);
127  int ComputeTerrainRadiation(const bool& day, int c, int d);
128  void ComputeRadiationBalance();
129  void InitializeTerrainSwSplitting(const int& i, const int& j,
130  int *i_max_unshoot, int *j_max_unshoot, double *diffmax_sw);
131  void InitializeTerrainRadiation(const bool& day, int *c, int *d);
132  void fillSWResultsGrids(const bool& day);
133 
134  void InitializeLW (const int i, const int j);
135 
136  static inline void CalculateIndex(const int indice, const int distance_max, int dim, int * min, int * max);
137  static inline void LWTerrainRadiationCore(const double bx2, const int j_shoot, const double z_shoot, const int j, const double z, const double cellsize, const double t_snow_shoot,const double t_snow_shoot_value ,const double t_a, const double vf, double * lwi, int * s);
138 
139 };
140 
141 #endif
Definition: TerrainRadiationAlgorithm.h:35
Definition: ViewFactorsSectors.h:25
Radiosity terrain radiation. For each cell of the domain, a view factor to every other visible cell o...
Definition: TerrainRadiationHelbig.h:74
Definition: ViewFactorsCluster.h:25
void getRadiation(const mio::Array2D< double > &direct, mio::Array2D< double > &diffuse, mio::Array2D< double > &terrain)
Definition: TerrainRadiationHelbig.cc:56
TerrainRadiationHelbig(const mio::Config &i_cfg, const mio::DEMObject &dem_in, const int &i_nbworkers, const std::string &method)
Definition: TerrainRadiationHelbig.cc:29
void setMeteo(const mio::Array2D< double > &albedo, const mio::Array2D< double > &ta, const mio::Array2D< double > &rh, const mio::Array2D< double > &ilwr)
Definition: TerrainRadiationHelbig.cc:65
Definition: ViewFactorsHelbig.h:27
int CellsRadComparator_Helbig(const void *cell1, const void *cell2)
Definition: TerrainRadiationHelbig.h:31
Definition: TerrainRadiationAlgorithm.h:24