7.1
general 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-2021 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 #include "cs_gwf_soil.h"
37 #include "cs_gwf_tracer.h"
38 
39 /*----------------------------------------------------------------------------*/
40 
42 
43 /*============================================================================
44  * Macro definitions
45  *============================================================================*/
46 
52 typedef enum {
53 
64 
78 
89 
93 
95 
102 typedef enum {
103 
104  /* -------- Main physical modelling */
105 
110  CS_GWF_GRAVITATION = 1<< 0, /* = 1 */
111 
112  /* --------- Main numerical options */
113 
120 
128 
133  CS_GWF_ENFORCE_DIVERGENCE_FREE = 1<< 8 /* = 256 */
134 
140 
170 #define CS_GWF_POST_SOIL_CAPACITY (1 << 0)
171 #define CS_GWF_POST_LIQUID_SATURATION (1 << 1)
172 #define CS_GWF_POST_PERMEABILITY (1 << 2)
173 #define CS_GWF_POST_DARCY_FLUX_BALANCE (1 << 3)
174 #define CS_GWF_POST_DARCY_FLUX_DIVERGENCE (1 << 4)
175 #define CS_GWF_POST_DARCY_FLUX_AT_BOUNDARY (1 << 5)
176 
181 /*============================================================================
182  * Type definitions
183  *============================================================================*/
184 
185 typedef struct _gwf_t cs_gwf_t;
186 
187 /*============================================================================
188  * Public function prototypes
189  *============================================================================*/
190 
191 /*----------------------------------------------------------------------------*/
197 /*----------------------------------------------------------------------------*/
198 
199 bool
200 cs_gwf_is_activated(void);
201 
202 /*----------------------------------------------------------------------------*/
212 /*----------------------------------------------------------------------------*/
213 
214 cs_gwf_t *
217  cs_gwf_option_flag_t option_flag);
218 
219 /*----------------------------------------------------------------------------*/
225 /*----------------------------------------------------------------------------*/
226 
227 cs_gwf_t *
228 cs_gwf_destroy_all(void);
229 
230 /*----------------------------------------------------------------------------*/
245 /*----------------------------------------------------------------------------*/
246 
247 void
249  cs_real_t l_viscosity,
250  cs_real_t g_viscosity,
251  cs_real_t l_diffusivity_h,
252  cs_real_t w_molar_mass,
253  cs_real_t h_molar_mass,
254  cs_real_t ref_temperature,
255  cs_real_t henry_constant);
256 
257 /*----------------------------------------------------------------------------*/
261 /*----------------------------------------------------------------------------*/
262 
263 void
264 cs_gwf_log_setup(void);
265 
266 /*----------------------------------------------------------------------------*/
273 /*----------------------------------------------------------------------------*/
274 
275 void
277  bool reset);
278 
279 /*----------------------------------------------------------------------------*/
286 /*----------------------------------------------------------------------------*/
287 
290 
291 /*----------------------------------------------------------------------------*/
298 /*----------------------------------------------------------------------------*/
299 
300 cs_real_t *
302 
303 /*----------------------------------------------------------------------------*/
315 /*----------------------------------------------------------------------------*/
316 
318 cs_gwf_add_soil(const char *z_name,
319  double bulk_density,
320  double sat_moisture,
321  cs_gwf_soil_hydraulic_model_t soil_model);
322 
323 /*----------------------------------------------------------------------------*/
337 /*----------------------------------------------------------------------------*/
338 
339 cs_gwf_tracer_t *
341  const char *eq_name,
342  const char *var_name);
343 
344 /*----------------------------------------------------------------------------*/
359 /*----------------------------------------------------------------------------*/
360 
361 cs_gwf_tracer_t *
362 cs_gwf_add_user_tracer(const char *eq_name,
363  const char *var_name,
364  cs_gwf_tracer_setup_t *setup,
365  cs_gwf_tracer_add_terms_t *add_terms);
366 
367 /*----------------------------------------------------------------------------*/
376 /*----------------------------------------------------------------------------*/
377 
378 cs_gwf_tracer_t *
379 cs_gwf_tracer_by_name(const char *eq_name);
380 
381 /*----------------------------------------------------------------------------*/
386 /*----------------------------------------------------------------------------*/
387 
388 void
390 
391 /*----------------------------------------------------------------------------*/
398 /*----------------------------------------------------------------------------*/
399 
400 void
401 cs_gwf_init_setup(void);
402 
403 /*----------------------------------------------------------------------------*/
411 /*----------------------------------------------------------------------------*/
412 
413 void
415  const cs_cdo_quantities_t *quant);
416 
417 /*----------------------------------------------------------------------------*/
428 /*----------------------------------------------------------------------------*/
429 
430 void
432  const cs_cdo_connect_t *connect,
433  const cs_cdo_quantities_t *quant,
434  const cs_time_step_t *ts,
435  bool cur2prev);
436 
437 /*----------------------------------------------------------------------------*/
447 /*----------------------------------------------------------------------------*/
448 
449 void
451  const cs_time_step_t *time_step,
452  const cs_cdo_connect_t *connect,
453  const cs_cdo_quantities_t *cdoq);
454 
455 /*----------------------------------------------------------------------------*/
464 /*----------------------------------------------------------------------------*/
465 
466 void
468  const cs_time_step_t *time_step,
469  const cs_cdo_connect_t *connect,
470  const cs_cdo_quantities_t *cdoq);
471 
472 /*----------------------------------------------------------------------------*/
486 /*----------------------------------------------------------------------------*/
487 
488 cs_real_t
490  const cs_cdo_quantities_t *cdoq,
491  const cs_gwf_tracer_t *tracer,
492  const char *z_name);
493 
494 /*----------------------------------------------------------------------------*/
501 /*----------------------------------------------------------------------------*/
502 
503 void
504 cs_gwf_extra_op(const cs_cdo_connect_t *connect,
505  const cs_cdo_quantities_t *cdoq);
506 
507 /*----------------------------------------------------------------------------*/
530 /*----------------------------------------------------------------------------*/
531 
532 void
533 cs_gwf_extra_post_sspf(void *input,
534  int mesh_id,
535  int cat_id,
536  int ent_flag[5],
537  cs_lnum_t n_cells,
538  cs_lnum_t n_i_faces,
539  cs_lnum_t n_b_faces,
540  const cs_lnum_t cell_ids[],
541  const cs_lnum_t i_face_ids[],
542  const cs_lnum_t b_face_ids[],
543  const cs_time_step_t *time_step);
544 
545 /*----------------------------------------------------------------------------*/
568 /*----------------------------------------------------------------------------*/
569 
570 void
571 cs_gwf_extra_post_uspf(void *input,
572  int mesh_id,
573  int cat_id,
574  int ent_flag[5],
575  cs_lnum_t n_cells,
576  cs_lnum_t n_i_faces,
577  cs_lnum_t n_b_faces,
578  const cs_lnum_t cell_ids[],
579  const cs_lnum_t i_face_ids[],
580  const cs_lnum_t b_face_ids[],
581  const cs_time_step_t *time_step);
582 
583 /*----------------------------------------------------------------------------*/
606 /*----------------------------------------------------------------------------*/
607 
608 void
609 cs_gwf_extra_post_mtpf(void *input,
610  int mesh_id,
611  int cat_id,
612  int ent_flag[5],
613  cs_lnum_t n_cells,
614  cs_lnum_t n_i_faces,
615  cs_lnum_t n_b_faces,
616  const cs_lnum_t cell_ids[],
617  const cs_lnum_t i_face_ids[],
618  const cs_lnum_t b_face_ids[],
619  const cs_time_step_t *time_step);
620 
621 /*----------------------------------------------------------------------------*/
622 
624 
625 #endif /* __CS_GWF_H__ */
void cs_gwf_init_setup(void)
Predefined settings for the Richards equation and the related equations defining the groundwater flow...
Definition: cs_gwf.c:2368
Definition: cs_gwf.h:90
Two phase flow modelling (gaz and liquid phases) in porous media.
Definition: cs_gwf.h:88
time step descriptor
Definition: cs_time_step.h:64
void cs_gwf_extra_op(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq)
Predefined extra-operations for the groundwater flow module.
Definition: cs_gwf.c:2706
Single phase (liquid phase) modelling in a porous media.
Definition: cs_gwf.h:77
void cs_gwf_log_setup(void)
Summary of the main cs_gwf_t structure.
Definition: cs_gwf.c:1896
Definition: cs_advection_field.h:149
cs_adv_field_t * cs_gwf_get_adv_field(void)
Retrieve the advection field related to the Darcy flux in the liquid phase.
Definition: cs_gwf.c:2107
void cs_gwf_compute_steady_state(const cs_mesh_t *mesh, const cs_time_step_t *time_step, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq)
Compute the steady-state of the groundwater flows module. Nothing is done if all equations are unstea...
Definition: cs_gwf.c:2537
cs_gwf_model_type_t model
Definition: cs_gwf_priv.h:501
cs_flag_t cs_gwf_option_flag_t
Definition: cs_gwf.h:94
cs_flag_t cs_gwf_tracer_model_t
Definition: cs_gwf_tracer.h:47
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
cs_real_t cs_gwf_integrate_tracer(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq, const cs_gwf_tracer_t *tracer, const char *z_name)
Compute the integral over a given set of cells of the field related to a tracer equation. This integral turns out to be exact for linear functions.
Definition: cs_gwf.c:2673
Main set of parameters/structures to manage the groundwater flow (GWF) module. This is an explicit de...
Definition: cs_gwf_priv.h:483
cs_gwf_model_type_t
Type of system of equation(s) to consider for the physical modelling.
Definition: cs_gwf.h:52
cs_gwf_t * cs_gwf_activate(cs_property_type_t pty_type, cs_gwf_model_type_t model, cs_gwf_option_flag_t option_flag)
Initialize the module dedicated to groundwater flows.
Definition: cs_gwf.c:1775
void cs_gwf_set_post_options(cs_flag_t post_flag, bool reset)
Set the flag dedicated to the post-processing of the GWF module.
Definition: cs_gwf.c:2063
Definition: cs_cdo_connect.h:79
cs_flag_t post_flag
Definition: cs_gwf_priv.h:503
Main structure to handle a soil in the groundawater flow module. Store a set of parameters and pointe...
Definition: cs_gwf_soil.h:221
Gravitation effects are taken into account in the Richards equation.
Definition: cs_gwf.h:110
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
Compute the mean-value of the hydraulic head field and subtract this mean-value to get a field with z...
Definition: cs_gwf.h:127
Single phase (liquid phase) modelling in a porous media.
Definition: cs_gwf.h:63
Definition: cs_cdo_quantities.h:129
void cs_gwf_extra_post_sspf(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_ids[], const cs_lnum_t i_face_ids[], const cs_lnum_t b_face_ids[], const cs_time_step_t *time_step)
Predefined post-processing output for the groundwater flow module in case of saturated single-phase f...
Definition: cs_gwf.c:2762
Definition: cs_mesh.h:84
void cs_gwf_finalize_setup(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant)
Last initialization step of the groundwater flow module. At this stage, the mesh quantities are defin...
Definition: cs_gwf.c:2408
void cs_gwf_extra_post_uspf(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_ids[], const cs_lnum_t i_face_ids[], const cs_lnum_t b_face_ids[], const cs_time_step_t *time_step)
Predefined post-processing output for the groundwater flow module in case of unsaturated single-phase...
Definition: cs_gwf.c:2901
bool cs_gwf_is_activated(void)
Check if the groundwater flow module has been activated.
Definition: cs_gwf.c:1754
void cs_gwf_compute(const cs_mesh_t *mesh, const cs_time_step_t *time_step, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq)
Compute the system related to groundwater flows module.
Definition: cs_gwf.c:2596
void cs_gwf_update(const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *ts, bool cur2prev)
Update the groundwater system (pressure head, head in law, moisture content, darcian velocity...
Definition: cs_gwf.c:2475
cs_gwf_tracer_t * cs_gwf_add_user_tracer(const char *eq_name, const char *var_name, cs_gwf_tracer_setup_t *setup, cs_gwf_tracer_add_terms_t *add_terms)
Add a new equation related to the groundwater flow module This equation is a particular type of unste...
Definition: cs_gwf.c:2275
cs_gwf_soil_t * cs_gwf_add_soil(const char *z_name, double bulk_density, double sat_moisture, cs_gwf_soil_hydraulic_model_t soil_model)
Create and add a new cs_gwf_soil_t structure. An initialization by default of all members is performe...
Definition: cs_gwf.c:2160
Activate a treatment to enforce a Darcy flux to be divergence-free.
Definition: cs_gwf.h:133
void cs_gwf_extra_post_mtpf(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_ids[], const cs_lnum_t i_face_ids[], const cs_lnum_t b_face_ids[], const cs_time_step_t *time_step)
Predefined post-processing output for the groundwater flow module in case of miscible two-phase flows...
Definition: cs_gwf.c:2984
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
Even if the Richards equation is steady-state, this equation is solved at each iteration.
Definition: cs_gwf.h:119
cs_gwf_model_bit_t
Elemental modelling choice either from the physical viewpoint or the numerical viewpoint.
Definition: cs_gwf.h:102
cs_gwf_soil_hydraulic_model_t
Predefined hydraulic model of soils used in the groundwater flow module.
Definition: cs_gwf_soil.h:119
#define END_C_DECLS
Definition: cs_defs.h:511
unsigned short int cs_flag_t
Definition: cs_defs.h:324
cs_flag_t cs_property_type_t
Definition: cs_property.h:102
void cs_gwf_add_tracer_terms(void)
Add new terms if needed (such as diffusion or reaction) to tracer equations according to the settings...
Definition: cs_gwf.c:2346
cs_gwf_t * cs_gwf_destroy_all(void)
Free all structures related to groundwater flows.
Definition: cs_gwf.c:1832
cs_gwf_tracer_t * cs_gwf_add_tracer(cs_gwf_tracer_model_t tr_model, const char *eq_name, const char *var_name)
Add a new equation related to the groundwater flow module This equation is a particular type of unste...
Definition: cs_gwf.c:2215
Definition: mesh.f90:26
void cs_gwf_set_two_phase_model(cs_real_t l_mass_density, cs_real_t l_viscosity, cs_real_t g_viscosity, cs_real_t l_diffusivity_h, cs_real_t w_molar_mass, cs_real_t h_molar_mass, cs_real_t ref_temperature, cs_real_t henry_constant)
Set the parameters defining the two-phase flow model. Use SI unit if not prescribed otherwise...
Definition: cs_gwf.c:2013
void() cs_gwf_tracer_add_terms_t(cs_gwf_tracer_t *tracer)
Generic function to update the terms to build in the algebraic system for a tracer equation according...
Definition: cs_gwf_tracer.h:271
cs_real_t * cs_gwf_get_uspf_head_in_law(void)
Retrieve the head used in soil updates when an unsaturated single-phase flow is considered. These values are located at cells.
Definition: cs_gwf.c:2127
cs_gwf_tracer_t * cs_gwf_tracer_by_name(const char *eq_name)
Retrieve the pointer to the cs_gwf_tracer_t structure associated to the name given as parameter...
Definition: cs_gwf.c:2319
void() cs_gwf_tracer_setup_t(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_adv_field_t *adv, const cs_real_t *l_saturation, cs_gwf_tracer_t *tracer)
Generic function to set the parameters related to a tracer equation.
Definition: cs_gwf_tracer.h:255