18 #ifndef SNOWDRIFTA3D_H 19 #define SNOWDRIFTA3D_H 23 #define SALTATION 1 // switch for saltation simulation 24 #define SUBLIMATION 0 // switch for drifting snow sublimation 25 #define FIELD3D_OUTPUT 0 // output with all three-dimensional fields (only possible for sublimation) 26 #define SUBLIMATION_OUTPUT 0 // debug output of drifting snow sublimation 27 #define T_FB 1 //switch for feedback between sublimation and air temperature 28 #define Q_FB 1 //switch for feedback between sublimation and humidity 29 #define C_FB 1 //switch for feedback between sublimation and snow concentration 30 #define READK 0 //define as 1 if you have K from ARPS wind fields INCLUDING turbulence 31 #define WRITE_DRIFT_FLUXES 0 //set to 1 in order to write snow drift fluxes 38 #include <meteoio/MeteoIO.h> 39 #include <meteoio/plugins/ARPSIO.h> 49 #pragma GCC diagnostic push 50 #pragma GCC diagnostic ignored "-Weffc++" 80 SnowDriftA3D(
const mio::DEMObject& dem,
const mio::Config& cfg);
84 virtual void setSnowSurfaceData(
const mio::Grid2DObject& cH_in,
const mio::Grid2DObject& sp_in,
const mio::Grid2DObject& rg_in,
85 const mio::Grid2DObject& N3_in,
const mio::Grid2DObject& rb_in);
90 virtual void Compute(
const mio::Date& calcDate);
91 bool isNewWindField(
const unsigned int current_step) ;
92 void setMeteo (
const unsigned int&
steps,
const mio::Grid2DObject& new_psum,
const mio::Grid2DObject& new_psum_ph,
const mio::Grid2DObject& new_p,
const mio::Grid2DObject& new_vw,
93 const mio::Grid2DObject& new_rh,
const mio::Grid2DObject& new_ta,
const mio::Grid2DObject& new_ilwr,
const mio::Date& calcDate,
94 const std::vector<mio::MeteoData>& vecMeteo);
96 void GetTResults(
double outtime_v[15],
double outtime_tau[15],
double outtime_salt[15],
double outtime_diff[15]);
98 double getTiming()
const;
102 std::string getGridsRequirements()
const;
106 void ConstructElements();
107 void InitializeNodes(
const mio::Grid3DObject& z_readMatr);
108 void CompleteNodes();
110 virtual void compSaltation(
bool setbound);
111 virtual void SnowMassChange(
bool setbound,
const mio::Date& calcDate);
112 virtual void Suspension();
113 virtual void Diffusion(
double deltaT,
double &diff_max,
double t);
117 virtual void Sublimation();
118 double terminalFallVelocity(
const double Radius,
const double Temperature,
const double RH,
const double altitude);
119 double calcS(
const double concentration,
const double sublradius,
const double dmdt);
120 double calcSubldM(
const double Radius,
const double AirTemperature,
const double RH,
const double WindSpeed,
const double altitude);
121 double reynoldsNumberforFallingParticles(
const double Radius,
const double Windspeed,
const double AirTemperature,
const double RH,
const double altitude);
122 double ventilationVelocity(
const double Radius,
const double Windspeed,
const double AirTemperature,
const double RH,
const double altitude);
123 double waterVaporDensity(
const double Temperature,
const double VaporPressure);
124 double RH_from_q(
const double AirTemp,
const double q,
const double altitude);
125 void initializeTRH();
133 virtual void Jacobian(
double *DETERMINANTJ,
double J[][3],
const int element,
const double *P,
int k,
const int ix,
const int iy,
const int iz);
134 virtual void J0fun(
double J0[3][3],
const double J[3][3]);
135 virtual double GQIntB(
double *DETERMINANTJ,
const int i,
const int j);
136 virtual double GQIntC(
double * DETERMINANTJ,
const double J0M[3][3][8],
const int i,
const int j,
const double b[3],
const double K[3][3]);
137 virtual double GQIntApdx(
double DETERMINANTJ[],
const double J0M[3][3][8],
const int i,
const int j,
double b[],
const double deltak);
138 virtual double GQIntAdxdx(
double *DETERMINANTJ,
double J0M[3][3][8],
const int i,
const int j,
double *b,
const double deltak);
139 virtual void TTfun(
double TT[3][8],
const double P[]);
140 virtual void phi(
double*PHI,
double*P);
141 virtual void setQuadraturePoints();
147 virtual void SolveEquation(
int timeStep,
int maxTimeStep,
const param_type param );
166 virtual void prepareSolve();
170 virtual void computeDiffusionTensor(
double K[3][3],
const unsigned int ix,
const unsigned int iy,
const unsigned int iz);
171 virtual void computeDriftVector(
double b[3],
const unsigned int ix,
const unsigned int iy,
const unsigned int iz );
172 virtual void computeElementParameters(
const int& element,
double DETERMINANTJ[8],
double J0M[3][3][8],
double J0[3][3],
double J[3][3],
double b[3],
double K[3][3],
double& deltak,
double& qualla,
const int ix,
const int iy,
const int iz);
174 virtual void computeElementSystem(
int &element,
int &nDofNodes,
int* dofNode,
double Ael[9][9],
double Del[9][9],
bool stationary,
double DETERMINANTJ[8],
double J0M[3][3][8],
double b[3],
double K[3][3],
double &deltak,
const double &dt,
CDoubleArray& f,
CDoubleArray& Psi);
176 virtual void computeDirichletBoundaryValues(
int element,
double DETERMINANTJ[8],
double J0M[3][3][8],
double J0[3][3],
double b[3],
double K[3][3],
double deltak,
int spec[8],
int length_spec,
int length_complSpec,
CDoubleArray& c00,
CDoubleArray& Psi);
178 virtual void addElementMatrix(
CDoubleArray& sA,
const CIntArray& colInd,
const CIntArray& rowPtr,
const double Bel[9][9],
const int element,
const int* spec,
const int length_spec);
180 virtual void computeDepositionFlux(
const CDoubleArray& c,
const double theta);
181 virtual void computeDepositionFluxSublimation(
const CDoubleArray& c,
const double theta);
189 void values_nodes_to_elements(
const mio::Grid3DObject& nodesGrid,
CDoubleArray& elementsArray );
190 void values_elements_to_nodes(mio::Grid3DObject& nodesGrid,
const CDoubleArray& elementsArray );
191 void setRobinBoundaryCondition(
const aspect_type aspect,
const double gamma_val,
const int ix,
const int iy,
const int iz,
CDoubleArray& var00,
const param_type param);
192 virtual void InitializeFEData();
197 virtual void classifySubdomain();
198 virtual int numberOfNonzeros();
199 void iterativeSublimationCalculation(
int timeStep,
int maxTimeStep);
205 double time_v[15], time_tau[15], time_salt[15], time_diff[15];
215 mio::Grid2DObject
cH;
216 mio::Grid2DObject
sp;
217 mio::Grid2DObject
rg;
218 mio::Grid2DObject
N3;
219 mio::Grid2DObject
rb;
222 unsigned int nx, ny,
nz;
263 void zeroRow(
int node);
309 mio::Array2D<double>
saltation, c_salt, mns_subl, mns_nosubl,dif_mns_subl;
312 mio::Grid2DObject mns,
vw, rh, ta, p, psum, psum_ph;
320 mio::Grid3DObject nodes_x, nodes_y,
nodes_z, nodes_sy, nodes_sx, nodes_slope, nodes_wstar;
321 mio::Grid3DObject nodes_u, nodes_v,
nodes_w, nodes_K;
323 mio::Grid3DObject nodes_Tair,nodes_Tair_ini, nodes_q, nodes_q_ini, nodes_RH, nodes_Subl, nodes_Subl_ini,
nodes_WindVel, nodes_tmp_c;
327 void buildWindFieldsTable(
const std::string& wind_field_string);
331 void debugOutputs(
const mio::Date& calcDate,
const std::string& fname,
const DRIFT_OUTPUT& filetype);
332 void writeOutput(
const std::string& fname);
335 static const double kinematicViscosityAir,
USTAR, molecularWeightofWater, thermalConductivityofAtm;
338 static const double c_red, grain_size, tau_thresh,
z0;
342 #pragma GCC diagnostic pop mio::Grid2DObject vw
Definition: SnowDrift.h:312
double ta_1D
Definition: SnowDrift.h:315
mio::Grid3DObject nodes_z
Definition: SnowDrift.h:320
DRIFT_OUTPUT
Definition: SnowDrift.h:55
mio::Grid2DObject sp
Definition: SnowDrift.h:216
Definition: SnowDrift.h:55
mio::Grid3DObject nodes_e
Definition: SnowDrift.h:322
CDoubleArray T00
Definition: SnowDrift.h:254
Definition: SnowDrift.h:56
double station_altitude
Definition: SnowDrift.h:208
CElementArray elems
Definition: SnowDrift.h:308
Definition: SnowDrift.h:57
mio::Array2D< double > qPoint
Definition: SnowDrift.h:294
unsigned int nNZ
Definition: SnowDrift.h:228
std::string wind
Definition: SnowDrift.h:59
CElementArray nodeMap
Definition: SnowDrift.h:298
CIntArray colA
Definition: SnowDrift.h:233
Definition: SnowDrift.h:59
Definition: SnowDrift.h:56
mio::Array2D< int > nz_face
Definition: SnowDrift.h:279
CDoubleArray c
Definition: SnowDrift.h:241
CDoubleArray gamma
Definition: SnowDrift.h:262
CDoubleArray sB
Definition: SnowDrift.h:232
mio::Grid2DObject cH
Definition: SnowDrift.h:215
Definition: SnowDrift.h:56
param_type
Definition: SnowDrift.h:56
Saltation saltation_obj
Definition: SnowDrift.h:202
CDoubleArray flux_z_subl
Definition: SnowDrift.h:304
double theta
Definition: SnowDrift.h:275
mio::Array2D< int > nx_face
Definition: SnowDrift.h:281
mio::Grid2DObject rg
Definition: SnowDrift.h:217
mio::Array2D< int > nz_bar
Definition: SnowDrift.h:283
Definition: SnowDrift.h:78
CIntArray n_corner
Definition: SnowDrift.h:291
static const bool thresh_snow
Definition: SnowDrift.h:339
Definition: EnergyBalance.h:68
mio::Grid3DObject nodes_w
Definition: SnowDrift.h:321
std::vector< struct WIND_FIELD > wind_fields
Definition: SnowDrift.h:328
int DOITERATION
Definition: SnowDrift.h:206
double auxLayerHeight
Definition: SnowDrift.h:207
Definition: SnowDrift.h:56
Definition: SnowpackInterface.h:127
CIntArray nnzA
Definition: SnowDrift.h:267
CDoubleArray gNeumann
Definition: SnowDrift.h:260
int wind_field_index
Definition: SnowDrift.h:329
unsigned int nElements
Definition: SnowDrift.h:227
mio::Array1D< int > CIntArray
Definition: SnowDrift.h:43
bool new_wind_status
Definition: SnowDrift.h:306
mio::IOManager io
Definition: SnowDrift.h:210
mio::Timer timer
Definition: SnowDrift.h:213
mio::Grid3DObject nodes_WindVel
Definition: SnowDrift.h:323
Definition: SnowDrift.h:56
CDoubleArray adjA
Definition: SnowDrift.h:268
mio::Array2D< int > nz_interior
Definition: SnowDrift.h:287
CDoubleArray q
Definition: SnowDrift.h:242
mio::Array2D< int > ny_face
Definition: SnowDrift.h:280
mio::Array2D< int > ny_interior
Definition: SnowDrift.h:288
CDoubleArray precond
Definition: SnowDrift.h:257
mio::Array2D< double > saltation
Definition: SnowDrift.h:309
mio::Array2D< int > nx_bar
Definition: SnowDrift.h:285
mio::Array1D< double > CDoubleArray
Definition: SnowDrift.h:42
double qualla
Definition: SnowDrift.h:273
Definition: SnowDrift.h:55
unsigned int nNodes
Definition: SnowDrift.h:226
Definition: SnowDrift.h:57
aspect_type
Definition: SnowDrift.h:57
static int steps
Definition: AlpineMain.cc:48
CDoubleArray Psi
Definition: SnowDrift.h:238
CElementArray dofMap
Definition: SnowDrift.h:302
bool STATIONARY
Definition: SnowDrift.h:324
CDoubleArray T
Definition: SnowDrift.h:243
SnowpackInterface * snowpack
Definition: SnowDrift.h:211
static const double z0
Definition: SnowDrift.h:338
CDoubleArray c00
Definition: SnowDrift.h:252
CDoubleArray sA
Definition: SnowDrift.h:231
unsigned int nz
Definition: SnowDrift.h:222
CDoubleArray gDirichlet
Definition: SnowDrift.h:261
CDoubleArray rhs
Definition: SnowDrift.h:246
CDoubleArray f
Definition: SnowDrift.h:249
unsigned int start_step
Definition: SnowDrift.h:59
mio::Array2D< int > CElementArray
Definition: SnowDrift.h:41
EnergyBalance * eb
Definition: SnowDrift.h:212
CDoubleArray q00
Definition: SnowDrift.h:253
mio::Array2D< int > ny_bar
Definition: SnowDrift.h:284
mio::Array2D< int > nx_interior
Definition: SnowDrift.h:289
mio::Grid2DObject N3
Definition: SnowDrift.h:218
static const double USTAR
Definition: SnowDrift.h:335
CIntArray rowA
Definition: SnowDrift.h:234
mio::Grid2DObject rb
Definition: SnowDrift.h:219
unsigned int nDOF
Definition: SnowDrift.h:225
mio::Date skip_date
Definition: SnowDrift.h:317