# | Line 73 | Line 73 | void SimSetup::createSim( void ){ | |
---|---|---|
73 | ||
74 | MakeStamps *the_stamps; | |
75 | Globals* the_globals; | |
76 | < | int i; |
76 | > | int i, j; |
77 | ||
78 | // get the stamps and globals; | |
79 | the_stamps = stamps; | |
# | Line 161 | Line 161 | void SimSetup::createSim( void ){ | |
161 | #endif // is_mpi | |
162 | ||
163 | // make an array of molecule stamps that match the components used. | |
164 | + | // also extract the used stamps out into a separate linked list |
165 | ||
166 | + | simnfo->nComponents = n_components; |
167 | + | simnfo->componentsNmol = components_nmol; |
168 | + | simnfo->compStamps = comp_stamps; |
169 | + | simnfo->headStamp = new LinkedMolStamp(); |
170 | + | |
171 | + | char* id; |
172 | + | LinkedMolStamp* headStamp = simnfo->headStamp; |
173 | + | LinkedMolStamp* currentStamp = NULL; |
174 | for( i=0; i<n_components; i++ ){ | |
175 | ||
176 | < | comp_stamps[i] = |
177 | < | the_stamps->getMolecule( the_components[i]->getType() ); |
176 | > | id = the_components[i]->getType(); |
177 | > | comp_stamps[i] = NULL; |
178 | > | |
179 | > | // check to make sure the component isn't already in the list |
180 | > | |
181 | > | comp_stamps[i] = headStamp->match( id ); |
182 | > | if( comp_stamps[i] == NULL ){ |
183 | > | |
184 | > | // extract the component from the list; |
185 | > | |
186 | > | currentStamp = the_stamps->extractMolStamp( id ); |
187 | > | if( currentStamp == NULL ){ |
188 | > | sprintf( painCave.errMsg, |
189 | > | "SimSetup error: Component \"%s\" was not found in the " |
190 | > | "list of declared molecules\n" |
191 | > | id ); |
192 | > | painCave.isFatal = 1; |
193 | > | simError(); |
194 | > | } |
195 | > | |
196 | > | headStamp->add( currentStamp ); |
197 | > | comp_stamps[i] = headStamp->match( id ); |
198 | > | } |
199 | } | |
200 | ||
201 | + | #ifdef IS_MPI |
202 | + | strcpy( checkPointMsg, "Component stamps successfully extracted\n" ); |
203 | + | MPIcheckPoint(); |
204 | + | #endif // is_mpi |
205 | + | |
206 | ||
207 | ||
208 | + | |
209 | // caclulate the number of atoms, bonds, bends and torsions | |
210 | ||
211 | tot_atoms = 0; | |
# | Line 177 | Line 213 | void SimSetup::createSim( void ){ | |
213 | tot_bends = 0; | |
214 | tot_torsions = 0; | |
215 | for( i=0; i<n_components; i++ ){ | |
216 | < | |
217 | < | tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); |
218 | < | tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); |
219 | < | tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); |
216 | > | |
217 | > | tot_atoms += components_nmol[i] * comp_stamps[i]->getNAtoms(); |
218 | > | tot_bonds += components_nmol[i] * comp_stamps[i]->getNBonds(); |
219 | > | tot_bends += components_nmol[i] * comp_stamps[i]->getNBends(); |
220 | tot_torsions += components_nmol[i] * comp_stamps[i]->getNTorsions(); | |
221 | } | |
222 | ||
# | Line 191 | Line 227 | void SimSetup::createSim( void ){ | |
227 | simnfo->n_bends = tot_bends; | |
228 | simnfo->n_torsions = tot_torsions; | |
229 | simnfo->n_SRI = tot_SRI; | |
230 | + | simnfo->n_mol = tot_nmol; |
231 | ||
232 | + | |
233 | + | #ifdef IS_MPI |
234 | + | |
235 | // divide the molecules among processors here. | |
236 | + | |
237 | + | mpiSimulation* mpiSim = new mpiSimulation( simnfo ); |
238 | + | |
239 | + | mpiSim->divideLabor(); |
240 | + | |
241 | + | // set up the local variables |
242 | + | |
243 | + | int localMol; |
244 | + | int local_atoms, local_bonds, local_bends, local_torsions, local_SRI; |
245 | + | |
246 | + | localMol = 0; |
247 | + | local_atoms = 0; |
248 | + | local_bonds = 0; |
249 | + | local_bends = 0; |
250 | + | local_torsions = 0; |
251 | + | for( i=0; i<n_components; i++ ){ |
252 | ||
253 | + | for( j=0; j<components_nmol[i]; j++ ){ |
254 | + | |
255 | + | if( mpiSim->getMyMolStart() <= j && |
256 | + | j <= mpiSim->getMyMolEnd() ){ |
257 | + | |
258 | + | local_atoms += comp_stamps[i]->getNAtoms(); |
259 | + | local_bonds += comp_stamps[i]->getNBonds(); |
260 | + | local_bends += comp_stamps[i]->getNBends(); |
261 | + | local_torsions += comp_stamps[i]->getNTorsions(); |
262 | + | localMol++; |
263 | + | } |
264 | + | } |
265 | + | } |
266 | ||
267 | + | |
268 | + | |
269 | + | simnfo->n_atoms = mpiSim->getMyNlocal(); |
270 | + | |
271 | + | |
272 | + | #endif // is_mpi |
273 | + | |
274 | + | |
275 | // create the atom and short range interaction arrays | |
276 | ||
277 | < | Atom::createArrays(tot_atoms); |
278 | < | the_atoms = new Atom*[tot_atoms]; |
279 | < | the_molecules = new Molecule[tot_nmol]; |
277 | > | Atom::createArrays(simnfo->n_atoms); |
278 | > | the_atoms = new Atom*[simnfo->n_atoms]; |
279 | > | the_molecules = new Molecule[simnfo->n_mol]; |
280 | ||
281 | ||
282 | < | if( tot_SRI ){ |
283 | < | the_sris = new SRI*[tot_SRI]; |
284 | < | the_excludes = new ex_pair[tot_SRI]; |
282 | > | if( simnfo->n_SRI ){ |
283 | > | the_sris = new SRI*[simnfo->n_SRI]; |
284 | > | the_excludes = new ex_pair[simnfo->n_SRI]; |
285 | } | |
286 | ||
287 | // set the arrays into the SimInfo object | |
# | Line 233 | Line 310 | void SimSetup::createSim( void ){ | |
310 | makeTorsions(); | |
311 | } | |
312 | ||
236 | – | // makeMolecules(); |
313 | ||
314 | // get some of the tricky things that may still be in the globals | |
315 | ||
# | Line 318 | Line 394 | void SimSetup::createSim( void ){ | |
394 | // } | |
395 | // else{ | |
396 | ||
397 | + | #ifdef IS_MPI |
398 | + | |
399 | + | // no init from bass |
400 | + | |
401 | + | sprintf( painCave.errMsg, |
402 | + | "Cannot intialize a parallel simulation without an initial configuration file.\n" ); |
403 | + | painCave.isFatal; |
404 | + | simError(); |
405 | + | |
406 | + | #else |
407 | + | |
408 | initFromBass(); | |
409 | + | |
410 | + | #endif // is_mpi |
411 | ||
412 | #ifdef IS_MPI | |
413 | < | strcpy( checkPointMsg, "initFromBass successfully created the lattice" ); |
413 | > | strcpy( checkPointMsg, "Successfully read in the initial configuration" ); |
414 | MPIcheckPoint(); | |
415 | #endif // is_mpi | |
416 | ||
# | Line 504 | Line 593 | void SimSetup::makeAtoms( void ){ | |
593 | the_molecules[molIndex].setNMembers( nMemb ); | |
594 | the_molecules[molIndex].setStartAtom( molStart ); | |
595 | the_molecules[molIndex].setEndAtom( molEnd ); | |
596 | + | the_molecules[molIndex].setStampID( i ); |
597 | molIndex++; | |
598 | ||
599 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |