9.2
general documentation
cs_function.h
Go to the documentation of this file.
1#ifndef CS_FUNCTION_H
2#define CS_FUNCTION_H
3
4/*============================================================================
5 * Function objects management.
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/*----------------------------------------------------------------------------
35 * Local headers
36 *----------------------------------------------------------------------------*/
37
38#include "base/cs_defs.h"
40#include "base/cs_param_types.h"
42
43/*============================================================================
44 * Macro definitions
45 *============================================================================*/
46
53/*
54 * Function property type
55 */
56
58#define CS_FUNCTION_INTENSIVE (1 << 0)
59
61#define CS_FUNCTION_EXTENSIVE (1 << 1)
62
64#define CS_FUNCTION_TIME_INDEPENDENT (1 << 2)
65
67#define CS_FUNCTION_USER (1 << 3)
68
70#define CS_FUNCTION_NO_MPI_CALL (1 << 4)
71
73#define CS_FUNCTION_NO_SUB_TASK (1 << 5)
74
77/*============================================================================
78 * Type definitions
79 *============================================================================*/
80
81/*----------------------------------------------------------------------------*/
105/*----------------------------------------------------------------------------*/
106
107typedef void
108(cs_eval_at_location_t) (int location_id,
109 cs_lnum_t n_elts,
110 const cs_lnum_t *elt_ids,
111 void *input,
112 void *vals);
113
114/* Function descriptor */
115/*---------------------*/
116
117typedef struct {
118
119 const char *name;
120 char *label;
123 const int id;
124 int type;
126 const int dim;
129 const int location_id;
137 int log;
156 void *func_input; /* Pointer to optional (untyped)
157 value or structure, for use by
158 evaluation function */
159
161
162/*=============================================================================
163 * Global variables
164 *============================================================================*/
165
166/*============================================================================
167 * Public function prototypes
168 *============================================================================*/
169
170/*----------------------------------------------------------------------------*/
189/*----------------------------------------------------------------------------*/
190
192cs_function_define_by_func(const char *name,
193 int location_id,
194 int dim,
195 bool is_intensive,
196 cs_datatype_t datatype,
197 cs_eval_at_location_t *data_func,
198 void *data_input);
199
200/*----------------------------------------------------------------------------*/
220/*----------------------------------------------------------------------------*/
221
224 int location_id,
225 int dim,
226 bool is_intensive,
227 cs_analytic_func_t *data_func,
228 void *data_input);
229
230/*----------------------------------------------------------------------------*/
250/*----------------------------------------------------------------------------*/
251
253cs_function_define_by_dof_func(const char *name,
254 int location_id,
255 int dim,
256 bool is_intensive,
257 cs_dof_func_t *data_func,
258 void *data_input);
259
260/*----------------------------------------------------------------------------
261 * Destroy all function management metadata.
262 *----------------------------------------------------------------------------*/
263
264void
266
267/*----------------------------------------------------------------------------*/
273/*----------------------------------------------------------------------------*/
274
275int
277
278/*----------------------------------------------------------------------------*/
288/*----------------------------------------------------------------------------*/
289
291cs_function_by_id(int id);
292
293/*----------------------------------------------------------------------------*/
303/*----------------------------------------------------------------------------*/
304
306cs_function_by_name(const char *name);
307
308/*----------------------------------------------------------------------------*/
318/*----------------------------------------------------------------------------*/
319
321cs_function_by_name_try(const char *name);
322
323/*----------------------------------------------------------------------------*/
330/*----------------------------------------------------------------------------*/
331
332void
334 const char *label);
335
336/*----------------------------------------------------------------------------*/
340/*----------------------------------------------------------------------------*/
341
342void
344
345/*----------------------------------------------------------------------------*/
350/*----------------------------------------------------------------------------*/
351
352void
354
355/*----------------------------------------------------------------------------*/
372/*----------------------------------------------------------------------------*/
373
374void
376 const cs_time_step_t *ts,
377 int location_id,
378 cs_lnum_t n_elts,
379 const cs_lnum_t *elt_ids,
380 void *vals);
381
382/*----------------------------------------------------------------------------*/
383
384#endif /* CS_FUNCTION_H */
time step descriptor
Definition: cs_time_step.h:60
cs_datatype_t
Definition: cs_defs.h:290
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
cs_function_t * cs_function_define_by_analytic_func(const char *name, int location_id, int dim, bool is_intensive, cs_analytic_func_t *data_func, void *data_input)
Define a function whose data values will be computed using the provided "degree of freedom" type eval...
Definition: cs_function.cpp:342
cs_function_t * cs_function_define_by_dof_func(const char *name, int location_id, int dim, bool is_intensive, cs_dof_func_t *data_func, void *data_input)
Define a function whose data values will be computed using the provided "degree of freedom" type eval...
Definition: cs_function.cpp:384
void() cs_eval_at_location_t(int location_id, cs_lnum_t n_elts, const cs_lnum_t *elt_ids, void *input, void *vals)
Function pointer for evaluation of local function values.
Definition: cs_function.h:108
cs_function_t * cs_function_by_name(const char *name)
Return a pointer to a function object based on its name.
Definition: cs_function.cpp:481
void cs_function_set_label(cs_function_t *f, const char *label)
Assig a label to a function object.
Definition: cs_function.cpp:527
cs_function_t * cs_function_define_by_func(const char *name, int location_id, int dim, bool is_intensive, cs_datatype_t datatype, cs_eval_at_location_t *data_func, void *data_input)
Define a function whose data values will be computed using the provided evaluation function.
Definition: cs_function.cpp:299
void cs_function_log_defs(void)
Log function definition setup information.
Definition: cs_function.cpp:541
void cs_function_evaluate(const cs_function_t *f, const cs_time_step_t *ts, int location_id, cs_lnum_t n_elts, const cs_lnum_t *elt_ids, void *vals)
Evaluate function values.
Definition: cs_function.cpp:783
void cs_function_log_all_settings(void)
Print info relative to all given function object settings to log file.
Definition: cs_function.cpp:689
cs_function_t * cs_function_by_name_try(const char *name)
Return a pointer to a function object based on its name if present.
Definition: cs_function.cpp:507
int cs_function_n_functions(void)
Return the number of defined functions.
Definition: cs_function.cpp:439
cs_function_t * cs_function_by_id(int id)
Return a pointer to a function object based on its id.
Definition: cs_function.cpp:457
void cs_function_destroy_all(void)
Destroy all functions management metadata.
Definition: cs_function.cpp:410
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
cs_restart_file_t
Definition: cs_restart_default.h:50
char * label
Definition: keywords.h:58
Definition: cs_function.h:117
cs_dof_func_t * dof_func
Definition: cs_function.h:153
const cs_datatype_t datatype
Definition: cs_function.h:131
int log
Definition: cs_function.h:137
cs_eval_at_location_t * eval_func
Definition: cs_function.h:149
const int id
Definition: cs_function.h:123
int post_vis
Definition: cs_function.h:133
const char * name
Definition: cs_function.h:119
cs_restart_file_t restart_file
Definition: cs_function.h:144
int type
Definition: cs_function.h:124
char * label
Definition: cs_function.h:120
const int location_id
Definition: cs_function.h:129
int time_stamp
Definition: cs_function.h:141
cs_analytic_func_t * analytic_func
Definition: cs_function.h:151
void * func_input
Definition: cs_function.h:156
const int dim
Definition: cs_function.h:126