ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/brains/SimInfo.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-3.0/src/brains/SimInfo.cpp (file contents):
Revision 1710 by tim, Thu Nov 4 19:48:22 2004 UTC vs.
Revision 1727 by tim, Thu Nov 11 16:41:58 2004 UTC

# Line 43 | Line 43 | SimInfo::~SimInfo() {
43   }
44  
45   SimInfo::~SimInfo() {
46 <    MemoryUtils::deleteVectorOfPointer(molecules_);
46 >    //MemoryUtils::deleteVectorOfPointer(molecules_);
47      delete sman_;
48  
49   }
50  
51  
52   bool SimInfo::addMolecule(Molecule* mol) {
53 <    std::vector<Molecule*>::iterator i;
53 >    MoleculeIterator i;
54      i = std::find(molecules_.begin(), molecules_.end(), mol);
55      if (i != molecules_.end() ) {
56        molecules_.push_back(mol);
56  
57 +        molecules_.insert(make_pair(mol->getGlobalIndex(), mol));
58 +        
59          nAtoms_ += mol->getNAtoms();
60          nBonds_ += mol->getNBonds();
61          nBends_ += mol->getNBends();
# Line 71 | Line 72 | bool SimInfo::removeMolecule(Molecule* mol) {
72   }
73  
74   bool SimInfo::removeMolecule(Molecule* mol) {
75 <    std::vector<Molecule*>::iterator i;
75 >    MoleculeIterator i;
76      i = std::find(molecules_.begin(), molecules_.end(), mol);
77  
78      if (i != molecules_.end() ) {
79 <        molecules_.push_back(mol);
79 >
80          nAtoms_ -= mol->getNAtoms();
81          nBonds_ -= mol->getNBonds();
82          nBends_ -= mol->getNBends();
# Line 85 | Line 86 | bool SimInfo::removeMolecule(Molecule* mol) {
86          nCutoffGroups_ -= mol->getNCutoffGroups();
87          nConstraints_ -= mol->getNConstraints();
88  
89 +        molecules_.erase(mol->getGlobalIndex());
90 +
91 +        delete mol;
92 +        
93          return true;
94      } else {
95          return false;
# Line 94 | Line 99 | Molecule* SimInfo::beginMolecule(std::vector<Molecule*
99   }    
100  
101          
102 < Molecule* SimInfo::beginMolecule(std::vector<Molecule*>::iterator& i) {
102 > Molecule* SimInfo::beginMolecule(MoleculeIterator& i) {
103      i = molecules_.begin();
104      return i == molecules_.end() ? NULL : *i;
105   }    
106  
107 < Molecule* SimInfo::nextMolecule(std::vector<Molecule*>::iterator& i) {
107 > Molecule* SimInfo::nextMolecule(MoleculeIterator& i) {
108      ++i;
109      return i == molecules_.end() ? NULL : *i;    
110   }
111  
112  
113 < void SimInfo::calcNDF() {
113 > void SimInfo::calcNdf() {
114      int ndf_local;
115 <    std::vector<Molecule*>::iterator i;
115 >    MoleculeIterator i;
116      std::vector<StuntDouble*>::iterator j;
117      Molecule* mol;
118      StuntDouble* integrableObject;
# Line 146 | Line 151 | void SimInfo::calcNDFRaw() {
151  
152   }
153  
154 < void SimInfo::calcNDFRaw() {
154 > void SimInfo::calcNdfRaw() {
155      int ndfRaw_local;
156  
157 <    std::vector<Molecule*>::iterator i;
157 >    MoleculeIterator i;
158      std::vector<StuntDouble*>::iterator j;
159      Molecule* mol;
160      StuntDouble* integrableObject;
# Line 181 | Line 186 | void SimInfo::calcNDFTrans() {
186   #endif
187   }
188  
189 < void SimInfo::calcNDFTrans() {
189 > void SimInfo::calcNdfTrans() {
190      int ndfTrans_local;
191  
192      ndfTrans_local = 3 * nIntegrableObjects_ - nConstraints_;
# Line 195 | Line 200 | void SimInfo::calcNDFTrans() {
200  
201      ndfTrans_ = ndfTrans_ - 3 - nZconstraints;
202  
203 + }
204 +
205 + void SimInfo::addExcludePairs(Molecule* mol) {
206 +    std::vector<Bond*>::iterator bondIter;
207 +    std::vector<Bend*>::iterator bendIter;
208 +    std::vector<Torsion*>::iterator torsionIter;
209 +    Bond* bond;
210 +    Bend* bend;
211 +    Torsion* torsion;
212 +    int a;
213 +    int b;
214 +    int c;
215 +    int d;
216 +    
217 +    for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) {
218 +        a = bond->getAtomA()->getGlobalIndex();
219 +        b = bond->getAtomB()->getGlobalIndex();        
220 +        exclude_.addPair(a, b);
221 +    }
222 +
223 +    for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) {
224 +        a = bend->getAtomA()->getGlobalIndex();
225 +        b = bend->getAtomB()->getGlobalIndex();        
226 +        c = bend->getAtomC()->getGlobalIndex();
227 +
228 +        exclude_.addPair(a, b);
229 +        exclude_.addPair(a, c);
230 +        exclude_.addPair(b, c);        
231 +    }
232 +
233 +    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextBond(torsionIter)) {
234 +        a = torsion->getAtomA()->getGlobalIndex();
235 +        b = torsion->getAtomB()->getGlobalIndex();        
236 +        c = torsion->getAtomC()->getGlobalIndex();        
237 +        d = torsion->getAtomD()->getGlobalIndex();        
238 +
239 +        exclude_.addPair(a, b);
240 +        exclude_.addPair(a, c);
241 +        exclude_.addPair(a, d);
242 +        exclude_.addPair(b, c);
243 +        exclude_.addPair(b, d);
244 +        exclude_.addPair(c, d);        
245 +    }
246 +
247 +    
248 + }
249 +
250 + void SimInfo::removeExcludePairs(Molecule* mol) {
251 +    std::vector<Bond*>::iterator bondIter;
252 +    std::vector<Bend*>::iterator bendIter;
253 +    std::vector<Torsion*>::iterator torsionIter;
254 +    Bond* bond;
255 +    Bend* bend;
256 +    Torsion* torsion;
257 +    int a;
258 +    int b;
259 +    int c;
260 +    int d;
261 +    
262 +    for (bond= mol->beginBond(bondIter); bond != NULL; bond = mol->nextBond(bondIter)) {
263 +        a = bond->getAtomA()->getGlobalIndex();
264 +        b = bond->getAtomB()->getGlobalIndex();        
265 +        exclude_.removePair(a, b);
266 +    }
267 +
268 +    for (bend= mol->beginBend(bendIter); bend != NULL; bend = mol->nextBend(bendIter)) {
269 +        a = bend->getAtomA()->getGlobalIndex();
270 +        b = bend->getAtomB()->getGlobalIndex();        
271 +        c = bend->getAtomC()->getGlobalIndex();
272 +
273 +        exclude_.removePair(a, b);
274 +        exclude_.removePair(a, c);
275 +        exclude_.removePair(b, c);        
276 +    }
277 +
278 +    for (torsion= mol->beginTorsion(torsionIter); torsion != NULL; torsion = mol->nextBond(torsionIter)) {
279 +        a = torsion->getAtomA()->getGlobalIndex();
280 +        b = torsion->getAtomB()->getGlobalIndex();        
281 +        c = torsion->getAtomC()->getGlobalIndex();        
282 +        d = torsion->getAtomD()->getGlobalIndex();        
283 +
284 +        exclude_.removePair(a, b);
285 +        exclude_.removePair(a, c);
286 +        exclude_.removePair(a, d);
287 +        exclude_.removePair(b, c);
288 +        exclude_.removePair(b, d);
289 +        exclude_.removePair(c, d);        
290 +    }
291 +
292   }
293  
294  
295 + void SimInfo::addMoleculeStamp(MoleculeStamp* molStamp, int nmol) {
296 +    int curStampId;
297 +
298 +    //index from 0
299 +    curStampId = molStampIds_.size();
300 +
301 +    moleculeStamps_.push_back(molStamp);
302 +    molStampIds_.insert(molStampIds_.end(), nmol, curStampId)
303 + }
304 +
305 + void SimInfo::update() {
306 +
307 +
308 +    
309 +    //SimInfo is responsible for creating localToGlobalAtomIndex and localToGlobalGroupIndex
310 +    std::vector<int> localToGlobalAtomIndex(getNAtoms(), 0);
311 +    std::vector<int> localToGlobalCutoffGroupIndex;
312 +    typename SimInfo::MoleculeIterator mi;
313 +    typename Molecule::AtomIterator ai;
314 +    typename Molecule::CutoffGroupIterator ci;
315 +    Molecule* mol;
316 +    Atom* atom;
317 +    CutoffGroup* cg;
318 +    mpiSimData parallelData;
319 +    int isError;
320 +
321 +    for (mol = beginMolecule(mi); mol != NULL; mol  = nextMolecule(mi)) {
322 +
323 +        //local index(index in DataStorge) of atom is important
324 +        for (atom = mol->beginAtom(ai); atom != NULL; atom = mol->nextAtom(ai)) {
325 +            localToGlobalAtomIndex[atom->getLocalIndex()] = atom->getGlobalIndex() + 1;
326 +        }
327 +
328 +        //local index of cutoff group is trivial, it only depends on the order of travesing
329 +        for (cg = mol->beginCutoffGroup(ci); cg != NULL; cg = mol->nextCutoffGroup(ci)) {
330 +            localToGlobalCutoffGroupIndex.push_back(cg->getGlobalIndex() + 1);
331 +        }        
332 +        
333 +    }
334 +
335 +    //Setup Parallel Data and pass the index arrays to fortran
336 +    parallelData.nMolGlobal = getNMolGlobal();
337 +    parallelData.nMolLocal = ;
338 +    parallelData.nAtomsGlobal = ;
339 +    parallelData.nAtomsLocal = ;
340 +    parallelData.nGroupsGlobal = ;
341 +    parallelData.nGroupsLocal = ;
342 +    parallelData.myNode = worldRank;
343 +    MPI_Comm_size(MPI_COMM_WORLD, &(parallelData->nProcessors));
344 +    
345 +    setFsimParallel(parallelData,            &(parallelData->nAtomsLocal),
346 +                    &localToGlobalAtomIndex[0],  &(parallelData->nGroupsLocal),
347 +                    &localToGlobalCutoffGroupIndex[0], &isError);
348 +
349 +    if (isError) {
350 +        sprintf(painCave.errMsg,
351 +                "mpiRefresh errror: fortran didn't like something we gave it.\n");
352 +        painCave.isFatal = 1;
353 +        simError();
354 +    }
355 +
356 +    sprintf(checkPointMsg, " mpiRefresh successful.\n");
357 +    MPIcheckPoint();
358 +
359 +
360 + }
361 +
362 + std::ostream& operator <<(ostream& o, SimInfo& info) {
363 +
364 +    return o;
365 + }
366 +
367   }//end namespace oopse

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines