7.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-2022 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 
48 typedef struct _gwf_tracer_t cs_gwf_tracer_t;
49 
50 /*============================================================================
51  * Public function pointer prototypes
52  *============================================================================*/
53 
54 /*----------------------------------------------------------------------------*/
61 /*----------------------------------------------------------------------------*/
62 
63 typedef void
64 (cs_gwf_tracer_init_setup_t) (cs_gwf_tracer_t *tracer);
65 
66 /*----------------------------------------------------------------------------*/
77 /*----------------------------------------------------------------------------*/
78 
79 typedef void
81  const cs_cdo_quantities_t *quant,
82  const cs_adv_field_t *adv,
83  cs_gwf_tracer_t *tracer);
84 
85 /*----------------------------------------------------------------------------*/
96 /*----------------------------------------------------------------------------*/
97 
98 typedef void
99 (cs_gwf_tracer_update_t) (cs_gwf_tracer_t *tracer,
100  cs_real_t t_eval,
101  const cs_mesh_t *mesh,
102  const cs_cdo_connect_t *connect,
103  const cs_cdo_quantities_t *quant);
104 
105 /*----------------------------------------------------------------------------*/
111 /*----------------------------------------------------------------------------*/
112 
113 typedef void
114 (cs_gwf_tracer_free_context_t) (cs_gwf_tracer_t *tracer);
115 
116 /*============================================================================
117  * Structure definitions
118  *============================================================================*/
119 
120 /* Set of parameters related to a tracer equation attached to a standard
121  modelling */
122 
123 typedef struct {
124 
125  /* Parameters to determine the behavior in each soil
126  * (array of size: n_soils)
127  */
128 
129  /* Common settings shared by all physical modelling */
130  /* ------------------------------------------------ */
131 
132  double *rho_bulk; /* bulk density (kg.m^-3) */
133  double *kd0; /* reference value of the distribution coefficient
134  (m^".kg^-1) */
135  double *rho_kd; /* Derived quantity: rho_bulk*kd0 */
136 
137  double *alpha_l; /* Longitudinal dispersivity */
138  double *alpha_t; /* Transversal dispersivity */
139 
140  double *wmd; /* Water molecular diffusivity (m^2.s^-1) */
141 
142  double *reaction_rate; /* First order decay coefficient (related to the
143  reaction term) */
144 
145  /* Precipitation members (set to NULL if not used) */
146  /* ----------------------------------------------- */
147 
148  double *conc_w_star; /* maximal value of the concentraction of tracer
149  in the liquid phase. Exceeded quantities are
150  stored in the solid phase (->
151  conc_precip). These values corresponds to the
152  user settings */
153 
154  cs_real_t *conc_satura; /* array storing the value of the saturated
155  concentration in the liquid phase at vertices
156  (only used in case of CDOVB schemes or CDOVCB
157  schemes */
158  cs_real_t *conc_precip; /* array storing the concentration in the
159  precipitation (solid) storage. The size may
160  vary w.r.t. to the discrtization scheme.
161  */
162 
164 
165  /* Sorption members (set to NULL if not used) */
166  /* ------------------------------------------ */
167 
168  double *k0_plus; /* kinetic coefficient towards site 2 locations
169  (m^3.kg^-1.s^-1) */
170  double *k0_minus; /* kinetic coefficient from site 2 locations
171  (s^-1) */
172 
173  cs_real_t *conc_site2; /* array allocated to n_cells */
174 
175  /* Variables used for the update of physical properties (shared pointers) */
176 
178 
180 
181 
182 /* Set of parameters describing a tracer structure */
183 /* ----------------------------------------------- */
184 
186 
188 
189  /* Physical modelling adopted for this tracer */
190 
192 
193  cs_field_t *diffusivity; /* NULL if no diffusion term is
194  build in the tracer equation */
195  int reaction_id; /* id related to the reaction
196  term in the tracer equation */
197 
203 
204  /* Pointer to a context structure according to the model */
205 
206  void *context;
207 
208  /* Pointers to functions */
209 
240 
241 };
242 
243 /*============================================================================
244  * Public function prototypes
245  *============================================================================*/
246 
247 /*----------------------------------------------------------------------------*/
256 /*----------------------------------------------------------------------------*/
257 
258 cs_gwf_tracer_t *
259 cs_gwf_tracer_by_name(const char *eq_name);
260 
261 /*----------------------------------------------------------------------------*/
281 /*----------------------------------------------------------------------------*/
282 
283 cs_gwf_tracer_t *
285  cs_gwf_model_type_t gwf_model,
286  const char *eq_name,
287  const char *var_name,
288  cs_adv_field_t *adv_field,
291 
292 /*----------------------------------------------------------------------------*/
298 /*----------------------------------------------------------------------------*/
299 
300 void
302 
303 /*----------------------------------------------------------------------------*/
310 /*----------------------------------------------------------------------------*/
311 
312 cs_real_t
314 
315 /*----------------------------------------------------------------------------*/
329 /*----------------------------------------------------------------------------*/
330 
331 void
332 cs_gwf_tracer_set_main_param(cs_gwf_tracer_t *tracer,
333  const char *soil_name,
334  double wmd,
335  double alpha_l,
336  double alpha_t,
337  double distrib_coef,
338  double reaction_rate);
339 
340 /*----------------------------------------------------------------------------*/
351 /*----------------------------------------------------------------------------*/
352 
353 void
354 cs_gwf_tracer_set_precip_param(cs_gwf_tracer_t *tracer,
355  const char *soil_name,
356  double conc_w_star);
357 
358 /*----------------------------------------------------------------------------*/
364 /*----------------------------------------------------------------------------*/
365 
366 void
368 
369 /*----------------------------------------------------------------------------*/
376 /*----------------------------------------------------------------------------*/
377 
378 void
380  const cs_cdo_quantities_t *quant);
381 
382 /*----------------------------------------------------------------------------*/
391 /*----------------------------------------------------------------------------*/
392 
393 void
395  const cs_mesh_t *mesh,
396  const cs_cdo_connect_t *connect,
397  const cs_cdo_quantities_t *quant);
398 
399 /*----------------------------------------------------------------------------*/
403 /*----------------------------------------------------------------------------*/
404 
405 void
407 
408 /*----------------------------------------------------------------------------*/
418 /*----------------------------------------------------------------------------*/
419 
420 void
422  const cs_time_step_t *time_step,
423  const cs_cdo_connect_t *connect,
424  const cs_cdo_quantities_t *cdoq);
425 
426 /*----------------------------------------------------------------------------*/
436 /*----------------------------------------------------------------------------*/
437 
438 void
440  const cs_time_step_t *time_step,
441  const cs_cdo_connect_t *connect,
442  const cs_cdo_quantities_t *cdoq);
443 
444 /*----------------------------------------------------------------------------*/
453 /*----------------------------------------------------------------------------*/
454 
455 void
456 cs_gwf_tracer_default_init_setup(cs_gwf_tracer_t *tracer);
457 
458 /*----------------------------------------------------------------------------*/
468 /*----------------------------------------------------------------------------*/
469 
470 void
472  const cs_cdo_quantities_t *quant,
473  const cs_adv_field_t *adv,
474  cs_gwf_tracer_t *tracer);
475 
476 /*----------------------------------------------------------------------------*/
486 /*----------------------------------------------------------------------------*/
487 
488 void
490  const cs_cdo_quantities_t *quant,
491  const cs_adv_field_t *adv,
492  cs_gwf_tracer_t *tracer);
493 
494 /*----------------------------------------------------------------------------*/
508 /*----------------------------------------------------------------------------*/
509 
510 cs_real_t
512  const cs_cdo_quantities_t *cdoq,
513  const cs_gwf_tracer_t *tracer,
514  const char *z_name);
515 
516 /*----------------------------------------------------------------------------*/
517 
519 
520 #endif /* __CS_GWF_TRACER_H__ */
cs_field_t * precip_field
Definition: cs_gwf_tracer.h:163
void cs_gwf_tracer_update_diff_tensor(cs_real_t t_eval, const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant)
Update the diffusion tensor related to each tracer equation.
Definition: cs_gwf_tracer.c:1663
time step descriptor
Definition: cs_time_step.h:64
double * alpha_l
Definition: cs_gwf_tracer.h:137
cs_real_t * conc_site2
Definition: cs_gwf_tracer.h:173
double * wmd
Definition: cs_gwf_tracer.h:140
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. Case of the default tracer modelling Rely on the generic function: cs_gwf_tracer_add_terms_t.
Definition: cs_gwf_tracer.c:1853
Definition: cs_advection_field.h:150
cs_real_t * conc_satura
Definition: cs_gwf_tracer.h:154
cs_gwf_tracer_model_t model
Definition: cs_gwf_tracer.h:191
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:1965
Field descriptor.
Definition: cs_field.h:125
double * conc_w_star
Definition: cs_gwf_tracer.h:148
cs_real_t * conc_precip
Definition: cs_gwf_tracer.h:158
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
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, 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 by default. Add a new equation rela...
Definition: cs_gwf_tracer.c:1305
void cs_gwf_tracer_log_all(void)
Display the main features related to each tracer.
Definition: cs_gwf_tracer.c:1695
int reaction_id
Definition: cs_gwf_tracer.h:195
double * reaction_rate
Definition: cs_gwf_tracer.h:142
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:2058
cs_gwf_model_type_t hydraulic_model
Definition: cs_gwf_tracer.h:187
cs_gwf_tracer_finalize_setup_t * finalize_setup
Definition: cs_gwf_tracer.h:237
Definition: cs_cdo_connect.h:61
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. At this stage, mesh and its related quantities have been built.
Definition: cs_gwf_tracer.h:80
cs_gwf_model_type_t
Type of system of equation(s) to consider for the physical modelling.
Definition: cs_gwf_param.h:102
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
Definition: cs_cdo_quantities.h:132
cs_field_t * diffusivity
Definition: cs_gwf_tracer.h:193
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 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_tracer.c:2153
Definition: cs_mesh.h:84
void cs_gwf_tracer_free_all(void)
Free all tracers.
Definition: cs_gwf_tracer.c:1347
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:1392
Definition: cs_gwf_tracer.h:123
const cs_field_t * darcy_velocity_field
Definition: cs_gwf_tracer.h:177
void cs_gwf_tracer_set_main_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:1432
cs_gwf_tracer_free_context_t * free_context
Definition: cs_gwf_tracer.h:239
cs_equation_t * equation
Definition: cs_gwf_tracer.h:202
cs_gwf_tracer_init_setup_t * init_setup
Definition: cs_gwf_tracer.h:238
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:99
void cs_gwf_tracer_set_precip_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:1498
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:1542
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:64
double * alpha_t
Definition: cs_gwf_tracer.h:138
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:1802
cs_gwf_tracer_update_t * update_diff_tensor
Definition: cs_gwf_tracer.h:235
double * rho_bulk
Definition: cs_gwf_tracer.h:132
cs_gwf_tracer_update_t * update_precipitation
Definition: cs_gwf_tracer.h:236
#define END_C_DECLS
Definition: cs_defs.h:511
void * context
Definition: cs_gwf_tracer.h:206
double * rho_kd
Definition: cs_gwf_tracer.h:135
double * k0_minus
Definition: cs_gwf_tracer.h:170
double * kd0
Definition: cs_gwf_tracer.h:133
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:1753
Main structure to handle the discretization and the resolution of an equation.
cs_flag_t cs_gwf_tracer_model_t
Definition: cs_gwf_param.h:256
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:1258
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:1579
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:114
Definition: mesh.f90:26
Definition: cs_gwf_tracer.h:185
double * k0_plus
Definition: cs_gwf_tracer.h:168