6.2
general 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-2020 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_types.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 
90 typedef enum {
91 
101 
103 
105 
120 typedef enum {
121 
122  CS_XDEF_SUPPORT_TIME, /* support for time step description */
123  CS_XDEF_SUPPORT_BOUNDARY, /* zones attached to boundary faces */
125 
127 
129 
136 typedef struct {
137 
170  int dim;
172  int z_id;
174 
177 
179 
180  void *input;
181 
182 } cs_xdef_t;
183 
189 typedef struct {
190 
211  int stride;
215  bool is_owner;
216 
218 
224 typedef struct {
225 
230  void *input;
231 
236 
238 
244 typedef struct {
245 
250  void *input;
251 
257 
262 
264 
270 typedef struct {
271 
276  void *input;
277 
282 
284 
285 /*============================================================================
286  * Public function prototypes
287  *============================================================================*/
288 
289 /*----------------------------------------------------------------------------*/
298 /*----------------------------------------------------------------------------*/
299 
300 static inline int
301 cs_get_vol_zone_id(const char *z_name)
302 {
303  int z_id = 0;
304  if (z_name != NULL) {
305  if (strlen(z_name) > 0) {
306  const cs_zone_t *z = cs_volume_zone_by_name(z_name);
307  z_id = z->id;
308  }
309  }
310  return z_id;
311 }
312 
313 /*----------------------------------------------------------------------------*/
322 /*----------------------------------------------------------------------------*/
323 
324 static inline int
325 cs_get_bdy_zone_id(const char *z_name)
326 {
327  int z_id = 0;
328  if (z_name != NULL) {
329  if (strlen(z_name) > 0) {
330  const cs_zone_t *z = cs_boundary_zone_by_name(z_name);
331  z_id = z->id;
332  }
333  }
334  return z_id;
335 }
336 
337 /*----------------------------------------------------------------------------*/
347 /*----------------------------------------------------------------------------*/
348 
349 inline static cs_real_t
350 cs_xdef_get_scalar_value(cs_xdef_t *def)
351 {
352  assert(def != NULL);
353  assert(def->dim == 1);
354  assert(def->type == CS_XDEF_BY_VALUE);
355 
356  cs_real_t *value = (cs_real_t *)def->input;
357 
358  return value[0];
359 }
360 
361 /*----------------------------------------------------------------------------*/
370 /*----------------------------------------------------------------------------*/
371 
372 inline static cs_real_t *
373 cs_xdef_get_array(cs_xdef_t *def)
374 {
375  assert(def != NULL);
376  assert(def->type == CS_XDEF_BY_ARRAY);
377 
379 
380  return ai->values;
381 }
382 
383 /*============================================================================
384  * Public function prototypes
385  *============================================================================*/
386 
387 /*----------------------------------------------------------------------------*/
401 /*----------------------------------------------------------------------------*/
402 
403 cs_xdef_t *
405  int dim,
406  int z_id,
407  cs_flag_t state,
408  cs_flag_t meta,
409  void *input);
410 
411 /*----------------------------------------------------------------------------*/
425 /*----------------------------------------------------------------------------*/
426 
427 cs_xdef_t *
429  int dim,
430  int z_id,
431  cs_flag_t state,
432  cs_flag_t meta,
433  void *input);
434 
435 /*----------------------------------------------------------------------------*/
448 /*----------------------------------------------------------------------------*/
449 
450 cs_xdef_t *
452  cs_flag_t state,
453  cs_flag_t meta,
454  void *input);
455 
456 /*----------------------------------------------------------------------------*/
464 /*----------------------------------------------------------------------------*/
465 
466 cs_xdef_t *
468 
469 /*----------------------------------------------------------------------------*/
477 /*----------------------------------------------------------------------------*/
478 
479 cs_xdef_t *
480 cs_xdef_copy(cs_xdef_t *src);
481 
482 /*----------------------------------------------------------------------------*/
491 /*----------------------------------------------------------------------------*/
492 
493 void
495  bool is_owner,
496  cs_real_t *array);
497 
498 /*----------------------------------------------------------------------------*/
506 /*----------------------------------------------------------------------------*/
507 
508 void
510  cs_lnum_t *array_index);
511 
512 /*----------------------------------------------------------------------------*/
520 /*----------------------------------------------------------------------------*/
521 
522 void
524  cs_quadrature_type_t qtype);
525 
526 /*----------------------------------------------------------------------------*/
535 /*----------------------------------------------------------------------------*/
536 
539 
540 /*----------------------------------------------------------------------------*/
548 /*----------------------------------------------------------------------------*/
549 
551 cs_xdef_get_type(const cs_xdef_t *d);
552 
553 /*----------------------------------------------------------------------------*/
561 /*----------------------------------------------------------------------------*/
562 
563 cs_flag_t
565 
566 /*----------------------------------------------------------------------------*/
573 /*----------------------------------------------------------------------------*/
574 
575 void
576 cs_xdef_log(const char *prefix,
577  const cs_xdef_t *d);
578 
579 /*----------------------------------------------------------------------------*/
580 
582 
583 #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:566
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:614
cs_time_func_t * func
Definition: cs_xdef.h:281
Input structure when a time step function is used for the definition.
Definition: cs_xdef.h:270
cs_xdef_t * cs_xdef_free(cs_xdef_t *d)
Free a cs_xdef_t structure.
Definition: cs_xdef.c:437
Definition: cs_xdef.h:100
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:726
cs_analytic_func_t * func
Definition: cs_xdef.h:235
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:122
#define BEGIN_C_DECLS
Definition: cs_defs.h:495
Input structure when an array is used for the definition.
Definition: cs_xdef.h:189
Definition: cs_xdef.h:95
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:670
cs_flag_t loc
Definition: cs_xdef.h:256
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:695
cs_flag_t state
Definition: cs_xdef.h:175
Definition: cs_xdef.h:93
cs_xdef_type_t cs_xdef_get_type(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.c:633
Definition: cs_xdef.h:124
Definition: cs_xdef.h:98
cs_xdef_t * cs_xdef_copy(cs_xdef_t *src)
copy a cs_xdef_t structure
Definition: cs_xdef.c:473
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:532
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:249
cs_flag_t cs_xdef_get_state_flag(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.c:652
double cs_real_t
Floating-point value.
Definition: cs_defs.h:307
int dim
Definition: cs_xdef.h:170
cs_xdef_type_t type
Definition: cs_xdef.h:171
void * input
Definition: cs_xdef.h:230
void * input
Definition: cs_xdef.h:180
cs_lnum_t * index
Definition: cs_xdef.h:214
Definition: cs_xdef.h:97
cs_xdef_support_t
Definition: cs_xdef.h:120
bool is_owner
Definition: cs_xdef.h:215
cs_real_t * values
Definition: cs_xdef.h:213
cs_quadrature_type_t
Definition: cs_quadrature.h:52
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:593
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_types.h:93
void() cs_dof_func_t(cs_lnum_t n_elts, const cs_lnum_t *elt_ids, bool compact, void *input, cs_real_t *retval)
Generic function pointer for defining a quantity at known locations (cells, faces, edges or vertices) with a function. elt_ids is optional. If not NULL, the function works on a sub-list of elements. Moreover, it enables to fill retval with an indirection if compact is set to false.
Definition: cs_param_types.h:118
cs_flag_t loc
Definition: cs_xdef.h:212
cs_quadrature_type_t qtype
Definition: cs_xdef.h:178
Input structure when a definition by DoF function is used.
Definition: cs_xdef.h:244
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_types.h:138
cs_xdef_type_t
Definition: cs_xdef.h:90
Definition: cs_xdef.h:92
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:374
Definition: cs_xdef.h:99
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:136
cs_dof_func_t * func
Definition: cs_xdef.h:261
Definition: cs_xdef.h:126
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:301
cs_xdef_support_t support
Definition: cs_xdef.h:173
Definition: cs_xdef.h:96
#define END_C_DECLS
Definition: cs_defs.h:496
void * input
Definition: cs_xdef.h:250
unsigned short int cs_flag_t
Definition: cs_defs.h:309
cs_flag_t meta
Definition: cs_xdef.h:176
int stride
Definition: cs_xdef.h:211
Definition: cs_xdef.h:94
Input structure when a definition by analytic function is used.
Definition: cs_xdef.h:224
int z_id
Definition: cs_xdef.h:172
void * input
Definition: cs_xdef.h:276
Definition: cs_xdef.h:102
Definition: cs_xdef.h:123
Definition: cs_zone.h:55