programmer's documentation
cs_advection_field.h
Go to the documentation of this file.
1 #ifndef __CS_ADVECTION_FIELD_H__
2 #define __CS_ADVECTION_FIELD_H__
3 
4 /*============================================================================
5  * Manage the definition/setting of advection fields
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2018 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_cdo.h"
35 #include "cs_cdo_connect.h"
36 #include "cs_cdo_local.h"
37 #include "cs_cdo_quantities.h"
38 #include "cs_mesh_location.h"
39 #include "cs_param.h"
40 #include "cs_property.h"
41 #include "cs_time_step.h"
42 
43 /*----------------------------------------------------------------------------*/
44 
46 
47 /*============================================================================
48  * Macro definitions
49  *============================================================================*/
50 
51 /*============================================================================
52  * Type definitions
53  *============================================================================*/
54 
55 
56 #define CS_ADVECTION_FIELD_POST_FIELD (1 << 0) // postprocess adv. field
57 #define CS_ADVECTION_FIELD_POST_COURANT (1 << 1) // postprocess Courant number
58 
59 typedef struct {
60 
61  char *restrict name;
62 
63  cs_desc_t desc; // Short descriptor (mask of bits)
64  cs_flag_t post_flag; // Short descriptor dedicated to postprocessing
65  int vtx_field_id; // id among cs_field_t structures (-1 if not used)
66  int cell_field_id; // id among cs_field_t structures (-1 if not used)
67 
68  cs_param_def_type_t def_type; // type of definition used
69  cs_def_t def; // structure used for simple definition
70 
71  /* Useful buffers to deal with more complex definitions
72  N.B.: array and struc are not owned by this structure. */
73  cs_desc_t array_desc; // short description of the related array
74 
75  const cs_real_t *array; // if the advection field hinges on an array
76  const void *struc; // if the advection field hinges on a structure
77 
79 
80 /* List of available keys for setting an advection field */
81 typedef enum {
82 
86 
88 
89 /*============================================================================
90  * Global variables
91  *============================================================================*/
92 
93 /*============================================================================
94  * Public function prototypes
95  *============================================================================*/
96 
97 /*----------------------------------------------------------------------------*/
105 /*----------------------------------------------------------------------------*/
106 
107 void
109  const cs_cdo_connect_t *connect,
110  const cs_time_step_t *time_step);
111 
112 /*----------------------------------------------------------------------------*/
120 /*----------------------------------------------------------------------------*/
121 
123 cs_advection_field_create(const char *name);
124 
125 /*----------------------------------------------------------------------------*/
133 /*----------------------------------------------------------------------------*/
134 
137 
138 /*----------------------------------------------------------------------------*/
147 /*----------------------------------------------------------------------------*/
148 
149 bool
151  const char *ref_name);
152 
153 /*----------------------------------------------------------------------------*/
161 /*----------------------------------------------------------------------------*/
162 
163 bool
165 
166 /*----------------------------------------------------------------------------*/
175 /*----------------------------------------------------------------------------*/
176 
177 bool
179 
180 /*----------------------------------------------------------------------------*/
188 /*----------------------------------------------------------------------------*/
189 
190 const char *
192 
193 /*----------------------------------------------------------------------------*/
202 /*----------------------------------------------------------------------------*/
203 
206 
207 /*----------------------------------------------------------------------------*/
213 /*----------------------------------------------------------------------------*/
214 
215 void
217 
218 /*----------------------------------------------------------------------------*/
226 /*----------------------------------------------------------------------------*/
227 
228 void
231  const char *keyval);
232 
233 /*----------------------------------------------------------------------------*/
240 /*----------------------------------------------------------------------------*/
241 
242 void
244  const cs_real_t vector[3]);
245 
246 /*----------------------------------------------------------------------------*/
253 /*----------------------------------------------------------------------------*/
254 
255 void
257  cs_analytic_func_t *func);
258 
259 /*----------------------------------------------------------------------------*/
266 /*----------------------------------------------------------------------------*/
267 
268 void
270  cs_desc_t desc);
271 
272 /*----------------------------------------------------------------------------*/
280 /*----------------------------------------------------------------------------*/
281 
282 void
284  const cs_real_t *array);
285 
286 /*----------------------------------------------------------------------------*/
292 /*----------------------------------------------------------------------------*/
293 
294 void
296 
297 /*----------------------------------------------------------------------------*/
307 /*----------------------------------------------------------------------------*/
308 
309 cs_field_t *
311  cs_mesh_location_type_t ml_type);
312 
313 /*----------------------------------------------------------------------------*/
321 /*----------------------------------------------------------------------------*/
322 
323 void
325  const cs_adv_field_t *adv,
326  cs_nvec3_t *vect);
327 
328 /*----------------------------------------------------------------------------*/
336 /*----------------------------------------------------------------------------*/
337 
338 void
340  const cs_adv_field_t *adv,
341  cs_nvec3_t *vect);
342 
343 /*----------------------------------------------------------------------------*/
351 /*----------------------------------------------------------------------------*/
352 
353 void
355  const cs_real_3_t xyz,
356  cs_nvec3_t *vect);
357 
358 /*----------------------------------------------------------------------------*/
365 /*----------------------------------------------------------------------------*/
366 
367 void
369  cs_real_t *cell_values);
370 
371 /*----------------------------------------------------------------------------*/
378 /*----------------------------------------------------------------------------*/
379 
380 void
382  cs_real_t *vtx_values);
383 
384 /*----------------------------------------------------------------------------*/
392 /*----------------------------------------------------------------------------*/
393 
394 double
396 
397 /*----------------------------------------------------------------------------*/
407 /*----------------------------------------------------------------------------*/
408 
409 void
411  const cs_param_advection_t a_info,
412  const cs_adv_field_t *adv,
413  cs_real_t *fluxes);
414 
415 /*----------------------------------------------------------------------------*/
432 /*----------------------------------------------------------------------------*/
433 
434 cs_real_t
436  const cs_param_advection_t a_info,
437  const cs_cell_mesh_t *cm,
438  cs_real_t tef_meas,
439  short int f,
440  short int e,
441  short int v1,
442  short int v2);
443 
444 /*----------------------------------------------------------------------------*/
457 /*----------------------------------------------------------------------------*/
458 
459 cs_real_t
461  short int v,
462  short int e,
463  short int f,
464  const cs_param_advection_t a_info,
465  const cs_adv_field_t *adv);
466 
467 /*----------------------------------------------------------------------------*/
473 /*----------------------------------------------------------------------------*/
474 
475 void
477 
478 /*----------------------------------------------------------------------------*/
486 /*----------------------------------------------------------------------------*/
487 
488 void
490  const cs_property_t *diff,
491  double peclet[]);
492 
493 /*----------------------------------------------------------------------------*/
494 
496 
497 #endif /* __CS_ADVECTION_FIELD_H__ */
void() cs_analytic_func_t(cs_real_t time, cs_lnum_t n_points, const cs_real_t *xyz, cs_real_t *retval)
Generic analytic function.
Definition: cs_cdo.h:170
time step descriptor
Definition: cs_time_step.h:51
#define restrict
Definition: cs_defs.h:122
void cs_advection_field_update(cs_adv_field_t *adv)
Update the values of the related field(s)
Definition: cs_advection_field.c:1544
bool cs_advection_field_is_uniform(const cs_adv_field_t *adv)
returns true if the advection field is uniform, otherwise false
Definition: cs_advection_field.c:218
void cs_advection_field_at_cells(const cs_adv_field_t *adv, cs_real_t *cell_values)
Compute the value of the advection field at cell centers.
Definition: cs_advection_field.c:817
void cs_advection_field_get_at_xyz(const cs_adv_field_t *adv, const cs_real_3_t xyz, cs_nvec3_t *vect)
Compute the value of the advection field for a given face.
Definition: cs_advection_field.c:766
Definition: cs_advection_field.h:59
Definition: cs_cdo.h:131
Field descriptor.
Definition: cs_field.h:124
cs_mesh_location_type_t
Definition: cs_mesh_location.h:60
double cs_advection_field_get_cell_max(const cs_adv_field_t *adv)
Compute the max. value of the advection field among cells.
Definition: cs_advection_field.c:1053
const char * cs_advection_field_get_name(const cs_adv_field_t *adv)
Retrieve the name of an advection field.
Definition: cs_advection_field.c:265
#define BEGIN_C_DECLS
Definition: cs_defs.h:451
int cell_field_id
Definition: cs_advection_field.h:66
cs_advection_field_key_t
Definition: cs_advection_field.h:81
cs_real_t cs_advection_field_get_flux_svef(const cs_cell_mesh_t *cm, short int v, short int e, short int f, const cs_param_advection_t a_info, const cs_adv_field_t *adv)
Compute the value of the flux of the advection field across the triangle defined by a vertex...
Definition: cs_advection_field.c:1424
void cs_advection_field_in_cell(const cs_cell_mesh_t *cm, const cs_adv_field_t *adv, cs_nvec3_t *vect)
Compute the value of the advection field at the cell center.
Definition: cs_advection_field.c:605
Definition: cs_cdo_local.h:132
Definition: cs_cdo_connect.h:56
void cs_advection_field_set_shared_pointers(const cs_cdo_quantities_t *quant, const cs_cdo_connect_t *connect, const cs_time_step_t *time_step)
Set shared pointers to main domain members.
Definition: cs_advection_field.c:103
cs_desc_t desc
Definition: cs_advection_field.h:63
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
Definition: cs_cdo_quantities.h:102
cs_param_def_type_t cs_advection_field_get_deftype(const cs_adv_field_t *adv)
Retrieve the type of definition used to set the current advection field structure.
Definition: cs_advection_field.c:285
Definition: cs_cdo.h:140
Definition: cs_param.h:232
const cs_real_t * array
Definition: cs_advection_field.h:75
double precision, dimension(:,:,:), allocatable v
Definition: atimbr.f90:114
void cs_advection_field_get_cell_vector(cs_lnum_t c_id, const cs_adv_field_t *adv, cs_nvec3_t *vect)
Compute the value of the advection field at the cell center.
Definition: cs_advection_field.c:685
void cs_advection_field_def_by_value(cs_adv_field_t *adv, const cs_real_t vector[3])
Define the value of a cs_adv_field_t structure.
Definition: cs_advection_field.c:409
cs_flag_t post_flag
Definition: cs_advection_field.h:64
void cs_advection_get_peclet(const cs_adv_field_t *adv, const cs_property_t *diff, double peclet[])
Compute the Peclet number in each cell.
Definition: cs_advection_field.c:1586
void cs_advection_field_summary(const cs_adv_field_t *adv)
Print a summary of a cs_adv_field_t structure.
Definition: cs_advection_field.c:302
cs_def_t def
Definition: cs_advection_field.h:69
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
Definition: cs_advection_field.h:84
Definition: cs_advection_field.h:85
Definition: cs_param.h:72
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
void cs_advection_field_at_vertices(const cs_adv_field_t *adv, cs_real_t *vtx_values)
Compute the value of the advection field at vertices.
Definition: cs_advection_field.c:908
void cs_advection_field_create_field(cs_adv_field_t *adv)
Create a cs_field_t structure related to an advection field.
Definition: cs_advection_field.c:498
void cs_advection_field_def_by_analytic(cs_adv_field_t *adv, cs_analytic_func_t *func)
Define a cs_adv_field_t structure thanks to an analytic function.
Definition: cs_advection_field.c:432
cs_adv_field_t * cs_advection_field_create(const char *name)
Create and initialize a new advection field structure.
Definition: cs_advection_field.c:124
#define END_C_DECLS
Definition: cs_defs.h:452
unsigned short int cs_flag_t
Definition: cs_defs.h:299
cs_desc_t array_desc
Definition: cs_advection_field.h:73
void cs_advection_field_set_array(cs_adv_field_t *adv, const cs_real_t *array)
Set the array related to the definition of a cs_adv_field_t structure.
Definition: cs_advection_field.c:478
void cs_advection_field_set_option(cs_adv_field_t *adv, cs_advection_field_key_t key, const char *keyval)
Set optional parameters related to a cs_adv_field_t structure.
Definition: cs_advection_field.c:354
void cs_advection_field_def_by_array(cs_adv_field_t *adv, cs_desc_t desc)
Define a cs_adv_field_t structure thanks to an array of values.
Definition: cs_advection_field.c:452
cs_real_t cs_advection_field_get_flux_tef(const cs_adv_field_t *adv, const cs_param_advection_t a_info, const cs_cell_mesh_t *cm, cs_real_t tef_meas, short int f, short int e, short int v1, short int v2)
Compute the value of the flux of the advection field across the triangle defined by the two vertices ...
Definition: cs_advection_field.c:1292
bool cs_advection_field_is_cellwise(const cs_adv_field_t *adv)
returns true if the advection field is uniform in each cell otherwise false
Definition: cs_advection_field.c:241
cs_adv_field_t * cs_advection_field_free(cs_adv_field_t *adv)
Free a cs_adv_field_t structure.
Definition: cs_advection_field.c:163
int vtx_field_id
Definition: cs_advection_field.h:65
cs_param_def_type_t def_type
Definition: cs_advection_field.h:68
Definition: cs_advection_field.h:83
char *restrict name
Definition: cs_advection_field.h:61
Definition: cs_property.h:66
cs_param_def_type_t
Definition: cs_param.h:94
void cs_advection_field_get_flux_dfaces(const cs_cell_mesh_t *cm, const cs_param_advection_t a_info, const cs_adv_field_t *adv, cs_real_t *fluxes)
Compute the value of the flux of the advection field across the the dual faces of a cell...
Definition: cs_advection_field.c:1107
const void * struc
Definition: cs_advection_field.h:76
bool cs_advection_field_check_name(const cs_adv_field_t *adv, const char *ref_name)
Check if the given advection field has the name ref_name.
Definition: cs_advection_field.c:188
cs_field_t * cs_advection_field_get_field(cs_adv_field_t *adv, cs_mesh_location_type_t ml_type)
Get a cs_field_t structure related to an advection field and a mesh location.
Definition: cs_advection_field.c:568