8.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-2023 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  * Standard C library headers
32  *----------------------------------------------------------------------------*/
33 
34 #include <string.h>
35 
36 /*----------------------------------------------------------------------------
37  * Local headers
38  *----------------------------------------------------------------------------*/
39 
40 #include "cs_base.h"
41 #include "cs_boundary_zone.h"
42 #include "cs_field.h"
43 #include "cs_mesh_adjacencies.h"
44 #include "cs_param_types.h"
45 #include "cs_quadrature.h"
46 #include "cs_volume_zone.h"
47 
48 /*----------------------------------------------------------------------------*/
49 
51 
52 /*============================================================================
53  * Macro definitions
54  *============================================================================*/
55 
56 /*============================================================================
57  * Type definitions
58  *============================================================================*/
59 
60 /*----------------------------------------------------------------------------*/
73 /*----------------------------------------------------------------------------*/
74 
75 typedef void *
76 (cs_xdef_free_input_t)(void *input);
77 
114 typedef enum {
115 
125 
127 
129 
144 typedef enum {
145 
146  CS_XDEF_SUPPORT_TIME, /* support for time step description */
147  CS_XDEF_SUPPORT_BOUNDARY, /* zones attached to boundary faces */
149 
151 
153 
160 typedef struct {
161 
194  int dim;
196  int z_id;
198 
201 
203 
204  void *context;
205 
206 } cs_xdef_t;
207 
213 typedef struct {
214 
267  int z_id;
268  int stride;
270  bool is_owner;
272 
274 
275  /* Automatic parameter */
276 
278 
279  /* Optional parameters */
280 
284 
286 
292 typedef struct {
293 
298  int z_id;
299 
305 
311  void *input;
312 
318 
320 
326 typedef struct {
327 
332  int z_id;
333 
340 
346 
351  void *input;
352 
358 
360 
366 typedef struct {
367 
372  int z_id;
373 
379 
385  void *input;
386 
392 
394 
395 /*============================================================================
396  * Public function prototypes
397  *============================================================================*/
398 
399 /*----------------------------------------------------------------------------*/
409 /*----------------------------------------------------------------------------*/
410 
411 static inline cs_real_t
413 {
414  assert(def != NULL);
415  assert(def->dim == 1);
416  assert(def->type == CS_XDEF_BY_VALUE);
417 
418  cs_real_t *value = (cs_real_t *)def->context;
419 
420  return value[0];
421 }
422 
423 /*----------------------------------------------------------------------------*/
432 /*----------------------------------------------------------------------------*/
433 
434 static inline cs_real_t *
436 {
437  if (def == NULL)
438  return NULL;
439 
440  assert(def->type == CS_XDEF_BY_ARRAY);
441 
443 
444  return ai->values;
445 }
446 
447 /*----------------------------------------------------------------------------*/
456 /*----------------------------------------------------------------------------*/
457 
458 static inline cs_field_t *
460 {
461  if (def == NULL)
462  return NULL;
463 
464  assert(def->type == CS_XDEF_BY_FIELD);
465 
466  return (cs_field_t *)def->context;
467 }
468 
469 /*============================================================================
470  * Public function prototypes
471  *============================================================================*/
472 
473 /*----------------------------------------------------------------------------*/
487 /*----------------------------------------------------------------------------*/
488 
489 cs_xdef_t *
491  int dim,
492  int z_id,
493  cs_flag_t state,
494  cs_flag_t meta,
495  void *context);
496 
497 /*----------------------------------------------------------------------------*/
511 /*----------------------------------------------------------------------------*/
512 
513 cs_xdef_t *
515  int dim,
516  int z_id,
517  cs_flag_t state,
518  cs_flag_t meta,
519  void *context);
520 
521 /*----------------------------------------------------------------------------*/
534 /*----------------------------------------------------------------------------*/
535 
536 cs_xdef_t *
538  cs_flag_t state,
539  cs_flag_t meta,
540  void *context);
541 
542 /*----------------------------------------------------------------------------*/
550 /*----------------------------------------------------------------------------*/
551 
552 cs_xdef_t *
554 
555 /*----------------------------------------------------------------------------*/
563 /*----------------------------------------------------------------------------*/
564 
565 cs_xdef_t *
566 cs_xdef_copy(cs_xdef_t *src);
567 
568 /*----------------------------------------------------------------------------*/
579 /*----------------------------------------------------------------------------*/
580 
581 void
583  void *input);
584 
585 /*----------------------------------------------------------------------------*/
596 /*----------------------------------------------------------------------------*/
597 
598 void
600  cs_xdef_free_input_t *free_input);
601 
602 /*----------------------------------------------------------------------------*/
610 /*----------------------------------------------------------------------------*/
611 
612 void
614  cs_quadrature_type_t qtype);
615 
616 /*----------------------------------------------------------------------------*/
625 /*----------------------------------------------------------------------------*/
626 
629 
630 /*----------------------------------------------------------------------------*/
638 /*----------------------------------------------------------------------------*/
639 
641 cs_xdef_get_type(const cs_xdef_t *d);
642 
643 /*----------------------------------------------------------------------------*/
651 /*----------------------------------------------------------------------------*/
652 
653 cs_flag_t
655 
656 /*----------------------------------------------------------------------------*/
664 /*----------------------------------------------------------------------------*/
665 
666 void
667 cs_xdef_log_setup(const char *prefix,
668  const cs_xdef_t *d);
669 
670 /*----------------------------------------------------------------------------*/
678 /*----------------------------------------------------------------------------*/
679 
680 void
681 cs_xdef_log(cs_log_t log_type,
682  const char *prefix,
683  const cs_xdef_t *d);
684 
685 /*----------------------------------------------------------------------------*/
693 /*----------------------------------------------------------------------------*/
694 
695 const char *
697 
698 /*----------------------------------------------------------------------------*/
707 /*----------------------------------------------------------------------------*/
708 
709 void
711  bool is_owner,
712  cs_real_t *values);
713 
714 /*----------------------------------------------------------------------------*/
724 /*----------------------------------------------------------------------------*/
725 
726 void
728  int z_id);
729 
730 /*----------------------------------------------------------------------------*/
739 /*----------------------------------------------------------------------------*/
740 
741 void
743 
744 /*----------------------------------------------------------------------------*/
751 /*----------------------------------------------------------------------------*/
752 
753 void
755  const cs_adjacency_t *adj);
756 
757 /*----------------------------------------------------------------------------*/
767 /*----------------------------------------------------------------------------*/
768 
769 void
771  cs_lnum_t n_elts,
772  const cs_lnum_t elt_ids[]);
773 
774 /*----------------------------------------------------------------------------*/
782 /*----------------------------------------------------------------------------*/
783 
784 cs_real_t *
786 
787 /*----------------------------------------------------------------------------*/
788 
790 
791 #endif /* __CS_XDEF_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:514
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
#define END_C_DECLS
Definition: cs_defs.h:515
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
unsigned short int cs_flag_t
Definition: cs_defs.h:321
cs_log_t
Definition: cs_log.h:48
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
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
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_quadrature_type_t
Definition: cs_quadrature.h:52
void cs_xdef_array_build_full2subset(const cs_xdef_t *d)
In case of definition by array, build the full2subset array. The direct members of the cs_xdef_t stru...
cs_xdef_t * cs_xdef_free(cs_xdef_t *d)
Free a cs_xdef_t structure.
Definition: cs_xdef.c:568
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:844
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:76
const char * cs_xdef_type_get_name(cs_xdef_type_t xdef_type)
Retrieve a pointer to the cs_xdef_type's name string.
cs_real_t * cs_xdef_field_get_values(cs_xdef_t *def)
Get the current field values in case of definition by field.
void cs_xdef_array_set_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,...
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
cs_xdef_type_t cs_xdef_get_type(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.c:863
static cs_field_t * cs_xdef_field_get(cs_xdef_t *def)
When the definition relies on a cs_field_t structure, return the pointer to the field structure.
Definition: cs_xdef.h:459
void cs_xdef_array_set_sublist(cs_xdef_t *d, cs_lnum_t n_elts, const cs_lnum_t elt_ids[])
In case of definition by array, set the optional sub-list of elements used to link elements in the pa...
cs_xdef_type_t
Definition: cs_xdef.h:114
@ CS_XDEF_BY_ANALYTIC_FUNCTION
Definition: cs_xdef.h:116
@ CS_XDEF_BY_SUB_DEFINITIONS
Definition: cs_xdef.h:122
@ CS_XDEF_BY_ARRAY
Definition: cs_xdef.h:117
@ CS_XDEF_BY_DOF_FUNCTION
Definition: cs_xdef.h:118
@ CS_XDEF_BY_TIME_FUNCTION
Definition: cs_xdef.h:123
@ CS_XDEF_BY_QOV
Definition: cs_xdef.h:121
@ CS_N_XDEF_TYPES
Definition: cs_xdef.h:126
@ CS_XDEF_BY_FUNCTION
Definition: cs_xdef.h:120
@ CS_XDEF_BY_VALUE
Definition: cs_xdef.h:124
@ CS_XDEF_BY_FIELD
Definition: cs_xdef.h:119
void cs_xdef_array_set_values(cs_xdef_t *d, bool is_owner, cs_real_t *values)
In case of definition by array, set the array values after having added this definition.
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:712
cs_flag_t cs_xdef_get_state_flag(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.c:882
void cs_xdef_array_set_adjacency(cs_xdef_t *d, const cs_adjacency_t *adj)
In case of definition by array, set the optional adjacency structure.
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:901
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:497
cs_xdef_support_t
Definition: cs_xdef.h:144
@ CS_XDEF_SUPPORT_BOUNDARY
Definition: cs_xdef.h:147
@ CS_XDEF_SUPPORT_VOLUME
Definition: cs_xdef.h:148
@ CS_XDEF_SUPPORT_TIME
Definition: cs_xdef.h:146
@ CS_N_XDEF_SUPPORTS
Definition: cs_xdef.h:150
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:304
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:412
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:918
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:769
cs_xdef_t * cs_xdef_copy(cs_xdef_t *src)
copy a cs_xdef_t structure
Definition: cs_xdef.c:651
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:823
static cs_real_t * cs_xdef_array_get_values(const cs_xdef_t *def)
Retrieve the values associated to the given definition. This should be a definition by array.
Definition: cs_xdef.h:435
Definition: cs_mesh_adjacencies.h:68
Field descriptor.
Definition: cs_field.h:131
Context structure when a definition by analytic function is used.
Definition: cs_xdef.h:292
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:317
cs_analytic_func_t * func
Definition: cs_xdef.h:304
void * input
Definition: cs_xdef.h:311
int z_id
Definition: cs_xdef.h:298
Context structure when an array is used for the definition.
Definition: cs_xdef.h:213
cs_lnum_t n_list_elts
Definition: cs_xdef.h:281
const cs_adjacency_t * adjacency
Definition: cs_xdef.h:283
cs_real_t * values
Definition: cs_xdef.h:273
cs_flag_t value_location
Definition: cs_xdef.h:269
bool full_length
Definition: cs_xdef.h:271
const cs_lnum_t * elt_ids
Definition: cs_xdef.h:282
bool is_owner
Definition: cs_xdef.h:270
int z_id
Definition: cs_xdef.h:267
cs_lnum_t * full2subset
Definition: cs_xdef.h:277
int stride
Definition: cs_xdef.h:268
Context structure when a definition by DoF function is used.
Definition: cs_xdef.h:326
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:357
cs_dof_func_t * func
Definition: cs_xdef.h:345
void * input
Definition: cs_xdef.h:351
cs_flag_t dof_location
Definition: cs_xdef.h:339
int z_id
Definition: cs_xdef.h:332
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:160
void * context
Definition: cs_xdef.h:204
cs_quadrature_type_t qtype
Definition: cs_xdef.h:202
cs_flag_t meta
Definition: cs_xdef.h:200
cs_xdef_type_t type
Definition: cs_xdef.h:195
cs_xdef_support_t support
Definition: cs_xdef.h:197
int z_id
Definition: cs_xdef.h:196
cs_flag_t state
Definition: cs_xdef.h:199
int dim
Definition: cs_xdef.h:194
Context structure when a time step function is used for the definition.
Definition: cs_xdef.h:366
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:391
cs_time_func_t * func
Definition: cs_xdef.h:378
void * input
Definition: cs_xdef.h:385
int z_id
Definition: cs_xdef.h:372