7.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-2022 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 
75 /*============================================================================
76  * Type definitions
77  *============================================================================*/
78 
79 /*----------------------------------------------------------------------------*/
103 /*----------------------------------------------------------------------------*/
104 
105 typedef void
106 (cs_eval_at_location_t) (int location_id,
107  cs_lnum_t n_elts,
108  const cs_lnum_t *elt_ids,
109  void *input,
110  void *vals);
111 
112 /* Function descriptor */
113 /*---------------------*/
114 
115 typedef struct {
116 
117  const char *name;
118  char *label;
121  const int id;
122  int type;
124  const int dim;
127  const int location_id;
131  int post_vis;
135  int log;
154  void *func_input; /* Pointer to optional (untyped)
155  value or structure, for use by
156  evaluation function */
157 
158 } cs_function_t;
159 
160 /*=============================================================================
161  * Global variables
162  *============================================================================*/
163 
164 /*============================================================================
165  * Public function prototypes
166  *============================================================================*/
167 
168 /*----------------------------------------------------------------------------*/
187 /*----------------------------------------------------------------------------*/
188 
190 cs_function_define_by_func(const char *name,
191  int location_id,
192  int dim,
193  bool is_intensive,
194  cs_datatype_t datatype,
195  cs_eval_at_location_t *data_func,
196  void *data_input);
197 
198 /*----------------------------------------------------------------------------*/
218 /*----------------------------------------------------------------------------*/
219 
221 cs_function_define_by_analytic_func(const char *name,
222  int location_id,
223  int dim,
224  bool is_intensive,
225  cs_analytic_func_t *data_func,
226  void *data_input);
227 
228 /*----------------------------------------------------------------------------*/
248 /*----------------------------------------------------------------------------*/
249 
251 cs_function_define_by_dof_func(const char *name,
252  int location_id,
253  int dim,
254  bool is_intensive,
255  cs_dof_func_t *data_func,
256  void *data_input);
257 
258 /*----------------------------------------------------------------------------
259  * Destroy all function management metadata.
260  *----------------------------------------------------------------------------*/
261 
262 void
264 
265 /*----------------------------------------------------------------------------*/
271 /*----------------------------------------------------------------------------*/
272 
273 int
275 
276 /*----------------------------------------------------------------------------*/
286 /*----------------------------------------------------------------------------*/
287 
289 cs_function_by_id(int id);
290 
291 /*----------------------------------------------------------------------------*/
301 /*----------------------------------------------------------------------------*/
302 
304 cs_function_by_name(const char *name);
305 
306 /*----------------------------------------------------------------------------*/
316 /*----------------------------------------------------------------------------*/
317 
319 cs_function_by_name_try(const char *name);
320 
321 /*----------------------------------------------------------------------------*/
328 /*----------------------------------------------------------------------------*/
329 
330 void
332  const char *label);
333 
334 /*----------------------------------------------------------------------------*/
338 /*----------------------------------------------------------------------------*/
339 
340 void
342 
343 /*----------------------------------------------------------------------------*/
348 /*----------------------------------------------------------------------------*/
349 
350 void
352 
353 /*----------------------------------------------------------------------------*/
370 /*----------------------------------------------------------------------------*/
371 
372 void
374  const cs_time_step_t *ts,
375  int location_id,
376  cs_lnum_t n_elts,
377  const cs_lnum_t *elt_ids,
378  void *vals);
379 
380 /*----------------------------------------------------------------------------*/
381 
383 
384 #endif /* __CS_FUNCTION_H__ */
cs_function_t * cs_function_by_name(const char *name)
Return a pointer to a function object based on its name.
Definition: cs_function.c:485
cs_restart_file_t restart_file
Definition: cs_function.h:142
cs_datatype_t
Definition: cs_defs.h:275
time step descriptor
Definition: cs_time_step.h:64
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.c:388
cs_eval_at_location_t * eval_func
Definition: cs_function.h:147
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.c:346
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.c:787
char * label
Definition: cs_function.h:118
#define BEGIN_C_DECLS
Definition: cs_defs.h:512
const int location_id
Definition: cs_function.h:127
const cs_datatype_t datatype
Definition: cs_function.h:129
cs_function_t * cs_function_by_id(int id)
Return a pointer to a function object based on its id.
Definition: cs_function.c:461
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.c:511
int log
Definition: cs_function.h:135
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
cs_dof_func_t * dof_func
Definition: cs_function.h:151
void cs_function_log_defs(void)
Log function definition setup information.
Definition: cs_function.c:545
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
Definition: cs_function.h:115
int time_stamp
Definition: cs_function.h:139
void * func_input
Definition: cs_function.h:154
int cs_function_n_functions(void)
Return the number of defined functions.
Definition: cs_function.c:443
const char * name
Definition: cs_function.h:117
void cs_function_destroy_all(void)
Destroy all functions management metadata.
Definition: cs_function.c:414
void cs_function_set_label(cs_function_t *f, const char *label)
Assig a label to a function object.
Definition: cs_function.c:531
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:316
#define END_C_DECLS
Definition: cs_defs.h:513
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:106
const int id
Definition: cs_function.h:121
int type
Definition: cs_function.h:122
int post_vis
Definition: cs_function.h:131
char * label
Definition: keywords.h:71
const int dim
Definition: cs_function.h:124
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.c:303
cs_restart_file_t
Definition: cs_restart_default.h:54
cs_analytic_func_t * analytic_func
Definition: cs_function.h:149
void cs_function_log_all_settings(void)
Print info relative to all given function object settings to log file.
Definition: cs_function.c:693