ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libBASS/interface.c
Revision: 988
Committed: Tue Jan 27 19:37:48 2004 UTC (20 years, 5 months ago) by gezelter
Content type: text/plain
File size: 7112 byte(s)
Log Message:
More BASS changes to do new rigidBody scheme

File Contents

# Content
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 #include "parse_interface.h"
6 #include "BASS_interface.h"
7 #include "simError.h"
8 #ifdef IS_MPI
9 #include "mpiBASS.h"
10 #endif
11
12 void interface_error( event* the_event );
13
14 void init_component( int comp_index ){
15 event* the_event;
16
17 the_event = (event* )malloc( sizeof( event ) );
18
19 the_event->event_type = COMPONENT;
20 the_event->err_msg = NULL;
21 the_event->evt.blk_index = comp_index;
22
23 if( !event_handler( the_event ) ) interface_error( the_event );
24 #ifdef IS_MPI
25 throwMPIEvent(the_event);
26 #endif
27
28 free( the_event );
29 }
30
31 void init_molecule( int mol_index ){
32 event* the_event;
33
34 the_event = (event* )malloc( sizeof( event ) );
35
36 the_event->event_type = MOLECULE;
37 the_event->err_msg = NULL;
38 the_event->evt.blk_index = mol_index;
39
40 if( !event_handler( the_event ) ) interface_error( the_event );
41 #ifdef IS_MPI
42 throwMPIEvent(the_event);
43 #endif
44
45 free( the_event );
46 }
47
48 void init_rigidbody( int rigidbody_index ){
49 event* the_event;
50
51 the_event = (event* )malloc( sizeof( event ) );
52
53 the_event->event_type = RIGIDBODY;
54 the_event->err_msg = NULL;
55 the_event->evt.blk_index = rigidbody_index;
56
57 if( !event_handler( the_event ) ) interface_error( the_event );
58 #ifdef IS_MPI
59 throwMPIEvent(the_event);
60 #endif
61
62 free( the_event );
63 }
64
65 void init_atom( int atom_index ){
66 event* the_event;
67
68 the_event = (event* )malloc( sizeof( event ) );
69
70 the_event->event_type = ATOM;
71 the_event->err_msg = NULL;
72 the_event->evt.blk_index = atom_index;
73
74 if( !event_handler( the_event ) ) interface_error( the_event );
75 #ifdef IS_MPI
76 throwMPIEvent(the_event);
77 #endif
78
79 free( the_event );
80 }
81
82 void init_bond( int bond_index ){
83 event* the_event;
84
85 the_event = (event* )malloc( sizeof( event ) );
86
87 the_event->event_type = BOND;
88 the_event->err_msg = NULL;
89 the_event->evt.blk_index = bond_index;
90
91 if( !event_handler( the_event ) ) interface_error( the_event );
92 #ifdef IS_MPI
93 throwMPIEvent(the_event);
94 #endif
95
96 free( the_event );
97 }
98
99 void init_bend( int bend_index ){
100 event* the_event;
101
102 the_event = (event* )malloc( sizeof( event ) );
103
104 the_event->event_type = BEND;
105 the_event->err_msg = NULL;
106 the_event->evt.blk_index = bend_index;
107
108 if( !event_handler( the_event ) ) interface_error( the_event );
109 #ifdef IS_MPI
110 throwMPIEvent(the_event);
111 #endif
112
113 free( the_event );
114 }
115
116 void init_torsion( int torsion_index ){
117 event* the_event;
118
119 the_event = (event* )malloc( sizeof( event ) );
120
121 the_event->event_type = TORSION;
122 the_event->err_msg = NULL;
123 the_event->evt.blk_index = torsion_index;
124
125 if( !event_handler( the_event ) ) interface_error( the_event );
126 #ifdef IS_MPI
127 throwMPIEvent(the_event);
128 #endif
129
130 free( the_event );
131 }
132
133 void init_member( int member_index ){
134 event* the_event;
135
136 the_event = (event* )malloc( sizeof( event ) );
137
138 the_event->event_type = MEMBER;
139 the_event->err_msg = NULL;
140 the_event->evt.blk_index = member_index;
141
142 if( !event_handler( the_event ) ) interface_error( the_event );
143 #ifdef IS_MPI
144 throwMPIEvent(the_event);
145 #endif
146
147 free( the_event );
148 }
149
150 void init_zconstraint( int zconstraint_index ){
151 event* the_event;
152
153 the_event = (event* )malloc( sizeof( event ) );
154
155 the_event->event_type = ZCONSTRAINT;
156 the_event->err_msg = NULL;
157 the_event->evt.blk_index = zconstraint_index;
158
159 if( !event_handler( the_event ) ) interface_error( the_event );
160 #ifdef IS_MPI
161 throwMPIEvent(the_event);
162 #endif
163
164 free( the_event );
165 }
166
167
168 /*
169 * the next few deal with the statement initializations
170 */
171
172 void init_members( struct node_tag* the_node,
173 struct namespc the_namespc ){
174 event* the_event;
175
176 the_event = (event* )malloc( sizeof( event ) );
177
178 the_event->event_type = MEMBERS;
179 the_event->err_msg = NULL;
180 the_event->evt.mbrs.a = the_node->the_data.mbrs.a;
181 the_event->evt.mbrs.b = the_node->the_data.mbrs.b;
182 the_event->evt.mbrs.c = the_node->the_data.mbrs.c;
183 the_event->evt.mbrs.d = the_node->the_data.mbrs.d;
184
185 if( !event_handler( the_event ) ) interface_error( the_event );
186 #ifdef IS_MPI
187 throwMPIEvent(the_event);
188 #endif
189
190 free( the_event );
191 }
192
193 void init_constraint( struct node_tag* the_node,
194 struct namespc the_namespc ){
195 event* the_event;
196
197 the_event = (event* )malloc( sizeof( event ) );
198
199 the_event->event_type = CONSTRAINT;
200 the_event->err_msg = NULL;
201 the_event->evt.cnstr = the_node->the_data.cnstr.constraint_val;
202
203 if( !event_handler( the_event ) ) interface_error( the_event );
204 #ifdef IS_MPI
205 throwMPIEvent(the_event);
206 #endif
207
208 free( the_event );
209 }
210
211 void init_assignment( struct node_tag* the_node,
212 struct namespc the_namespc ){
213 event* the_event;
214
215 the_event = (event* )malloc( sizeof( event ) );
216
217 the_event->event_type = ASSIGNMENT;
218 the_event->err_msg = NULL;
219
220 strcpy( the_event->evt.asmt.lhs, the_node->the_data.asmt.identifier );
221 switch( the_node->the_data.asmt.type ){
222
223 case STR_ASSN:
224 the_event->evt.asmt.asmt_type = STRING;
225 strcpy( the_event->evt.asmt.rhs.sval,
226 the_node->the_data.asmt.rhs.str_ptr );
227 break;
228
229 case INT_ASSN:
230 the_event->evt.asmt.asmt_type = INT;
231 the_event->evt.asmt.rhs.ival = the_node->the_data.asmt.rhs.i_val;
232 break;
233
234 case DOUBLE_ASSN:
235 the_event->evt.asmt.asmt_type = DOUBLE;
236 the_event->evt.asmt.rhs.dval = the_node->the_data.asmt.rhs.d_val;
237 break;
238 }
239
240 if( !event_handler( the_event ) ) interface_error( the_event );
241 #ifdef IS_MPI
242 throwMPIEvent(the_event);
243 #endif
244
245 free( the_event );
246 }
247
248 void init_position( struct node_tag* the_node,
249 struct namespc the_namespc ){
250 event* the_event;
251
252 the_event = (event* )malloc( sizeof( event ) );
253
254 the_event->event_type = POSITION;
255 the_event->err_msg = NULL;
256 the_event->evt.pos.x = the_node->the_data.pos.x;
257 the_event->evt.pos.y = the_node->the_data.pos.y;
258 the_event->evt.pos.z = the_node->the_data.pos.z;
259
260 if( !event_handler( the_event ) ) interface_error( the_event );
261 #ifdef IS_MPI
262 throwMPIEvent(the_event);
263 #endif
264
265 free( the_event );
266 }
267
268 void init_orientation( struct node_tag* the_node,
269 struct namespc the_namespc ){
270 event* the_event;
271
272 the_event = (event* )malloc( sizeof( event ) );
273
274 the_event->event_type = ORIENTATION;
275 the_event->err_msg = NULL;
276 the_event->evt.ornt.x = the_node->the_data.ort.x;
277 the_event->evt.ornt.y = the_node->the_data.ort.y;
278 the_event->evt.ornt.z = the_node->the_data.ort.z;
279
280 if( !event_handler( the_event ) ) interface_error( the_event );
281 #ifdef IS_MPI
282 throwMPIEvent(the_event);
283 #endif
284
285 free( the_event );
286 }
287
288
289 void end_of_block( void ){
290 event* the_event;
291
292 the_event = (event* )malloc( sizeof( event ) );
293
294 the_event->event_type = BLOCK_END;
295 the_event->err_msg = NULL;
296
297 if( !event_handler( the_event ) ) interface_error( the_event );
298 #ifdef IS_MPI
299 throwMPIEvent(the_event);
300 #endif
301
302 free( the_event );
303 }
304
305 void interface_error( event* the_event ){
306
307 sprintf( painCave.errMsg,
308 "**Interface event error**\n"
309 "%s\n",
310 the_event->err_msg );
311 painCave.isFatal = 1;
312 simError();
313 #ifdef IS_MPI
314 mpiInterfaceExit();
315 #endif //IS_MPI
316 }