ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libBASS/interface.c
Revision: 957
Committed: Mon Jan 19 16:08:21 2004 UTC (20 years, 5 months ago) by gezelter
Content type: text/plain
File size: 6740 byte(s)
Log Message:
BASS changes to add RigidBodies and LJrcut

File Contents

# User Rev Content
1 mmeineke 377 #include <stdio.h>
2     #include <stdlib.h>
3     #include <string.h>
4    
5 mmeineke 854 #include "parse_interface.h"
6     #include "BASS_interface.h"
7     #include "simError.h"
8 mmeineke 377 #ifdef IS_MPI
9 mmeineke 854 #include "mpiBASS.h"
10 mmeineke 377 #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 gezelter 957 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 mmeineke 377 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 mmeineke 675 void init_zconstraint( int zconstraint_index ){
134     event* the_event;
135 mmeineke 377
136 mmeineke 675 the_event = (event* )malloc( sizeof( event ) );
137    
138     the_event->event_type = ZCONSTRAINT;
139     the_event->err_msg = NULL;
140     the_event->evt.blk_index = zconstraint_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    
151 mmeineke 377 /*
152     * the next few deal with the statement initializations
153     */
154    
155     void init_members( struct node_tag* the_node,
156     struct namespc the_namespc ){
157     event* the_event;
158    
159     the_event = (event* )malloc( sizeof( event ) );
160    
161     the_event->event_type = MEMBER;
162     the_event->err_msg = NULL;
163     the_event->evt.mbr.a = the_node->the_data.mbr.a;
164     the_event->evt.mbr.b = the_node->the_data.mbr.b;
165     the_event->evt.mbr.c = the_node->the_data.mbr.c;
166     the_event->evt.mbr.d = the_node->the_data.mbr.d;
167    
168     if( !event_handler( the_event ) ) interface_error( the_event );
169     #ifdef IS_MPI
170     throwMPIEvent(the_event);
171     #endif
172    
173     free( the_event );
174     }
175    
176     void init_constraint( struct node_tag* the_node,
177     struct namespc the_namespc ){
178     event* the_event;
179    
180     the_event = (event* )malloc( sizeof( event ) );
181    
182     the_event->event_type = CONSTRAINT;
183     the_event->err_msg = NULL;
184     the_event->evt.cnstr = the_node->the_data.cnstr.constraint_val;
185    
186     if( !event_handler( the_event ) ) interface_error( the_event );
187     #ifdef IS_MPI
188     throwMPIEvent(the_event);
189     #endif
190    
191     free( the_event );
192     }
193    
194     void init_assignment( struct node_tag* the_node,
195     struct namespc the_namespc ){
196     event* the_event;
197    
198     the_event = (event* )malloc( sizeof( event ) );
199    
200     the_event->event_type = ASSIGNMENT;
201     the_event->err_msg = NULL;
202    
203     strcpy( the_event->evt.asmt.lhs, the_node->the_data.asmt.identifier );
204     switch( the_node->the_data.asmt.type ){
205    
206     case STR_ASSN:
207     the_event->evt.asmt.asmt_type = STRING;
208     strcpy( the_event->evt.asmt.rhs.sval,
209     the_node->the_data.asmt.rhs.str_ptr );
210     break;
211    
212     case INT_ASSN:
213     the_event->evt.asmt.asmt_type = INT;
214     the_event->evt.asmt.rhs.ival = the_node->the_data.asmt.rhs.i_val;
215     break;
216    
217     case DOUBLE_ASSN:
218     the_event->evt.asmt.asmt_type = DOUBLE;
219     the_event->evt.asmt.rhs.dval = the_node->the_data.asmt.rhs.d_val;
220     break;
221     }
222    
223     if( !event_handler( the_event ) ) interface_error( the_event );
224     #ifdef IS_MPI
225     throwMPIEvent(the_event);
226     #endif
227    
228     free( the_event );
229     }
230    
231     void init_position( struct node_tag* the_node,
232     struct namespc the_namespc ){
233     event* the_event;
234    
235     the_event = (event* )malloc( sizeof( event ) );
236    
237     the_event->event_type = POSITION;
238     the_event->err_msg = NULL;
239     the_event->evt.pos.x = the_node->the_data.pos.x;
240     the_event->evt.pos.y = the_node->the_data.pos.y;
241     the_event->evt.pos.z = the_node->the_data.pos.z;
242    
243     if( !event_handler( the_event ) ) interface_error( the_event );
244     #ifdef IS_MPI
245     throwMPIEvent(the_event);
246     #endif
247    
248     free( the_event );
249     }
250    
251     void init_orientation( struct node_tag* the_node,
252     struct namespc the_namespc ){
253     event* the_event;
254    
255     the_event = (event* )malloc( sizeof( event ) );
256    
257     the_event->event_type = ORIENTATION;
258     the_event->err_msg = NULL;
259     the_event->evt.ornt.x = the_node->the_data.ort.x;
260     the_event->evt.ornt.y = the_node->the_data.ort.y;
261     the_event->evt.ornt.z = the_node->the_data.ort.z;
262    
263     if( !event_handler( the_event ) ) interface_error( the_event );
264     #ifdef IS_MPI
265     throwMPIEvent(the_event);
266     #endif
267    
268     free( the_event );
269     }
270    
271    
272     void end_of_block( void ){
273     event* the_event;
274    
275     the_event = (event* )malloc( sizeof( event ) );
276    
277     the_event->event_type = BLOCK_END;
278     the_event->err_msg = NULL;
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     void interface_error( event* the_event ){
289    
290     sprintf( painCave.errMsg,
291     "**Interface event error**\n"
292     "%s\n",
293     the_event->err_msg );
294     painCave.isFatal = 1;
295     simError();
296     #ifdef IS_MPI
297     mpiInterfaceExit();
298     #endif //IS_MPI
299     }