programmer's documentation
cs_xdef.h
Go to the documentation of this file.
1 #ifndef __CS_XDEF_H__
2 #define __CS_XDEF_H__
3 
4 /*============================================================================
5  * Routines to handle extended definitions of quantities (cs_xdef_t structures)
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2019 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 <string.h>
35 
36 #include "cs_base.h"
37 #include "cs_boundary_zone.h"
38 #include "cs_param.h"
39 #include "cs_quadrature.h"
40 #include "cs_volume_zone.h"
41 
42 /*----------------------------------------------------------------------------*/
43 
45 
46 /*============================================================================
47  * Macro definitions
48  *============================================================================*/
49 
50 /*============================================================================
51  * Type definitions
52  *============================================================================*/
53 
82 typedef enum {
83 
91 
93 
95 
110 typedef enum {
111 
112  CS_XDEF_SUPPORT_TIME, /* support for time step description */
113  CS_XDEF_SUPPORT_BOUNDARY, /* zones attached to boundary faces */
115 
117 
119 
126 typedef struct {
127 
159  int dim;
161  int z_id;
163 
166 
168 
169  void *input;
170 
171 } cs_xdef_t;
172 
178 typedef struct {
179 
199  int stride;
203  bool is_owner;
204 
206 
212 typedef struct {
213 
218  void *input;
219 
224 
226 
232 typedef struct {
233 
241  void *input;
243 
245 
246 /*============================================================================
247  * Public function prototypes
248  *============================================================================*/
249 
250 /*----------------------------------------------------------------------------*/
259 /*----------------------------------------------------------------------------*/
260 
261 static inline int
262 cs_get_vol_zone_id(const char *z_name)
263 {
264  int z_id = 0;
265  if (z_name != NULL) {
266  if (strlen(z_name) > 0) {
267  const cs_zone_t *z = cs_volume_zone_by_name(z_name);
268  z_id = z->id;
269  }
270  }
271  return z_id;
272 }
273 
274 /*----------------------------------------------------------------------------*/
283 /*----------------------------------------------------------------------------*/
284 
285 static inline int
286 cs_get_bdy_zone_id(const char *z_name)
287 {
288  int z_id = 0;
289  if (z_name != NULL) {
290  if (strlen(z_name) > 0) {
291  const cs_zone_t *z = cs_boundary_zone_by_name(z_name);
292  z_id = z->id;
293  }
294  }
295  return z_id;
296 }
297 
298 /*============================================================================
299  * Public function prototypes
300  *============================================================================*/
301 
302 /*----------------------------------------------------------------------------*/
316 /*----------------------------------------------------------------------------*/
317 
318 cs_xdef_t *
320  int dim,
321  int z_id,
322  cs_flag_t state,
323  cs_flag_t meta,
324  void *input);
325 
326 /*----------------------------------------------------------------------------*/
340 /*----------------------------------------------------------------------------*/
341 
342 cs_xdef_t *
344  int dim,
345  int z_id,
346  cs_flag_t state,
347  cs_flag_t meta,
348  void *input);
349 
350 /*----------------------------------------------------------------------------*/
363 /*----------------------------------------------------------------------------*/
364 
365 cs_xdef_t *
367  cs_flag_t state,
368  cs_flag_t meta,
369  void *input);
370 
371 /*----------------------------------------------------------------------------*/
379 /*----------------------------------------------------------------------------*/
380 
381 cs_xdef_t *
383 
384 /*----------------------------------------------------------------------------*/
392 /*----------------------------------------------------------------------------*/
393 
394 cs_xdef_t *
395 cs_xdef_copy(cs_xdef_t *src);
396 
397 /*----------------------------------------------------------------------------*/
406 /*----------------------------------------------------------------------------*/
407 
408 void
410  bool is_owner,
411  cs_real_t *array);
412 
413 /*----------------------------------------------------------------------------*/
421 /*----------------------------------------------------------------------------*/
422 
423 void
425  cs_lnum_t *array_index);
426 
427 /*----------------------------------------------------------------------------*/
435 /*----------------------------------------------------------------------------*/
436 
437 void
439  cs_quadrature_type_t qtype);
440 
441 /*----------------------------------------------------------------------------*/
450 /*----------------------------------------------------------------------------*/
451 
454 
455 /*----------------------------------------------------------------------------*/
463 /*----------------------------------------------------------------------------*/
464 
466 cs_xdef_get_type(const cs_xdef_t *d);
467 
468 /*----------------------------------------------------------------------------*/
476 /*----------------------------------------------------------------------------*/
477 
478 cs_flag_t
480 
481 /*----------------------------------------------------------------------------*/
488 /*----------------------------------------------------------------------------*/
489 
490 void
491 cs_xdef_log(const char *prefix,
492  const cs_xdef_t *d);
493 
494 /*----------------------------------------------------------------------------*/
495 
497 
498 #endif /* __CS_XDEF_H__ */
void cs_xdef_set_array_index(cs_xdef_t *d, cs_lnum_t *array_index)
In case of definition by array, set the index to get access to the array values.
Definition: cs_xdef.c:537
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_param.h:66
cs_quadrature_type_t cs_xdef_get_quadrature(cs_xdef_t *d)
Get the type of quadrature to use for evaluating the given description.
Definition: cs_xdef.c:585
cs_time_func_t * func
Definition: cs_xdef.h:242
Input structure when a time step function is used for the definition.
Definition: cs_xdef.h:232
cs_xdef_t * cs_xdef_free(cs_xdef_t *d)
Free a cs_xdef_t structure.
Definition: cs_xdef.c:409
Definition: cs_xdef.h:90
const cs_zone_t * cs_boundary_zone_by_name(const char *name)
Return a pointer to a boundary zone based on its name if present.
Definition: cs_boundary_zone.c:705
cs_analytic_func_t * func
Definition: cs_xdef.h:223
cs_xdef_t * cs_xdef_volume_create(cs_xdef_type_t type, int dim, int z_id, cs_flag_t state, cs_flag_t meta, void *input)
Allocate and initialize a new cs_xdef_t structure based on volumic elements.
Definition: cs_xdef.c:92
int id
Definition: cs_zone.h:59
Definition: cs_xdef.h:112
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
Input structure when an array is used for the definition.
Definition: cs_xdef.h:178
Definition: cs_xdef.h:86
void cs_xdef_log(const char *prefix, const cs_xdef_t *d)
Output the settings related to a cs_xdef_t structure.
Definition: cs_xdef.c:641
const cs_zone_t * cs_volume_zone_by_name(const char *name)
Return a pointer to a volume zone based on its name if present.
Definition: cs_volume_zone.c:676
cs_flag_t state
Definition: cs_xdef.h:164
Definition: cs_xdef.h:85
cs_xdef_type_t cs_xdef_get_type(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.c:604
Definition: cs_xdef.h:114
cs_xdef_t * cs_xdef_copy(cs_xdef_t *src)
copy a cs_xdef_t structure
Definition: cs_xdef.c:444
void cs_xdef_set_array(cs_xdef_t *d, bool is_owner, cs_real_t *array)
In case of definition by array, set the array after having added this definition. ...
Definition: cs_xdef.c:503
cs_xdef_t * cs_xdef_boundary_create(cs_xdef_type_t type, int dim, int z_id, cs_flag_t state, cs_flag_t meta, void *input)
Allocate and initialize a new cs_xdef_t structure based on boundary elements.
Definition: cs_xdef.c:235
cs_flag_t cs_xdef_get_state_flag(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.c:623
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
int dim
Definition: cs_xdef.h:159
cs_xdef_type_t type
Definition: cs_xdef.h:160
void * input
Definition: cs_xdef.h:218
void * input
Definition: cs_xdef.h:169
cs_lnum_t * index
Definition: cs_xdef.h:202
Definition: cs_xdef.h:88
cs_xdef_support_t
Definition: cs_xdef.h:110
bool is_owner
Definition: cs_xdef.h:203
cs_real_t * values
Definition: cs_xdef.h:201
cs_quadrature_type_t
Definition: cs_quadrature.h:51
void cs_xdef_set_quadrature(cs_xdef_t *d, cs_quadrature_type_t qtype)
Set the type of quadrature to use for evaluating the given description.
Definition: cs_xdef.c:564
cs_flag_t loc
Definition: cs_xdef.h:200
cs_quadrature_type_t qtype
Definition: cs_xdef.h:167
cs_xdef_type_t
Definition: cs_xdef.h:82
Definition: cs_xdef.h:84
static int input(void)
cs_xdef_t * cs_xdef_timestep_create(cs_xdef_type_t type, cs_flag_t state, cs_flag_t meta, void *input)
Allocate and initialize a new cs_xdef_t structure for setting the time step.
Definition: cs_xdef.c:346
Definition: cs_xdef.h:89
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:126
Definition: cs_xdef.h:116
static int cs_get_vol_zone_id(const char *z_name)
Retrieve the volume zone if from the zone name (If name = NULL or has an empty length, all entities are selected)
Definition: cs_xdef.h:262
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_xdef_support_t support
Definition: cs_xdef.h:162
Definition: cs_xdef.h:87
void() cs_time_func_t(int time_iter, double time, void *input, cs_real_t *retval)
Function which defines the evolution of a quantity according to the number of iteration already done...
Definition: cs_param.h:88
#define END_C_DECLS
Definition: cs_defs.h:468
unsigned short int cs_flag_t
Definition: cs_defs.h:304
cs_flag_t meta
Definition: cs_xdef.h:165
int stride
Definition: cs_xdef.h:199
Input structure when an analytic function is used for the definition.
Definition: cs_xdef.h:212
int z_id
Definition: cs_xdef.h:161
void * input
Definition: cs_xdef.h:241
static int cs_get_bdy_zone_id(const char *z_name)
Retrieve the boundary zone if from the zone name (If name = NULL or has an empty length, all entities are selected)
Definition: cs_xdef.h:286
Definition: cs_xdef.h:92
Definition: cs_xdef.h:113
Definition: cs_zone.h:55