9.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-2026 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 <cstring>
35
36/*----------------------------------------------------------------------------
37 * Local headers
38 *----------------------------------------------------------------------------*/
39
40#include "base/cs_base.h"
42#include "base/cs_field.h"
43#include "base/cs_param_types.h"
44#include "base/cs_volume_zone.h"
45#include "cdo/cs_quadrature.h"
47
48/*============================================================================
49 * Macro definitions
50 *============================================================================*/
51
52/*============================================================================
53 * Type definitions
54 *============================================================================*/
55
56/*----------------------------------------------------------------------------*/
69/*----------------------------------------------------------------------------*/
70
71typedef void *
72(cs_xdef_free_input_t)(void *input);
73
110typedef enum {
111
121
123
125
140typedef enum {
141
142 CS_XDEF_SUPPORT_TIME, /* support for time step description */
143 CS_XDEF_SUPPORT_BOUNDARY, /* zones attached to boundary faces */
145
147
149
156typedef struct {
157
190 int dim;
192 int z_id;
194
197
199
200 void *context;
201
202} cs_xdef_t;
203
209typedef struct {
210
263 int z_id;
268
270
271 /* Automatic parameter */
272
274
275 /* Optional parameters */
276
280
282
288typedef struct {
289
294 int z_id;
295
301
307 void *input;
308
314
316
322typedef struct {
323
328 int z_id;
329
336
342
348 void *input;
349
355
357
363typedef struct {
364
369 int z_id;
370
376
382 void *input;
383
389
391
392/*============================================================================
393 * Public function prototypes
394 *============================================================================*/
395
396/*----------------------------------------------------------------------------*/
406/*----------------------------------------------------------------------------*/
407
408static inline cs_real_t
410{
411 assert(def != NULL);
412 assert(def->dim == 1);
413 assert(def->type == CS_XDEF_BY_VALUE);
414
415 cs_real_t *value = (cs_real_t *)def->context;
416
417 return value[0];
418}
419
420/*----------------------------------------------------------------------------*/
429/*----------------------------------------------------------------------------*/
430
431static inline void
433 cs_real_t val)
434{
435 assert(def != NULL);
436 assert(def->dim == 1);
437 assert(def->type == CS_XDEF_BY_VALUE);
438
439 cs_real_t *values = (cs_real_t *)def->context;
440
441 values[0] = val;
442}
443
444/*----------------------------------------------------------------------------*/
453/*----------------------------------------------------------------------------*/
454
455static inline cs_real_t *
457{
458 if (def == NULL)
459 return NULL;
460
461 assert(def->type == CS_XDEF_BY_ARRAY);
462
464
465 return ai->values;
466}
467
468/*----------------------------------------------------------------------------*/
477/*----------------------------------------------------------------------------*/
478
479static inline cs_field_t *
481{
482 if (def == NULL)
483 return NULL;
484
485 assert(def->type == CS_XDEF_BY_FIELD);
486
487 return (cs_field_t *)def->context;
488}
489
490/*============================================================================
491 * Public function prototypes
492 *============================================================================*/
493
494/*----------------------------------------------------------------------------*/
508/*----------------------------------------------------------------------------*/
509
510cs_xdef_t *
512 int dim,
513 int z_id,
514 cs_flag_t state,
515 cs_flag_t meta,
516 void *context);
517
518/*----------------------------------------------------------------------------*/
532/*----------------------------------------------------------------------------*/
533
534cs_xdef_t *
536 int dim,
537 int z_id,
538 cs_flag_t state,
539 cs_flag_t meta,
540 void *context);
541
542/*----------------------------------------------------------------------------*/
555/*----------------------------------------------------------------------------*/
556
557cs_xdef_t *
559 cs_flag_t state,
560 cs_flag_t meta,
561 void *context);
562
563/*----------------------------------------------------------------------------*/
571/*----------------------------------------------------------------------------*/
572
573cs_xdef_t *
575
576/*----------------------------------------------------------------------------*/
584/*----------------------------------------------------------------------------*/
585
586cs_xdef_t *
588
589/*----------------------------------------------------------------------------*/
600/*----------------------------------------------------------------------------*/
601
602void
604 void *input);
605
606/*----------------------------------------------------------------------------*/
617/*----------------------------------------------------------------------------*/
618
619void
621 cs_xdef_free_input_t *free_input);
622
623/*----------------------------------------------------------------------------*/
631/*----------------------------------------------------------------------------*/
632
633void
636
637/*----------------------------------------------------------------------------*/
646/*----------------------------------------------------------------------------*/
647
650
651/*----------------------------------------------------------------------------*/
659/*----------------------------------------------------------------------------*/
660
663
664/*----------------------------------------------------------------------------*/
672/*----------------------------------------------------------------------------*/
673
676
677/*----------------------------------------------------------------------------*/
685/*----------------------------------------------------------------------------*/
686
687void
688cs_xdef_log_setup(const char *prefix,
689 const cs_xdef_t *d);
690
691/*----------------------------------------------------------------------------*/
699/*----------------------------------------------------------------------------*/
700
701void
702cs_xdef_log(cs_log_t log_type,
703 const char *prefix,
704 const cs_xdef_t *d);
705
706/*----------------------------------------------------------------------------*/
714/*----------------------------------------------------------------------------*/
715
716const char *
718
719/*----------------------------------------------------------------------------*/
728/*----------------------------------------------------------------------------*/
729
730void
732 bool is_owner,
733 cs_real_t *values);
734
735/*----------------------------------------------------------------------------*/
745/*----------------------------------------------------------------------------*/
746
747void
749 int z_id);
750
751/*----------------------------------------------------------------------------*/
760/*----------------------------------------------------------------------------*/
761
762void
764
765/*----------------------------------------------------------------------------*/
772/*----------------------------------------------------------------------------*/
773
774void
776 const cs_adjacency_t *adj);
777
778/*----------------------------------------------------------------------------*/
788/*----------------------------------------------------------------------------*/
789
790void
792 cs_lnum_t n_elts,
793 const cs_lnum_t elt_ids[]);
794
795/*----------------------------------------------------------------------------*/
803/*----------------------------------------------------------------------------*/
804
805cs_real_t *
807
808/*----------------------------------------------------------------------------*/
809
810
811#endif /* CS_XDEF_H */
Field descriptor.
Definition: cs_field.h:275
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
unsigned short int cs_flag_t
Definition: cs_defs.h:334
cs_log_t
Definition: cs_log.h:44
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
Type of quadrature to use when computing an integral quantity. This rationale is used for integrals a...
Definition: cs_quadrature.h:79
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...
Definition: cs_xdef.cpp:1143
cs_quadrature_type_t cs_xdef_get_quadrature(const cs_xdef_t *d)
Get the type of quadrature to use for evaluating the given description.
Definition: cs_xdef.cpp:840
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.cpp:110
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,...
Definition: cs_xdef.cpp:1114
static cs_field_t * cs_xdef_field_get(const 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:480
cs_xdef_type_t cs_xdef_get_type(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.cpp:859
cs_xdef_t * cs_xdef_copy(cs_xdef_t *src)
copy a cs_xdef_t structure
Definition: cs_xdef.cpp:645
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...
Definition: cs_xdef.cpp:1231
cs_xdef_type_t
Definition: cs_xdef.h:110
@ CS_XDEF_BY_ANALYTIC_FUNCTION
Definition: cs_xdef.h:112
@ CS_XDEF_BY_SUB_DEFINITIONS
Definition: cs_xdef.h:118
@ CS_XDEF_BY_ARRAY
Definition: cs_xdef.h:113
@ CS_XDEF_BY_DOF_FUNCTION
Definition: cs_xdef.h:114
@ CS_XDEF_BY_TIME_FUNCTION
Definition: cs_xdef.h:119
@ CS_XDEF_BY_QOV
Definition: cs_xdef.h:117
@ CS_N_XDEF_TYPES
Definition: cs_xdef.h:122
@ CS_XDEF_BY_FUNCTION
Definition: cs_xdef.h:116
@ CS_XDEF_BY_VALUE
Definition: cs_xdef.h:120
@ CS_XDEF_BY_FIELD
Definition: cs_xdef.h:115
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.
Definition: cs_xdef.cpp:1076
cs_xdef_t * cs_xdef_free(cs_xdef_t *d)
Free a cs_xdef_t structure.
Definition: cs_xdef.cpp:562
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.cpp:298
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.cpp:706
cs_flag_t cs_xdef_get_state_flag(const cs_xdef_t *d)
Retrieve the flag dedicated to the state.
Definition: cs_xdef.cpp:878
cs_real_t * cs_xdef_field_get_values(cs_xdef_t *def)
Get the current field values in case of definition by field.
Definition: cs_xdef.cpp:1261
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.
Definition: cs_xdef.cpp:1201
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.cpp:897
cs_xdef_support_t
Definition: cs_xdef.h:140
@ CS_XDEF_SUPPORT_BOUNDARY
Definition: cs_xdef.h:143
@ CS_XDEF_SUPPORT_VOLUME
Definition: cs_xdef.h:144
@ CS_XDEF_SUPPORT_TIME
Definition: cs_xdef.h:142
@ CS_N_XDEF_SUPPORTS
Definition: cs_xdef.h:146
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.cpp:914
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.cpp:764
const char * cs_xdef_type_get_name(cs_xdef_type_t xdef_type)
Retrieve a pointer to the cs_xdef_type's name string.
Definition: cs_xdef.cpp:1056
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.cpp:819
static cs_real_t cs_xdef_get_scalar_value(const 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:409
static void cs_xdef_set_scalar_value(cs_xdef_t *def, cs_real_t val)
Set the value associated to the given definition. This should be a definition by value and the dimens...
Definition: cs_xdef.h:432
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:72
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:456
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.cpp:491
Definition: cs_mesh_adjacencies.h:68
Context structure when a definition by analytic function is used.
Definition: cs_xdef.h:288
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:313
cs_analytic_func_t * func
Definition: cs_xdef.h:300
void * input
Definition: cs_xdef.h:307
int z_id
Definition: cs_xdef.h:294
Context structure when an array is used for the definition.
Definition: cs_xdef.h:209
cs_lnum_t n_list_elts
Definition: cs_xdef.h:277
const cs_adjacency_t * adjacency
Definition: cs_xdef.h:279
cs_real_t * values
Definition: cs_xdef.h:269
cs_flag_t value_location
Definition: cs_xdef.h:265
bool full_length
Definition: cs_xdef.h:267
const cs_lnum_t * elt_ids
Definition: cs_xdef.h:278
bool is_owner
Definition: cs_xdef.h:266
int z_id
Definition: cs_xdef.h:263
cs_lnum_t * full2subset
Definition: cs_xdef.h:273
int stride
Definition: cs_xdef.h:264
Context structure when a definition by DoF function is used.
Definition: cs_xdef.h:322
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:354
cs_dof_func_t * func
Definition: cs_xdef.h:341
void * input
Definition: cs_xdef.h:348
cs_flag_t dof_location
Definition: cs_xdef.h:335
int z_id
Definition: cs_xdef.h:328
Structure storing medata for defining a quantity in a very flexible way.
Definition: cs_xdef.h:156
void * context
Definition: cs_xdef.h:200
cs_quadrature_type_t qtype
Definition: cs_xdef.h:198
cs_flag_t meta
Definition: cs_xdef.h:196
cs_xdef_type_t type
Definition: cs_xdef.h:191
cs_xdef_support_t support
Definition: cs_xdef.h:193
int z_id
Definition: cs_xdef.h:192
cs_flag_t state
Definition: cs_xdef.h:195
int dim
Definition: cs_xdef.h:190
Context structure when a time step function is used for the definition.
Definition: cs_xdef.h:363
cs_xdef_free_input_t * free_input
Definition: cs_xdef.h:388
cs_time_func_t * func
Definition: cs_xdef.h:375
void * input
Definition: cs_xdef.h:382
int z_id
Definition: cs_xdef.h:369