programmer's documentation
mei_node.h
Go to the documentation of this file.
1 #ifndef __MEI_NODE_H__
2 #define __MEI_NODE_H__
3 
10 /*
11  This file is part of Code_Saturne, a general-purpose CFD tool.
12 
13  Copyright (C) 1998-2015 EDF S.A.
14 
15  This program is free software; you can redistribute it and/or modify it under
16  the terms of the GNU General Public License as published by the Free Software
17  Foundation; either version 2 of the License, or (at your option) any later
18  version.
19 
20  This program is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
23  details.
24 
25  You should have received a copy of the GNU General Public License along with
26  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
27  Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 */
29 
30 /*----------------------------------------------------------------------------*/
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif /* __cplusplus */
35 
36 
37 /*----------------------------------------------------------------------------
38  * Local headers
39  *----------------------------------------------------------------------------*/
40 
41 #include "mei_hash_table.h"
42 
43 /*============================================================================
44  * Type definitions
45  *============================================================================*/
46 
51 typedef struct
52 {
53  double value;
54 } const_node_t;
55 
60 typedef struct
61 {
62  char *i;
63  int l;
64  int c;
65 } id_node_t;
66 
71 typedef struct
72 {
73  char *name;
74  int l;
75  int c;
76  struct _mei_node_t *op;
77 } func_node_t;
78 
83 typedef struct
84 {
85  char *name;
86  int l;
87  int c;
88  int nops;
89  struct _mei_node_t *op[];
90 } func2_node_t;
91 
96 typedef struct
97 {
98  char *name;
99  char *data;
100  int l;
101  int c;
102  int col1;
103  int col2;
104  struct _mei_node_t *op;
106 
111 typedef struct
112 {
113  int oper;
114  int nops;
115  struct _mei_node_t *op[];
116 } opr_node_t;
117 
122 typedef union
123 {
124  const_node_t con; /* constants */
125  id_node_t id; /* identifiers */
126  func_node_t func; /* function with one argument */
127  func2_node_t funcx; /* function with two, three, or four arguments */
128  interp1d_node_t interp1d; /* function of 1D interpolation */
129  opr_node_t opr; /* operators */
130 } node_type_t;
131 
136 /* union must be last entry in _mei_node_t */
137 /* because operNodeType may dynamically increase */
138 
140 {
142  hash_table_t *ht;
144 };
145 
150 typedef struct _mei_node_t mei_node_t;
151 
152 /*============================================================================
153  * Public function prototypes
154  *============================================================================*/
155 
156 /*----------------------------------------------------------------------------*/
157 /* Build a node for a constant.
158  *
159  * param [in] value real value of the constant
160  *
161  * return built node
162  */
163 /*----------------------------------------------------------------------------*/
164 
165 mei_node_t *
166 mei_const_node(const double value);
167 
168 /*----------------------------------------------------------------------------*/
169 /* Build a node for a variable.
170  *
171  * param [in] variable label of the variable
172  *
173  * return built node
174  */
175 /*----------------------------------------------------------------------------*/
176 
177 mei_node_t *
178 mei_id_node(const char *variable);
179 
180 /*----------------------------------------------------------------------------*/
181 /* Build a node for a function of a single variable.
182  *
183  * param [in] function label of the function
184  * param [in] expr node that represents the variable of the function
185  *
186  * return built node
187  */
188 /*----------------------------------------------------------------------------*/
189 
190 mei_node_t *
191 mei_func_node(const char *const,
192  mei_node_t *const expr);
193 
194 /*----------------------------------------------------------------------------*/
195 /* Build a node for a function of a several variables.
196  *
197  * param [in] function label of the function
198  * param [in] nops number of variables
199  * param [in] ... list of nodes which represent variables of the function
200  *
201  * return built node
202  */
203 /*----------------------------------------------------------------------------*/
204 
205 mei_node_t *
206 mei_funcx_node(const char *function,
207  const int nops,
208  ...);
209 
210 /*----------------------------------------------------------------------------*/
211 /* Build a node for an 1D interpolation.
212  *
213  * param [in] function interp1d
214  * param [in] data name of the file which contains data
215  * param [in] col1 abscissa for interpolation
216  * param [in] col2 ordinate for interpolation
217  * param [in] expr node that represents the variable to be interpolate
218  *
219  * return built node
220  */
221 /*----------------------------------------------------------------------------*/
222 
223 mei_node_t *
224 mei_interp1d_node(const char *function,
225  const mei_node_t *data,
226  const mei_node_t *col1,
227  const mei_node_t *col2,
228  const mei_node_t *expr);
229 
230 /*----------------------------------------------------------------------------*/
231 /*
232  * Build a node for an operators and its operands.
233  *
234  * param [in] oper operator
235  * param [in] nops number of operand
236  * param [in] ... list of nodes which represent operands
237  *
238  * return built node
239  */
240 /*----------------------------------------------------------------------------*/
241 
242 mei_node_t *
243 mei_opr_node(const int oper,
244  const int nops,
245  ...);
246 
247 /*----------------------------------------------------------------------------*/
248 /*
249  * Return label of a node.
250  *
251  * param [in] n node
252  *
253  * return label of a node
254  */
255 /*----------------------------------------------------------------------------*/
256 
257 char *
258 mei_label_node(mei_node_t *p);
259 
260 /*----------------------------------------------------------------------------*/
261 /*
262  * Free memory.
263  *
264  * param [in] n node
265  */
266 /*----------------------------------------------------------------------------*/
267 
268 void
269 mei_free_node(mei_node_t *p);
270 
271 /*----------------------------------------------------------------------------*/
272 
273 #ifdef __cplusplus
274 }
275  #endif /* __cplusplus */
276 
277 #endif /* __NODE_H__ */
278 
int l
Definition: mei_node.h:100
hash_table_t * ht
Definition: mei_node.h:142
Function with two arguments node.
Definition: mei_node.h:83
int nops
Definition: mei_node.h:88
Function with single argument node.
Definition: mei_node.h:71
int c
Definition: mei_node.h:101
Hash table, intended to provide a symbol table.
char * data
Definition: mei_node.h:99
char * name
Definition: mei_node.h:98
Type of a node.
Definition: mei_node.h:122
General node definition.
Definition: mei_node.h:139
int l
Definition: mei_node.h:74
Definition: cs_field_pointer.h:66
Constants node.
Definition: mei_node.h:51
int oper
Definition: mei_node.h:113
struct _mei_node_t * op
Definition: mei_node.h:76
int col1
Definition: mei_node.h:102
double value
Definition: mei_node.h:53
node_type_t * type
Definition: mei_node.h:143
const_node_t con
Definition: mei_node.h:124
mei_flag_t flag
Definition: mei_node.h:141
char * name
Definition: mei_node.h:73
mei_node_t * mei_funcx_node(const char *function, const int nops,...)
Build a node for a function of a several variables.
Definition: mei_node.c:178
int nops
Definition: mei_node.h:114
func_node_t func
Definition: mei_node.h:126
func2_node_t funcx
Definition: mei_node.h:127
Operators node.
Definition: mei_node.h:111
int l
Definition: mei_node.h:63
Identifiers node.
Definition: mei_node.h:60
char * i
Definition: mei_node.h:62
id_node_t id
Definition: mei_node.h:125
mei_node_t * mei_id_node(const char *variable)
Build a node for a variable.
Definition: mei_node.c:105
int c
Definition: mei_node.h:87
int l
Definition: mei_node.h:86
char * name
Definition: mei_node.h:85
mei_flag_t
List of the different type of symbol.
Definition: mei_hash_table.h:49
char * mei_label_node(mei_node_t *p)
Return label of a node.
Definition: mei_node.c:323
mei_node_t * mei_func_node(const char *const, mei_node_t *const expr)
Build a node for a function of a single variable.
Definition: mei_node.c:139
interp1d_node_t interp1d
Definition: mei_node.h:128
mei_node_t * mei_interp1d_node(const char *function, const mei_node_t *data, const mei_node_t *col1, const mei_node_t *col2, const mei_node_t *expr)
Build a node for an 1D interpolation.
Definition: mei_node.c:237
int col2
Definition: mei_node.h:103
mei_node_t * mei_const_node(const double value)
Build a node for a constant.
Definition: mei_node.c:79
struct _mei_node_t * op
Definition: mei_node.h:104
mei_node_t * mei_opr_node(const int oper, const int nops,...)
Build a node for an operators and its operands.
Definition: mei_node.c:285
opr_node_t opr
Definition: mei_node.h:129
int c
Definition: mei_node.h:75
int c
Definition: mei_node.h:64
Function of interpolation 1D.
Definition: mei_node.h:96
void mei_free_node(mei_node_t *p)
Free memory.
Definition: mei_node.c:364