ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/visitors/OtherVisitor.cpp
(Generate patch)

Comparing:
trunk/src/visitors/OtherVisitor.cpp (file contents), Revision 543 by tim, Thu May 26 22:45:00 2005 UTC vs.
branches/development/src/visitors/OtherVisitor.cpp (file contents), Revision 1702 by kstocke1, Thu Apr 5 19:49:59 2012 UTC

# Line 6 | Line 6
6   * redistribute this software in source and binary code form, provided
7   * that the following conditions are met:
8   *
9 < * 1. Acknowledgement of the program authors must be made in any
10 < *    publication of scientific results based in part on use of the
11 < *    program.  An acceptable form of acknowledgement is citation of
12 < *    the article in which the program was described (Matthew
13 < *    A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher
14 < *    J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented
15 < *    Parallel Simulation Engine for Molecular Dynamics,"
16 < *    J. Comput. Chem. 26, pp. 252-271 (2005))
17 < *
18 < * 2. Redistributions of source code must retain the above copyright
9 > * 1. Redistributions of source code must retain the above copyright
10   *    notice, this list of conditions and the following disclaimer.
11   *
12 < * 3. Redistributions in binary form must reproduce the above copyright
12 > * 2. Redistributions in binary form must reproduce the above copyright
13   *    notice, this list of conditions and the following disclaimer in the
14   *    documentation and/or other materials provided with the
15   *    distribution.
# Line 37 | Line 28
28   * arising out of the use of or inability to use software, even if the
29   * University of Notre Dame has been advised of the possibility of
30   * such damages.
31 + *
32 + * SUPPORT OPEN SCIENCE!  If you use OpenMD or its source code in your
33 + * research, please cite the appropriate papers when you publish your
34 + * work.  Good starting points are:
35 + *                                                                      
36 + * [1]  Meineke, et al., J. Comp. Chem. 26, 252-271 (2005).            
37 + * [2]  Fennell & Gezelter, J. Chem. Phys. 124, 234104 (2006).          
38 + * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 24107 (2008).          
39 + * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40 + * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
42   #include "selection/SelectionManager.hpp"
43   #include "visitors/OtherVisitor.hpp"
# Line 44 | Line 45
45   #include "primitives/RigidBody.hpp"
46   #include "primitives/Molecule.hpp"
47   #include "brains/SimInfo.hpp"
48 < namespace oopse {
48 > namespace OpenMD {
49  
50    void WrappingVisitor::visit(Atom *atom) {
51      internalVisit(atom);
# Line 223 | Line 224 | namespace oopse {
224      return result;
225    }
226  
227 <  //----------------------------------------------------------------------------//
227 >  //------------------------------------------------------------------------//
228  
229 <  XYZVisitor::XYZVisitor(SimInfo *info) :
230 <    BaseVisitor(), seleMan(info), evaluator(info){
231 <      this->info = info;
232 <      visitorName = "XYZVisitor";
233 <
234 <      evaluator.loadScriptString("select all");
235 <
236 <      if (!evaluator.isDynamic()) {
237 <        seleMan.setSelectionSet(evaluator.evaluate());
238 <      }
239 <
240 <    }
241 <
229 >  XYZVisitor::XYZVisitor(SimInfo *info) : BaseVisitor(), seleMan(info),
230 >                                          evaluator(info), doPositions_(true),
231 >                                          doVelocities_(false),
232 >                                          doForces_(false), doVectors_(false),
233 >                                          doCharges_(false) {
234 >    this->info = info;
235 >    visitorName = "XYZVisitor";
236 >    
237 >    evaluator.loadScriptString("select all");
238 >    
239 >    if (!evaluator.isDynamic()) {
240 >      seleMan.setSelectionSet(evaluator.evaluate());
241 >    }
242 >  }
243 >  
244    XYZVisitor::XYZVisitor(SimInfo *info, const std::string& script) :
245 <    BaseVisitor(), seleMan(info), evaluator(info) {
246 <      this->info = info;
247 <      visitorName = "XYZVisitor";
248 <
249 <      evaluator.loadScriptString(script);
250 <
251 <      if (!evaluator.isDynamic()) {
252 <        seleMan.setSelectionSet(evaluator.evaluate());
253 <      }
254 <          
245 >    BaseVisitor(), seleMan(info), evaluator(info), doPositions_(true),
246 >    doVelocities_(false), doForces_(false), doVectors_(false),
247 >    doCharges_(false) {
248 >    
249 >    this->info = info;
250 >    visitorName = "XYZVisitor";
251 >    
252 >    evaluator.loadScriptString(script);
253 >    
254 >    if (!evaluator.isDynamic()) {
255 >      seleMan.setSelectionSet(evaluator.evaluate());
256      }
257 +  }
258      
259    void XYZVisitor::visit(Atom *atom) {
260      if (isSelected(atom))
# Line 260 | Line 265 | namespace oopse {
265      if (isSelected(datom))
266        internalVisit(datom);
267    }
268 <
268 >  
269    void XYZVisitor::visit(RigidBody *rb) {
270      if (isSelected(rb))
271        internalVisit(rb);
272    }
273 <
273 >  
274    void XYZVisitor::update() {
275      //if dynamic, we need to re-evaluate the selection
276      if (evaluator.isDynamic()) {
277        seleMan.setSelectionSet(evaluator.evaluate());
278      }
279    }
280 <
280 >  
281    void XYZVisitor::internalVisit(StuntDouble *sd) {
282      GenericData *                     data;
283      AtomData *                        atomData;
284      AtomInfo *                        atomInfo;
285      std::vector<AtomInfo *>::iterator i;
286      char                              buffer[1024];
287 <
287 >    
288      //if there is not atom data, just skip it
289      data = sd->getPropertyByName("ATOMDATA");
290 <
290 >    
291      if (data != NULL) {
292        atomData = dynamic_cast<AtomData *>(data);
293 <
293 >      
294        if (atomData == NULL)
295          return;
296      } else
297        return;
298  
299      for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
300 <         atomInfo = atomData->nextAtomInfo(i) ) {
301 <      sprintf(buffer,
302 <              "%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f",
303 <              atomInfo->atomTypeName.c_str(),
304 <              atomInfo->pos[0],
305 <              atomInfo->pos[1],
306 <              atomInfo->pos[2],
307 <              atomInfo->dipole[0],
308 <              atomInfo->dipole[1],
309 <              atomInfo->dipole[2]);
310 <      frame.push_back(buffer);
311 <    }
300 >         atomInfo = atomData->nextAtomInfo(i) ) {
301 >    
302 >      std::string line;
303 >      sprintf(buffer, "%s", atomInfo->atomTypeName.c_str());
304 >      line += buffer;
305 >      
306 >      if (doPositions_){
307 >        sprintf(buffer, "%15.8f%15.8f%15.8f", atomInfo->pos[0],
308 >                atomInfo->pos[1], atomInfo->pos[2]);
309 >        line += buffer;
310 >      }      
311 >      if (doCharges_ && atomInfo->hasCharge) {
312 >        sprintf(buffer, "%15.8f", atomInfo->charge);
313 >        line += buffer;
314 >      }
315 >      if (doVectors_ && atomInfo->hasVector) {
316 >        sprintf(buffer, "%15.8f%15.8f%15.8f", atomInfo->vec[0],
317 >                atomInfo->vec[1], atomInfo->vec[2]);
318 >        line += buffer;
319 >      }
320 >      if (doVelocities_ && atomInfo->hasVelocity) {
321 >        sprintf(buffer, "%15.8f%15.8f%15.8f", atomInfo->vel[0],
322 >                atomInfo->vel[1], atomInfo->vel[2]);
323 >        line += buffer;
324 >      }
325 >      if (doForces_ && atomInfo->hasForce) {
326 >        sprintf(buffer, "%15.8f%15.8f%15.8f", atomInfo->frc[0],
327 >                atomInfo->frc[1], atomInfo->frc[2]);
328 >        line += buffer;
329 >      }      
330 >      frame.push_back(line);
331 >    }    
332    }
333  
334    bool XYZVisitor::isSelected(StuntDouble *sd) {
# Line 313 | Line 338 | namespace oopse {
338    void XYZVisitor::writeFrame(std::ostream &outStream) {
339      std::vector<std::string>::iterator i;
340      char buffer[1024];
341 <
341 >    
342      if (frame.size() == 0)
343        std::cerr << "Current Frame does not contain any atoms" << std::endl;
344 <
344 >    
345      //total number of atoms  
346      outStream << frame.size() << std::endl;
347 <
347 >    
348      //write comment line
349      Snapshot* currSnapshot = info->getSnapshotManager()->getCurrentSnapshot();
350      Mat3x3d box = currSnapshot->getHmat();
# Line 330 | Line 355 | namespace oopse {
355              box(0, 0), box(0, 1), box(0, 2),
356              box(1, 0), box(1, 1), box(1, 2),
357              box(2, 0), box(2, 1), box(2, 2));
358 <
358 >    
359      outStream << buffer << std::endl;
360 <
360 >    
361      for( i = frame.begin(); i != frame.end(); ++i )
362        outStream << *i << std::endl;
363    }
364 <
364 >  
365 >  std::string XYZVisitor::trimmedName(const std::string&atomTypeName) {    
366 >    return atomTypeName.substr(0, atomTypeName.find('-'));
367 >  }
368 >  
369    const std::string XYZVisitor::toString() {
370      char        buffer[65535];
371      std::string result;
372 <
372 >    
373      sprintf(buffer,
374              "------------------------------------------------------------------\n");
375      result += buffer;
376 <
376 >    
377      sprintf(buffer, "Visitor name: %s\n", visitorName.c_str());
378      result += buffer;
379 <
379 >    
380      sprintf(buffer,
381              "Visitor Description: assemble the atom data and output xyz file\n");
382      result += buffer;
# Line 355 | Line 384 | namespace oopse {
384      sprintf(buffer,
385              "------------------------------------------------------------------\n");
386      result += buffer;
387 <
387 >    
388      return result;
389    }
390 <
390 >  
391    //----------------------------------------------------------------------------//
392 <
392 >  
393    void PrepareVisitor::internalVisit(Atom *atom) {
394      GenericData *data;
395      AtomData *   atomData;
396 <
396 >    
397      //if visited property is  existed, remove it
398      data = atom->getPropertyByName("VISITED");
399 <
399 >    
400      if (data != NULL) {
401        atom->removeProperty("VISITED");
402      }
403 <
403 >    
404      //remove atomdata
405      data = atom->getPropertyByName("ATOMDATA");
406  
# Line 440 | Line 469 | namespace oopse {
469      visitorName = "WaterTypeVisitor";
470      waterTypeList.insert("TIP3P_RB_0");
471      waterTypeList.insert("TIP4P_RB_0");
472 +    waterTypeList.insert("TIP4P-Ew_RB_0");
473      waterTypeList.insert("TIP5P_RB_0");
474 +    waterTypeList.insert("TIP5P-E_RB_0");
475      waterTypeList.insert("SPCE_RB_0");
476 +    waterTypeList.insert("SPC_RB_0");
477    }
478  
479    void WaterTypeVisitor::visit(RigidBody *rb) {
# Line 454 | Line 486 | namespace oopse {
486      std::vector<AtomInfo *>::iterator i;
487  
488      rbName = rb->getType();
489 <
489 >    
490      if (waterTypeList.find(rbName) != waterTypeList.end()) {
491        myAtoms = rb->getAtoms();
492  
493        for( atomIter = myAtoms.begin(); atomIter != myAtoms.end();
494             ++atomIter ) {
495          data = (*atomIter)->getPropertyByName("ATOMDATA");
496 <
496 >        
497          if (data != NULL) {
498            atomData = dynamic_cast<AtomData *>(data);
499 <
499 >          
500            if (atomData == NULL)
501              continue;
502          } else
503            continue;
504 <
504 >        
505          for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
506               atomInfo = atomData->nextAtomInfo(i) ) {
507            atomInfo->atomTypeName = trimmedName(atomInfo->atomTypeName);
# Line 504 | Line 536 | namespace oopse {
536      return result;
537    }
538  
539 < } //namespace oopse
539 > } //namespace OpenMD

Comparing:
trunk/src/visitors/OtherVisitor.cpp (property svn:keywords), Revision 543 by tim, Thu May 26 22:45:00 2005 UTC vs.
branches/development/src/visitors/OtherVisitor.cpp (property svn:keywords), Revision 1702 by kstocke1, Thu Apr 5 19:49:59 2012 UTC

# Line 0 | Line 1
1 + Author Id Revision Date

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines