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 1120 by tim, Mon Apr 19 20:54:58 2004 UTC vs.
Revision 1126 by tim, Tue Apr 20 05:39:38 2004 UTC

# Line 47 | Line 47 | const string IgnoreVisitor::toString(){
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    result += buffer;
# Line 82 | Line 85 | void WrappingVisitor::internalVisit(StuntDouble* sd){
85    GenericData* data;
86    AtomData* atomData;
87    AtomInfo* atomInfo;
85  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 136 | 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 178 | Line 202 | const string ReplicateVisitor::toString(){
202    sprintf(buffer ,"------------------------------------------------------------------\n");
203    result += buffer;
204  
205 <  sprintf(buffer ,"Visitor name: %s", visitorName.c_str());
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    result += buffer;
# Line 255 | Line 282 | void XYZVisitor::internalVisit(StuntDouble* sd){
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  
261  frame.push_back(buffer);
262          
291   }
292  
293   bool XYZVisitor::isIgnore(StuntDouble* sd){
# Line 294 | 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(Atom * atom){
# Line 340 | Line 387 | void PrepareVisitor::internalVisit(RigidBody * rb){
387      
388    for(atomIter = myAtoms.begin(); atomIter != myAtoms.end(); ++atomIter)
389     internalVisit (*atomIter);  
390 < }
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", 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