Alpine3D 20241222.625fd38
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>
22#include <alpine3d/MPIControl.h>
28
29#include <ctime>
30
31//Optimisation #6 by GS : Function to sort CellList's array by radiation
32inline int CellsRadComparator_Helbig(const void *cell1, const void *cell2)
33{
34 const double c1 = ((CellsList *)cell1)->radiation;
35 const double c2 = ((CellsList *)cell2)->radiation;
36 if (c1 > c2)
37 return -1;
38 if (c1 < c2)
39 return 1;
40 return 0;
41}
42
78{
79
80public:
81 TerrainRadiationHelbig(const mio::Config &i_cfg, const mio::DEMObject &dem_in, const int &i_nbworkers, const std::string &method);
82
83 virtual void getRadiation(mio::Array2D<double> &direct, mio::Array2D<double> &diffuse,
84 mio::Array2D<double> &terrain, const mio::Array2D<double> &direct_unshaded_horizontal,
85 const mio::Array2D<double> &total_ilwr, mio::Array2D<double> &sky_ilwr,
86 mio::Array2D<double> &terrain_ilwr, double solarAzimuth, double solarElevation);
87 virtual void setMeteo(const mio::Array2D<double> &albedo, const mio::Array2D<double> &ta);
88
89private:
90 mio::DEMObject dem;
91 double sw_radius;
92 double lw_radius;
93
94 int dimx, dimy;
95 double cellsize;
96
97 double itEps1_SW;
98 double mean_glob_start; // mean reflectable direct and diffuse sky shortwave radiation
99 int LW_distance_index; //for LW: index of the maximum emitting distance
100 const static int NB_UNROLL = 3; //Define the number of unrolled calculation in loop to LWTerrainRadiationStep
101
102 mio::Array2D<double> meteo2d_ta, albedo_grid;
103 mio::Array2D<double> lw_t, lwi, lw_sky;
104
105 double lw_eps_stern; //stopping criterion
106 double max_glob_start; // maximum of reflectable direct and diffuse sky shortwave radiation
107
108 double itEps_SW;
109 double itEps_LW;
110 double max_alb; // max ground albedo
111
112 mio::Array2D<double> total_diff, tdir, tdiff, sw_t, glob_start, glob_h_isovf, glob_h, t_snowold, total_terrain, tot_ilwr;
113
114 double lw_start_l1;
115
116 ViewFactorsHelbig viewFactorsHelbigObj;
117 ViewFactorsSectors viewSectorFactorsObj;
118 ViewFactorsCluster viewFactorsClusterObj;
119
120 std::vector<CellsList> lwt_byCell;
121
122 void Compute();
123 int SWTerrainRadiationStep(const double threshold_itEps_SW, int &i_max_unshoot, int &j_max_unshoot, unsigned int n, const clock_t t0);
124 int LWTerrainRadiationStep(const double threshold_itEps_LW, const int itMax_LW, int &i_max_unshoot_lw, int &j_max_unshoot_lw, unsigned int n, const clock_t t0);
125 void ComputeTerrainRadiation(const bool &day, int i_max_unshoot, int j_max_unshoot, int i_max_unshoot_lw, int j_max_unshoot_lw);
126 void ComputeRadiationBalance();
127 void InitializeTerrainSwSplitting(const int i, const int j,
128 int &i_max_unshoot, int &j_max_unshoot, double &diffmax_sw);
129 void InitializeTerrainRadiation(const bool &day, int &i_max_unshoot, int &j_max_unshoot, int &i_max_unshoot_lw, int &j_max_unshoot_lw);
130 void fillSWResultsGrids(const bool &day);
131
132 void InitializeLW(const int i, const int j, int &i_max_unshoot_lw, int &j_max_unshoot_lw, double &diffmax_lw);
133 void getSkyViewFactor(mio::Array2D<double> &o_sky_vf);
134
135 static inline void CalculateIndex(const int indice, const int distance_max, int dim, int *min, int *max);
136 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);
137};
138
139#endif
int CellsRadComparator_Helbig(const void *cell1, const void *cell2)
Definition: TerrainRadiationHelbig.h:32
Definition: TerrainRadiationAlgorithm.h:26
Definition: TerrainRadiationAlgorithm.h:37
Radiosity terrain radiation. For each cell of the domain, a view factor to every other visible cell o...
Definition: TerrainRadiationHelbig.h:78
TerrainRadiationHelbig(const mio::Config &i_cfg, const mio::DEMObject &dem_in, const int &i_nbworkers, const std::string &method)
Definition: TerrainRadiationHelbig.cc:29
virtual void getRadiation(mio::Array2D< double > &direct, mio::Array2D< double > &diffuse, mio::Array2D< double > &terrain, const mio::Array2D< double > &direct_unshaded_horizontal, const mio::Array2D< double > &total_ilwr, mio::Array2D< double > &sky_ilwr, mio::Array2D< double > &terrain_ilwr, double solarAzimuth, double solarElevation)
Definition: TerrainRadiationHelbig.cc:68
virtual void setMeteo(const mio::Array2D< double > &albedo, const mio::Array2D< double > &ta)
Definition: TerrainRadiationHelbig.cc:88
Definition: ViewFactorsCluster.h:25
Definition: ViewFactorsHelbig.h:28
Definition: ViewFactorsSectors.h:25