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-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 <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 
193  int stride;
197 
199 
205 typedef struct {
206 
211  void *input;
212 
217 
219 
225 typedef struct {
226 
234  void *input;
236 
238 
239 /*============================================================================
240  * Public function prototypes
241  *============================================================================*/
242 
243 /*----------------------------------------------------------------------------*/
252 /*----------------------------------------------------------------------------*/
253 
254 static inline int
255 cs_get_vol_zone_id(const char *z_name)
256 {
257  int z_id = 0;
258  if (z_name != NULL) {
259  if (strlen(z_name) > 0) {
260  const cs_zone_t *z = cs_volume_zone_by_name(z_name);
261  z_id = z->id;
262  }
263  }
264  return z_id;
265 }
266 
267 /*----------------------------------------------------------------------------*/
276 /*----------------------------------------------------------------------------*/
277 
278 static inline int
279 cs_get_bdy_zone_id(const char *z_name)
280 {
281  int z_id = 0;
282  if (z_name != NULL) {
283  if (strlen(z_name) > 0) {
284  const cs_zone_t *z = cs_boundary_zone_by_name(z_name);
285  z_id = z->id;
286  }
287  }
288  return z_id;
289 }
290 
291 /*============================================================================
292  * Public function prototypes
293  *============================================================================*/
294 
295 /*----------------------------------------------------------------------------*/
309 /*----------------------------------------------------------------------------*/
310 
311 cs_xdef_t *
313  int dim,
314  int z_id,
315  cs_flag_t state,
316  cs_flag_t meta,
317  void *input);
318 
319 /*----------------------------------------------------------------------------*/
333 /*----------------------------------------------------------------------------*/
334 
335 cs_xdef_t *
337  int dim,
338  int z_id,
339  cs_flag_t state,
340  cs_flag_t meta,
341  void *input);
342 
343 /*----------------------------------------------------------------------------*/
356 /*----------------------------------------------------------------------------*/
357 
358 cs_xdef_t *
360  cs_flag_t state,
361  cs_flag_t meta,
362  void *input);
363 
364 /*----------------------------------------------------------------------------*/
372 /*----------------------------------------------------------------------------*/
373 
374 cs_xdef_t *
376 
377 /*----------------------------------------------------------------------------*/
385 /*----------------------------------------------------------------------------*/
386 
387 cs_xdef_t *
388 cs_xdef_copy(cs_xdef_t *src);
389 
390 /*----------------------------------------------------------------------------*/
399 /*----------------------------------------------------------------------------*/
400 
401 void
403  bool is_owner,
404  cs_real_t *array);
405 
406 /*----------------------------------------------------------------------------*/
414 /*----------------------------------------------------------------------------*/
415 
416 void
418  cs_lnum_t *array_index);
419 
420 /*----------------------------------------------------------------------------*/
428 /*----------------------------------------------------------------------------*/
429 
430 void
432  cs_quadrature_type_t qtype);
433 
434 /*----------------------------------------------------------------------------*/
443 /*----------------------------------------------------------------------------*/
444 
447 
448 /*----------------------------------------------------------------------------*/
456 /*----------------------------------------------------------------------------*/
457 
459 cs_xdef_get_type(const cs_xdef_t *d);
460 
461 /*----------------------------------------------------------------------------*/
469 /*----------------------------------------------------------------------------*/
470 
471 cs_flag_t
473 
474 /*----------------------------------------------------------------------------*/
480 /*----------------------------------------------------------------------------*/
481 
482 void
484 
485 /*----------------------------------------------------------------------------*/
486 
488 
489 #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:515
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:563
cs_xdef_t * cs_xdef_free(cs_xdef_t *d)
Free a cs_xdef_t structure.
Definition: cs_xdef.c:384
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:641
cs_analytic_func_t * func
Definition: cs_xdef.h:216
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:462
Input structure when an array is used for the definition.
Definition: cs_xdef.h:178
Definition: cs_xdef.h:86
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:614
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:582
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:420
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:479
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:208
cs_flag_t cs_xdef_get_state_flag(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.c:601
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
int dim
Definition: cs_xdef.h:159
cs_real_t() cs_timestep_func_t(int time_iter, double time, void *input)
Function which defines the time step according to the number of iteration already done...
Definition: cs_param.h:89
cs_xdef_type_t type
Definition: cs_xdef.h:160
void * input
Definition: cs_xdef.h:211
void * input
Definition: cs_xdef.h:169
cs_lnum_t * index
Definition: cs_xdef.h:196
Definition: cs_xdef.h:88
cs_xdef_support_t
Definition: cs_xdef.h:110
cs_real_t * values
Definition: cs_xdef.h:195
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:542
cs_flag_t loc
Definition: cs_xdef.h:194
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:321
void * input
Definition: cs_xdef.h:234
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:255
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
cs_xdef_support_t support
Definition: cs_xdef.h:162
Definition: cs_xdef.h:87
#define END_C_DECLS
Definition: cs_defs.h:463
unsigned short int cs_flag_t
Definition: cs_defs.h:299
cs_flag_t meta
Definition: cs_xdef.h:165
int stride
Definition: cs_xdef.h:193
Input structure when an analytic function is used for the definition.
Definition: cs_xdef.h:205
int z_id
Definition: cs_xdef.h:161
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:279
Definition: cs_xdef.h:92
cs_timestep_func_t * func
Definition: cs_xdef.h:235
Definition: cs_xdef.h:113
void cs_xdef_log(cs_xdef_t *d)
Output the settings related to a a cs_xdef_t structure.
Definition: cs_xdef.c:618
Definition: cs_zone.h:55
Input structure when a time step function is used for the definition.
Definition: cs_xdef.h:225