programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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-2017 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 #include "cs_xdef.h"
43 #include "cs_xdef_eval.h"
44 
45 /*----------------------------------------------------------------------------*/
46 
48 
49 /*============================================================================
50  * Macro definitions
51  *============================================================================*/
52 
53 /*============================================================================
54  * Type definitions
55  *============================================================================*/
56 
57 
58 #define CS_ADVECTION_FIELD_POST_COURANT (1 << 0) // postprocess Courant number
59 #define CS_ADVECTION_FIELD_STEADY (1 << 1) // steady-state field
60 
61 typedef struct {
62 
63  int id;
64  char *restrict name;
65 
66  cs_flag_t loc_flag; // Short descriptor for localization
67  cs_flag_t flag; // Short descriptor dedicated to postprocessing
68  int vtx_field_id; // id among cs_field_t structures (-1 if not used)
69  int cell_field_id; // id among cs_field_t structures (-1 if not used)
70 
71  /* We assume that there is only one definition assicated to an advection
72  field */
74 
75  /* Function pointers */
80 
82 
83 /* List of available keys for setting an advection field */
84 typedef enum {
85 
91 
93 
94 /*============================================================================
95  * Global variables
96  *============================================================================*/
97 
98 /*============================================================================
99  * Public function prototypes
100  *============================================================================*/
101 
102 /*----------------------------------------------------------------------------*/
110 /*----------------------------------------------------------------------------*/
111 
112 void
114  const cs_cdo_connect_t *connect,
115  const cs_time_step_t *time_step);
116 
117 /*----------------------------------------------------------------------------*/
123 /*----------------------------------------------------------------------------*/
124 
125 int
127 
128 /*----------------------------------------------------------------------------*/
137 /*----------------------------------------------------------------------------*/
138 
140 cs_advection_field_by_name(const char *name);
141 
142 /*----------------------------------------------------------------------------*/
151 /*----------------------------------------------------------------------------*/
152 
155 
156 /*----------------------------------------------------------------------------*/
164 /*----------------------------------------------------------------------------*/
165 
167 cs_advection_field_add(const char *name);
168 
169 /*----------------------------------------------------------------------------*/
175 /*----------------------------------------------------------------------------*/
176 
177 void
179 
180 /*----------------------------------------------------------------------------*/
189 /*----------------------------------------------------------------------------*/
190 
191 bool
193  const char *ref_name);
194 
195 /*----------------------------------------------------------------------------*/
203 /*----------------------------------------------------------------------------*/
204 
205 bool
207 
208 /*----------------------------------------------------------------------------*/
217 /*----------------------------------------------------------------------------*/
218 
219 bool
221 
222 /*----------------------------------------------------------------------------*/
230 /*----------------------------------------------------------------------------*/
231 
232 const char *
234 
235 /*----------------------------------------------------------------------------*/
244 /*----------------------------------------------------------------------------*/
245 
248 
249 /*----------------------------------------------------------------------------*/
253 /*----------------------------------------------------------------------------*/
254 
255 void
257 
258 /*----------------------------------------------------------------------------*/
265 /*----------------------------------------------------------------------------*/
266 
267 void
270 
271 /*----------------------------------------------------------------------------*/
278 /*----------------------------------------------------------------------------*/
279 
280 void
282  cs_real_t vector[3]);
283 
284 /*----------------------------------------------------------------------------*/
292 /*----------------------------------------------------------------------------*/
293 
294 void
296  cs_analytic_func_t *func,
297  void *input);
298 
299 /*----------------------------------------------------------------------------*/
308 /*----------------------------------------------------------------------------*/
309 
310 void
312  cs_flag_t loc,
313  cs_real_t *array,
314  cs_lnum_t *index);
315 
316 /*----------------------------------------------------------------------------*/
323 /*----------------------------------------------------------------------------*/
324 
325 void
327  cs_field_t *field);
328 
329 /*----------------------------------------------------------------------------*/
334 /*----------------------------------------------------------------------------*/
335 
336 void
338 
339 /*----------------------------------------------------------------------------*/
349 /*----------------------------------------------------------------------------*/
350 
351 cs_field_t *
353  cs_mesh_location_type_t ml_type);
354 
355 /*----------------------------------------------------------------------------*/
363 /*----------------------------------------------------------------------------*/
364 
365 void
367  const cs_adv_field_t *adv,
368  cs_nvec3_t *vect);
369 
370 /*----------------------------------------------------------------------------*/
378 /*----------------------------------------------------------------------------*/
379 
380 void
382  const cs_adv_field_t *adv,
383  cs_nvec3_t *vect);
384 
385 /*----------------------------------------------------------------------------*/
394 /*----------------------------------------------------------------------------*/
395 
396 void
398  const cs_cell_mesh_t *cm,
399  const cs_real_3_t xyz,
400  cs_nvec3_t *vect);
401 
402 /*----------------------------------------------------------------------------*/
409 /*----------------------------------------------------------------------------*/
410 
411 void
413  cs_real_t *cell_values);
414 
415 /*----------------------------------------------------------------------------*/
422 /*----------------------------------------------------------------------------*/
423 
424 void
426  cs_real_t *vtx_values);
427 
428 /*----------------------------------------------------------------------------*/
437 /*----------------------------------------------------------------------------*/
438 
439 void
441  const cs_adv_field_t *adv,
442  cs_real_t *fluxes);
443 
444 /*----------------------------------------------------------------------------*/
460 /*----------------------------------------------------------------------------*/
461 
462 cs_real_t
464  const cs_cell_mesh_t *cm,
465  const cs_real_t tef_meas,
466  short int f,
467  short int e,
468  short int v1,
469  short int v2);
470 
471 /*----------------------------------------------------------------------------*/
478 /*----------------------------------------------------------------------------*/
479 
480 void
481 cs_advection_field_update(bool cur2prev);
482 
483 /*----------------------------------------------------------------------------*/
491 /*----------------------------------------------------------------------------*/
492 
493 void
495  const cs_property_t *diff,
496  cs_real_t peclet[]);
497 
498 /*----------------------------------------------------------------------------*/
499 
501 
502 #endif /* __CS_ADVECTION_FIELD_H__ */
void( cs_xdef_eval_cw_xyz_t)(const cs_cell_mesh_t *cm, cs_lnum_t n_points, const cs_real_t *xyz, const cs_time_step_t *ts, void *input, cs_real_t *eval)
Function pointer for evaluating a quantity at several locations in a cell defined through a descripto...
Definition: cs_xdef_eval.h:113
void cs_advection_field_get_flux_dfaces(const cs_cell_mesh_t *cm, 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:909
time step descriptor
Definition: cs_time_step.h:51
void cs_advection_field_update(bool cur2prev)
For each cs_adv_field_t structures, update the values of the related field(s)
Definition: cs_advection_field.c:1275
#define restrict
Definition: cs_defs.h:122
cs_xdef_eval_cw_t * get_eval_at_cell_cw
Definition: cs_advection_field.h:78
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:317
cs_xdef_t * definition
Definition: cs_advection_field.h:73
void cs_advection_field_def_by_array(cs_adv_field_t *adv, cs_flag_t loc, cs_real_t *array, cs_lnum_t *index)
Define a cs_adv_field_t structure thanks to an array of values.
Definition: cs_advection_field.c:545
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:836
void cs_advection_get_peclet(const cs_adv_field_t *adv, const cs_property_t *diff, cs_real_t peclet[])
Compute the Peclet number in each cell.
Definition: cs_advection_field.c:1323
Definition: cs_advection_field.h:61
cs_adv_field_t * cs_advection_field_by_id(int id)
Search in the array of advection field structures which one has the id given in argument.
Definition: cs_advection_field.c:173
Field descriptor.
Definition: cs_field.h:124
cs_mesh_location_type_t
Definition: cs_mesh_location.h:60
void cs_advection_field_def_by_value(cs_adv_field_t *adv, cs_real_t vector[3])
Define the value of a cs_adv_field_t structure.
Definition: cs_advection_field.c:473
void cs_advection_field_def_by_analytic(cs_adv_field_t *adv, cs_analytic_func_t *func, void *input)
Define a cs_adv_field_t structure thanks to an analytic function.
Definition: cs_advection_field.c:507
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:366
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
cs_flag_t flag
Definition: cs_advection_field.h:67
int cell_field_id
Definition: cs_advection_field.h:69
cs_advection_field_key_t
Definition: cs_advection_field.h:84
cs_real_t cs_advection_field_get_flux_tef(const cs_adv_field_t *adv, const cs_cell_mesh_t *cm, const 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:1130
Definition: cs_advection_field.h:87
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:727
Definition: cs_cdo_local.h:138
cs_xdef_eval_t * get_eval_at_cell
Definition: cs_advection_field.h:77
Definition: cs_cdo_connect.h:55
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:109
void cs_advection_field_set_option(cs_adv_field_t *adv, cs_advection_field_key_t key)
Set optional parameters related to a cs_adv_field_t structure.
Definition: cs_advection_field.c:434
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
int cs_advection_field_get_n_fields(void)
Get the number of allocated cs_adv_field_t structures.
Definition: cs_advection_field.c:128
Definition: cs_cdo_quantities.h:89
Definition: cs_cdo.h:130
cs_xdef_eval_t * get_eval_all_vertices
Definition: cs_advection_field.h:76
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:758
cs_flag_t loc_flag
Definition: cs_advection_field.h:66
void( cs_xdef_eval_t)(cs_lnum_t n_elts, const cs_lnum_t *elt_ids, bool compact, const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *quant, const cs_time_step_t *ts, void *input, cs_real_t *eval)
Function pointer for evaluating a quantity defined through a descriptor (cs_xdef_t structure) ...
Definition: cs_xdef_eval.h:68
Definition: cs_advection_field.h:86
cs_xdef_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:386
int id
Definition: cs_advection_field.h:63
Definition: cs_advection_field.h:88
cs_xdef_type_t
Definition: cs_xdef.h:50
void cs_advection_field_get_at_xyz(const cs_adv_field_t *adv, const cs_cell_mesh_t *cm, 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:798
Definition: cs_xdef.h:72
void( cs_xdef_eval_cw_t)(const cs_cell_mesh_t *cm, const cs_time_step_t *ts, void *input, cs_real_t *eval)
Function pointer for evaluating a quantity defined through a descriptor (cs_xdef_t structure) by a ce...
Definition: cs_xdef_eval.h:92
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
Definition: cs_advection_field.h:90
cs_adv_field_t * cs_advection_field_by_name(const char *name)
Search in the array of advection field structures which one has the name given in argument...
Definition: cs_advection_field.c:145
void( cs_analytic_func_t)(cs_real_t time, cs_lnum_t n_elts, const cs_lnum_t *elt_ids, const cs_real_t *coords, bool compact, void *input, cs_real_t *retval)
Generic function pointer for an analytic function elt_ids is optional. If not NULL, it enables to access in coords at the right location and the same thing to fill retval if compact is set to false.
Definition: cs_cdo.h:169
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:871
void cs_advection_field_log_setup(void)
Print all setup information related to cs_adv_field_t structures.
Definition: cs_advection_field.c:401
void cs_advection_field_create_fields(void)
Create all needed cs_field_t structures related to an advection field.
Definition: cs_advection_field.c:617
#define END_C_DECLS
Definition: cs_defs.h:454
void cs_advection_field_destroy_all(void)
Free all alllocated cs_adv_field_t structures and its related array.
Definition: cs_advection_field.c:253
unsigned short int cs_flag_t
Definition: cs_defs.h:299
Definition: cs_advection_field.h:89
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:340
int vtx_field_id
Definition: cs_advection_field.h:68
char *restrict name
Definition: cs_advection_field.h:64
Definition: cs_property.h:62
cs_xdef_eval_cw_xyz_t * get_eval_at_xyz_cw
Definition: cs_advection_field.h:79
void cs_advection_field_def_by_field(cs_adv_field_t *adv, cs_field_t *field)
Define a cs_adv_field_t structure thanks to an array of values.
Definition: cs_advection_field.c:584
cs_adv_field_t * cs_advection_field_add(const char *name)
Add and initialize a new advection field structure.
Definition: cs_advection_field.c:196
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:287
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:690