My Project
programmer's documentation
cs_calcium.h
Go to the documentation of this file.
1 #ifndef __CS_CALCIUM_H__
2 #define __CS_CALCIUM_H__
3 
4 /*============================================================================
5  * Basic CALCIUM-mappable functions for code coupling using SALOME's YACS
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2019 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  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_base.h"
35 
36 /*----------------------------------------------------------------------------*/
37 
39 
40 /*=============================================================================
41  * Local Macro Definitions
42  *============================================================================*/
43 
44 /* Instance continuation directive */
45 
46 #define CS_CALCIUM_CONTINUE 20
47 #define CS_CALCIUM_STOP 22
48 
49 /* Maximum string Lengths (based on CALCIUM's limits) */
50 
51 #define CS_CALCIUM_INSTANCE_LEN 72
52 #define CS_CALCIUM_VARIABLE_LEN 144
53 
54 /*=============================================================================
55  * Type Definitions
56  *============================================================================*/
57 
58 /* CALCIUM Variable type dependency */
59 
60 typedef enum {
61 
62  CALCIUM_time, /* Physical time */
63  CALCIUM_iteration /* Iteration number */
64 
66 
67 /* CALCIUM Variable type dependency */
68 
69 typedef enum {
70 
71  CALCIUM_continue, /* Use last values after disconnect */
72  CALCIUM_stop /* Stop after disconnect */
73 
75 
76 /*=============================================================================
77  * Public function prototypes
78  *============================================================================*/
79 
80 /*----------------------------------------------------------------------------
81  * Connection
82  *
83  * parameters:
84  * comp_id <-- id of component to connect (0 to n-1, Code_Saturne local)
85  * s --> name of calling instance
86  * (CS_CALCIUM_INSTANCE_LEN chars max)
87  *
88  * returns:
89  * 0 in case of success, error code otherwise
90  *----------------------------------------------------------------------------*/
91 
92 int
93 cs_calcium_connect(int comp_id,
94  char *s);
95 
96 /*----------------------------------------------------------------------------
97  * Disconnection
98  *
99  * parameters:
100  * comp_id <-- id of component to connect (0 to n-1, Code_Saturne local)
101  * cont --> continuation directive (continue with last values or stop)
102  *
103  * returns:
104  * 0 in case of success, error code otherwise
105  *----------------------------------------------------------------------------*/
106 
107 int
108 cs_calcium_disconnect(int comp_id,
110 
111 /*----------------------------------------------------------------------------
112  * Read values, blocking until they are available.
113  *
114  * parameters:
115  * comp_id <-- id of component to connect (0 to n-1, Code_Saturne local)
116  * time_dep <-- type of time dependency (time or iteration)
117  * min_time <-> lower bound of read interval
118  * max_time <-- upper bound of read interval
119  * iteration <-> iteration number of read
120  * var_name <-- name of the variable to read
121  * n_val_max <-- maximum number of values to read
122  * n_val_read <-- maximum number of values to read
123  * val --> values read
124  *
125  * returns:
126  * 0 in case of success, error code otherwise
127  *----------------------------------------------------------------------------*/
128 
129 int
130 cs_calcium_read_int(int comp_id,
131  cs_calcium_timedep_t time_dep,
132  double *min_time,
133  double *max_time,
134  int *iteration,
135  const char *var_name,
136  int n_val_max,
137  int *n_val_read,
138  int val[]);
139 
140 int
141 cs_calcium_read_float(int comp_id,
142  cs_calcium_timedep_t time_dep,
143  double *min_time,
144  double *max_time,
145  int *iteration,
146  const char *var_name,
147  int n_val_max,
148  int *n_val_read,
149  float val[]);
150 
151 int
152 cs_calcium_read_double(int comp_id,
153  cs_calcium_timedep_t time_dep,
154  double *min_time,
155  double *max_time,
156  int *iteration,
157  const char *var_name,
158  int n_val_max,
159  int *n_val_read,
160  double val[]);
161 
162 /*----------------------------------------------------------------------------
163  * Write values.
164  *
165  * parameters:
166  * comp_id <-- id of component to connect (0 to n-1, Code_Saturne local)
167  * time_dep <-- type of time dependency (time or iteration)
168  * cur_time <-- current time
169  * iteration <-- iteration number
170  * var_name <-- name of the variable to read
171  * n_val <-- number of values to read
172  * val <-- values written
173  *
174  * returns:
175  * 0 in case of success, error code otherwise
176  *----------------------------------------------------------------------------*/
177 
178 int
179 cs_calcium_write_int(int comp_id,
180  cs_calcium_timedep_t time_dep,
181  double cur_time,
182  int iteration,
183  const char *var_name,
184  int n_val,
185  const int val[]);
186 
187 int
188 cs_calcium_write_float(int comp_id,
189  cs_calcium_timedep_t time_dep,
190  double cur_time,
191  int iteration,
192  const char *var_name,
193  int n_val,
194  const float val[]);
195 
196 int
197 cs_calcium_write_double(int comp_id,
198  cs_calcium_timedep_t time_dep,
199  double cur_time,
200  int iteration,
201  const char *var_name,
202  int n_val,
203  const double val[]);
204 
205 /*----------------------------------------------------------------------------
206  * Assign a component and its id
207  *
208  * parameters:
209  * comp_id <-- id of component (0 to n-1, Code_Saturne local)
210  * comp <-- pointer to component
211  *----------------------------------------------------------------------------*/
212 
213 void
214 cs_calcium_set_component(int comp_id,
215  void *comp);
216 
217 /*----------------------------------------------------------------------------
218  * Set the CALCIUM-mappable function's verbosity
219  *
220  * parameters:
221  * n_echo <-- verbosity (none if -1, headers if 0,
222  * headers + n first and last elements if > 0.
223  *----------------------------------------------------------------------------*/
224 
225 void
226 cs_calcium_set_verbosity(int n_echo);
227 
228 /*----------------------------------------------------------------------------
229  * Load YACS and corresponding Calcium functions.
230  *
231  * parameters:
232  * lib_path <-- path to shared library containing the yacsinit() function.
233  *----------------------------------------------------------------------------*/
234 
235 void
236 cs_calcium_load_yacs(const char *lib_path);
237 
238 /*----------------------------------------------------------------------------
239  * Unload YACS and corresponding Calcium functions
240  *----------------------------------------------------------------------------*/
241 
242 void
244 
245 /*----------------------------------------------------------------------------
246  * Initialize YACS component and enter event loop.
247  *
248  * This must be called after cs_calcium_load_yacs().
249  *
250  * Note that the YACS event loop does not return, sot the YACS component
251  * description should ensure that the code's main run() method (or similar)
252  * is called in the component body.
253  *----------------------------------------------------------------------------*/
254 
255 void
257 
258 /*----------------------------------------------------------------------------*/
259 
261 
262 #endif /* __CS_CALCIUM_H__ */
263 
cs_calcium_connect
int cs_calcium_connect(int comp_id, char *s)
Definition: cs_calcium.c:477
cs_calcium_write_float
int cs_calcium_write_float(int comp_id, cs_calcium_timedep_t time_dep, double cur_time, int iteration, const char *var_name, int n_val, const float val[])
Definition: cs_calcium.c:766
cs_calcium_start_yacs
void cs_calcium_start_yacs(void)
Definition: cs_calcium.c:993
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
CALCIUM_stop
Definition: cs_calcium.h:72
CALCIUM_continue
Definition: cs_calcium.h:71
cs_calcium_set_verbosity
void cs_calcium_set_verbosity(int n_echo)
Definition: cs_calcium.c:887
cs_calcium_set_component
void cs_calcium_set_component(int comp_id, void *comp)
Definition: cs_calcium.c:870
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_calcium_disconnect
int cs_calcium_disconnect(int comp_id, cs_calcium_continuation_t cont)
Definition: cs_calcium.c:501
cs_calcium_continuation_t
cs_calcium_continuation_t
Definition: cs_calcium.h:69
CALCIUM_time
Definition: cs_calcium.h:62
cs_calcium_write_double
int cs_calcium_write_double(int comp_id, cs_calcium_timedep_t time_dep, double cur_time, int iteration, const char *var_name, int n_val, const double val[])
Definition: cs_calcium.c:822
cs_calcium_read_double
int cs_calcium_read_double(int comp_id, cs_calcium_timedep_t time_dep, double *min_time, double *max_time, int *iteration, const char *var_name, int n_val_max, int *n_val_read, double val[])
Definition: cs_calcium.c:656
cs_calcium_unload_yacs
void cs_calcium_unload_yacs(void)
Definition: cs_calcium.c:959
cs_calcium_read_float
int cs_calcium_read_float(int comp_id, cs_calcium_timedep_t time_dep, double *min_time, double *max_time, int *iteration, const char *var_name, int n_val_max, int *n_val_read, float val[])
Definition: cs_calcium.c:594
cs_calcium_load_yacs
void cs_calcium_load_yacs(const char *lib_path)
Definition: cs_calcium.c:900
cs_calcium_read_int
int cs_calcium_read_int(int comp_id, cs_calcium_timedep_t time_dep, double *min_time, double *max_time, int *iteration, const char *var_name, int n_val_max, int *n_val_read, int val[])
Definition: cs_calcium.c:533
cs_calcium_timedep_t
cs_calcium_timedep_t
Definition: cs_calcium.h:60
cs_calcium_write_int
int cs_calcium_write_int(int comp_id, cs_calcium_timedep_t time_dep, double cur_time, int iteration, const char *var_name, int n_val, const int val[])
Definition: cs_calcium.c:710
CALCIUM_iteration
Definition: cs_calcium.h:63
cs_base.h