programmer's documentation
cs_gwf.h
Go to the documentation of this file.
1 #ifndef __CS_GWF_H__
2 #define __CS_GWF_H__
3 
4 /*============================================================================
5  * Set of main functions to handle the groundwater flow module with CDO
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2018 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 /*----------------------------------------------------------------------------
31  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_base.h"
35 #include "cs_equation.h"
36 
37 /*----------------------------------------------------------------------------*/
38 
40 
41 /*============================================================================
42  * Macro definitions
43  *============================================================================*/
44 
45 /*============================================================================
46  * Type definitions
47  *============================================================================*/
48 
49 typedef enum {
50 
51  CS_SOILKEY_SAT_MOISTURE, // Set the saturated moisture content
52  CS_SOILKEY_RES_MOISTURE, // Set the residual moisture content
53  CS_SOILKEY_BULK_DENSITY, // Set the bulk density of a soil
54 
55  /* Keys specific to the Tracy model */
56  CS_SOILKEY_TRACY_SAT_H, // Head related to the saturated moisture content
57  CS_SOILKEY_TRACY_RES_H, // Head related to the residual moisture content
58 
60 
62 
63 
64 /* Type of predefined modelling for the groundwater flows */
65 typedef enum {
66 
67  CS_GWF_HYDRAULIC_COMPOSITE, /* Mixed of predefined groundwater model */
68  CS_GWF_HYDRAULIC_GENUCHTEN, /* Van Genuchten-Mualem laws for dimensionless
69  moisture content and hydraulic conductivity */
70  CS_GWF_HYDRAULIC_SATURATED, /* media is satured */
71  CS_GWF_HYDRAULIC_TRACY, /* Tracy model for unsaturated soils */
72  CS_GWF_HYDRAULIC_USER, /* User-defined model */
74 
76 
77 /* Parameters defining the van Genuchten-Mualen law */
78 typedef struct {
79 
80  double n; // 1.25 < n < 6
81  double m; // m = 1 - 1/n
82  double scale; // scale parameter [m^-1]
83  double tortuosity; // tortuosity param. for saturated hydraulic conductivity
84 
86 
87 typedef struct {
88 
89  double h_r;
90  double h_s;
91 
93 
94 typedef struct _gwf_t cs_gwf_t;
95 
96 /*============================================================================
97  * Public function prototypes
98  *============================================================================*/
99 
100 /*----------------------------------------------------------------------------*/
106 /*----------------------------------------------------------------------------*/
107 
108 cs_gwf_t *
109 cs_gwf_create(void);
110 
111 /*----------------------------------------------------------------------------*/
119 /*----------------------------------------------------------------------------*/
120 
121 cs_gwf_t *
122 cs_gwf_finalize(cs_gwf_t *gw);
123 
124 /*----------------------------------------------------------------------------*/
132 /*----------------------------------------------------------------------------*/
133 
134 int
135 cs_gwf_get_n_soils(const cs_gwf_t *gw);
136 
137 /*----------------------------------------------------------------------------*/
144 /*----------------------------------------------------------------------------*/
145 
146 void
147 cs_gwf_set_gravity_vector(cs_gwf_t *gw,
148  const cs_real_3_t gvec);
149 
150 /*----------------------------------------------------------------------------*/
159 /*----------------------------------------------------------------------------*/
160 
161 void
163  cs_flag_t location_flag);
164 
165 /*----------------------------------------------------------------------------*/
171 /*----------------------------------------------------------------------------*/
172 
173 void
174 cs_gwf_summary(const cs_gwf_t *gw);
175 
176 /*----------------------------------------------------------------------------*/
190 /*----------------------------------------------------------------------------*/
191 
192 cs_equation_t *
193 cs_gwf_initialize(int richards_eq_id,
194  int n_soils,
195  int n_tracer_eqs,
196  cs_property_t *permeability,
197  cs_property_t *soil_capacity,
198  cs_adv_field_t *adv_field,
199  cs_gwf_t *gw);
200 
201 /*----------------------------------------------------------------------------*/
212 /*----------------------------------------------------------------------------*/
213 
214 void
215 cs_gwf_add_iso_soil_by_value(cs_gwf_t *gw,
217  const char *ml_name,
218  double k_s,
219  double theta_s,
220  double rho);
221 
222 /*----------------------------------------------------------------------------*/
233 /*----------------------------------------------------------------------------*/
234 
235 void
236 cs_gwf_add_ortho_soil_by_value(cs_gwf_t *gw,
238  const char *ml_name,
239  cs_real_t *ks,
240  double theta_s,
241  double rho);
242 
243 /*----------------------------------------------------------------------------*/
254 /*----------------------------------------------------------------------------*/
255 
256 void
257 cs_gwf_add_aniso_soil_by_value(cs_gwf_t *gw,
259  const char *ml_name,
260  cs_real_t *ks,
261  double theta_s,
262  double rho);
263 
264 /*----------------------------------------------------------------------------*/
273 /*----------------------------------------------------------------------------*/
274 
275 void
276 cs_gwf_set_soil_param(cs_gwf_t *gw,
277  const char *ml_name,
278  cs_gwf_soilkey_t key,
279  const cs_real_t val);
280 
281 /*----------------------------------------------------------------------------*/
296 /*----------------------------------------------------------------------------*/
297 
298 cs_equation_t *
299 cs_gwf_add_tracer(cs_gwf_t *gw,
300  int tracer_eq_id,
301  const char *eqname,
302  const char *varname);
303 
304 /*----------------------------------------------------------------------------*/
321 /*----------------------------------------------------------------------------*/
322 
323 void
324 cs_gwf_set_tracer_param(cs_gwf_t *gw,
325  int tracer_eq_id,
326  const char *ml_name,
327  double wmd,
328  double alpha_l,
329  double alpha_t,
330  double distrib_coef,
331  double reaction_rate);
332 
333 /*----------------------------------------------------------------------------*/
340 /*----------------------------------------------------------------------------*/
341 
342 void
343 cs_gwf_richards_setup(cs_gwf_t *gw,
344  cs_equation_t *richards);
345 
346 /*----------------------------------------------------------------------------*/
355 /*----------------------------------------------------------------------------*/
356 
357 bool
358 cs_gwf_tracer_needs_reaction(const cs_gwf_t *gw,
359  int eq_id);
360 
361 /*----------------------------------------------------------------------------*/
370 /*----------------------------------------------------------------------------*/
371 
372 bool
373 cs_gwf_tracer_needs_diffusion(const cs_gwf_t *gw,
374  int eq_id);
375 
376 /*----------------------------------------------------------------------------*/
384 /*----------------------------------------------------------------------------*/
385 
386 void
387 cs_gwf_tracer_setup(int tracer_eq_id,
388  cs_equation_t *eq,
389  cs_gwf_t *gw);
390 
391 /*----------------------------------------------------------------------------*/
400 /*----------------------------------------------------------------------------*/
401 
402 void
404  int n_equations,
405  cs_equation_t **equations,
406  cs_gwf_t *gw);
407 
408 /*----------------------------------------------------------------------------*/
420 /*----------------------------------------------------------------------------*/
421 
422 void
424  const cs_time_step_t *time_step,
425  double dt_cur,
426  const cs_cdo_connect_t *connect,
427  const cs_cdo_quantities_t *cdoq,
428  cs_equation_t *eqs[],
429  cs_gwf_t *gw);
430 
431 /*----------------------------------------------------------------------------*/
453 /*----------------------------------------------------------------------------*/
454 
455 void
456 cs_gwf_extra_post(void *input,
457  int mesh_id,
458  int cat_id,
459  int ent_flag[5],
460  cs_lnum_t n_cells,
461  cs_lnum_t n_i_faces,
462  cs_lnum_t n_b_faces,
463  const cs_lnum_t cell_list[],
464  const cs_lnum_t i_face_list[],
465  const cs_lnum_t b_face_list[],
466  const cs_time_step_t *time_step);
467 
468 /*----------------------------------------------------------------------------*/
469 
471 
472 #endif /* __CS_GWF_H__ */
void cs_gwf_richards_setup(cs_gwf_t *gw, cs_equation_t *richards)
Predefined settings for the Richards equation.
Definition: cs_gwf.c:1841
Definition: cs_gwf.h:87
time step descriptor
Definition: cs_time_step.h:51
Definition: cs_gwf.h:56
Definition: cs_advection_field.h:59
void cs_gwf_add_iso_soil_by_value(cs_gwf_t *gw, cs_gwf_hydraulic_model_t model, const char *ml_name, double k_s, double theta_s, double rho)
Add a new soil attached to an isotropic permeability.
Definition: cs_gwf.c:1470
Definition: cs_gwf.h:51
cs_gwf_t * cs_gwf_create(void)
Create a structure dedicated to manage groundwater flows.
Definition: cs_gwf.c:1128
cs_gwf_hydraulic_model_t
Definition: cs_gwf.h:65
double h_r
Definition: cs_gwf.h:89
Definition: cs_gwf.h:53
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
Definition: cs_gwf.h:59
double scale
Definition: cs_gwf.h:82
Definition: cs_gwf.h:78
Definition: cs_cdo_connect.h:56
double m
Definition: cs_gwf.h:81
void cs_gwf_extra_post(void *input, int mesh_id, int cat_id, int ent_flag[5], cs_lnum_t n_cells, cs_lnum_t n_i_faces, cs_lnum_t n_b_faces, const cs_lnum_t cell_list[], const cs_lnum_t i_face_list[], const cs_lnum_t b_face_list[], const cs_time_step_t *time_step)
Predefined post-processing output for the groundwater flow module prototype of this function is fixed...
Definition: cs_gwf.c:2539
Definition: cs_gwf.h:71
double h_s
Definition: cs_gwf.h:90
cs_equation_t * cs_gwf_add_tracer(cs_gwf_t *gw, int tracer_eq_id, const char *eqname, const char *varname)
Add a new equation related to the groundwater flow module This equation is a specific unsteady advect...
Definition: cs_gwf.c:1696
Definition: cs_gwf.h:72
void cs_gwf_tracer_setup(int tracer_eq_id, cs_equation_t *eq, cs_gwf_t *gw)
Predefined settings for a tracer equation.
Definition: cs_gwf.c:2082
void cs_gwf_set_gravity_vector(cs_gwf_t *gw, const cs_real_3_t gvec)
Activate the gravity and set the gravitaty vector.
Definition: cs_gwf.c:1225
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:102
cs_gwf_t * cs_gwf_finalize(cs_gwf_t *gw)
Free the main structure related to groundwater flows.
Definition: cs_gwf.c:1170
Definition: cs_mesh.h:63
int cs_gwf_get_n_soils(const cs_gwf_t *gw)
Get the number of requested soils.
Definition: cs_gwf.c:1207
double tortuosity
Definition: cs_gwf.h:83
Definition: cs_gwf.h:68
Definition: cs_gwf.h:67
double n
Definition: cs_gwf.h:80
void cs_gwf_set_soil_param(cs_gwf_t *gw, const char *ml_name, cs_gwf_soilkey_t key, const cs_real_t val)
Set parameters related to a cs_gwf_t structure.
Definition: cs_gwf.c:1555
void cs_gwf_compute(const cs_mesh_t *mesh, const cs_time_step_t *time_step, double dt_cur, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq, cs_equation_t *eqs[], cs_gwf_t *gw)
Compute the system related to groundwater flows module.
Definition: cs_gwf.c:2412
Definition: cs_gwf.h:52
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
bool cs_gwf_tracer_needs_reaction(const cs_gwf_t *gw, int eq_id)
Check if one needs to add a reaction term for a given tracer.
Definition: cs_gwf.c:2023
void cs_gwf_summary(const cs_gwf_t *gw)
Summary of a cs_gwf_t structure.
Definition: cs_gwf.c:1265
void cs_gwf_add_ortho_soil_by_value(cs_gwf_t *gw, cs_gwf_hydraulic_model_t model, const char *ml_name, cs_real_t *ks, double theta_s, double rho)
Add a new soil attached to an orthotropic permeability.
Definition: cs_gwf.c:1498
void cs_gwf_final_initialization(const cs_cdo_connect_t *connect, int n_equations, cs_equation_t **equations, cs_gwf_t *gw)
Last initialization step of the groundwater flow module.
Definition: cs_gwf.c:2169
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
void cs_gwf_set_tracer_param(cs_gwf_t *gw, int tracer_eq_id, const char *ml_name, double wmd, double alpha_l, double alpha_t, double distrib_coef, double reaction_rate)
Add a new equation related to the groundwater flow module This equation is a specific unsteady advect...
Definition: cs_gwf.c:1762
Definition: cs_gwf.h:70
Definition: cs_gwf.h:73
#define END_C_DECLS
Definition: cs_defs.h:452
unsigned short int cs_flag_t
Definition: cs_defs.h:299
Definition: cs_gwf.h:57
Definition: cs_field_pointer.h:98
bool cs_gwf_tracer_needs_diffusion(const cs_gwf_t *gw, int eq_id)
Check if one needs to add a diffusion term for a given tracer.
Definition: cs_gwf.c:2052
subroutine richards(icvrge, dt)
Definition: richards.f90:82
cs_gwf_soilkey_t
Definition: cs_gwf.h:49
void cs_gwf_set_darcian_flux_location(cs_gwf_t *gw, cs_flag_t location_flag)
Advanced setting: indicate where the darcian flux is stored cs_cdo_primal_cell is the default setting...
Definition: cs_gwf.c:1248
Definition: cs_property.h:66
Definition: mesh.f90:26
cs_equation_t * cs_gwf_initialize(int richards_eq_id, int n_soils, int n_tracer_eqs, cs_property_t *permeability, cs_property_t *soil_capacity, cs_adv_field_t *adv_field, cs_gwf_t *gw)
Initialize the module dedicated to groundwater flows.
Definition: cs_gwf.c:1403
void cs_gwf_add_aniso_soil_by_value(cs_gwf_t *gw, cs_gwf_hydraulic_model_t model, const char *ml_name, cs_real_t *ks, double theta_s, double rho)
Add a new soil attached to an orthotropic permeability.
Definition: cs_gwf.c:1527