Alpine3D  Alpine3D-3.2.0
TerrainRadiation.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 TERRAINRADIATION_H
19 #define TERRAINRADIATION_H
20 
21 
22 #include <meteoio/MeteoIO.h>
23 #include <alpine3d/MPIControl.h>
29 
30 #include <ctime>
31 
48  public:
49  TerrainRadiation(const mio::Config& i_cfg, const mio::DEMObject &dem_in, const int& i_nbworkers, const std::string& method);
50 
51  void getRadiation(const mio::Array2D<double>& direct, mio::Array2D<double>& diffuse, mio::Array2D<double>& terrain);
52  void setMeteo(const mio::Array2D<double>& albedo, const mio::Array2D<double>& ta,
53  const mio::Array2D<double>& rh, const mio::Array2D<double>& ilwr);
54 
55  private:
56  void Compute();
57  int SWTerrainRadiationStep(const double threshold_itEps_SW, size_t& c, size_t& d,
58  mio::Array2D<double>& sw_Q_out, double& Rmy);
59  int LWTerrainRadiationStep(const double threshold_itEps_LW, const int itMax_LW, const int i_shoot,
60  const int j_shoot, unsigned int n);
61  int ComputeTerrainRadiation(const double& threshold_itEps_SW, const bool& day, size_t& c, size_t& d,
62  mio::Array2D<double>& sw_Q_out, double& Rmy);
63  void ComputeProgressiveRefinement();
64  void InitializeTerrainSwSplitting(size_t& i_max_unshoot, size_t& j_max_unshoot, mio::Array2D<double>& sw_Q_out);
65  void InitializeTerrainRadiation(const bool& day);
66  void fillSWResultsGrids(const bool& day);
67  void InitializeLW (const int i, const int j, double &lw_eps_stern);
68 
69 
70  static inline void CalculateIndex(const int indice, const int distance_max, int dim, int * min, int * max);
71  static inline void LWTerrainRadiationCore(const double bx2, const int j_shoot, const double z_shoot, const int j,
72  const double z, const double cellsize, const double t_snow_shoot,
73  const double t_snow_shoot_value, const double t_a, const double vf,
74  double * lwi, int * s);
75 
76  ViewFactors viewFactorsObj;
77  mio::DEMObject dem;
78  size_t dimx, dimy;
79  double cellsize;
80 
81  mio::Array2D<double> albedo_grid, meteo2d_ilwr, meteo2d_ta, meteo2d_rh;
82  mio::Array2D<double> total_diff, sw_t, glob_start, glob_h_isovf, glob_h, t_snowold;
83  mio::Array2D<double> lw_t,lwi, lw_sky;
84  std::vector<CellsList> lwt_byCell;
85 
86  mio::Array2D<double> tdir, tdiff;
87  mio::Array2D<double> Mmy;
88  mio::Array2D<double> Mt;
89 
90  double itEps1_SW;
91  double mean_glob_start; // mean reflectable direct and diffuse sky shortwave radiation
92  double lw_eps_stern; //stopping criterion
93  double max_glob_start; // maximum of reflectable direct and diffuse sky shortwave radiation
94  double itEps_SW;
95  double itEps_LW;
96  double max_alb; // max ground albedo
97  double lw_start_l1;
98  double sw_radius;
99 
100  double threshold_itEps_SW;
101 
102  size_t startx, nx;
103  size_t starty, ny;
104 
105  int LW_distance_index; //for LW: index of the maximum emitting distance
106 
107  const static int NB_UNROLL = 3; //Define the number of unrolled calculation in loop to LWTerrainRadiationStep
108 };
109 
110 #endif
Definition: TerrainRadiationAlgorithm.h:35
void getRadiation(const mio::Array2D< double > &direct, mio::Array2D< double > &diffuse, mio::Array2D< double > &terrain)
Definition: TerrainRadiation.cc:84
Full computation of the terrain reflected radiation by ray-tracing. Ray tracing is used between all c...
Definition: TerrainRadiation.h:47
Definition: ViewFactors.h:25
TerrainRadiation(const mio::Config &i_cfg, const mio::DEMObject &dem_in, const int &i_nbworkers, const std::string &method)
Definition: TerrainRadiation.cc:25
void setMeteo(const mio::Array2D< double > &albedo, const mio::Array2D< double > &ta, const mio::Array2D< double > &rh, const mio::Array2D< double > &ilwr)
Definition: TerrainRadiation.cc:97