8.3
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-2024 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 "cs_defs.h"
39#include "cs_mesh_location.h"
40#include "cs_param_types.h"
41#include "cs_restart_default.h"
42
43/*----------------------------------------------------------------------------*/
44
46
47/*============================================================================
48 * Macro definitions
49 *============================================================================*/
50
57/*
58 * Function property type
59 */
60
62#define CS_FUNCTION_INTENSIVE (1 << 0)
63
65#define CS_FUNCTION_EXTENSIVE (1 << 1)
66
68#define CS_FUNCTION_TIME_INDEPENDENT (1 << 2)
69
71#define CS_FUNCTION_USER (1 << 3)
72
74#define CS_FUNCTION_NO_MPI_CALL (1 << 4)
75
77#define CS_FUNCTION_NO_SUB_TASK (1 << 5)
78
81/*============================================================================
82 * Type definitions
83 *============================================================================*/
84
85/*----------------------------------------------------------------------------*/
109/*----------------------------------------------------------------------------*/
110
111typedef void
112(cs_eval_at_location_t) (int location_id,
113 cs_lnum_t n_elts,
114 const cs_lnum_t *elt_ids,
115 void *input,
116 void *vals);
117
118/* Function descriptor */
119/*---------------------*/
120
121typedef struct {
122
123 const char *name;
124 char *label;
127 const int id;
128 int type;
130 const int dim;
133 const int location_id;
141 int log;
160 void *func_input; /* Pointer to optional (untyped)
161 value or structure, for use by
162 evaluation function */
163
165
166/*=============================================================================
167 * Global variables
168 *============================================================================*/
169
170/*============================================================================
171 * Public function prototypes
172 *============================================================================*/
173
174/*----------------------------------------------------------------------------*/
193/*----------------------------------------------------------------------------*/
194
196cs_function_define_by_func(const char *name,
197 int location_id,
198 int dim,
199 bool is_intensive,
200 cs_datatype_t datatype,
201 cs_eval_at_location_t *data_func,
202 void *data_input);
203
204/*----------------------------------------------------------------------------*/
224/*----------------------------------------------------------------------------*/
225
228 int location_id,
229 int dim,
230 bool is_intensive,
231 cs_analytic_func_t *data_func,
232 void *data_input);
233
234/*----------------------------------------------------------------------------*/
254/*----------------------------------------------------------------------------*/
255
257cs_function_define_by_dof_func(const char *name,
258 int location_id,
259 int dim,
260 bool is_intensive,
261 cs_dof_func_t *data_func,
262 void *data_input);
263
264/*----------------------------------------------------------------------------
265 * Destroy all function management metadata.
266 *----------------------------------------------------------------------------*/
267
268void
270
271/*----------------------------------------------------------------------------*/
277/*----------------------------------------------------------------------------*/
278
279int
281
282/*----------------------------------------------------------------------------*/
292/*----------------------------------------------------------------------------*/
293
295cs_function_by_id(int id);
296
297/*----------------------------------------------------------------------------*/
307/*----------------------------------------------------------------------------*/
308
310cs_function_by_name(const char *name);
311
312/*----------------------------------------------------------------------------*/
322/*----------------------------------------------------------------------------*/
323
325cs_function_by_name_try(const char *name);
326
327/*----------------------------------------------------------------------------*/
334/*----------------------------------------------------------------------------*/
335
336void
338 const char *label);
339
340/*----------------------------------------------------------------------------*/
344/*----------------------------------------------------------------------------*/
345
346void
348
349/*----------------------------------------------------------------------------*/
354/*----------------------------------------------------------------------------*/
355
356void
358
359/*----------------------------------------------------------------------------*/
376/*----------------------------------------------------------------------------*/
377
378void
380 const cs_time_step_t *ts,
381 int location_id,
382 cs_lnum_t n_elts,
383 const cs_lnum_t *elt_ids,
384 void *vals);
385
386/*----------------------------------------------------------------------------*/
387
389
390#endif /* __CS_FUNCTION_H__ */
cs_datatype_t
Definition: cs_defs.h:300
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
#define END_C_DECLS
Definition: cs_defs.h:543
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
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:346
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:388
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:112
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:485
void cs_function_set_label(cs_function_t *f, const char *label)
Assig a label to a function object.
Definition: cs_function.cpp:531
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:303
void cs_function_log_defs(void)
Log function definition setup information.
Definition: cs_function.cpp:545
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:787
void cs_function_log_all_settings(void)
Print info relative to all given function object settings to log file.
Definition: cs_function.cpp:693
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:511
int cs_function_n_functions(void)
Return the number of defined functions.
Definition: cs_function.cpp:443
cs_function_t * cs_function_by_id(int id)
Return a pointer to a function object based on its id.
Definition: cs_function.cpp:461
void cs_function_destroy_all(void)
Destroy all functions management metadata.
Definition: cs_function.cpp:414
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:54
char * label
Definition: keywords.h:58
Definition: cs_function.h:121
cs_dof_func_t * dof_func
Definition: cs_function.h:157
const cs_datatype_t datatype
Definition: cs_function.h:135
int log
Definition: cs_function.h:141
cs_eval_at_location_t * eval_func
Definition: cs_function.h:153
const int id
Definition: cs_function.h:127
int post_vis
Definition: cs_function.h:137
const char * name
Definition: cs_function.h:123
cs_restart_file_t restart_file
Definition: cs_function.h:148
int type
Definition: cs_function.h:128
char * label
Definition: cs_function.h:124
const int location_id
Definition: cs_function.h:133
int time_stamp
Definition: cs_function.h:145
cs_analytic_func_t * analytic_func
Definition: cs_function.h:155
void * func_input
Definition: cs_function.h:160
const int dim
Definition: cs_function.h:130
time step descriptor
Definition: cs_time_step.h:64