My Project
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__ */
cs_xdef_time_func_input_t::input
void * input
Definition: cs_xdef.h:241
CS_N_XDEF_TYPES
Definition: cs_xdef.h:92
cs_quadrature.h
input
static int input(void)
cs_get_bdy_zone_id
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,...
Definition: cs_xdef.h:286
cs_xdef_array_input_t::stride
int stride
Definition: cs_xdef.h:199
cs_xdef_t
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:126
CS_XDEF_BY_FIELD
Definition: cs_xdef.h:86
cs_zone_t
Definition: cs_zone.h:55
cs_xdef_analytic_input_t::func
cs_analytic_func_t * func
Definition: cs_xdef.h:223
cs_xdef_get_type
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
cs_boundary_zone.h
cs_xdef_get_state_flag
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
cs_xdef_analytic_input_t
Input structure when an analytic function is used for the definition.
Definition: cs_xdef.h:212
cs_xdef_get_quadrature
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
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
CS_XDEF_BY_VALUE
Definition: cs_xdef.h:90
CS_XDEF_BY_ANALYTIC_FUNCTION
Definition: cs_xdef.h:84
cs_volume_zone_by_name
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_real_t
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
CS_XDEF_SUPPORT_TIME
Definition: cs_xdef.h:112
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_xdef_analytic_input_t::input
void * input
Definition: cs_xdef.h:218
cs_xdef_t::meta
cs_flag_t meta
Definition: cs_xdef.h:165
cs_xdef_t::input
void * input
Definition: cs_xdef.h:169
cs_xdef_volume_create
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
cs_xdef_log
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
CS_XDEF_SUPPORT_VOLUME
Definition: cs_xdef.h:114
CS_XDEF_BY_FUNCTION
Definition: cs_xdef.h:87
cs_volume_zone.h
cs_xdef_copy
cs_xdef_t * cs_xdef_copy(cs_xdef_t *src)
copy a cs_xdef_t structure
Definition: cs_xdef.c:444
cs_xdef_set_array
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_time_func_t
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
cs_xdef_array_input_t::loc
cs_flag_t loc
Definition: cs_xdef.h:200
cs_xdef_boundary_create
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_get_vol_zone_id
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,...
Definition: cs_xdef.h:262
CS_XDEF_BY_QOV
Definition: cs_xdef.h:88
cs_xdef_t::state
cs_flag_t state
Definition: cs_xdef.h:164
cs_xdef_support_t
cs_xdef_support_t
Definition: cs_xdef.h:110
CS_XDEF_SUPPORT_BOUNDARY
Definition: cs_xdef.h:113
CS_XDEF_BY_ARRAY
Definition: cs_xdef.h:85
cs_xdef_t::qtype
cs_quadrature_type_t qtype
Definition: cs_xdef.h:167
cs_xdef_t::support
cs_xdef_support_t support
Definition: cs_xdef.h:162
cs_lnum_t
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_xdef_t::type
cs_xdef_type_t type
Definition: cs_xdef.h:160
cs_xdef_t::z_id
int z_id
Definition: cs_xdef.h:161
cs_analytic_func_t
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,...
Definition: cs_param.h:66
cs_xdef_set_quadrature
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_zone_t::id
int id
Definition: cs_zone.h:59
cs_xdef_array_input_t::is_owner
bool is_owner
Definition: cs_xdef.h:203
cs_boundary_zone_by_name
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:706
cs_xdef_time_func_input_t
Input structure when a time step function is used for the definition.
Definition: cs_xdef.h:232
cs_xdef_timestep_create
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
cs_xdef_type_t
cs_xdef_type_t
Definition: cs_xdef.h:82
CS_N_XDEF_SUPPORTS
Definition: cs_xdef.h:116
cs_xdef_set_array_index
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
cs_xdef_array_input_t::values
cs_real_t * values
Definition: cs_xdef.h:201
cs_flag_t
unsigned short int cs_flag_t
Definition: cs_defs.h:304
cs_xdef_array_input_t::index
cs_lnum_t * index
Definition: cs_xdef.h:202
cs_xdef_t::dim
int dim
Definition: cs_xdef.h:159
cs_xdef_time_func_input_t::func
cs_time_func_t * func
Definition: cs_xdef.h:242
cs_quadrature_type_t
cs_quadrature_type_t
Definition: cs_quadrature.h:51
CS_XDEF_BY_TIME_FUNCTION
Definition: cs_xdef.h:89
type
void const cs_int_t * type
Definition: cs_measures_util.h:425
cs_param.h
cs_base.h
cs_xdef_array_input_t
Input structure when an array is used for the definition.
Definition: cs_xdef.h:178
cs_xdef_free
cs_xdef_t * cs_xdef_free(cs_xdef_t *d)
Free a cs_xdef_t structure.
Definition: cs_xdef.c:409