7.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  * Functions to handle extended definitions of quantities
6  *============================================================================*/
7 
8 /*
9  This file is part of code_saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2022 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 
54 /*----------------------------------------------------------------------------*/
67 /*----------------------------------------------------------------------------*/
68 
69 typedef void *
70 (cs_xdef_free_input_t)(void *input);
71 
108 typedef enum {
109 
119 
121 
123 
138 typedef enum {
139 
140  CS_XDEF_SUPPORT_TIME, /* support for time step description */
141  CS_XDEF_SUPPORT_BOUNDARY, /* zones attached to boundary faces */
143 
145 
147 
154 typedef struct {
155 
188  int dim;
189  cs_xdef_type_t type;
190  int z_id;
191  cs_xdef_support_t support;
192 
195 
197 
198  void *context;
199 
200 } cs_xdef_t;
201 
207 typedef struct {
208 
239  int z_id;
240  int stride;
243  bool is_owner;
244 
245  const cs_lnum_t *index;
246  const cs_lnum_t *ids;
247 
249 
255 typedef struct {
256 
261  int z_id;
262 
268 
274  void *input;
275 
281 
283 
289 typedef struct {
290 
295  int z_id;
296 
303 
309 
314  void *input;
315 
321 
323 
329 typedef struct {
330 
336 
342  void *input;
343 
349 
351 
352 /*============================================================================
353  * Public function prototypes
354  *============================================================================*/
355 
356 /*----------------------------------------------------------------------------*/
365 /*----------------------------------------------------------------------------*/
366 
367 static inline int
368 cs_get_vol_zone_id(const char *z_name)
369 {
370  int z_id = 0;
371  if (z_name != NULL) {
372  if (strlen(z_name) > 0) {
373  const cs_zone_t *z = cs_volume_zone_by_name(z_name);
374  z_id = z->id;
375  }
376  }
377  return z_id;
378 }
379 
380 /*----------------------------------------------------------------------------*/
389 /*----------------------------------------------------------------------------*/
390 
391 static inline int
392 cs_get_bdy_zone_id(const char *z_name)
393 {
394  int z_id = 0;
395  if (z_name != NULL) {
396  if (strlen(z_name) > 0) {
397  const cs_zone_t *z = cs_boundary_zone_by_name(z_name);
398  z_id = z->id;
399  }
400  }
401  return z_id;
402 }
403 
404 /*----------------------------------------------------------------------------*/
414 /*----------------------------------------------------------------------------*/
415 
416 inline static cs_real_t
418 {
419  assert(def != NULL);
420  assert(def->dim == 1);
421  assert(def->type == CS_XDEF_BY_VALUE);
422 
423  cs_real_t *value = (cs_real_t *)def->context;
424 
425  return value[0];
426 }
427 
428 /*----------------------------------------------------------------------------*/
437 /*----------------------------------------------------------------------------*/
438 
439 inline static cs_real_t *
441 {
442  assert(def != NULL);
443  assert(def->type == CS_XDEF_BY_ARRAY);
444 
446 
447  return ai->values;
448 }
449 
450 /*============================================================================
451  * Public function prototypes
452  *============================================================================*/
453 
454 /*----------------------------------------------------------------------------*/
468 /*----------------------------------------------------------------------------*/
469 
470 cs_xdef_t *
471 cs_xdef_volume_create(cs_xdef_type_t type,
472  int dim,
473  int z_id,
474  cs_flag_t state,
475  cs_flag_t meta,
476  void *context);
477 
478 /*----------------------------------------------------------------------------*/
492 /*----------------------------------------------------------------------------*/
493 
494 cs_xdef_t *
495 cs_xdef_boundary_create(cs_xdef_type_t type,
496  int dim,
497  int z_id,
498  cs_flag_t state,
499  cs_flag_t meta,
500  void *context);
501 
502 /*----------------------------------------------------------------------------*/
515 /*----------------------------------------------------------------------------*/
516 
517 cs_xdef_t *
518 cs_xdef_timestep_create(cs_xdef_type_t type,
519  cs_flag_t state,
520  cs_flag_t meta,
521  void *context);
522 
523 /*----------------------------------------------------------------------------*/
531 /*----------------------------------------------------------------------------*/
532 
533 cs_xdef_t *
535 
536 /*----------------------------------------------------------------------------*/
544 /*----------------------------------------------------------------------------*/
545 
546 cs_xdef_t *
547 cs_xdef_copy(cs_xdef_t *src);
548 
549 /*----------------------------------------------------------------------------*/
560 /*----------------------------------------------------------------------------*/
561 
562 void
564  void *input);
565 
566 /*----------------------------------------------------------------------------*/
577 /*----------------------------------------------------------------------------*/
578 
579 void
581  cs_xdef_free_input_t *free_input);
582 
583 /*----------------------------------------------------------------------------*/
592 /*----------------------------------------------------------------------------*/
593 
594 void
596  bool is_owner,
597  cs_real_t *array);
598 
599 /*----------------------------------------------------------------------------*/
609 /*----------------------------------------------------------------------------*/
610 
611 void
613  int z_id);
614 
615 /*----------------------------------------------------------------------------*/
624 /*----------------------------------------------------------------------------*/
625 
626 void
628  const cs_lnum_t *index,
629  const cs_lnum_t *ids);
630 
631 /*----------------------------------------------------------------------------*/
639 /*----------------------------------------------------------------------------*/
640 
641 void
643  cs_quadrature_type_t qtype);
644 
645 /*----------------------------------------------------------------------------*/
654 /*----------------------------------------------------------------------------*/
655 
658 
659 /*----------------------------------------------------------------------------*/
667 /*----------------------------------------------------------------------------*/
668 
669 cs_xdef_type_t
670 cs_xdef_get_type(const cs_xdef_t *d);
671 
672 /*----------------------------------------------------------------------------*/
680 /*----------------------------------------------------------------------------*/
681 
682 cs_flag_t
684 
685 /*----------------------------------------------------------------------------*/
693 /*----------------------------------------------------------------------------*/
694 
695 void
696 cs_xdef_log_setup(const char *prefix,
697  const cs_xdef_t *d);
698 
699 /*----------------------------------------------------------------------------*/
707 /*----------------------------------------------------------------------------*/
708 
709 void
710 cs_xdef_log(cs_log_t log_type,
711  const char *prefix,
712  const cs_xdef_t *d);
713 
714 /*----------------------------------------------------------------------------*/
722 /*----------------------------------------------------------------------------*/
723 
724 const char *
725 cs_xdef_type_get_name(cs_xdef_type_t xdef_type);
726 
727 /*----------------------------------------------------------------------------*/
728 
730 
731 #endif /* __CS_XDEF_H__ */
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 *context)
Allocate and initialize a new cs_xdef_t structure based on boundary elements.
Definition: cs_xdef.c:290
cs_analytic_func_t * func
Definition: cs_xdef.h:267
cs_xdef_t * cs_xdef_timestep_create(cs_xdef_type_t type, cs_flag_t state, cs_flag_t meta, void *context)
Allocate and initialize a new cs_xdef_t structure for setting the time step.
Definition: cs_xdef.c:449
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:887
cs_time_func_t * func
Definition: cs_xdef.h:335
cs_xdef_t * cs_xdef_free(cs_xdef_t *d)
Free a cs_xdef_t structure.
Definition: cs_xdef.c:519
void cs_xdef_set_input_context(cs_xdef_t *d, void *input)
In the case of a definition by an analytic function, a time function or a function relying on degrees...
Definition: cs_xdef.c:659
Definition: cs_xdef.h:118
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
int id
Definition: cs_zone.h:59
Definition: cs_xdef.h:140
cs_real_t * values
Definition: cs_xdef.h:242
#define BEGIN_C_DECLS
Definition: cs_defs.h:510
Definition: cs_xdef.h:113
Context structure when a time step function is used for the definition.
Definition: cs_xdef.h:329
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:320
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
void * context
Definition: cs_xdef.h:198
cs_flag_t state
Definition: cs_xdef.h:193
Definition: cs_xdef.h:111
cs_xdef_type_t cs_xdef_get_type(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.c:906
Definition: cs_xdef.h:142
Definition: cs_xdef.h:116
void cs_xdef_set_array_pointers(cs_xdef_t *d, const cs_lnum_t *index, const cs_lnum_t *ids)
In case of definition by array, set the optional index and ids arrays that may be useful when operati...
Definition: cs_xdef.c:837
cs_xdef_t * cs_xdef_copy(cs_xdef_t *src)
copy a cs_xdef_t structure
Definition: cs_xdef.c:598
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:771
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:348
int z_id
Definition: cs_xdef.h:295
static cs_real_t * cs_xdef_get_array(cs_xdef_t *def)
Retrieve the values associated to the given definition. This should be a definition by array...
Definition: cs_xdef.h:440
cs_flag_t cs_xdef_get_state_flag(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.c:925
double cs_real_t
Floating-point value.
Definition: cs_defs.h:322
int dim
Definition: cs_xdef.h:188
cs_xdef_type_t type
Definition: cs_xdef.h:189
void * input
Definition: cs_xdef.h:314
static cs_real_t cs_xdef_get_scalar_value(cs_xdef_t *def)
Retrieve the value associated to the given definition. This should be a definition by value and the d...
Definition: cs_xdef.h:417
Context structure when a definition by analytic function is used.
Definition: cs_xdef.h:255
const cs_lnum_t * ids
Definition: cs_xdef.h:246
Definition: cs_xdef.h:115
cs_xdef_support_t
Definition: cs_xdef.h:138
void() cs_dof_func_t(cs_lnum_t n_elts, const cs_lnum_t *elt_ids, bool dense_output, void *input, cs_real_t *retval)
Generic function pointer for computing a quantity at predefined locations such as degrees of freedom ...
Definition: cs_param_types.h:154
int z_id
Definition: cs_xdef.h:239
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:866
cs_flag_t loc
Definition: cs_xdef.h:241
Context structure when a definition by DoF function is used.
Definition: cs_xdef.h:289
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 dense_output, void *input, cs_real_t *retval)
Generic function pointer for an evaluation relying on an analytic function.
Definition: cs_param_types.h:127
cs_dof_func_t * func
Definition: cs_xdef.h:308
cs_quadrature_type_t qtype
Definition: cs_xdef.h:196
cs_xdef_type_t
Definition: cs_xdef.h:108
Definition: cs_xdef.h:110
int z_id
Definition: cs_xdef.h:261
Definition: cs_xdef.h:117
void * input
Definition: cs_xdef.h:274
int stride
Definition: cs_xdef.h:240
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:154
cs_log_t
Definition: cs_log.h:48
void cs_xdef_set_free_input_function(cs_xdef_t *d, cs_xdef_free_input_t *free_input)
In case of a definition by an analytic function, a time function or a function relying on degrees of ...
Definition: cs_xdef.c:716
Definition: cs_xdef.h:144
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:368
void cs_xdef_log_setup(const char *prefix, const cs_xdef_t *d)
Output the settings related to a cs_xdef_t structure in the setup logging file.
Definition: cs_xdef.c:944
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
cs_xdef_support_t support
Definition: cs_xdef.h:191
Definition: cs_xdef.h:114
#define END_C_DECLS
Definition: cs_defs.h:511
void cs_xdef_set_array_zone_id(cs_xdef_t *d, int z_id)
In case of definition by array, set the zone id related to the size of the array. By default...
Definition: cs_xdef.c:809
unsigned short int cs_flag_t
Definition: cs_defs.h:324
void() cs_time_func_t(double time, void *input, cs_real_t *retval)
Function which defines the evolution of a quantity according to the current time and any structure gi...
Definition: cs_param_types.h:172
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:280
bool is_owner
Definition: cs_xdef.h:243
cs_flag_t meta
Definition: cs_xdef.h:194
Definition: cs_xdef.h:112
const cs_lnum_t * index
Definition: cs_xdef.h:245
int z_id
Definition: cs_xdef.h:190
void * input
Definition: cs_xdef.h:342
Context structure when an array is used for the definition.
Definition: cs_xdef.h:207
const char * cs_xdef_type_get_name(cs_xdef_type_t xdef_type)
Retrieve a pointer to the cs_xdef_type&#39;s name string.
Definition: cs_xdef.c:1101
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:392
Definition: cs_xdef.h:120
Definition: cs_xdef.h:141
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 *context)
Allocate and initialize a new cs_xdef_t structure based on volumic elements.
Definition: cs_xdef.c:115
void *() cs_xdef_free_input_t(void *input)
Destroy an input data structure. Complex data structure can be used when a cs_xdef_t structure is def...
Definition: cs_xdef.h:70
void cs_xdef_log(cs_log_t log_type, const char *prefix, const cs_xdef_t *d)
Output the settings related to a cs_xdef_t structure.
Definition: cs_xdef.c:961
cs_flag_t loc
Definition: cs_xdef.h:302
Definition: cs_zone.h:55