7.1
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-2021 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 
232  int z_id;
233  int stride;
237  bool is_owner;
238 
240 
246 typedef struct {
247 
251  int z_id;
252 
257 
262  void *input;
263 
268 
270 
276 typedef struct {
277 
281  int z_id;
282 
288 
293 
298  void *input;
299 
304 
306 
312 typedef struct {
313 
318 
323  void *input;
324 
329 
331 
332 /*============================================================================
333  * Public function prototypes
334  *============================================================================*/
335 
336 /*----------------------------------------------------------------------------*/
345 /*----------------------------------------------------------------------------*/
346 
347 static inline int
348 cs_get_vol_zone_id(const char *z_name)
349 {
350  int z_id = 0;
351  if (z_name != NULL) {
352  if (strlen(z_name) > 0) {
353  const cs_zone_t *z = cs_volume_zone_by_name(z_name);
354  z_id = z->id;
355  }
356  }
357  return z_id;
358 }
359 
360 /*----------------------------------------------------------------------------*/
369 /*----------------------------------------------------------------------------*/
370 
371 static inline int
372 cs_get_bdy_zone_id(const char *z_name)
373 {
374  int z_id = 0;
375  if (z_name != NULL) {
376  if (strlen(z_name) > 0) {
377  const cs_zone_t *z = cs_boundary_zone_by_name(z_name);
378  z_id = z->id;
379  }
380  }
381  return z_id;
382 }
383 
384 /*----------------------------------------------------------------------------*/
394 /*----------------------------------------------------------------------------*/
395 
396 inline static cs_real_t
397 cs_xdef_get_scalar_value(cs_xdef_t *def)
398 {
399  assert(def != NULL);
400  assert(def->dim == 1);
401  assert(def->type == CS_XDEF_BY_VALUE);
402 
403  cs_real_t *value = (cs_real_t *)def->context;
404 
405  return value[0];
406 }
407 
408 /*----------------------------------------------------------------------------*/
417 /*----------------------------------------------------------------------------*/
418 
419 inline static cs_real_t *
420 cs_xdef_get_array(cs_xdef_t *def)
421 {
422  assert(def != NULL);
423  assert(def->type == CS_XDEF_BY_ARRAY);
424 
426 
427  return ai->values;
428 }
429 
430 /*============================================================================
431  * Public function prototypes
432  *============================================================================*/
433 
434 /*----------------------------------------------------------------------------*/
448 /*----------------------------------------------------------------------------*/
449 
450 cs_xdef_t *
451 cs_xdef_volume_create(cs_xdef_type_t type,
452  int dim,
453  int z_id,
454  cs_flag_t state,
455  cs_flag_t meta,
456  void *context);
457 
458 /*----------------------------------------------------------------------------*/
472 /*----------------------------------------------------------------------------*/
473 
474 cs_xdef_t *
475 cs_xdef_boundary_create(cs_xdef_type_t type,
476  int dim,
477  int z_id,
478  cs_flag_t state,
479  cs_flag_t meta,
480  void *context);
481 
482 /*----------------------------------------------------------------------------*/
495 /*----------------------------------------------------------------------------*/
496 
497 cs_xdef_t *
498 cs_xdef_timestep_create(cs_xdef_type_t type,
499  cs_flag_t state,
500  cs_flag_t meta,
501  void *context);
502 
503 /*----------------------------------------------------------------------------*/
511 /*----------------------------------------------------------------------------*/
512 
513 cs_xdef_t *
515 
516 /*----------------------------------------------------------------------------*/
524 /*----------------------------------------------------------------------------*/
525 
526 cs_xdef_t *
527 cs_xdef_copy(cs_xdef_t *src);
528 
529 /*----------------------------------------------------------------------------*/
540 /*----------------------------------------------------------------------------*/
541 
542 void
544  void *input);
545 
546 /*----------------------------------------------------------------------------*/
557 /*----------------------------------------------------------------------------*/
558 
559 void
561  cs_xdef_free_input_t *free_input);
562 
563 /*----------------------------------------------------------------------------*/
572 /*----------------------------------------------------------------------------*/
573 
574 void
576  bool is_owner,
577  cs_real_t *array);
578 
579 /*----------------------------------------------------------------------------*/
587 /*----------------------------------------------------------------------------*/
588 
589 void
591  cs_lnum_t *array_index);
592 
593 /*----------------------------------------------------------------------------*/
601 /*----------------------------------------------------------------------------*/
602 
603 void
605  cs_quadrature_type_t qtype);
606 
607 /*----------------------------------------------------------------------------*/
616 /*----------------------------------------------------------------------------*/
617 
620 
621 /*----------------------------------------------------------------------------*/
629 /*----------------------------------------------------------------------------*/
630 
631 cs_xdef_type_t
632 cs_xdef_get_type(const cs_xdef_t *d);
633 
634 /*----------------------------------------------------------------------------*/
642 /*----------------------------------------------------------------------------*/
643 
644 cs_flag_t
646 
647 /*----------------------------------------------------------------------------*/
654 /*----------------------------------------------------------------------------*/
655 
656 void
657 cs_xdef_log(const char *prefix,
658  const cs_xdef_t *d);
659 
660 /*----------------------------------------------------------------------------*/
668 /*----------------------------------------------------------------------------*/
669 
670 const char *
671 cs_xdef_type_get_name(cs_xdef_type_t xdef_type);
672 
673 /*----------------------------------------------------------------------------*/
674 
676 
677 #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:786
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:287
cs_analytic_func_t * func
Definition: cs_xdef.h:256
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:435
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:834
cs_time_func_t * func
Definition: cs_xdef.h:317
cs_xdef_t * cs_xdef_free(cs_xdef_t *d)
Free a cs_xdef_t structure.
Definition: cs_xdef.c:504
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:640
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:235
#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:312
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:303
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:890
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:853
Definition: cs_xdef.h:142
Definition: cs_xdef.h:116
cs_xdef_t * cs_xdef_copy(cs_xdef_t *src)
copy a cs_xdef_t structure
Definition: cs_xdef.c:579
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:752
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:328
int z_id
Definition: cs_xdef.h:281
cs_flag_t cs_xdef_get_state_flag(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.c:872
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:298
Context structure when a definition by analytic function is used.
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:127
int z_id
Definition: cs_xdef.h:232
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:813
cs_flag_t loc
Definition: cs_xdef.h:234
Context structure when a definition by DoF function is used.
Definition: cs_xdef.h:276
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:100
cs_dof_func_t * func
Definition: cs_xdef.h:292
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:251
Definition: cs_xdef.h:117
void * input
Definition: cs_xdef.h:262
int stride
Definition: cs_xdef.h:233
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:154
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:697
Definition: cs_xdef.h:144
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
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:145
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:267
bool is_owner
Definition: cs_xdef.h:237
cs_flag_t meta
Definition: cs_xdef.h:194
Definition: cs_xdef.h:112
cs_lnum_t * index
Definition: cs_xdef.h:236
int z_id
Definition: cs_xdef.h:190
void * input
Definition: cs_xdef.h:323
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:1030
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:116
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
cs_flag_t loc
Definition: cs_xdef.h:287
Definition: cs_zone.h:55