9.2
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-2026 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 "base/cs_base.h"
36#include "cdo/cs_cdo_connect.h"
38#include "gwf/cs_gwf_param.h"
40#include "mesh/cs_mesh.h"
41#include "cdo/cs_property.h"
42#include "base/cs_volume_zone.h"
43
44/*============================================================================
45 * Macro definitions
46 *============================================================================*/
47
48/*============================================================================
49 * Public function pointer prototypes
50 *============================================================================*/
51
53typedef struct _gwf_soil_t cs_gwf_soil_t;
54
55/*----------------------------------------------------------------------------*/
68/*----------------------------------------------------------------------------*/
69
70typedef void
71(cs_gwf_soil_update_t) (const cs_real_t t_eval,
72 const cs_mesh_t *mesh,
73 const cs_cdo_connect_t *connect,
74 const cs_cdo_quantities_t *quant,
75 const cs_zone_t *zone,
76 cs_gwf_soil_t *soil);
77
78/*----------------------------------------------------------------------------*/
85/*----------------------------------------------------------------------------*/
86
87typedef void
88(cs_gwf_soil_free_param_t)(void **p_param);
89
90/*----------------------------------------------------------------------------*/
101/*----------------------------------------------------------------------------*/
102
103typedef void
105 const double pc,
106 double *sl,
107 double *dsldpc,
108 double *krl,
109 double *krg);
110
111/*============================================================================
112 * Type definitions
113 *============================================================================*/
114
133typedef enum {
134
139
141
143
159typedef enum {
160
164
166
168
178typedef struct {
179
199
200 double n;
201 double m;
202 double scale;
204
206
218
247 double n;
248 double m;
249 double inv_m;
250 double pr_r;
251 double inv_pr_r;
252 double sl_r;
253 double sl_s;
254 double sl_range;
255
315 double sle_thres;
316
317 /* Function pointer */
318
320
321 /* Derived quantities */
322
323 double pc_star;
325 double sle_alpha;
326 double sle_beta;
327
328 double krg_star;
330 double krg_alpha;
331
332 double krl_star;
334 double krl_alpha;
335
336};
337
339
351
424 int id;
426
429
430
432 double porosity;
434 double abs_permeability[3][3];
435
438
439 /* Pointers to functions */
440
443
444};
445
446/*============================================================================
447 * User-defined function prototypes
448 *============================================================================*/
449
450/*============================================================================
451 * Public function prototypes
452 *============================================================================*/
453
454/*----------------------------------------------------------------------------*/
460/*----------------------------------------------------------------------------*/
461
462int
464
465/*----------------------------------------------------------------------------*/
481/*----------------------------------------------------------------------------*/
482
483cs_gwf_soil_t *
484cs_gwf_soil_create(const cs_zone_t *zone,
485 cs_gwf_model_type_t hydraulic_model,
487 cs_property_type_t perm_type,
488 double k_abs[3][3],
489 double porosity,
490 double bulk_density,
491 void *hydraulic_context);
492
493/*----------------------------------------------------------------------------*/
501/*----------------------------------------------------------------------------*/
502
503cs_gwf_soil_t *
504cs_gwf_soil_by_id(int id);
505
506/*----------------------------------------------------------------------------*/
514/*----------------------------------------------------------------------------*/
515
516cs_gwf_soil_t *
517cs_gwf_soil_by_name(const char *name);
518
519/*----------------------------------------------------------------------------*/
527/*----------------------------------------------------------------------------*/
528
529const cs_zone_t *
530cs_gwf_soil_get_zone(int soil_id);
531
532/*----------------------------------------------------------------------------*/
536/*----------------------------------------------------------------------------*/
537
538void
540
541/*----------------------------------------------------------------------------*/
549/*----------------------------------------------------------------------------*/
550
551void
553 cs_flag_t post_flag,
554 cs_lnum_t n_cells);
555
556/*----------------------------------------------------------------------------*/
560/*----------------------------------------------------------------------------*/
561
562void
564
565/*----------------------------------------------------------------------------*/
574/*----------------------------------------------------------------------------*/
575
576void
578 const cs_mesh_t *mesh,
579 const cs_cdo_connect_t *connect,
580 const cs_cdo_quantities_t *cdoq);
581
582/*----------------------------------------------------------------------------*/
590/*----------------------------------------------------------------------------*/
591
592void
594 const cs_real_t *sliq);
595
596/*----------------------------------------------------------------------------*/
605/*----------------------------------------------------------------------------*/
606
607void
609 cs_property_t *soil_porosity);
610
611/*----------------------------------------------------------------------------*/
619/*----------------------------------------------------------------------------*/
620
621void
623
624/*----------------------------------------------------------------------------*/
634/*----------------------------------------------------------------------------*/
635
636void
638 const cs_cdo_connect_t *connect);
639
640/*----------------------------------------------------------------------------*/
647/*----------------------------------------------------------------------------*/
648
649const double *
651
652/*----------------------------------------------------------------------------*/
658/*----------------------------------------------------------------------------*/
659
660const short int *
662
663/*----------------------------------------------------------------------------*/
669/*----------------------------------------------------------------------------*/
670
671const int *
673
674/*----------------------------------------------------------------------------*/
682/*----------------------------------------------------------------------------*/
683
685cs_gwf_soil_get_porosity(int soil_id);
686
687/*----------------------------------------------------------------------------*/
695/*----------------------------------------------------------------------------*/
696
699
700/*----------------------------------------------------------------------------*/
707/*----------------------------------------------------------------------------*/
708
709int
711
712/*----------------------------------------------------------------------------*/
732/*----------------------------------------------------------------------------*/
733
734void
735cs_gwf_soil_set_vgm_spf_param(cs_gwf_soil_t *soil,
736 double theta_r,
737 double alpha,
738 double n,
739 double L);
740
741/*----------------------------------------------------------------------------*/
763/*----------------------------------------------------------------------------*/
764
765void
766cs_gwf_soil_set_vgm_tpf_param(cs_gwf_soil_t *soil,
767 double n,
768 double pr_r,
769 double sl_r,
770 double sl_s);
771
772/*----------------------------------------------------------------------------*/
783/*----------------------------------------------------------------------------*/
784
785void
787 cs_gwf_soil_join_type_t sle_jtype,
789 double sle_thres);
790
791/*----------------------------------------------------------------------------*/
800/*----------------------------------------------------------------------------*/
801
802void
803cs_gwf_soil_set_user_model_param(cs_gwf_soil_t *soil,
804 void *param,
805 cs_gwf_soil_update_t *update_func,
806 cs_gwf_soil_free_param_t *free_param_func);
807
808/*----------------------------------------------------------------------------*/
818/*----------------------------------------------------------------------------*/
819
820void
822
823/*----------------------------------------------------------------------------*/
824
825#endif /* CS_GWF_SOIL_H */
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
unsigned short int cs_flag_t
Definition: cs_defs.h:334
cs_gwf_model_type_t
Type of system of equation(s) to consider for the physical modelling.
Definition: cs_gwf_param.h:123
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.cpp:1715
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.cpp:1991
const int * cs_gwf_soil_get_soil_state(void)
Get the array storing the soil state associated to each cell.
Definition: cs_gwf_soil.cpp:1678
cs_gwf_soil_t * cs_gwf_soil_by_id(int id)
Retrieve a soil structure from its id.
Definition: cs_gwf_soil.cpp:1086
int cs_gwf_get_n_soils(void)
Get the number of allocated soils.
Definition: cs_gwf_soil.cpp:914
cs_gwf_soil_state_t
Kind of state in which a cell is.
Definition: cs_gwf_soil.h:159
@ CS_GWF_SOIL_STATE_UNSATURATED
Definition: cs_gwf_soil.h:162
@ CS_GWF_SOIL_STATE_SATURATED
Definition: cs_gwf_soil.h:161
@ CS_GWF_SOIL_STATE_DRY
Definition: cs_gwf_soil.h:163
@ CS_GWF_SOIL_N_STATES
Definition: cs_gwf_soil.h:165
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.cpp:1224
cs_gwf_soil_t * cs_gwf_soil_by_name(const char *name)
Retrieve a soil structure from its name.
Definition: cs_gwf_soil.cpp:1105
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.cpp:938
void cs_gwf_soil_free_all(void)
Free all cs_gwf_soil_t structures.
Definition: cs_gwf_soil.cpp:1154
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.cpp:1416
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.cpp:1897
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.cpp:1461
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:104
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:71
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.cpp:1490
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.cpp:1778
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.cpp:1581
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.cpp:1732
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.cpp:1542
const short int * cs_gwf_soil_get_cell2soil(void)
Get the array storing the associated soil for each cell.
Definition: cs_gwf_soil.cpp:1664
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.cpp:1650
cs_real_t cs_gwf_soil_get_porosity(int soil_id)
Get the porosity value for the given soil id.
Definition: cs_gwf_soil.cpp:1694
void cs_gwf_soil_log_setup(void)
Summary of the settings related to all cs_gwf_soil_t structures.
Definition: cs_gwf_soil.cpp:1257
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.cpp:1135
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.cpp:1836
cs_gwf_soil_join_type_t
Kind of joining function used with closure laws.
Definition: cs_gwf_soil.h:133
@ CS_GWF_SOIL_JOIN_C1_POLY_ORDER2
Definition: cs_gwf_soil.h:138
@ CS_GWF_SOIL_JOIN_C1_HYPERBOLIC
Definition: cs_gwf_soil.h:136
@ CS_GWF_SOIL_JOIN_C1_EXPONENTIAL
Definition: cs_gwf_soil.h:137
@ CS_GWF_SOIL_N_JOINS
Definition: cs_gwf_soil.h:140
@ CS_GWF_SOIL_JOIN_NOTHING
Definition: cs_gwf_soil.h:135
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:88
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:119
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:350
double abs_permeability[3][3]
Definition: cs_gwf_soil.h:434
cs_gwf_soil_free_param_t * free_model_param
Definition: cs_gwf_soil.h:442
void * model_param
Definition: cs_gwf_soil.h:437
double porosity
Definition: cs_gwf_soil.h:432
cs_gwf_soil_model_t model
Definition: cs_gwf_soil.h:436
void * hydraulic_context
Definition: cs_gwf_soil.h:428
int abs_permeability_dim
Definition: cs_gwf_soil.h:433
cs_gwf_soil_update_t * update_properties
Definition: cs_gwf_soil.h:441
double bulk_density
Definition: cs_gwf_soil.h:431
cs_gwf_model_type_t hydraulic_model
Definition: cs_gwf_soil.h:427
int id
Definition: cs_gwf_soil.h:424
int zone_id
Definition: cs_gwf_soil.h:425
Definition: cs_gwf_soil.h:217
cs_gwf_soil_join_type_t kr_jtype
Definition: cs_gwf_soil.h:314
cs_gwf_soil_join_type_t sle_jtype
Definition: cs_gwf_soil.h:313
double dkrldsl_star
Definition: cs_gwf_soil.h:333
double dsldpc_star
Definition: cs_gwf_soil.h:324
double sl_r
Definition: cs_gwf_soil.h:252
double pc_star
Definition: cs_gwf_soil.h:323
double inv_pr_r
Definition: cs_gwf_soil.h:251
double sl_range
Definition: cs_gwf_soil.h:254
double krl_star
Definition: cs_gwf_soil.h:332
double krl_alpha
Definition: cs_gwf_soil.h:334
double m
Definition: cs_gwf_soil.h:248
double sle_thres
Definition: cs_gwf_soil.h:315
double sl_s
Definition: cs_gwf_soil.h:253
double sle_beta
Definition: cs_gwf_soil.h:326
double krg_star
Definition: cs_gwf_soil.h:328
double inv_m
Definition: cs_gwf_soil.h:249
double n
Definition: cs_gwf_soil.h:247
cs_gwf_soil_tpf_eval_t * eval_properties
Definition: cs_gwf_soil.h:319
double sle_alpha
Definition: cs_gwf_soil.h:325
double krg_alpha
Definition: cs_gwf_soil.h:330
double dkrgdsl_star
Definition: cs_gwf_soil.h:329
double pr_r
Definition: cs_gwf_soil.h:250
Definition: cs_cdo_connect.h:57
Definition: cs_cdo_quantities.h:142
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:178
double tortuosity
Definition: cs_gwf_soil.h:203
double residual_moisture
Definition: cs_gwf_soil.h:198
double m
Definition: cs_gwf_soil.h:201
double scale
Definition: cs_gwf_soil.h:202
double n
Definition: cs_gwf_soil.h:200
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:51