7.1
general documentation
cs_gwf_tracer.h
Go to the documentation of this file.
1 #ifndef __CS_GWF_TRACER_H__
2 #define __CS_GWF_TRACER_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-2021 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_advection_field.h"
36 #include "cs_base.h"
37 #include "cs_equation.h"
38 
39 /*----------------------------------------------------------------------------*/
40 
42 
43 /*============================================================================
44  * Typedef definition
45  *============================================================================*/
46 
48 
49 typedef struct _gwf_tracer_t cs_gwf_tracer_t;
50 
51 /*============================================================================
52  * Public function pointer prototypes
53  *============================================================================*/
54 
55 /*----------------------------------------------------------------------------*/
66 /*----------------------------------------------------------------------------*/
67 
68 typedef void
69 (cs_gwf_tracer_update_t) (cs_gwf_tracer_t *tracer,
70  cs_real_t t_eval,
71  const cs_mesh_t *mesh,
72  const cs_cdo_connect_t *connect,
73  const cs_cdo_quantities_t *quant);
74 
75 /*----------------------------------------------------------------------------*/
81 /*----------------------------------------------------------------------------*/
82 
83 typedef void
84 (cs_gwf_tracer_free_context_t) (cs_gwf_tracer_t *tracer);
85 
86 /*============================================================================
87  * Structure definitions
88  *============================================================================*/
89 
100 /* Type of predefined modelling for the groundwater flows */
101 typedef enum {
102 
109  CS_GWF_TRACER_USER = 1<< 0, /* = 1 */
110 
111  /* Physical phenomena to consider */
112  /* ------------------------------ */
113 
122 
133 
138  CS_GWF_TRACER_PRECIPITATION = 1<< 4, /* = 16 */
139 
141 
144 /* Set of parameters related to a tracer equation attached to a standard
145  modelling */
146 
147 typedef struct {
148 
149  /* Parameters to determine the behavior in each soil
150  * (array of size: n_soils)
151  */
152 
153  /* Common settings shared by all physical modelling */
154  /* ------------------------------------------------ */
155 
156  double *rho_bulk; /* bulk density (kg.m^-3) */
157  double *kd0; /* reference value of the distribution coefficient
158  (m^".kg^-1) */
159  double *rho_kd; /* Derived quantity: rho_bulk*kd0 */
160 
161  double *alpha_l; /* Longitudinal dispersivity */
162  double *alpha_t; /* Transversal dispersivity */
163 
164  double *wmd; /* Water molecular diffusivity (m^2.s^-1) */
165 
166  double *reaction_rate; /* First order decay coefficient (related to the
167  reaction term) */
168 
169  /* Precipitation members (set to NULL if not used) */
170  /* ----------------------------------------------- */
171 
172  double *conc_w_star; /* maximal value of the concentraction of tracer
173  in the liquid phase. Exceeded quantities are
174  stored in the solid phase (->
175  conc_precip). These values corresponds to the
176  user settings */
177 
178  cs_real_t *conc_satura; /* array storing the value of the saturated
179  concentration in the liquid phase at vertices
180  (only used in case of CDOVB schemes or CDOVCB
181  schemes */
182  cs_real_t *conc_precip; /* array storing the concentration in the
183  precipitation (solid) storage. The size may
184  vary w.r.t. to the discrtization scheme.
185  */
186 
188 
189  /* Sorption members (set to NULL if not used) */
190  /* ------------------------------------------ */
191 
192  double *k0_plus; /* kinetic coefficient towards site 2 locations
193  (m^3.kg^-1.s^-1) */
194  double *k0_minus; /* kinetic coefficient from site 2 locations
195  (s^-1) */
196 
197  cs_real_t *conc_site2; /* array allocated to n_cells */
198 
199  /* Variables used for the update of physical properties (shared pointers) */
200 
202 
203  /* liquid saturation also called the moisture content, denoted by \theta
204  (-) no unit */
206 
208 
209 /* Set of parameters describing a tracer structure */
210 /* ----------------------------------------------- */
211 
213 
214  int id; /* tracer id */
215  cs_equation_t *eq; /* related equation */
216 
217  /* Physical modelling adopted for this tracer */
218 
220 
221  cs_field_t *diffusivity; /* NULL if no diffusion term is
222  build in the tracer equation */
223  int reaction_id; /* id related to the reaction
224  term in the tracer equation */
225 
226  /* Pointer to a context structure according to the model */
227 
228  void *context;
229 
230  /* Pointers to functions */
231 
235 
236 };
237 
238 /*============================================================================
239  * Public function pointer prototypes
240  *============================================================================*/
241 
242 /*----------------------------------------------------------------------------*/
252 /*----------------------------------------------------------------------------*/
253 
254 typedef void
256  const cs_cdo_quantities_t *quant,
257  const cs_adv_field_t *adv,
258  const cs_real_t *l_saturation,
259  cs_gwf_tracer_t *tracer);
260 
261 /*----------------------------------------------------------------------------*/
268 /*----------------------------------------------------------------------------*/
269 
270 typedef void
271 (cs_gwf_tracer_add_terms_t) (cs_gwf_tracer_t *tracer);
272 
273 /*============================================================================
274  * Public function prototypes
275  *============================================================================*/
276 
277 /*----------------------------------------------------------------------------*/
295 /*----------------------------------------------------------------------------*/
296 
297 cs_gwf_tracer_t *
298 cs_gwf_tracer_init(int tracer_id,
299  const char *eq_name,
300  const char *var_name,
301  cs_adv_field_t *adv_field,
303 
304 /*----------------------------------------------------------------------------*/
312 /*----------------------------------------------------------------------------*/
313 
314 cs_gwf_tracer_t *
315 cs_gwf_tracer_free(cs_gwf_tracer_t *tracer);
316 
317 /*----------------------------------------------------------------------------*/
331 /*----------------------------------------------------------------------------*/
332 
333 void
334 cs_gwf_set_main_tracer_param(cs_gwf_tracer_t *tracer,
335  const char *soil_name,
336  double wmd,
337  double alpha_l,
338  double alpha_t,
339  double distrib_coef,
340  double reaction_rate);
341 
342 /*----------------------------------------------------------------------------*/
353 /*----------------------------------------------------------------------------*/
354 
355 void
356 cs_gwf_set_precip_tracer_param(cs_gwf_tracer_t *tracer,
357  const char *soil_name,
358  double conc_w_star);
359 
360 /*----------------------------------------------------------------------------*/
369 /*----------------------------------------------------------------------------*/
370 
371 void
372 cs_gwf_tracer_add_terms(cs_gwf_tracer_t *tracer);
373 
374 /*----------------------------------------------------------------------------*/
385 /*----------------------------------------------------------------------------*/
386 
387 void
389  const cs_cdo_quantities_t *quant,
390  const cs_adv_field_t *adv,
391  const cs_real_t *l_saturation,
392  cs_gwf_tracer_t *tracer);
393 
394 /*----------------------------------------------------------------------------*/
405 /*----------------------------------------------------------------------------*/
406 
407 void
409  const cs_cdo_quantities_t *quant,
410  const cs_adv_field_t *adv,
411  const cs_real_t *l_saturation,
412  cs_gwf_tracer_t *tracer);
413 
414 /*----------------------------------------------------------------------------*/
420 /*----------------------------------------------------------------------------*/
421 
422 void
423 cs_gwf_tracer_log_setup(const cs_gwf_tracer_t *tracer);
424 
425 /*----------------------------------------------------------------------------*/
438 /*----------------------------------------------------------------------------*/
439 
440 cs_real_t
442  const cs_cdo_quantities_t *cdoq,
443  const cs_gwf_tracer_t *tracer,
444  const cs_zone_t *z);
445 
446 /*----------------------------------------------------------------------------*/
460 /*----------------------------------------------------------------------------*/
461 
462 cs_real_t
464  const cs_cdo_quantities_t *cdoq,
465  const cs_gwf_tracer_t *tracer,
466  const cs_zone_t *z);
467 
468 /*----------------------------------------------------------------------------*/
469 
471 
472 #endif /* __CS_GWF_TRACER_H__ */
double * k0_plus
Definition: cs_gwf_tracer.h:192
double * rho_kd
Definition: cs_gwf_tracer.h:159
int id
Definition: cs_gwf_tracer.h:214
cs_equation_t * eq
Definition: cs_gwf_tracer.h:215
Definition: cs_advection_field.h:149
cs_gwf_tracer_model_t model
Definition: cs_gwf_tracer.h:219
double * conc_w_star
Definition: cs_gwf_tracer.h:172
void cs_gwf_set_main_tracer_param(cs_gwf_tracer_t *tracer, const char *soil_name, double wmd, double alpha_l, double alpha_t, double distrib_coef, double reaction_rate)
For a specified soil set the main parameters corresponding to a default modelling of a tracer transpo...
Definition: cs_gwf_tracer.c:1079
Field descriptor.
Definition: cs_field.h:125
cs_field_t * precip_field
Definition: cs_gwf_tracer.h:187
double * alpha_t
Definition: cs_gwf_tracer.h:162
cs_real_t * conc_precip
Definition: cs_gwf_tracer.h:182
cs_flag_t cs_gwf_tracer_model_t
Definition: cs_gwf_tracer.h:47
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
int reaction_id
Definition: cs_gwf_tracer.h:223
const cs_field_t * darcy_velocity_field
Definition: cs_gwf_tracer.h:201
Definition: cs_cdo_connect.h:79
EK model with 5 parameters.
Definition: cs_gwf_tracer.h:132
Definition: cs_gwf_tracer.h:147
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
Definition: cs_cdo_quantities.h:129
void cs_gwf_tracer_log_setup(const cs_gwf_tracer_t *tracer)
Display the main features related to a tracer.
Definition: cs_gwf_tracer.c:1496
cs_field_t * diffusivity
Definition: cs_gwf_tracer.h:221
double * kd0
Definition: cs_gwf_tracer.h:157
double * alpha_l
Definition: cs_gwf_tracer.h:161
Definition: cs_mesh.h:84
cs_gwf_tracer_update_t * update_precipitation
Definition: cs_gwf_tracer.h:233
double * reaction_rate
Definition: cs_gwf_tracer.h:166
cs_gwf_tracer_model_bit_t
Flags specifying the general behavior of a tracer associated to the groundwater flow module...
Definition: cs_gwf_tracer.h:101
EK model with 3 parameters.
Definition: cs_gwf_tracer.h:121
const cs_real_t * l_saturation
Definition: cs_gwf_tracer.h:205
cs_gwf_tracer_update_t * update_diff_tensor
Definition: cs_gwf_tracer.h:232
cs_real_t * conc_site2
Definition: cs_gwf_tracer.h:197
cs_real_t cs_gwf_tracer_integrate_sat(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq, const cs_gwf_tracer_t *tracer, const cs_zone_t *z)
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. Case of a fully saturated model.
Definition: cs_gwf_tracer.c:1644
cs_gwf_tracer_t * cs_gwf_tracer_free(cs_gwf_tracer_t *tracer)
Free a cs_gwf_tracer_t structure.
Definition: cs_gwf_tracer.c:1047
void cs_gwf_tracer_saturated_setup(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)
Set the parameters related to a standard tracer equation case of a fully saturated flow model...
Definition: cs_gwf_tracer.c:1309
void() cs_gwf_tracer_update_t(cs_gwf_tracer_t *tracer, cs_real_t t_eval, const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant)
Generic function to update the phisical properties related to a tracer modelling. ...
Definition: cs_gwf_tracer.h:69
double * k0_minus
Definition: cs_gwf_tracer.h:194
double * wmd
Definition: cs_gwf_tracer.h:164
cs_gwf_tracer_t * cs_gwf_tracer_init(int tracer_id, const char *eq_name, const char *var_name, cs_adv_field_t *adv_field, cs_gwf_tracer_model_t model)
Create a new cs_gwf_tracer_t structure and initialize its members by default. Add a new equation rela...
Definition: cs_gwf_tracer.c:923
void cs_gwf_set_precip_tracer_param(cs_gwf_tracer_t *tracer, const char *soil_name, double conc_w_star)
For a specified soil set the parameters corresponding to a precipitation modelling of a tracer transp...
Definition: cs_gwf_tracer.c:1147
cs_real_t * conc_satura
Definition: cs_gwf_tracer.h:178
Add the precipitation phenomena to the default tracer equation.
Definition: cs_gwf_tracer.h:138
#define END_C_DECLS
Definition: cs_defs.h:511
unsigned short int cs_flag_t
Definition: cs_defs.h:324
void * context
Definition: cs_gwf_tracer.h:228
User-defined tracer.
Definition: cs_gwf_tracer.h:109
void cs_gwf_tracer_add_terms(cs_gwf_tracer_t *tracer)
Add terms to the algebraic system related to a tracer equation according to the settings. Case of the standard tracer modelling Rely on the generic function: cs_gwf_tracer_add_terms_t.
Definition: cs_gwf_tracer.c:1195
cs_gwf_tracer_free_context_t * free_context
Definition: cs_gwf_tracer.h:234
Main structure to handle the discretization and the resolution of an equation.
cs_real_t cs_gwf_tracer_integrate(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq, const cs_gwf_tracer_t *tracer, const cs_zone_t *z)
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_tracer.c:1540
double * rho_bulk
Definition: cs_gwf_tracer.h:156
void() cs_gwf_tracer_free_context_t(cs_gwf_tracer_t *tracer)
Generic function to free the input of a tracer model.
Definition: cs_gwf_tracer.h:84
Definition: mesh.f90:26
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
void cs_gwf_tracer_unsaturated_setup(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)
Set the parameters related to a standard tracer equation in case of an unsaturated flow model...
Definition: cs_gwf_tracer.c:1406
Definition: cs_gwf_tracer.h:212
Definition: cs_zone.h:55
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