Alpine3D

Alpine3D Svn Source Tree

Root/trunk/alpine3d/SnowpackInterfaceWorker.h

1/***********************************************************************************/
2/* This file is part of Alpine3D.
3 Alpine3D is free software: you can redistribute it and/or modify
4 it under the terms of the GNU Lesser General Public License as published by
5 the Free Software Foundation, either version 3 of the License, or
6 (at your option) any later version.
7
8 Alpine3D is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU Lesser General Public License for more details.
12
13 You should have received a copy of the GNU Lesser General Public License
14 along with Alpine3D. If not, see <http://www.gnu.org/licenses/>.
15*/
16#ifndef SNOWPACKINTERFACEWORKER_H
17#define SNOWPACKINTERFACEWORKER_H
18
19#include <alpine3d/DataAssimilation.h>
20#include <alpine3d/snowdrift/SnowDrift.h>
21#include <alpine3d/ebalance/EnergyBalance.h>
22#include <alpine3d/runoff/Runoff.h>
23#include <alpine3d/MeteoObj.h> //for the SnGrids
24#include <snowpack/libsnowpack.h> //for TechSnow
25
26class SnowpackInterfaceWorker
27{
28public:
29SnowpackInterfaceWorker(const mio::Config& io_cfg,
30 const mio::DEMObject& dem_in,
31 const mio::Grid2DObject& landuse_in,
32 const std::vector< std::pair<size_t,size_t> >& pts_in,
33 const std::vector<SnowStation*>& snow_stations,
34 const std::vector<std::pair<size_t,size_t> >& snow_stations_coord,
35 const size_t offset_in);
36
37~SnowpackInterfaceWorker();
38
39void setUseDrift(const bool useDrift_in) {useDrift = useDrift_in;}
40void setUseEBalance(const bool useEBalance_in) {useEBalance = useEBalance_in;}
41void getOutputSNO(std::vector<SnowStation*>& snow_station) const;
42void getOutputSpecialPoints(std::vector<SnowStation*>& ptr_snow_pixel, std::vector<CurrentMeteo*>& ptr_meteo_pixel,
43 std::vector<SurfaceFluxes*>& ptr_surface_flux);
44void clearSpecialPointsData();
45
46mio::Grid2DObject getGrid(const SnGrids::Parameters& param) const;
47double& getGridPoint(const SnGrids::Parameters& param, const size_t& ii, const size_t& jj);
48
49void runModel(const mio::Date& julian,
50 const mio::Grid2DObject &psum,
51 const mio::Grid2DObject &psum_ph,
52 const mio::Grid2DObject &psum_tech,
53 const mio::Grid2DObject &rh,
54 const mio::Grid2DObject &ta,
55 const mio::Grid2DObject &vw,
56 const mio::Grid2DObject &dw,
57 const mio::Grid2DObject &mns,
58 const mio::Grid2DObject &shortwave,
59 const mio::Grid2DObject &diffuse,
60 const mio::Grid2DObject &longwave,
61 const double solarElevation);
62
63void grooming(const mio::Date &current_date, const mio::Grid2DObject &grooming_map);
64
65static int round_landuse(const double& landuse_dbl);
66static bool skipThisCell(const double& landuse_val, const double& dem_val);
67static bool is_special(const std::vector< std::pair<size_t,size_t> >& pts_in, const size_t& ix, const size_t& iy);
68static void uniqueOutputGrids(std::vector<std::string>& output_grids);
69void getLateralFlow(std::vector<SnowStation*>& snow_station);
70void setLateralFlow(const std::vector<SnowStation*>& snow_station);
71
72private:
73void initGrids(std::vector<std::string>& params);
74void gatherSpecialPoints(const CurrentMeteo& meteoPixel, const SnowStation& snowPixel, const SurfaceFluxes& surfaceFlux);
75void fillGrids(const size_t& ii, const size_t& jj, const CurrentMeteo& meteoPixel, const SnowStation& snowPixel, const SurfaceFluxes& surfaceFlux);
76
77private:
78SnowpackConfig sn_cfg; // created on element
79Snowpack sn;
80Meteo meteo;
81Stability stability;
82TechSnow sn_techsnow;
83
84const mio::DEMObject dem;
85const size_t dimx, dimy, offset;
86std::vector<SnowStation*> SnowStations; // Save different Pixel values
87std::vector<std::pair<size_t,size_t> > SnowStationsCoord;
88std::vector<bool> isSpecialPoint;
89
90const mio::Grid2DObject landuse;
91mio::Grid2DObject store;
92std::map< SnGrids::Parameters, mio::Grid2DObject > grids;
93
94// cache special point data for output on master process:
95std::vector<SnowStation> snow_pixel;
96std::vector<CurrentMeteo> meteo_pixel;
97std::vector<SurfaceFluxes> surface_flux;
98std::vector<double> soil_temp_depths;
99
100double calculation_step_length;
101double height_of_wind_value;
102double snow_temp_depth, snow_avg_temp_depth, snow_avg_rho_depth;
103bool useDrift, useEBalance, useCanopy;
104};
105
106#endif

Archive Download this file

Revision: HEAD