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