9.2
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-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
36#include "base/cs_base.h"
37#include "cdo/cs_equation.h"
38#include "gwf/cs_gwf_param.h"
39
40/*============================================================================
41 * Typedef definition
42 *============================================================================*/
43
49typedef struct _gwf_tracer_t cs_gwf_tracer_t;
50
51/* \struct cs_gwf_tracer_default_context_t
52 *
53 * \brief Set of parameters related to a tracer equation attached to a standard
54 * modelling
55 */
56
57typedef struct _gwf_tracer_default_context_t cs_gwf_tracer_default_context_t;
58
59/*============================================================================
60 * Public function pointer prototypes
61 *============================================================================*/
62
63/*----------------------------------------------------------------------------*/
70/*----------------------------------------------------------------------------*/
71
72typedef void
74
75/*----------------------------------------------------------------------------*/
86/*----------------------------------------------------------------------------*/
87
88typedef void
90 const cs_cdo_quantities_t *quant,
91 const cs_adv_field_t *adv,
92 cs_gwf_tracer_t *tracer);
93
94/*----------------------------------------------------------------------------*/
106/*----------------------------------------------------------------------------*/
107
108typedef void
110 void *context,
111 const cs_time_step_t *ts,
112 const cs_mesh_t *mesh,
113 const cs_cdo_connect_t *connect,
114 const cs_cdo_quantities_t *quant);
115
116/*----------------------------------------------------------------------------*/
122/*----------------------------------------------------------------------------*/
123
124typedef void
126
127/*----------------------------------------------------------------------------*/
142/*----------------------------------------------------------------------------*/
143
144typedef void
146 const cs_cdo_quantities_t *cdoq,
147 const cs_equation_t *eq,
148 const cs_zone_t *zone,
149 void *context,
150 double results[]);
151
152/*============================================================================
153 * Structure definitions
154 *============================================================================*/
155
156/* Structure to handle of radioactive decay chain */
157
158typedef struct {
159
160 char *name; /* Name of the decay chain */
161 int id; /* Position in the array of chain decays */
162
163 int n_tracers; /* Number of tracers in the decay chain */
164 cs_gwf_tracer_unit_t unit; /* Type of unit measure:
165 * - mole (classical tracer)
166 * - Becquerel (activity)
167 */
168
169 cs_gwf_tracer_t **tracers; /* Array of tracers associated to the
170 decay chain. tracers[0] is the parent
171 without any ancestor. */
172
173 cs_xdef_t **st_defs; /* List of source term definitions */
174
176
177/* Set of parameters related to a tracer equation attached to a standard
178 modelling */
179
181
182 /* Common settings shared by all physical modelling */
183 /* ------------------------------------------------ */
184
185 double decay_coef; /* First order decay coefficient (related to the
186 reaction term). This value is intrinsic to the
187 component (a radioactive element for instance)
188 and not to the soil. */
189
190 /* The following parameters are defined for each soil (arrays of size equal
191 * to n_soils) */
192
193 double *rho_bulk; /* bulk density (kg.m^-3) */
194 double *kd0; /* reference value of the distribution coefficient
195 (m^".kg^-1) */
196 double *rho_kd; /* Derived quantity: rho_bulk*kd0 */
197
198 double *alpha_l; /* Longitudinal dispersivity */
199 double *alpha_t; /* Transversal dispersivity */
200
201 double *wmd; /* Water molecular diffusivity (m^2.s^-1) */
202
203 /* Precipitation members (set to null if not used) */
204 /* ----------------------------------------------- */
205
206 double *conc_l_star; /* maximal value of the concentration of
207 * tracer in the liquid phase in mol/m^3. There
208 * is one user-defined value for each soil. The
209 * exceeded quantities are stored in the solid
210 * phase (-> precip_mass). These values
211 * corresponds to the user settings
212 */
213
214 cs_real_t *precip_mass; /* array storing the mass of precipitate
215 * (solid) in the dedicated auxiliary
216 * storage. The size of this array may vary
217 * w.r.t. to the discretization scheme.
218 */
219
220 cs_field_t *precip_field; /* field structure storing the (interpolated)
221 * values of the concentration of precipitate
222 * in mol/kg in each cell.
223 */
224
225 /* Sorption members (set to null if not used) */
226 /* ------------------------------------------ */
227
228 double *k0_plus; /* kinetic coefficient towards site 2 locations
229 (m^3.kg^-1.s^-1) */
230 double *k0_minus; /* kinetic coefficient from site 2 locations
231 (s^-1) */
232
233 cs_real_t *conc_site2; /* array allocated to n_cells whatever the
234 space discretization is */
235
236 /* Variables used for the update of physical properties (shared pointers) */
237
239
240};
241
242/* Set of parameters describing a tracer structure */
243/* ----------------------------------------------- */
244
246
258
265
272
280
292
298 void *context;
299
307
314
359
361
365
369};
370
371/*============================================================================
372 * Public function prototypes
373 *============================================================================*/
374
375/*----------------------------------------------------------------------------*/
384/*----------------------------------------------------------------------------*/
385
387cs_gwf_tracer_by_name(const char *eq_name);
388
389/*----------------------------------------------------------------------------*/
415/*----------------------------------------------------------------------------*/
416
419 cs_gwf_model_type_t gwf_model,
420 const char *eq_name,
421 const char *var_name,
422 cs_adv_field_t *adv_field,
423 double lambda,
424 int chain_position,
425 int chain_id,
426 cs_gwf_tracer_init_setup_t *init_setup,
427 cs_gwf_tracer_finalize_setup_t *finalize_setup);
428
429/*----------------------------------------------------------------------------*/
433/*----------------------------------------------------------------------------*/
434
435void
437
438/*----------------------------------------------------------------------------*/
445/*----------------------------------------------------------------------------*/
446
449
450/*----------------------------------------------------------------------------*/
463/*----------------------------------------------------------------------------*/
464
465void
467 const char *soil_name,
468 double wmd,
469 double alpha_l,
470 double alpha_t,
471 double distrib_coef);
472
473/*----------------------------------------------------------------------------*/
484/*----------------------------------------------------------------------------*/
485
486void
488 const char *soil_name,
489 double conc_l_star);
490
491/*----------------------------------------------------------------------------*/
497/*----------------------------------------------------------------------------*/
498
499void
501
502/*----------------------------------------------------------------------------*/
509/*----------------------------------------------------------------------------*/
510
511void
513 const cs_cdo_quantities_t *quant);
514
515/*----------------------------------------------------------------------------*/
526/*----------------------------------------------------------------------------*/
527
528void
530 const cs_mesh_t *mesh,
531 const cs_cdo_connect_t *connect,
532 const cs_cdo_quantities_t *quant);
533
534/*----------------------------------------------------------------------------*/
538/*----------------------------------------------------------------------------*/
539
540void
542
543/*----------------------------------------------------------------------------*/
553/*----------------------------------------------------------------------------*/
554
555void
557 const cs_time_step_t *time_step,
558 const cs_cdo_connect_t *connect,
559 const cs_cdo_quantities_t *cdoq);
560
561/*----------------------------------------------------------------------------*/
571/*----------------------------------------------------------------------------*/
572
573void
575 const cs_time_step_t *time_step,
576 const cs_cdo_connect_t *connect,
577 const cs_cdo_quantities_t *cdoq);
578
579/*----------------------------------------------------------------------------*/
588/*----------------------------------------------------------------------------*/
589
590void
592
593/*----------------------------------------------------------------------------*/
603/*----------------------------------------------------------------------------*/
604
605void
607 const cs_cdo_quantities_t *quant,
608 const cs_adv_field_t *adv,
609 cs_gwf_tracer_t *tracer);
610
611/*----------------------------------------------------------------------------*/
621/*----------------------------------------------------------------------------*/
622
623void
625 const cs_cdo_quantities_t *quant,
626 const cs_adv_field_t *adv,
627 cs_gwf_tracer_t *tracer);
628
629/*----------------------------------------------------------------------------*/
645/*----------------------------------------------------------------------------*/
646
647double
649 const cs_cdo_quantities_t *cdoq,
650 const cs_gwf_tracer_t *tracer,
651 const char *z_name);
652
653/*----------------------------------------------------------------------------*/
671/*----------------------------------------------------------------------------*/
672
673void
675 const cs_cdo_quantities_t *cdoq,
676 const cs_gwf_tracer_t *tracer,
677 const char *z_name,
678 double results[]);
679
680/*----------------------------------------------------------------------------*/
690/*----------------------------------------------------------------------------*/
691
694 const char *chain_name,
696
697/*----------------------------------------------------------------------------*/
706/*----------------------------------------------------------------------------*/
707
710
711/*----------------------------------------------------------------------------*/
720/*----------------------------------------------------------------------------*/
721
723cs_gwf_tracer_decay_chain_by_name(const char *chain_name);
724
725/*----------------------------------------------------------------------------*/
736/*----------------------------------------------------------------------------*/
737
740 int id);
741
742/*----------------------------------------------------------------------------*/
753/*----------------------------------------------------------------------------*/
754
757 int id);
758
759/*----------------------------------------------------------------------------*/
770/*----------------------------------------------------------------------------*/
771
774 int id);
775
776/*----------------------------------------------------------------------------*/
777
778#endif /* CS_GWF_TRACER_H */
Field descriptor.
Definition: cs_field.h:275
time step descriptor
Definition: cs_time_step.h:60
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
@ lambda
Definition: cs_field_pointer.h:105
cs_flag_t cs_gwf_tracer_model_t
Flags specifying the general behavior of a tracer associated to the groundwater flow module.
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:123
cs_gwf_tracer_unit_t
Type of unit for the expression of the radioactive inventory.
Definition: cs_gwf_param.h:107
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.cpp:2590
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.cpp:2540
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.cpp:2045
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.cpp:2945
void cs_gwf_tracer_free_all(void)
Free all tracer structures and all decay chains.
Definition: cs_gwf_tracer.cpp:2098
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.cpp:2339
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:73
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:145
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.cpp:2428
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.cpp:3073
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:109
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.cpp:3293
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.cpp:3181
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.cpp:3323
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.cpp:2650
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.cpp:2148
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.cpp:2811
void cs_gwf_tracer_log_all(void)
Display the main features related to each tracer.
Definition: cs_gwf_tracer.cpp:2459
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.cpp:1993
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.cpp:3256
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.cpp:3352
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.cpp:2303
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.cpp:3130
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:89
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:125
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.cpp:2252
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.cpp:3232
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.cpp:2186
Definition: mesh.f90:26
Definition: cs_gwf_tracer.h:180
cs_real_t * precip_mass
Definition: cs_gwf_tracer.h:214
double * kd0
Definition: cs_gwf_tracer.h:194
double decay_coef
Definition: cs_gwf_tracer.h:185
double * rho_bulk
Definition: cs_gwf_tracer.h:193
double * conc_l_star
Definition: cs_gwf_tracer.h:206
cs_real_t * conc_site2
Definition: cs_gwf_tracer.h:233
cs_field_t * precip_field
Definition: cs_gwf_tracer.h:220
double * k0_plus
Definition: cs_gwf_tracer.h:228
double * alpha_t
Definition: cs_gwf_tracer.h:199
double * k0_minus
Definition: cs_gwf_tracer.h:230
const cs_field_t * darcy_velocity_field
Definition: cs_gwf_tracer.h:238
double * rho_kd
Definition: cs_gwf_tracer.h:196
double * wmd
Definition: cs_gwf_tracer.h:201
double * alpha_l
Definition: cs_gwf_tracer.h:198
Definition: cs_gwf_tracer.h:245
cs_gwf_tracer_integrate_t * integrate
Definition: cs_gwf_tracer.h:360
void * context
Definition: cs_gwf_tracer.h:298
int chain_id
Definition: cs_gwf_tracer.h:313
cs_gwf_tracer_model_t model
Definition: cs_gwf_tracer.h:264
int reaction_id
Definition: cs_gwf_tracer.h:279
cs_gwf_tracer_init_setup_t * init_setup
Definition: cs_gwf_tracer.h:362
cs_gwf_tracer_free_context_t * free_context
Definition: cs_gwf_tracer.h:364
cs_gwf_tracer_finalize_setup_t * finalize_setup
Definition: cs_gwf_tracer.h:363
cs_equation_t * equation
Definition: cs_gwf_tracer.h:291
cs_gwf_tracer_update_t * update_decay_chain_st
Definition: cs_gwf_tracer.h:358
int chain_position_id
Definition: cs_gwf_tracer.h:306
cs_gwf_model_type_t hydraulic_model
Definition: cs_gwf_tracer.h:257
cs_gwf_tracer_update_t * update_precipitation
Definition: cs_gwf_tracer.h:357
cs_field_t * diffusivity
Definition: cs_gwf_tracer.h:271
cs_gwf_tracer_update_t * update_diff_pty
Definition: cs_gwf_tracer.h:356
Definition: cs_advection_field.h:151
Definition: cs_cdo_connect.h:57
Definition: cs_cdo_quantities.h:142
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:190
Main structure to handle the discretization and the resolution of an equation.
Definition: cs_gwf_tracer.h:158
char * name
Definition: cs_gwf_tracer.h:160
cs_xdef_t ** st_defs
Definition: cs_gwf_tracer.h:173
int id
Definition: cs_gwf_tracer.h:161
cs_gwf_tracer_t ** tracers
Definition: cs_gwf_tracer.h:169
int n_tracers
Definition: cs_gwf_tracer.h:163
cs_gwf_tracer_unit_t unit
Definition: cs_gwf_tracer.h:164
Set of parameters describing a tracer structure.
Definition: cs_mesh.h:85
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:156
Definition: cs_zone.h:51