8.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-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_advection_field.h"
36 #include "cs_base.h"
37 #include "cs_equation.h"
38 #include "cs_gwf_param.h"
39 
40 /*----------------------------------------------------------------------------*/
41 
43 
44 /*============================================================================
45  * Typedef definition
46  *============================================================================*/
47 
53 typedef struct _gwf_tracer_t cs_gwf_tracer_t;
54 
55 /* \struct cs_gwf_tracer_default_context_t
56  *
57  * \brief Set of parameters related to a tracer equation attached to a standard
58  * modelling
59  */
60 
61 typedef struct _gwf_tracer_default_context_t cs_gwf_tracer_default_context_t;
62 
63 /*============================================================================
64  * Public function pointer prototypes
65  *============================================================================*/
66 
67 /*----------------------------------------------------------------------------*/
74 /*----------------------------------------------------------------------------*/
75 
76 typedef void
78 
79 /*----------------------------------------------------------------------------*/
90 /*----------------------------------------------------------------------------*/
91 
92 typedef void
94  const cs_cdo_quantities_t *quant,
95  const cs_adv_field_t *adv,
96  cs_gwf_tracer_t *tracer);
97 
98 /*----------------------------------------------------------------------------*/
110 /*----------------------------------------------------------------------------*/
111 
112 typedef void
114  void *context,
115  const cs_time_step_t *ts,
116  const cs_mesh_t *mesh,
117  const cs_cdo_connect_t *connect,
118  const cs_cdo_quantities_t *quant);
119 
120 /*----------------------------------------------------------------------------*/
126 /*----------------------------------------------------------------------------*/
127 
128 typedef void
130 
131 /*----------------------------------------------------------------------------*/
146 /*----------------------------------------------------------------------------*/
147 
148 typedef void
150  const cs_cdo_quantities_t *cdoq,
151  const cs_equation_t *eq,
152  const cs_zone_t *zone,
153  void *context,
154  double results[]);
155 
156 /*============================================================================
157  * Structure definitions
158  *============================================================================*/
159 
160 /* Structure to handle of radioactive decay chain */
161 
162 typedef struct {
163 
164  char *name; /* Name of the decay chain */
165  int id; /* Position in the array of chain decays */
166 
167  int n_tracers; /* Number of tracers in the decay chain */
168  cs_gwf_tracer_unit_t unit; /* Type of unit measure:
169  * - mole (classical tracer)
170  * - Becquerel (activity)
171  */
172 
173  cs_gwf_tracer_t **tracers; /* Array of tracers associated to the
174  decay chain. tracers[0] is the parent
175  without any ancestor. */
176 
177  cs_xdef_t **st_defs; /* List of source term definitions */
178 
180 
181 /* Set of parameters related to a tracer equation attached to a standard
182  modelling */
183 
185 
186  /* Common settings shared by all physical modelling */
187  /* ------------------------------------------------ */
188 
189  double decay_coef; /* First order decay coefficient (related to the
190  reaction term). This value is intrinsic to the
191  component (a radioactive element for instance)
192  and not to the soil. */
193 
194  /* The following parameters are defined for each soil (arrays of size equal
195  * to n_soils) */
196 
197  double *rho_bulk; /* bulk density (kg.m^-3) */
198  double *kd0; /* reference value of the distribution coefficient
199  (m^".kg^-1) */
200  double *rho_kd; /* Derived quantity: rho_bulk*kd0 */
201 
202  double *alpha_l; /* Longitudinal dispersivity */
203  double *alpha_t; /* Transversal dispersivity */
204 
205  double *wmd; /* Water molecular diffusivity (m^2.s^-1) */
206 
207  /* Precipitation members (set to NULL if not used) */
208  /* ----------------------------------------------- */
209 
210  double *conc_l_star; /* maximal value of the concentration of
211  * tracer in the liquid phase in mol/m^3. There
212  * is one user-defined value for each soil. The
213  * exceeded quantities are stored in the solid
214  * phase (-> precip_mass). These values
215  * corresponds to the user settings
216  */
217 
218  cs_real_t *precip_mass; /* array storing the mass of precipitate
219  * (solid) in the dedicated auxiliary
220  * storage. The size of this array may vary
221  * w.r.t. to the discretization scheme.
222  */
223 
224  cs_field_t *precip_field; /* field structure storing the (interpolated)
225  * values of the concentration of precipitate
226  * in mol/kg in each cell.
227  */
228 
229  /* Sorption members (set to NULL if not used) */
230  /* ------------------------------------------ */
231 
232  double *k0_plus; /* kinetic coefficient towards site 2 locations
233  (m^3.kg^-1.s^-1) */
234  double *k0_minus; /* kinetic coefficient from site 2 locations
235  (s^-1) */
236 
237  cs_real_t *conc_site2; /* array allocated to n_cells whatever the
238  space discretization is */
239 
240  /* Variables used for the update of physical properties (shared pointers) */
241 
243 
244 };
245 
246 /* Set of parameters describing a tracer structure */
247 /* ----------------------------------------------- */
248 
250 
262 
269 
276 
284 
296 
302  void *context;
303 
311 
317  int chain_id;
318 
363 
365 
369 
373 };
374 
375 /*============================================================================
376  * Public function prototypes
377  *============================================================================*/
378 
379 /*----------------------------------------------------------------------------*/
388 /*----------------------------------------------------------------------------*/
389 
391 cs_gwf_tracer_by_name(const char *eq_name);
392 
393 /*----------------------------------------------------------------------------*/
419 /*----------------------------------------------------------------------------*/
420 
423  cs_gwf_model_type_t gwf_model,
424  const char *eq_name,
425  const char *var_name,
426  cs_adv_field_t *adv_field,
427  double lambda,
428  int chain_position,
429  int chain_id,
430  cs_gwf_tracer_init_setup_t *init_setup,
431  cs_gwf_tracer_finalize_setup_t *finalize_setup);
432 
433 /*----------------------------------------------------------------------------*/
437 /*----------------------------------------------------------------------------*/
438 
439 void
441 
442 /*----------------------------------------------------------------------------*/
449 /*----------------------------------------------------------------------------*/
450 
451 cs_real_t
453 
454 /*----------------------------------------------------------------------------*/
467 /*----------------------------------------------------------------------------*/
468 
469 void
471  const char *soil_name,
472  double wmd,
473  double alpha_l,
474  double alpha_t,
475  double distrib_coef);
476 
477 /*----------------------------------------------------------------------------*/
488 /*----------------------------------------------------------------------------*/
489 
490 void
492  const char *soil_name,
493  double conc_l_star);
494 
495 /*----------------------------------------------------------------------------*/
501 /*----------------------------------------------------------------------------*/
502 
503 void
505 
506 /*----------------------------------------------------------------------------*/
513 /*----------------------------------------------------------------------------*/
514 
515 void
517  const cs_cdo_quantities_t *quant);
518 
519 /*----------------------------------------------------------------------------*/
530 /*----------------------------------------------------------------------------*/
531 
532 void
534  const cs_mesh_t *mesh,
535  const cs_cdo_connect_t *connect,
536  const cs_cdo_quantities_t *quant);
537 
538 /*----------------------------------------------------------------------------*/
542 /*----------------------------------------------------------------------------*/
543 
544 void
546 
547 /*----------------------------------------------------------------------------*/
557 /*----------------------------------------------------------------------------*/
558 
559 void
561  const cs_time_step_t *time_step,
562  const cs_cdo_connect_t *connect,
563  const cs_cdo_quantities_t *cdoq);
564 
565 /*----------------------------------------------------------------------------*/
575 /*----------------------------------------------------------------------------*/
576 
577 void
579  const cs_time_step_t *time_step,
580  const cs_cdo_connect_t *connect,
581  const cs_cdo_quantities_t *cdoq);
582 
583 /*----------------------------------------------------------------------------*/
592 /*----------------------------------------------------------------------------*/
593 
594 void
596 
597 /*----------------------------------------------------------------------------*/
607 /*----------------------------------------------------------------------------*/
608 
609 void
611  const cs_cdo_quantities_t *quant,
612  const cs_adv_field_t *adv,
613  cs_gwf_tracer_t *tracer);
614 
615 /*----------------------------------------------------------------------------*/
625 /*----------------------------------------------------------------------------*/
626 
627 void
629  const cs_cdo_quantities_t *quant,
630  const cs_adv_field_t *adv,
631  cs_gwf_tracer_t *tracer);
632 
633 /*----------------------------------------------------------------------------*/
649 /*----------------------------------------------------------------------------*/
650 
651 double
653  const cs_cdo_quantities_t *cdoq,
654  const cs_gwf_tracer_t *tracer,
655  const char *z_name);
656 
657 /*----------------------------------------------------------------------------*/
675 /*----------------------------------------------------------------------------*/
676 
677 void
679  const cs_cdo_quantities_t *cdoq,
680  const cs_gwf_tracer_t *tracer,
681  const char *z_name,
682  double results[]);
683 
684 /*----------------------------------------------------------------------------*/
694 /*----------------------------------------------------------------------------*/
695 
698  const char *chain_name,
699  cs_gwf_tracer_unit_t unit);
700 
701 /*----------------------------------------------------------------------------*/
710 /*----------------------------------------------------------------------------*/
711 
714 
715 /*----------------------------------------------------------------------------*/
724 /*----------------------------------------------------------------------------*/
725 
727 cs_gwf_tracer_decay_chain_by_name(const char *chain_name);
728 
729 /*----------------------------------------------------------------------------*/
740 /*----------------------------------------------------------------------------*/
741 
744  int id);
745 
746 /*----------------------------------------------------------------------------*/
757 /*----------------------------------------------------------------------------*/
758 
761  int id);
762 
763 /*----------------------------------------------------------------------------*/
774 /*----------------------------------------------------------------------------*/
775 
778  int id);
779 
780 /*----------------------------------------------------------------------------*/
781 
783 
784 #endif /* __CS_GWF_TRACER_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
@ lambda
Definition: cs_field_pointer.h:106
cs_flag_t cs_gwf_tracer_model_t
Definition: cs_gwf_param.h:296
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_tracer_unit_t
Type of unit for the expression of the radioactive inventory.
Definition: cs_gwf_param.h:110
cs_gwf_tracer_decay_chain_t * cs_gwf_tracer_decay_chain_by_id(int id)
Retrieve the decay chain structure associated to the given id If not found, it returns the NULL point...
Definition: cs_gwf_tracer.c:3251
void cs_gwf_tracer_compute_all(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 new (unsteady) state for all tracer equations. Nothing is done if all equations are stead...
Definition: cs_gwf_tracer.c:2620
cs_equation_param_t * cs_gwf_tracer_decay_chain_get_equation_param(cs_gwf_tracer_decay_chain_t *tdc, int id)
Retrieve the equation parameters for the tracer at the position "id" in the decay chain structure....
Definition: cs_gwf_tracer.c:3375
cs_gwf_tracer_t * cs_gwf_tracer_decay_chain_get_tracer(cs_gwf_tracer_decay_chain_t *tdc, int id)
Retrieve the tracer structure for the tracer at the position "id" in the decay chain structure....
Definition: cs_gwf_tracer.c:3314
void cs_gwf_tracer_compute_steady_all(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 for all tracer equations. Nothing is done if all equations are unsteady.
Definition: cs_gwf_tracer.c:2571
void cs_gwf_tracer_unsat_finalize_setup(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_adv_field_t *adv, 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:2977
void cs_gwf_tracer_free_all(void)
Free all tracer structures and all decay chains.
Definition: cs_gwf_tracer.c:2140
void cs_gwf_tracer_finalize_setup(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant)
Finalize the tracer setup.
Definition: cs_gwf_tracer.c:2374
void() cs_gwf_tracer_init_setup_t(cs_gwf_tracer_t *tracer)
Generic function to update the first setup stage (the one done before building mesh and its related q...
Definition: cs_gwf_tracer.h:77
void() cs_gwf_tracer_integrate_t(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq, const cs_equation_t *eq, const cs_zone_t *zone, void *context, double results[])
Compute the quantity of tracer using an integral of the tracer concentration over a given set of cell...
Definition: cs_gwf_tracer.h:149
cs_equation_t * cs_gwf_tracer_decay_chain_get_equation(cs_gwf_tracer_decay_chain_t *tdc, int id)
Retrieve the equation structure for the tracer at the position "id" in the decay chain structure....
Definition: cs_gwf_tracer.c:3345
void cs_gwf_tracer_update_diff_pty(const cs_time_step_t *ts, const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant)
Update the diffusion property related to each tracer equation The update strategy depends on the soil...
Definition: cs_gwf_tracer.c:2460
double cs_gwf_tracer_integrate(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 of the tracer concentration over a given set of cells. This integral gives the n...
Definition: cs_gwf_tracer.c:3106
void() cs_gwf_tracer_update_t(cs_gwf_tracer_t *tracer, void *context, const cs_time_step_t *ts, const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant)
Generic function to update the properties related to a tracer. This function depends on a numerical s...
Definition: cs_gwf_tracer.h:113
cs_gwf_tracer_decay_chain_t * cs_gwf_tracer_create_decay_chain(int n_tracers, const char *chain_name, cs_gwf_tracer_unit_t unit)
Create a decay chain structure to manage several linked tracers.
Definition: cs_gwf_tracer.c:3200
cs_gwf_tracer_decay_chain_t * cs_gwf_tracer_decay_chain_by_name(const char *chain_name)
Retrieve the decay chain structure associated to the name given as parameter. If not found,...
Definition: cs_gwf_tracer.c:3275
cs_gwf_tracer_t * cs_gwf_tracer_add(cs_gwf_tracer_model_t tr_model, cs_gwf_model_type_t gwf_model, const char *eq_name, const char *var_name, cs_adv_field_t *adv_field, double lambda, int chain_position, int chain_id, cs_gwf_tracer_init_setup_t *init_setup, cs_gwf_tracer_finalize_setup_t *finalize_setup)
Create a new cs_gwf_tracer_t structure and initialize its members. This creation of a new tracer is f...
Definition: cs_gwf_tracer.c:2084
void cs_gwf_tracer_default_init_setup(cs_gwf_tracer_t *tracer)
Add terms to the algebraic system related to a tracer equation according to the settings....
Definition: cs_gwf_tracer.c:2675
cs_real_t cs_gwf_tracer_get_time_theta_max(void)
Retrieve the max. value of the theta parameter associated to a time scheme. Loop on all tracer equati...
Definition: cs_gwf_tracer.c:2191
void cs_gwf_tracer_sat_finalize_setup(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_adv_field_t *adv, 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:2837
void cs_gwf_tracer_log_all(void)
Display the main features related to each tracer.
Definition: cs_gwf_tracer.c:2492
void cs_gwf_tracer_init_setup(void)
Initial setup step for tracer equations. Soils and equation parameters are defined at this stage....
Definition: cs_gwf_tracer.c:2337
void cs_gwf_tracer_integrate_by_terms(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq, const cs_gwf_tracer_t *tracer, const char *z_name, double results[])
Compute the quantity of tracer using the integral of the tracer concentration over a given set of cel...
Definition: cs_gwf_tracer.c:3156
void() cs_gwf_tracer_finalize_setup_t(const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_adv_field_t *adv, cs_gwf_tracer_t *tracer)
Generic function to finalize the setup of parameters related to a tracer equation....
Definition: cs_gwf_tracer.h:93
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:129
void cs_gwf_tracer_set_precip_param(cs_gwf_tracer_t *tracer, const char *soil_name, double conc_l_star)
For a specified soil set the parameters corresponding to a precipitation modelling of a tracer transp...
Definition: cs_gwf_tracer.c:2293
void cs_gwf_tracer_set_soil_param(cs_gwf_tracer_t *tracer, const char *soil_name, double wmd, double alpha_l, double alpha_t, double distrib_coef)
Set the main parameters corresponding to a default modelling of a tracer transport equation for a spe...
Definition: cs_gwf_tracer.c:2230
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_tracer.c:2031
Definition: mesh.f90:26
Definition: cs_gwf_tracer.h:184
cs_real_t * precip_mass
Definition: cs_gwf_tracer.h:218
double * kd0
Definition: cs_gwf_tracer.h:198
double decay_coef
Definition: cs_gwf_tracer.h:189
double * rho_bulk
Definition: cs_gwf_tracer.h:197
double * conc_l_star
Definition: cs_gwf_tracer.h:210
cs_real_t * conc_site2
Definition: cs_gwf_tracer.h:237
cs_field_t * precip_field
Definition: cs_gwf_tracer.h:224
double * k0_plus
Definition: cs_gwf_tracer.h:232
double * alpha_t
Definition: cs_gwf_tracer.h:203
double * k0_minus
Definition: cs_gwf_tracer.h:234
const cs_field_t * darcy_velocity_field
Definition: cs_gwf_tracer.h:242
double * rho_kd
Definition: cs_gwf_tracer.h:200
double * wmd
Definition: cs_gwf_tracer.h:205
double * alpha_l
Definition: cs_gwf_tracer.h:202
Definition: cs_gwf_tracer.h:249
cs_gwf_tracer_integrate_t * integrate
Definition: cs_gwf_tracer.h:364
void * context
Definition: cs_gwf_tracer.h:302
int chain_id
Definition: cs_gwf_tracer.h:317
cs_gwf_tracer_model_t model
Definition: cs_gwf_tracer.h:268
int reaction_id
Definition: cs_gwf_tracer.h:283
cs_gwf_tracer_init_setup_t * init_setup
Definition: cs_gwf_tracer.h:366
cs_gwf_tracer_free_context_t * free_context
Definition: cs_gwf_tracer.h:368
cs_gwf_tracer_finalize_setup_t * finalize_setup
Definition: cs_gwf_tracer.h:367
cs_equation_t * equation
Definition: cs_gwf_tracer.h:295
cs_gwf_tracer_update_t * update_decay_chain_st
Definition: cs_gwf_tracer.h:362
int chain_position_id
Definition: cs_gwf_tracer.h:310
cs_gwf_model_type_t hydraulic_model
Definition: cs_gwf_tracer.h:261
cs_gwf_tracer_update_t * update_precipitation
Definition: cs_gwf_tracer.h:361
cs_field_t * diffusivity
Definition: cs_gwf_tracer.h:275
cs_gwf_tracer_update_t * update_diff_pty
Definition: cs_gwf_tracer.h:360
Definition: cs_advection_field.h:150
Definition: cs_cdo_connect.h:61
Definition: cs_cdo_quantities.h:137
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:192
Main structure to handle the discretization and the resolution of an equation.
Field descriptor.
Definition: cs_field.h:131
Definition: cs_gwf_tracer.h:162
char * name
Definition: cs_gwf_tracer.h:164
cs_xdef_t ** st_defs
Definition: cs_gwf_tracer.h:177
int id
Definition: cs_gwf_tracer.h:165
cs_gwf_tracer_t ** tracers
Definition: cs_gwf_tracer.h:173
int n_tracers
Definition: cs_gwf_tracer.h:167
cs_gwf_tracer_unit_t unit
Definition: cs_gwf_tracer.h:168
Set of parameters describing a tracer structure.
Definition: cs_mesh.h:85
time step descriptor
Definition: cs_time_step.h:64
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:160
Definition: cs_zone.h:55