ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/OtherVisitor.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/OtherVisitor.cpp (file contents):
Revision 1118 by tim, Mon Apr 19 03:52:27 2004 UTC vs.
Revision 1127 by tim, Tue Apr 20 16:56:40 2004 UTC

# Line 38 | Line 38 | const string IgnoreVisitor::toString(){
38  
39   const string IgnoreVisitor::toString(){
40    char buffer[65535];
41 +  string result;
42    set<string>::iterator i;
43    
44 <  sprintf(buffer,"------------------------------------------------------------------\n");
45 <  sprintf(buffer,"Visitor name: %s", visitorName.c_str());
44 >  sprintf(buffer ,"------------------------------------------------------------------\n");
45 >  result += buffer;
46  
47 +  sprintf(buffer ,"Visitor name: %s", visitorName.c_str());
48 +  result += buffer;
49 +
50 +  sprintf(buffer ,"Visitor Description: ignore  stuntdoubles\n");
51 +  result += buffer;
52 +
53    //print the ignore type list
54 <  sprintf(buffer, "Ignore type list contains below types:\n");
55 <  for(i = itList.begin(); i != itList.end(); ++i)
49 <    sprintf(buffer,"%s,\t", i->c_str());
50 <  sprintf(buffer,"\n");
54 >  sprintf(buffer , "Ignore type list contains below types:\n");
55 >  result += buffer;
56  
57 <  sprintf(buffer,"------------------------------------------------------------------\n");
57 >  for(i = itList.begin(); i != itList.end(); ++i){
58 >    sprintf(buffer ,"%s,\t", i->c_str());
59 >    result += buffer;
60  
61 +  }
62 +  sprintf(buffer ,"\n");
63 +  result += buffer;
64 +
65 +  sprintf(buffer ,"------------------------------------------------------------------\n");
66 +  result += buffer;
67 +
68    return buffer;
69   }
70  
# Line 71 | Line 85 | void WrappingVisitor::internalVisit(StuntDouble* sd){
85    GenericData* data;
86    AtomData* atomData;
87    AtomInfo* atomInfo;
74  double pos[3];
88    vector<AtomInfo*>::iterator i;
89  
90    data = sd->getProperty("ATOMDATA");
91 <  if(data != NULL)
91 >  if(data != NULL){
92      atomData = dynamic_cast<AtomData*>(data);  
93      if(atomData == NULL)
94        return;
95 +  }
96    else
97      return;
98  
99 <  for(atomInfo = atomData->beginAtomInfo(i); atomInfo != NULL; atomData->nextAtomInfo(i))
99 >  for(atomInfo = atomData->beginAtomInfo(i); atomInfo; atomInfo = atomData->nextAtomInfo(i))
100      info->wrapVector(atomInfo->pos);
101 +
102    
103   }
104  
105 + const string WrappingVisitor::toString(){
106 +  char buffer[65535];
107 +  string result;
108 +  
109 +  sprintf(buffer ,"------------------------------------------------------------------\n");
110 +  result += buffer;
111 +
112 +  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
113 +  result += buffer;
114 +
115 +  sprintf(buffer ,"Visitor Description: wrapping atoms back to periodic box\n");
116 +  result += buffer;
117 +
118 +  sprintf(buffer,"------------------------------------------------------------------\n");
119 +  result += buffer;
120 +
121 +  return result;
122 + }
123 +
124   //----------------------------------------------------------------------------//
125  
126 < ReplicateVisitor::ReplicateVisitor(SimInfo* info, IntVec3 replicateOpt) : BaseVisitor(){
126 > ReplicateVisitor::ReplicateVisitor(SimInfo* info, IntVec3 opt) : BaseVisitor(){
127    this->info = info;
128    visitorName = "ReplicateVisitor";
129 <  this->replicateOpt = replicateOpt;
129 >  this->replicateOpt = opt;
130    //generate the replicate directions
131 <  for(int i = 0; i < replicateOpt[0]; i ++)
132 <    for(int j = 0; i < replicateOpt[1]; j ++)
133 <      for(int k = 0; i < replicateOpt[2]; k ++)
131 >  for(int i = 0; i <= replicateOpt[0]; i ++)
132 >    for(int j = 0; j <= replicateOpt[1]; j ++)
133 >      for(int k = 0; k <= replicateOpt[2]; k ++)
134          //skip original frame
135          if(i == 0 && j ==0 && k ==0)
136            continue;
# Line 125 | Line 159 | void ReplicateVisitor::internalVisit(StuntDouble* sd){
159    
160    //if there is not atom data, just skip it
161    data = sd->getProperty("ATOMDATA");
162 <  if(data != NULL)
162 >  if(data != NULL){
163      atomData = dynamic_cast<AtomData*>(data);  
164      if(atomData == NULL)
165        return;
166 +  }
167    else
168      return;
169  
# Line 161 | Line 196 | const string ReplicateVisitor::toString(){
196  
197   const string ReplicateVisitor::toString(){
198    char buffer[65535];
199 +  string result;
200    set<string>::iterator i;
201    
202 <  sprintf(buffer,"------------------------------------------------------------------\n");
203 <  sprintf(buffer,"Visitor name: %s", visitorName.c_str());
202 >  sprintf(buffer ,"------------------------------------------------------------------\n");
203 >  result += buffer;
204  
205 +  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
206 +  result += buffer;
207 +
208 +  sprintf(buffer ,"Visitor Description: replicate the atoms in different direction\n");
209 +  result += buffer;
210 +  
211    //print the replicate direction
212 <  sprintf(buffer, "repeatX = %d:\n", replicateOpt[0]);
213 <  sprintf(buffer, "repeatY = %d:\n", replicateOpt[1]);
172 <  sprintf(buffer, "repeatZ = %d:\n", replicateOpt[2]);
212 >  sprintf(buffer , "repeatX = %d:\n", replicateOpt[0]);
213 >  result += buffer;
214  
215 +  sprintf(buffer , "repeatY = %d:\n", replicateOpt[1]);
216 +  result += buffer;
217  
218 +  sprintf(buffer , "repeatZ = %d:\n", replicateOpt[2]);
219 +  result += buffer;
220 +
221 +
222    sprintf(buffer,"------------------------------------------------------------------\n");
223 +  result += buffer;
224  
225 <  return buffer;
225 >  return result;
226   }
227  
228   //----------------------------------------------------------------------------//
# Line 210 | Line 258 | void XYZVisitor::internalVisit(StuntDouble* sd){
258    
259    //if there is not atom data, just skip it
260    data = sd->getProperty("ATOMDATA");
261 <  if(data != NULL)
261 >  if(data != NULL){
262      atomData = dynamic_cast<AtomData*>(data);  
263      if(atomData == NULL)
264        return;
265 +  }
266    else
267      return;
268  
# Line 221 | Line 270 | void XYZVisitor::internalVisit(StuntDouble* sd){
270  
271      if(printDipole)
272        sprintf(buffer, "%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f",
273 <                  atomInfo->AtomType,
273 >                  atomInfo->AtomType.c_str(),
274                    atomInfo->pos[0],
275                    atomInfo->pos[1],
276                    atomInfo->pos[2],
# Line 230 | Line 279 | void XYZVisitor::internalVisit(StuntDouble* sd){
279                    atomInfo->dipole[2]);
280      else
281        sprintf(buffer, "%s%15.8f%15.8f%15.8f",
282 <                  atomInfo->AtomType,
282 >                  atomInfo->AtomType.c_str(),
283                    atomInfo->pos[0],
284                    atomInfo->pos[1],
285 <                  atomInfo->pos[2]);        
285 >                  atomInfo->pos[2]);  
286 >
287 >    frame.push_back(buffer);
288 >              
289    }
290  
239  frame.push_back(buffer);
240          
291   }
292  
293   bool XYZVisitor::isIgnore(StuntDouble* sd){
# Line 272 | Line 322 | void XYZVisitor::writeFrame(ostream& outStream){
322      outStream << *i << endl;
323   }
324  
325 + const string XYZVisitor::toString(){
326 +  char buffer[65535];
327 +  string result;
328 +  
329 +  sprintf(buffer ,"------------------------------------------------------------------\n");
330 +  result += buffer;
331 +
332 +  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
333 +  result += buffer;
334 +
335 +  sprintf(buffer ,"Visitor Description: assemble the atom data  and output xyz file\n");
336 +  result += buffer;
337 +
338 +  sprintf(buffer,"------------------------------------------------------------------\n");
339 +  result += buffer;
340 +
341 +  return result;
342 + }
343 +
344   //----------------------------------------------------------------------------//
345  
346 < void PrepareVisitor::internalVisit(StuntDouble * sd){
346 > void PrepareVisitor::internalVisit(Atom * atom){
347    GenericData* data;
348    AtomData* atomData;
349  
350    //if visited property is  existed, remove it
351 <  data = sd->getProperty("VISITED");
351 >  data = atom->getProperty("VISITED");
352    if(data != NULL){
353 <    sd->removeProperty("VISITED");  
353 >    atom->removeProperty("VISITED");  
354    }
355  
356    //remove atomdata
357 <  data = sd->getProperty("ATOMDATA");
358 <  if(data != NULL)
357 >  data = atom->getProperty("ATOMDATA");
358 >  if(data != NULL){
359      atomData = dynamic_cast<AtomData*>(data);  
360      if(atomData != NULL)
361 <      sd->removeProperty("ATOMDATA");
361 >      atom->removeProperty("ATOMDATA");
362 >  }
363 >  
364   }
365  
366 + void PrepareVisitor::internalVisit(RigidBody * rb){
367 +  GenericData* data;
368 +  AtomData* atomData;
369 +  vector<Atom*> myAtoms;
370 +  vector<Atom*>::iterator atomIter;
371 +  
372 +  //if visited property is  existed, remove it
373 +  data = rb->getProperty("VISITED");
374 +  if(data != NULL){
375 +    rb->removeProperty("VISITED");  
376 +  }
377 +
378 +  //remove atomdata
379 +  data = rb->getProperty("ATOMDATA");
380 +  if(data != NULL){
381 +    atomData = dynamic_cast<AtomData*>(data);  
382 +    if(atomData != NULL)
383 +      rb->removeProperty("ATOMDATA");
384 +  }
385 +
386 +  myAtoms = rb->getAtoms();
387 +    
388 +  for(atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter)
389 +   internalVisit (*atomIter);  
390 + }
391 +
392 + const string PrepareVisitor::toString(){
393 +  char buffer[65535];
394 +  string result;
395 +  
396 +  sprintf(buffer ,"------------------------------------------------------------------\n");
397 +  result += buffer;
398 +
399 +  sprintf(buffer ,"Visitor name: %s", visitorName.c_str());
400 +  result += buffer;
401 +
402 +  sprintf(buffer ,"Visitor Description: prepare for operation of other vistors\n");
403 +  result += buffer;
404 +
405 +  sprintf(buffer ,"------------------------------------------------------------------\n");
406 +  result += buffer;
407 +
408 +  return result;
409 + }
410 +
411 + //----------------------------------------------------------------------------//
412 +
413 + WaterTypeVisitor:: WaterTypeVisitor(){
414 +  visitorName = "WaterTypeVisitor";
415 +  waterTypeList.insert("TIP3P_RB_0");
416 +  waterTypeList.insert("TIP4P_RB_0");
417 +  waterTypeList.insert("TIP5P_RB_0");
418 +  waterTypeList.insert("SPCE_RB_0");  
419 + }
420 +
421 +
422 + void WaterTypeVisitor:: visit(RigidBody* rb){
423 +  string rbName;
424 +  vector<Atom*> myAtoms;
425 +  vector<Atom*>::iterator atomIter;
426 +  GenericData* data;
427 +  AtomData* atomData;
428 +  AtomInfo* atomInfo;
429 +  vector<AtomInfo*>::iterator i;
430 +  
431 +  rbName = rb->getType();
432 +
433 +  if(waterTypeList.find(rbName) != waterTypeList.end()){
434 +
435 +    myAtoms = rb->getAtoms();    
436 +    for(atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter){
437 +
438 +      data = (*atomIter)->getProperty("ATOMDATA");
439 +      if(data != NULL){
440 +        atomData = dynamic_cast<AtomData*>(data);  
441 +        if(atomData == NULL)
442 +          continue;
443 +      }
444 +      else
445 +        continue;
446 +      
447 +      for(atomInfo = atomData->beginAtomInfo(i); atomInfo; atomInfo = atomData->nextAtomInfo(i)){
448 +        replaceType(atomInfo->AtomType);
449 +      }//end for(atomInfo)
450 +
451 +    }//end for(atomIter)
452 +      
453 +  }//end if (waterTypeList.find(rbName) != waterTypeList.end())
454 +  
455 + }
456 +
457 + void WaterTypeVisitor:: replaceType(string& atomType){
458 +  atomType = atomType.substr(0, atomType.find('_'));
459 + }
460 +
461 + const string WaterTypeVisitor:: toString(){
462 +  char buffer[65535];
463 +  string result;
464 +  
465 +  sprintf(buffer ,"------------------------------------------------------------------\n");
466 +  result += buffer;
467 +
468 +  sprintf(buffer ,"Visitor name: %s\n", visitorName.c_str());
469 +  result += buffer;
470 +
471 +  sprintf(buffer ,"Visitor Description: Replace the atom type in water model\n");
472 +  result += buffer;
473 +
474 +  sprintf(buffer ,"------------------------------------------------------------------\n");
475 +  result += buffer;
476 +
477 +  return result;
478 + }
479 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines