8.1
general documentation
cs_gwf_soil.h
Go to the documentation of this file.
1 #ifndef __CS_GWF_SOIL_H__
2 #define __CS_GWF_SOIL_H__
3 
4 /*============================================================================
5  * Set of main functions to handle soils in the groundwater flow module
6  * when using CDO schemes
7  *============================================================================*/
8 
9 /*
10  This file is part of code_saturne, a general-purpose CFD tool.
11 
12  Copyright (C) 1998-2023 EDF S.A.
13 
14  This program is free software; you can redistribute it and/or modify it under
15  the terms of the GNU General Public License as published by the Free Software
16  Foundation; either version 2 of the License, or (at your option) any later
17  version.
18 
19  This program is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22  details.
23 
24  You should have received a copy of the GNU General Public License along with
25  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
26  Street, Fifth Floor, Boston, MA 02110-1301, USA.
27 */
28 
29 /*----------------------------------------------------------------------------*/
30 
31 /*----------------------------------------------------------------------------
32  * Local headers
33  *----------------------------------------------------------------------------*/
34 
35 #include "cs_base.h"
36 #include "cs_cdo_connect.h"
37 #include "cs_cdo_quantities.h"
38 #include "cs_gwf_param.h"
39 #include "cs_gwf_hydraulic_model.h"
40 #include "cs_mesh.h"
41 #include "cs_property.h"
42 #include "cs_volume_zone.h"
43 
44 /*----------------------------------------------------------------------------*/
45 
47 
48 /*============================================================================
49  * Macro definitions
50  *============================================================================*/
51 
52 /*============================================================================
53  * Public function pointer prototypes
54  *============================================================================*/
55 
57 typedef struct _gwf_soil_t cs_gwf_soil_t;
58 
59 /*----------------------------------------------------------------------------*/
72 /*----------------------------------------------------------------------------*/
73 
74 typedef void
75 (cs_gwf_soil_update_t) (const cs_real_t t_eval,
76  const cs_mesh_t *mesh,
77  const cs_cdo_connect_t *connect,
78  const cs_cdo_quantities_t *quant,
79  const cs_zone_t *zone,
80  cs_gwf_soil_t *soil);
81 
82 /*----------------------------------------------------------------------------*/
89 /*----------------------------------------------------------------------------*/
90 
91 typedef void
92 (cs_gwf_soil_free_param_t)(void **p_param);
93 
94 /*----------------------------------------------------------------------------*/
105 /*----------------------------------------------------------------------------*/
106 
107 typedef void
109  const double pc,
110  double *sl,
111  double *dsldpc,
112  double *krl,
113  double *krg);
114 
115 /*============================================================================
116  * Type definitions
117  *============================================================================*/
118 
137 typedef enum {
138 
143 
145 
147 
163 typedef enum {
164 
168 
170 
172 
182 typedef struct {
183 
203 
204  double n;
205  double m;
206  double scale;
207  double tortuosity;
208 
210 
222 
251  double n;
252  double m;
253  double inv_m;
254  double pr_r;
255  double inv_pr_r;
256  double sl_r;
257  double sl_s;
258  double sl_range;
259 
319  double sle_thres;
320 
321  /* Function pointer */
322 
324 
325  /* Derived quantities */
326 
327  double pc_star;
328  double dsldpc_star;
329  double sle_alpha;
330  double sle_beta;
331 
332  double krg_star;
333  double dkrgdsl_star;
334  double krg_alpha;
335 
336  double krl_star;
337  double dkrldsl_star;
338  double krl_alpha;
339 
340 };
341 
343 
354 struct _gwf_soil_t {
355 
428  int id;
429  int zone_id;
430 
433 
434 
435  double bulk_density;
436  double porosity;
438  double abs_permeability[3][3];
439 
441  void *model_param;
442 
443  /* Pointers to functions */
444 
447 
448 };
449 
450 /*============================================================================
451  * User-defined function prototypes
452  *============================================================================*/
453 
454 /*============================================================================
455  * Public function prototypes
456  *============================================================================*/
457 
458 /*----------------------------------------------------------------------------*/
464 /*----------------------------------------------------------------------------*/
465 
466 int
467 cs_gwf_get_n_soils(void);
468 
469 /*----------------------------------------------------------------------------*/
485 /*----------------------------------------------------------------------------*/
486 
487 cs_gwf_soil_t *
488 cs_gwf_soil_create(const cs_zone_t *zone,
489  cs_gwf_model_type_t hydraulic_model,
490  cs_gwf_soil_model_t model,
491  cs_property_type_t perm_type,
492  double k_abs[3][3],
493  double porosity,
494  double bulk_density,
495  void *hydraulic_context);
496 
497 /*----------------------------------------------------------------------------*/
505 /*----------------------------------------------------------------------------*/
506 
507 cs_gwf_soil_t *
508 cs_gwf_soil_by_id(int id);
509 
510 /*----------------------------------------------------------------------------*/
518 /*----------------------------------------------------------------------------*/
519 
520 cs_gwf_soil_t *
521 cs_gwf_soil_by_name(const char *name);
522 
523 /*----------------------------------------------------------------------------*/
531 /*----------------------------------------------------------------------------*/
532 
533 const cs_zone_t *
534 cs_gwf_soil_get_zone(int soil_id);
535 
536 /*----------------------------------------------------------------------------*/
540 /*----------------------------------------------------------------------------*/
541 
542 void
544 
545 /*----------------------------------------------------------------------------*/
553 /*----------------------------------------------------------------------------*/
554 
555 void
557  cs_flag_t post_flag,
558  cs_lnum_t n_cells);
559 
560 /*----------------------------------------------------------------------------*/
564 /*----------------------------------------------------------------------------*/
565 
566 void
568 
569 /*----------------------------------------------------------------------------*/
578 /*----------------------------------------------------------------------------*/
579 
580 void
581 cs_gwf_soil_update(cs_real_t time_eval,
582  const cs_mesh_t *mesh,
583  const cs_cdo_connect_t *connect,
584  const cs_cdo_quantities_t *cdoq);
585 
586 /*----------------------------------------------------------------------------*/
594 /*----------------------------------------------------------------------------*/
595 
596 void
598  const cs_real_t *sliq);
599 
600 /*----------------------------------------------------------------------------*/
609 /*----------------------------------------------------------------------------*/
610 
611 void
613  cs_property_t *soil_porosity);
614 
615 /*----------------------------------------------------------------------------*/
623 /*----------------------------------------------------------------------------*/
624 
625 void
627 
628 /*----------------------------------------------------------------------------*/
638 /*----------------------------------------------------------------------------*/
639 
640 void
642  const cs_cdo_connect_t *connect);
643 
644 /*----------------------------------------------------------------------------*/
651 /*----------------------------------------------------------------------------*/
652 
653 const double *
655 
656 /*----------------------------------------------------------------------------*/
662 /*----------------------------------------------------------------------------*/
663 
664 const short int *
666 
667 /*----------------------------------------------------------------------------*/
673 /*----------------------------------------------------------------------------*/
674 
675 const int *
677 
678 /*----------------------------------------------------------------------------*/
686 /*----------------------------------------------------------------------------*/
687 
688 cs_real_t
689 cs_gwf_soil_get_porosity(int soil_id);
690 
691 /*----------------------------------------------------------------------------*/
699 /*----------------------------------------------------------------------------*/
700 
701 cs_real_t
703 
704 /*----------------------------------------------------------------------------*/
711 /*----------------------------------------------------------------------------*/
712 
713 int
715 
716 /*----------------------------------------------------------------------------*/
736 /*----------------------------------------------------------------------------*/
737 
738 void
739 cs_gwf_soil_set_vgm_spf_param(cs_gwf_soil_t *soil,
740  double theta_r,
741  double alpha,
742  double n,
743  double L);
744 
745 /*----------------------------------------------------------------------------*/
767 /*----------------------------------------------------------------------------*/
768 
769 void
770 cs_gwf_soil_set_vgm_tpf_param(cs_gwf_soil_t *soil,
771  double n,
772  double pr_r,
773  double sl_r,
774  double sl_s);
775 
776 /*----------------------------------------------------------------------------*/
787 /*----------------------------------------------------------------------------*/
788 
789 void
790 cs_gwf_soil_set_vgm_tpf_advanced_param(cs_gwf_soil_t *soil,
791  cs_gwf_soil_join_type_t sle_jtype,
792  cs_gwf_soil_join_type_t kr_jtype,
793  double sle_thres);
794 
795 /*----------------------------------------------------------------------------*/
804 /*----------------------------------------------------------------------------*/
805 
806 void
807 cs_gwf_soil_set_user_model_param(cs_gwf_soil_t *soil,
808  void *param,
809  cs_gwf_soil_update_t *update_func,
810  cs_gwf_soil_free_param_t *free_param_func);
811 
812 /*----------------------------------------------------------------------------*/
822 /*----------------------------------------------------------------------------*/
823 
824 void
826 
827 /*----------------------------------------------------------------------------*/
828 
830 
831 #endif /* __CS_GWF_SOIL_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:514
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
#define END_C_DECLS
Definition: cs_defs.h:515
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
unsigned short int cs_flag_t
Definition: cs_defs.h:321
cs_gwf_model_type_t
Type of system of equation(s) to consider for the physical modelling.
Definition: cs_gwf_param.h:126
cs_gwf_soil_model_t
Predefined hydraulic model of soils used in the groundwater flow module.
Definition: cs_gwf_param.h:279
cs_real_t cs_gwf_soil_get_saturated_moisture(int soil_id)
Get the saturated moisture for the given soil id.
Definition: cs_gwf_soil.c:1697
void cs_gwf_soil_set_user_model_param(cs_gwf_soil_t *soil, void *param, cs_gwf_soil_update_t *update_func, cs_gwf_soil_free_param_t *free_param_func)
Set a soil defined by a user-defined model.
Definition: cs_gwf_soil.c:1967
const cs_zone_t * cs_gwf_soil_get_zone(int soil_id)
Retrieve a zone associated to a soil from its id.
Definition: cs_gwf_soil.c:1130
int cs_gwf_get_n_soils(void)
Get the number of allocated soils.
Definition: cs_gwf_soil.c:911
cs_gwf_soil_state_t
Kind of state in which a cell is.
Definition: cs_gwf_soil.h:163
@ CS_GWF_SOIL_STATE_UNSATURATED
Definition: cs_gwf_soil.h:166
@ CS_GWF_SOIL_STATE_SATURATED
Definition: cs_gwf_soil.h:165
@ CS_GWF_SOIL_STATE_DRY
Definition: cs_gwf_soil.h:167
@ CS_GWF_SOIL_N_STATES
Definition: cs_gwf_soil.h:169
void cs_gwf_soil_finalize_setup(cs_gwf_model_type_t gwf_model, cs_flag_t post_flag, cs_lnum_t n_cells)
Last initialization step for the soil structures/parameters.
Definition: cs_gwf_soil.c:1218
void cs_gwf_soil_free_all(void)
Free all cs_gwf_soil_t structures.
Definition: cs_gwf_soil.c:1149
const short int * cs_gwf_soil_get_cell2soil(void)
Get the array storing the associated soil for each cell.
Definition: cs_gwf_soil.c:1646
cs_gwf_soil_t * cs_gwf_soil_by_id(int id)
Retrieve a soil structure from its id.
Definition: cs_gwf_soil.c:1081
void cs_gwf_soil_update(cs_real_t time_eval, const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq)
Update the soil properties.
Definition: cs_gwf_soil.c:1395
void cs_gwf_soil_set_vgm_tpf_advanced_param(cs_gwf_soil_t *soil, cs_gwf_soil_join_type_t sle_jtype, cs_gwf_soil_join_type_t kr_jtype, double sle_thres)
Set advanced parameter settings related to a Van Genuchten-Mualen soil model.
Definition: cs_gwf_soil.c:1875
void cs_gwf_soil_update_soil_state(cs_lnum_t n_cells, const cs_real_t *sliq)
Update the soil state associated to each cell w.r.t. the given liquid saturation.
Definition: cs_gwf_soil.c:1443
const double * cs_gwf_soil_get_dual_porous_volume(void)
Get the array storing the dual volume weighted by the soil porosity Array of size n_vertices.
Definition: cs_gwf_soil.c:1632
void() cs_gwf_soil_tpf_eval_t(const cs_gwf_soil_vgm_tpf_param_t *sp, const double pc, double *sl, double *dsldpc, double *krl, double *krg)
Compute the values of the different properties related to a soil in the case of a Van Genuchten-Muale...
Definition: cs_gwf_soil.h:108
void() cs_gwf_soil_update_t(const cs_real_t t_eval, const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_zone_t *zone, cs_gwf_soil_t *soil)
Generic function to update the properties related to a hydraulic model given the soil model....
Definition: cs_gwf_soil.h:75
void cs_gwf_soil_define_shared_properties(cs_property_t *abs_permeability, cs_property_t *soil_porosity)
Set the definition of the soil porosity and absolute permeability (which are properties always define...
Definition: cs_gwf_soil.c:1472
cs_gwf_soil_t * cs_gwf_soil_create(const cs_zone_t *zone, cs_gwf_model_type_t hydraulic_model, cs_gwf_soil_model_t model, cs_property_type_t perm_type, double k_abs[3][3], double porosity, double bulk_density, void *hydraulic_context)
Create a new cs_gwf_soil_t structure and add it to the array of soils. An initialization by default o...
Definition: cs_gwf_soil.c:935
void cs_gwf_soil_set_vgm_spf_param(cs_gwf_soil_t *soil, double theta_r, double alpha, double n, double L)
Set a soil defined by a Van Genuchten-Mualem model in the case of single-phase flow in an (unsaturate...
Definition: cs_gwf_soil.c:1760
void cs_gwf_soil_build_dual_porous_volume(const cs_cdo_quantities_t *cdoq, const cs_cdo_connect_t *connect)
Build an array storing the dual volume associated to each vertex taking into account the porosity of ...
Definition: cs_gwf_soil.c:1563
int cs_gwf_soil_get_permeability_max_dim(void)
Retrieve the max dim (aniso=9; iso=1) for the absolute permeability associated to each soil.
Definition: cs_gwf_soil.c:1714
cs_gwf_soil_t * cs_gwf_soil_by_name(const char *name)
Retrieve a soil structure from its name.
Definition: cs_gwf_soil.c:1100
void cs_gwf_soil_define_sspf_property(cs_property_t *moisture_content)
Set the definition of the soil porosity and absolute porosity (which are properties always defined)....
Definition: cs_gwf_soil.c:1524
const int * cs_gwf_soil_get_soil_state(void)
Get the array storing the soil state associated to each cell.
Definition: cs_gwf_soil.c:1660
cs_real_t cs_gwf_soil_get_porosity(int soil_id)
Get the porosity value for the given soil id.
Definition: cs_gwf_soil.c:1676
void cs_gwf_soil_log_setup(void)
Summary of the settings related to all cs_gwf_soil_t structures.
Definition: cs_gwf_soil.c:1252
void cs_gwf_soil_set_vgm_tpf_param(cs_gwf_soil_t *soil, double n, double pr_r, double sl_r, double sl_s)
Set the parameters related to a Van Genuchten-Mualen model to defined the behavior of a soil in the c...
Definition: cs_gwf_soil.c:1816
cs_gwf_soil_join_type_t
Kind of joining function used with closure laws.
Definition: cs_gwf_soil.h:137
@ CS_GWF_SOIL_JOIN_C1_POLY_ORDER2
Definition: cs_gwf_soil.h:142
@ CS_GWF_SOIL_JOIN_C1_HYPERBOLIC
Definition: cs_gwf_soil.h:140
@ CS_GWF_SOIL_JOIN_C1_EXPONENTIAL
Definition: cs_gwf_soil.h:141
@ CS_GWF_SOIL_N_JOINS
Definition: cs_gwf_soil.h:144
@ CS_GWF_SOIL_JOIN_NOTHING
Definition: cs_gwf_soil.h:139
void() cs_gwf_soil_free_param_t(void **p_param)
Generic function to set free the parameter structure associated to a soil.
Definition: cs_gwf_soil.h:92
void cs_gwf_soil_set_joining_poly_order(int order)
Set the value of the polynomial order considered when regularizing the Van Genuchten-Mualen soil law ...
cs_flag_t cs_property_type_t
Definition: cs_property.h:123
double precision, dimension(ncharm), save alpha
Definition: cpincl.f90:96
Definition: mesh.f90:26
Main structure to handle a soil in the groundwater flow module: its definition, the way to update its...
Definition: cs_gwf_soil.h:354
double abs_permeability[3][3]
Definition: cs_gwf_soil.h:438
cs_gwf_soil_free_param_t * free_model_param
Definition: cs_gwf_soil.h:446
void * model_param
Definition: cs_gwf_soil.h:441
double porosity
Definition: cs_gwf_soil.h:436
cs_gwf_soil_model_t model
Definition: cs_gwf_soil.h:440
void * hydraulic_context
Definition: cs_gwf_soil.h:432
int abs_permeability_dim
Definition: cs_gwf_soil.h:437
cs_gwf_soil_update_t * update_properties
Definition: cs_gwf_soil.h:445
double bulk_density
Definition: cs_gwf_soil.h:435
cs_gwf_model_type_t hydraulic_model
Definition: cs_gwf_soil.h:431
int id
Definition: cs_gwf_soil.h:428
int zone_id
Definition: cs_gwf_soil.h:429
Definition: cs_gwf_soil.h:221
cs_gwf_soil_join_type_t kr_jtype
Definition: cs_gwf_soil.h:318
cs_gwf_soil_join_type_t sle_jtype
Definition: cs_gwf_soil.h:317
double dkrldsl_star
Definition: cs_gwf_soil.h:337
double dsldpc_star
Definition: cs_gwf_soil.h:328
double sl_r
Definition: cs_gwf_soil.h:256
double pc_star
Definition: cs_gwf_soil.h:327
double inv_pr_r
Definition: cs_gwf_soil.h:255
double sl_range
Definition: cs_gwf_soil.h:258
double krl_star
Definition: cs_gwf_soil.h:336
double krl_alpha
Definition: cs_gwf_soil.h:338
double m
Definition: cs_gwf_soil.h:252
double sle_thres
Definition: cs_gwf_soil.h:319
double sl_s
Definition: cs_gwf_soil.h:257
double sle_beta
Definition: cs_gwf_soil.h:330
double krg_star
Definition: cs_gwf_soil.h:332
double inv_m
Definition: cs_gwf_soil.h:253
double n
Definition: cs_gwf_soil.h:251
cs_gwf_soil_tpf_eval_t * eval_properties
Definition: cs_gwf_soil.h:323
double sle_alpha
Definition: cs_gwf_soil.h:329
double krg_alpha
Definition: cs_gwf_soil.h:334
double dkrgdsl_star
Definition: cs_gwf_soil.h:333
double pr_r
Definition: cs_gwf_soil.h:254
Definition: cs_cdo_connect.h:61
Definition: cs_cdo_quantities.h:137
Structure to handle the Van Genuchten-Mualem model of soil in the case of a single-phase flow in a po...
Definition: cs_gwf_soil.h:182
double tortuosity
Definition: cs_gwf_soil.h:207
double residual_moisture
Definition: cs_gwf_soil.h:202
double m
Definition: cs_gwf_soil.h:205
double scale
Definition: cs_gwf_soil.h:206
double n
Definition: cs_gwf_soil.h:204
Structure to handle the Van Genuchten-Mualem model of soil in the case of a two-phase flow in a porou...
Definition: cs_mesh.h:85
Structure associated to the definition of a property relying on the cs_xdef_t structure.
Definition: cs_zone.h:55