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 1764 by gezelter, Tue Jul 3 18:32:27 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 > #include "brains/Thermo.hpp"
49  
50 + namespace OpenMD {
51 +
52    void WrappingVisitor::visit(Atom *atom) {
53      internalVisit(atom);
54    }
# Line 76 | Line 79 | namespace oopse {
79  
80      Snapshot* currSnapshot = info->getSnapshotManager()->getCurrentSnapshot();
81      
82 <    for( atomInfo = atomData->beginAtomInfo(i); atomInfo; atomInfo = atomData->nextAtomInfo(i) ) {
82 >    for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
83 >         atomInfo = atomData->nextAtomInfo(i) ) {
84 >
85        Vector3d newPos = atomInfo->pos - origin_;
86        currSnapshot->wrapVector(newPos);
87        atomInfo->pos = newPos;
88 +
89      }
90    }
91  
92    void WrappingVisitor::update() {
93      if (useCom_){
94 <      origin_ = info->getCom();
94 >      Thermo thermo(info);
95 >      origin_ = thermo.getCom();
96      }
97    }
98    
# Line 223 | Line 230 | namespace oopse {
230      return result;
231    }
232  
233 <  //----------------------------------------------------------------------------//
227 <
228 <  XYZVisitor::XYZVisitor(SimInfo *info) :
229 <    BaseVisitor(), seleMan(info), evaluator(info){
230 <      this->info = info;
231 <      visitorName = "XYZVisitor";
232 <
233 <      evaluator.loadScriptString("select all");
234 <
235 <      if (!evaluator.isDynamic()) {
236 <        seleMan.setSelectionSet(evaluator.evaluate());
237 <      }
238 <
239 <    }
233 >  //------------------------------------------------------------------------//
234  
235 +  XYZVisitor::XYZVisitor(SimInfo *info) : BaseVisitor(), seleMan(info),
236 +                                          evaluator(info), doPositions_(true),
237 +                                          doVelocities_(false),
238 +                                          doForces_(false), doVectors_(false),
239 +                                          doCharges_(false) {
240 +    this->info = info;
241 +    visitorName = "XYZVisitor";
242 +    
243 +    evaluator.loadScriptString("select all");
244 +    
245 +    if (!evaluator.isDynamic()) {
246 +      seleMan.setSelectionSet(evaluator.evaluate());
247 +    }
248 +  }
249 +  
250    XYZVisitor::XYZVisitor(SimInfo *info, const std::string& script) :
251 <    BaseVisitor(), seleMan(info), evaluator(info) {
252 <      this->info = info;
253 <      visitorName = "XYZVisitor";
254 <
255 <      evaluator.loadScriptString(script);
256 <
257 <      if (!evaluator.isDynamic()) {
258 <        seleMan.setSelectionSet(evaluator.evaluate());
259 <      }
260 <          
251 >    BaseVisitor(), seleMan(info), evaluator(info), doPositions_(true),
252 >    doVelocities_(false), doForces_(false), doVectors_(false),
253 >    doCharges_(false) {
254 >    
255 >    this->info = info;
256 >    visitorName = "XYZVisitor";
257 >    
258 >    evaluator.loadScriptString(script);
259 >    
260 >    if (!evaluator.isDynamic()) {
261 >      seleMan.setSelectionSet(evaluator.evaluate());
262      }
263 +  }
264      
265    void XYZVisitor::visit(Atom *atom) {
266      if (isSelected(atom))
# Line 260 | Line 271 | namespace oopse {
271      if (isSelected(datom))
272        internalVisit(datom);
273    }
274 <
274 >  
275    void XYZVisitor::visit(RigidBody *rb) {
276      if (isSelected(rb))
277        internalVisit(rb);
278    }
279 <
279 >  
280    void XYZVisitor::update() {
281      //if dynamic, we need to re-evaluate the selection
282      if (evaluator.isDynamic()) {
283        seleMan.setSelectionSet(evaluator.evaluate());
284      }
285    }
286 <
286 >  
287    void XYZVisitor::internalVisit(StuntDouble *sd) {
288      GenericData *                     data;
289      AtomData *                        atomData;
290      AtomInfo *                        atomInfo;
291      std::vector<AtomInfo *>::iterator i;
292      char                              buffer[1024];
293 <
293 >    
294      //if there is not atom data, just skip it
295      data = sd->getPropertyByName("ATOMDATA");
296 <
296 >    
297      if (data != NULL) {
298        atomData = dynamic_cast<AtomData *>(data);
299 <
299 >      
300        if (atomData == NULL)
301          return;
302      } else
303        return;
304  
305      for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
306 <         atomInfo = atomData->nextAtomInfo(i) ) {
307 <      sprintf(buffer,
308 <              "%s%15.8f%15.8f%15.8f%15.8f%15.8f%15.8f",
309 <              atomInfo->atomTypeName.c_str(),
310 <              atomInfo->pos[0],
311 <              atomInfo->pos[1],
312 <              atomInfo->pos[2],
313 <              atomInfo->dipole[0],
314 <              atomInfo->dipole[1],
315 <              atomInfo->dipole[2]);
316 <      frame.push_back(buffer);
317 <    }
306 >         atomInfo = atomData->nextAtomInfo(i) ) {
307 >    
308 >      std::string line;
309 >      sprintf(buffer, "%s", atomInfo->atomTypeName.c_str());
310 >      line += buffer;
311 >      
312 >      if (doPositions_){
313 >        sprintf(buffer, "%15.8f%15.8f%15.8f", atomInfo->pos[0],
314 >                atomInfo->pos[1], atomInfo->pos[2]);
315 >        line += buffer;
316 >      }      
317 >      if (doCharges_ && atomInfo->hasCharge) {
318 >        sprintf(buffer, "%15.8f", atomInfo->charge);
319 >        line += buffer;
320 >      }
321 >      if (doVectors_ && atomInfo->hasVector) {
322 >        sprintf(buffer, "%15.8f%15.8f%15.8f", atomInfo->vec[0],
323 >                atomInfo->vec[1], atomInfo->vec[2]);
324 >        line += buffer;
325 >      }
326 >      if (doVelocities_ && atomInfo->hasVelocity) {
327 >        sprintf(buffer, "%15.8f%15.8f%15.8f", atomInfo->vel[0],
328 >                atomInfo->vel[1], atomInfo->vel[2]);
329 >        line += buffer;
330 >      }
331 >      if (doForces_ && atomInfo->hasForce) {
332 >        sprintf(buffer, "%15.8f%15.8f%15.8f", atomInfo->frc[0],
333 >                atomInfo->frc[1], atomInfo->frc[2]);
334 >        line += buffer;
335 >      }      
336 >      frame.push_back(line);
337 >    }    
338    }
339  
340    bool XYZVisitor::isSelected(StuntDouble *sd) {
# Line 313 | Line 344 | namespace oopse {
344    void XYZVisitor::writeFrame(std::ostream &outStream) {
345      std::vector<std::string>::iterator i;
346      char buffer[1024];
347 <
347 >    
348      if (frame.size() == 0)
349        std::cerr << "Current Frame does not contain any atoms" << std::endl;
350 <
350 >    
351      //total number of atoms  
352      outStream << frame.size() << std::endl;
353 <
353 >    
354      //write comment line
355      Snapshot* currSnapshot = info->getSnapshotManager()->getCurrentSnapshot();
356      Mat3x3d box = currSnapshot->getHmat();
# Line 330 | Line 361 | namespace oopse {
361              box(0, 0), box(0, 1), box(0, 2),
362              box(1, 0), box(1, 1), box(1, 2),
363              box(2, 0), box(2, 1), box(2, 2));
364 <
364 >    
365      outStream << buffer << std::endl;
366 <
366 >    
367      for( i = frame.begin(); i != frame.end(); ++i )
368        outStream << *i << std::endl;
369    }
370 <
370 >  
371 >  std::string XYZVisitor::trimmedName(const std::string&atomTypeName) {    
372 >    return atomTypeName.substr(0, atomTypeName.find('-'));
373 >  }
374 >  
375    const std::string XYZVisitor::toString() {
376      char        buffer[65535];
377      std::string result;
378 <
378 >    
379      sprintf(buffer,
380              "------------------------------------------------------------------\n");
381      result += buffer;
382 <
382 >    
383      sprintf(buffer, "Visitor name: %s\n", visitorName.c_str());
384      result += buffer;
385 <
385 >    
386      sprintf(buffer,
387              "Visitor Description: assemble the atom data and output xyz file\n");
388      result += buffer;
# Line 355 | Line 390 | namespace oopse {
390      sprintf(buffer,
391              "------------------------------------------------------------------\n");
392      result += buffer;
393 <
393 >    
394      return result;
395    }
396 <
396 >  
397    //----------------------------------------------------------------------------//
398 <
398 >  
399    void PrepareVisitor::internalVisit(Atom *atom) {
400      GenericData *data;
401      AtomData *   atomData;
402 <
402 >    
403      //if visited property is  existed, remove it
404      data = atom->getPropertyByName("VISITED");
405 <
405 >    
406      if (data != NULL) {
407        atom->removeProperty("VISITED");
408      }
409 <
409 >    
410      //remove atomdata
411      data = atom->getPropertyByName("ATOMDATA");
412  
# Line 440 | Line 475 | namespace oopse {
475      visitorName = "WaterTypeVisitor";
476      waterTypeList.insert("TIP3P_RB_0");
477      waterTypeList.insert("TIP4P_RB_0");
478 +    waterTypeList.insert("TIP4P-Ew_RB_0");
479      waterTypeList.insert("TIP5P_RB_0");
480 +    waterTypeList.insert("TIP5P-E_RB_0");
481      waterTypeList.insert("SPCE_RB_0");
482 +    waterTypeList.insert("SPC_RB_0");
483    }
484  
485    void WaterTypeVisitor::visit(RigidBody *rb) {
# Line 454 | Line 492 | namespace oopse {
492      std::vector<AtomInfo *>::iterator i;
493  
494      rbName = rb->getType();
495 <
495 >    
496      if (waterTypeList.find(rbName) != waterTypeList.end()) {
497        myAtoms = rb->getAtoms();
498  
499        for( atomIter = myAtoms.begin(); atomIter != myAtoms.end();
500             ++atomIter ) {
501          data = (*atomIter)->getPropertyByName("ATOMDATA");
502 <
502 >        
503          if (data != NULL) {
504            atomData = dynamic_cast<AtomData *>(data);
505 <
505 >          
506            if (atomData == NULL)
507              continue;
508          } else
509            continue;
510 <
510 >        
511          for( atomInfo = atomData->beginAtomInfo(i); atomInfo;
512               atomInfo = atomData->nextAtomInfo(i) ) {
513            atomInfo->atomTypeName = trimmedName(atomInfo->atomTypeName);
# Line 504 | Line 542 | namespace oopse {
542      return result;
543    }
544  
545 < } //namespace oopse
545 > } //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 1764 by gezelter, Tue Jul 3 18:32:27 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines