Alpine3D 20241222.625fd38
TerrainRadiationComplex.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 TERRAINRadiationComplex_H
19#define TERRAINRadiationComplex_H
20
21#include <meteoio/MeteoIO.h>
22
27#include <array>
28
68{
69
70public:
71 TerrainRadiationComplex(const mio::Config &cfg, const mio::DEMObject &dem_in, const std::string &method);
73
74 virtual void getRadiation(mio::Array2D<double>& direct, mio::Array2D<double>& diffuse,
75 mio::Array2D<double>& terrain, const mio::Array2D<double>& direct_unshaded_horizontal,
76 const mio::Array2D<double>& total_ilwr, mio::Array2D<double>& sky_ilwr,
77 mio::Array2D<double>& terrain_ilwr, double solarAzimuth, double solarElevation);
78 virtual void setMeteo(const mio::Array2D<double>& albedo, const mio::Array2D<double>& ta);
79
80 void getSkyViewFactor(mio::Array2D<double> &o_sky_vf);
81 void setSP(const mio::Date timestamp, const double solarAzimuth, const double solarElevation);
82 void writeSP(const unsigned int max_steps);
83
84private:
85 typedef std::array<double, 3> Vec3D;
86
87 // Initialisation Functions
88 void initBasicSetHorizontal();
89 void initBasicSetRotated();
90 void initViewList();
91 void initRList();
92 void initSortList();
93 void WriteViewList();
94 bool ReadViewList();
95
96 // auxiliary functions
97 void TriangleNormal(size_t ii_dem, size_t jj_dem, int which_triangle, Vec3D &v_out);
98 double IntersectionRayTriangle(const Vec3D &v_view, size_t ii_0, size_t jj_0, size_t ii_dem, size_t jj_dem, size_t which_triangle);
99 size_t vectorToSPixel(const Vec3D &vec_in, size_t ii_dem, size_t jj_dem, size_t which_triangle);
100 void initSkyViewFactor();
101 double computeSkyViewFactor(size_t ii_dem, size_t jj_dem, size_t which_triangle);
102 double getLandViewFactor(size_t ii_dem, size_t jj_dem, size_t which_triangle);
103 double getSkyViewFactor(size_t ii_dem, size_t jj_dem, size_t which_triangle);
104 void getVectorSun(double solarAzimuth, double solarElevation, Vec3D &v_out);
105 double TerrainBiggestDifference(const mio::Array3D<double> &terrain_old, const mio::Array3D<double> &terrain_new);
106
107 // Standard Vector operations
108 double NormOfVector(const Vec3D &vec1);
109 void normalizeVector(const Vec3D &vec1, Vec3D &v_out);
110 double VectorScalarProduct(const Vec3D &vec1, const Vec3D &vec2);
111 void VectorCrossProduct(const Vec3D &vec1, const Vec3D &vec2, Vec3D &v_out);
112 void VectorSum(const Vec3D &vec1, const Vec3D &vec2, Vec3D &v_out);
113 void VectorDifference(const Vec3D &vec1, const Vec3D &vec2, Vec3D &v_out);
114 void VectorStretch(const Vec3D &vec1, double factor, Vec3D &v_out);
115 void RotN(const Vec3D &axis, const Vec3D &vec_in, double rad, Vec3D &v_out);
116 void ProjectVectorToPlane(const Vec3D &vec1, const Vec3D &plane_normal, Vec3D &v_out);
117 double AngleBetween2Vectors(const Vec3D &vec1, const Vec3D &vec2);
118
119 // PVP functions
120 void readSP();
121
122 //
123 void resizeArrays();
124
125
126 // Output functions
127 void PrintProgress(double percentage);
128
129 // Variables
130 const size_t dimx, dimy;
131 size_t dimx_process;
132 size_t startx, endx;
133 mio::DEMObject dem;
134 const mio::Config &cfg;
135
136 SnowBRDF BRDFobject;
137 SolarPanel SP;
138 std::vector<std::vector<double> > pv_points;
139
140 mio::Array3D<std::vector<double>> SortList; // Used for speedup in Terrain Iterations
141 std::vector<Vec3D> BasicSet_Horizontal; // Horizontal Basic Set [MT 2.1.1 Basic Set]
142 mio::Array4D<Vec3D> BasicSet_rotated; // Basic Set rotated in Triangular Pixel Plane [MT 2.1.3 View List, eq. 2.38]
143 mio::Array4D<std::vector<double>> ViewList; // Stores all information of network between pixels [MT 2.1.3 View List, eq. 2.47]
144 mio::Array2D<double> RList; // List pre-storage of BRDF values
145 mio::Array2D<double> albedo_grid; // Albedo value for each square Pixel
146
147 mio::Array2D<double> sky_vf_mean; // Grid to store view factor
148 std::vector<mio::Array2D<double>> sky_vf; // Array to stor grid of view factor for both values of which_triangle
149 unsigned int M_epsilon; // Number of small circles in Basic Set [MT fig. 2.1]
150 unsigned int M_phi; // Number of vectors per small circle of Basic Set [MT fig. 2.1]
151 unsigned int S; // Number of vectors per Basic Set [MT fig. 2.1]
152 double delta_F_max; // Stopping Treshold for Iteration in W/m2 [MT eq. 2.100]
153
154 // Keys from io-file
155 bool if_anisotropy = false; // Anisotropic or Isotropic Snow Model ?
156 bool if_multiple = false; // Do Multiple Scattering in Terrain or not ?
157 bool if_write_view_list = true; // Write ViewList to file ?
158 bool if_read_view_list = false; // Read existing View-list file? -> Speeds up Initialisation by factor ~200
159};
160
161#endif
Definition: SnowBRDF.h:6
Definition: SolarPanel.h:11
Definition: TerrainRadiationAlgorithm.h:37
This module calculates the radiative transfer of SW radiation in snow-covered terrain....
Definition: TerrainRadiationComplex.h:68
TerrainRadiationComplex(const mio::Config &cfg, const mio::DEMObject &dem_in, const std::string &method)
Definition: TerrainRadiationComplex.cc:31
void getSkyViewFactor(mio::Array2D< double > &o_sky_vf)
Definition: TerrainRadiationComplex.cc:1132
~TerrainRadiationComplex()
Definition: TerrainRadiationComplex.cc:187
virtual void setMeteo(const mio::Array2D< double > &albedo, const mio::Array2D< double > &ta)
Definition: TerrainRadiationComplex.cc:903
void setSP(const mio::Date timestamp, const double solarAzimuth, const double solarElevation)
Definition: TerrainRadiationComplex.cc:1417
void writeSP(const unsigned int max_steps)
Definition: TerrainRadiationComplex.cc:1422
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)
Computes direct, diffuse and terrain radiation for each gridpoint. Terrain radiation.
Definition: TerrainRadiationComplex.cc:606