ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/src/brains/SimInfo.hpp
(Generate patch)

Comparing branches/development/src/brains/SimInfo.hpp (file contents):
Revision 1467 by gezelter, Sat Jul 17 15:33:03 2010 UTC vs.
Revision 1528 by gezelter, Fri Dec 17 20:11:05 2010 UTC

# Line 67 | Line 67
67   #define __OPENMD_C
68   #include "brains/fSimulation.h"
69  
70 + using namespace std;
71   namespace OpenMD{
72  
73 +  enum CutoffMethod {
74 +    HARD,
75 +    SWITCHING_FUNCTION,
76 +    SHIFTED_POTENTIAL,
77 +    SHIFTED_FORCE
78 +  };
79 +
80    //forward decalration
81    class SnapshotManager;
82    class Molecule;
83    class SelectionManager;
84    class StuntDouble;
85 +
86    /**
87 <   * @class SimInfo SimInfo.hpp "brains/SimInfo.hpp"
88 <   * @brief One of the heavy weight classes of OpenMD, SimInfo maintains a list of molecules.
89 <    * The Molecule class maintains all of the concrete objects
90 <    * (atoms, bond, bend, torsions, inversions, rigid bodies, cutoff groups,
91 <    * constraints). In both the single and parallel versions, atoms and
92 <    * rigid bodies have both global and local indices.  The local index is
93 <    * not relevant to molecules or cutoff groups.
94 <    */
87 >   * @class SimInfo SimInfo.hpp "brains/SimInfo.hpp"
88 >   *
89 >   * @brief One of the heavy-weight classes of OpenMD, SimInfo
90 >   * maintains objects and variables relating to the current
91 >   * simulation.  This includes the master list of Molecules.  The
92 >   * Molecule class maintains all of the concrete objects (Atoms,
93 >   * Bond, Bend, Torsions, Inversions, RigidBodies, CutoffGroups,
94 >   * Constraints). In both the single and parallel versions, Atoms and
95 >   * RigidBodies have both global and local indices.
96 >   */
97    class SimInfo {
98    public:
99 <    typedef std::map<int, Molecule*>::iterator  MoleculeIterator;
100 <
99 >    typedef map<int, Molecule*>::iterator  MoleculeIterator;
100 >    
101      /**
102       * Constructor of SimInfo
103 <     * @param molStampPairs MoleculeStamp Array. The first element of the pair is molecule stamp, the
104 <     * second element is the total number of molecules with the same molecule stamp in the system
103 >     *
104 >     * @param molStampPairs MoleculeStamp Array. The first element of
105 >     * the pair is molecule stamp, the second element is the total
106 >     * number of molecules with the same molecule stamp in the system
107 >     *
108       * @param ff pointer of a concrete ForceField instance
109 +     *
110       * @param simParams
96     * @note
111       */
112      SimInfo(ForceField* ff, Globals* simParams);
113      virtual ~SimInfo();
114  
115      /**
116       * Adds a molecule
117 <     * @return return true if adding successfully, return false if the molecule is already in SimInfo
117 >     *
118 >     * @return return true if adding successfully, return false if the
119 >     * molecule is already in SimInfo
120 >     *
121       * @param mol molecule to be added
122       */
123      bool addMolecule(Molecule* mol);
124  
125      /**
126       * Removes a molecule from SimInfo
127 <     * @return true if removing successfully, return false if molecule is not in this SimInfo
127 >     *
128 >     * @return true if removing successfully, return false if molecule
129 >     * is not in this SimInfo
130       */
131      bool removeMolecule(Molecule* mol);
132  
# Line 127 | Line 146 | namespace OpenMD{
146      }
147  
148      /**
149 <     * Returns the total number of integrable objects (total number of rigid bodies plus the total number
150 <     * of atoms which do not belong to the rigid bodies) in the system
149 >     * Returns the total number of integrable objects (total number of
150 >     * rigid bodies plus the total number of atoms which do not belong
151 >     * to the rigid bodies) in the system
152       */
153      int getNGlobalIntegrableObjects() {
154        return nGlobalIntegrableObjects_;
155      }
156  
157      /**
158 <     * Returns the total number of integrable objects (total number of rigid bodies plus the total number
159 <     * of atoms which do not belong to the rigid bodies) in the system
158 >     * Returns the total number of integrable objects (total number of
159 >     * rigid bodies plus the total number of atoms which do not belong
160 >     * to the rigid bodies) in the system
161       */
162      int getNGlobalRigidBodies() {
163        return nGlobalRigidBodies_;
# Line 231 | Line 252 | namespace OpenMD{
252  
253      int getFdf();
254      
255 <    //getNZconstraint and setNZconstraint ruin the coherent of SimInfo class, need refactorying
255 >    //getNZconstraint and setNZconstraint ruin the coherence of
256 >    //SimInfo class, need refactoring
257          
258      /** Returns the total number of z-constraint molecules in the system */
259      int getNZconstraint() {
# Line 267 | Line 289 | namespace OpenMD{
289  
290      /** Returns the center of the mass of the whole system.*/
291      Vector3d getCom();
292 <   /** Returns the center of the mass and Center of Mass velocity of the whole system.*/
292 >    /** Returns the center of the mass and Center of Mass velocity of
293 >        the whole system.*/
294      void getComAll(Vector3d& com,Vector3d& comVel);
295  
296 <    /** Returns intertia tensor for the entire system and system Angular Momentum.*/
296 >    /** Returns intertia tensor for the entire system and system
297 >        Angular Momentum.*/
298      void getInertiaTensor(Mat3x3d &intertiaTensor,Vector3d &angularMomentum);
299      
300      /** Returns system angular momentum */
301      Vector3d getAngularMomentum();
302  
303 <    /** Returns volume of system as estimated by an ellipsoid defined by the radii of gyration*/
303 >    /** Returns volume of system as estimated by an ellipsoid defined
304 >        by the radii of gyration*/
305      void getGyrationalVolume(RealType &vol);
306 <    /** Overloaded version of gyrational volume that also returns det(I) so dV/dr can be calculated*/
306 >    /** Overloaded version of gyrational volume that also returns
307 >        det(I) so dV/dr can be calculated*/
308      void getGyrationalVolume(RealType &vol, RealType &detI);
309 <    /** main driver function to interact with fortran during the initialization and molecule migration */
309 >    /** main driver function to interact with fortran during the
310 >        initialization and molecule migration */
311      void update();
312  
313      /** Returns the local index manager */
# Line 318 | Line 345 | namespace OpenMD{
345        return globalMolMembership_[id];
346      }
347  
348 <    RealType getRcut() {
349 <      return rcut_;
348 >    RealType getCutoffRadius() {
349 >      return cutoffRadius_;
350      }
351  
352 <    RealType getRsw() {
353 <      return rsw_;
352 >    RealType getSwitchingRadius() {
353 >      return switchingRadius_;
354      }
355  
356 <    RealType getList() {
357 <      return rlist_;
356 >    RealType getListRadius() {
357 >      return listRadius_;
358      }
359          
360 <    std::string getFinalConfigFileName() {
360 >    string getFinalConfigFileName() {
361        return finalConfigFileName_;
362      }
363  
364 <    void setFinalConfigFileName(const std::string& fileName) {
364 >    void setFinalConfigFileName(const string& fileName) {
365        finalConfigFileName_ = fileName;
366      }
367  
368 <    std::string getRawMetaData() {
368 >    string getRawMetaData() {
369        return rawMetaData_;
370      }
371 <    void setRawMetaData(const std::string& rawMetaData) {
371 >    void setRawMetaData(const string& rawMetaData) {
372        rawMetaData_ = rawMetaData;
373      }
374          
375 <    std::string getDumpFileName() {
375 >    string getDumpFileName() {
376        return dumpFileName_;
377      }
378          
379 <    void setDumpFileName(const std::string& fileName) {
379 >    void setDumpFileName(const string& fileName) {
380        dumpFileName_ = fileName;
381      }
382  
383 <    std::string getStatFileName() {
383 >    string getStatFileName() {
384        return statFileName_;
385      }
386          
387 <    void setStatFileName(const std::string& fileName) {
387 >    void setStatFileName(const string& fileName) {
388        statFileName_ = fileName;
389      }
390          
391 <    std::string getRestFileName() {
391 >    string getRestFileName() {
392        return restFileName_;
393      }
394          
395 <    void setRestFileName(const std::string& fileName) {
395 >    void setRestFileName(const string& fileName) {
396        restFileName_ = fileName;
397      }
398  
# Line 373 | Line 400 | namespace OpenMD{
400       * Sets GlobalGroupMembership
401       * @see #SimCreator::setGlobalIndex
402       */  
403 <    void setGlobalGroupMembership(const std::vector<int>& globalGroupMembership) {
403 >    void setGlobalGroupMembership(const vector<int>& globalGroupMembership) {
404        assert(globalGroupMembership.size() == static_cast<size_t>(nGlobalAtoms_));
405        globalGroupMembership_ = globalGroupMembership;
406      }
# Line 382 | Line 409 | namespace OpenMD{
409       * Sets GlobalMolMembership
410       * @see #SimCreator::setGlobalIndex
411       */        
412 <    void setGlobalMolMembership(const std::vector<int>& globalMolMembership) {
412 >    void setGlobalMolMembership(const vector<int>& globalMolMembership) {
413        assert(globalMolMembership.size() == static_cast<size_t>(nGlobalAtoms_));
414        globalMolMembership_ = globalMolMembership;
415      }
# Line 400 | Line 427 | namespace OpenMD{
427        return useAtomicVirial_;
428      }
429  
403    //below functions are just forward functions
404    //To compose or to inherit is always a hot debate. In general, is-a relation need subclassing, in the
405    //the other hand, has-a relation need composing.
430      /**
431       * Adds property into property map
432       * @param genData GenericData to be added into PropertyMap
# Line 413 | Line 437 | namespace OpenMD{
437       * Removes property from PropertyMap by name
438       * @param propName the name of property to be removed
439       */
440 <    void removeProperty(const std::string& propName);
440 >    void removeProperty(const string& propName);
441  
442      /**
443       * clear all of the properties
# Line 424 | Line 448 | namespace OpenMD{
448       * Returns all names of properties
449       * @return all names of properties
450       */
451 <    std::vector<std::string> getPropertyNames();
451 >    vector<string> getPropertyNames();
452  
453      /**
454       * Returns all of the properties in PropertyMap
455       * @return all of the properties in PropertyMap
456       */      
457 <    std::vector<GenericData*> getProperties();
457 >    vector<GenericData*> getProperties();
458  
459      /**
460       * Returns property
# Line 438 | Line 462 | namespace OpenMD{
462       * @return a pointer point to property with propName. If no property named propName
463       * exists, return NULL
464       */      
465 <    GenericData* getPropertyByName(const std::string& propName);
465 >    GenericData* getPropertyByName(const string& propName);
466  
467      /**
468       * add all special interaction pairs (including excluded
# Line 454 | Line 478 | namespace OpenMD{
478  
479  
480      /** Returns the unique atom types of local processor in an array */
481 <    std::set<AtomType*> getUniqueAtomTypes();
481 >    set<AtomType*> getUniqueAtomTypes();
482 >
483 >    /** Returns the set of atom types present in this simulation */
484 >    set<AtomType*> getSimulatedAtomTypes();
485          
486 <    friend std::ostream& operator <<(std::ostream& o, SimInfo& info);
486 >    friend ostream& operator <<(ostream& o, SimInfo& info);
487  
488      void getCutoff(RealType& rcut, RealType& rsw);
489          
# Line 471 | Line 498 | namespace OpenMD{
498       */
499      void setupFortranSim();
500  
501 <    /** Figure out the radius of cutoff, radius of switching function and pass them to fortran */
502 <    void setupCutoff();
503 <
504 <    /** Figure out which coulombic correction method to use and pass to fortran */
505 <    void setupElectrostaticSummationMethod( int isError );
506 <
501 >    /** Figure out the cutoff radius */
502 >    void setupCutoffRadius();
503 >    /** Figure out the cutoff method */
504 >    void setupCutoffMethod();
505 >    /** Figure out the switching radius */
506 >    void setupSwitchingRadius();
507 >    /** Figure out the neighbor list skin thickness */
508 >    void setupSkinThickness();
509      /** Figure out which polynomial type to use for the switching function */
510      void setupSwitchingFunction();
511  
# Line 488 | Line 517 | namespace OpenMD{
517      void calcNdfRaw();
518      void calcNdfTrans();
519  
491    ForceField* forceField_;      
492    Globals* simParams_;
493
494    std::map<int, Molecule*>  molecules_; /**< Molecule array */
495
520      /**
521 <     * Adds molecule stamp and the total number of the molecule with same molecule stamp in the whole
522 <     * system.
521 >     * Adds molecule stamp and the total number of the molecule with
522 >     * same molecule stamp in the whole system.
523       */
524      void addMoleculeStamp(MoleculeStamp* molStamp, int nmol);
525 <        
526 <    //degress of freedom
527 <    int ndf_;           /**< number of degress of freedom (excludes constraints),  ndf_ is local */
528 <    int fdf_local;       /**< number of frozen degrees of freedom */
505 <    int fdf_;            /**< number of frozen degrees of freedom */
506 <    int ndfRaw_;    /**< number of degress of freedom (includes constraints),  ndfRaw_ is local */
507 <    int ndfTrans_; /**< number of translation degress of freedom, ndfTrans_ is local */
508 <    int nZconstraint_; /** number of  z-constraint molecules, nZconstraint_ is global */
509 <        
510 <    //number of global objects
511 <    int nGlobalMols_;       /**< number of molecules in the system */
512 <    int nGlobalAtoms_;   /**< number of atoms in the system */
513 <    int nGlobalCutoffGroups_; /**< number of cutoff groups in this system */
514 <    int nGlobalIntegrableObjects_; /**< number of integrable objects in this system */
515 <    int nGlobalRigidBodies_; /**< number of rigid bodies in this system */
516 <    /**
517 <     * the size of globalGroupMembership_  is nGlobalAtoms. Its index is  global index of an atom, and the
518 <     * corresponding content is the global index of cutoff group this atom belong to.
519 <     * It is filled by SimCreator once and only once, since it never changed during the simulation.
520 <     */
521 <    std::vector<int> globalGroupMembership_;
525 >
526 >    // Other classes holdingn important information
527 >    ForceField* forceField_; /**< provides access to defined atom types, bond types, etc. */
528 >    Globals* simParams_;     /**< provides access to simulation parameters set by user */
529  
530 <    /**
524 <     * the size of globalMolMembership_  is nGlobalAtoms. Its index is  global index of an atom, and the
525 <     * corresponding content is the global index of molecule this atom belong to.
526 <     * It is filled by SimCreator once and only once, since it is never changed during the simulation.
527 <     */
528 <    std::vector<int> globalMolMembership_;        
529 <
530 <        
531 <    std::vector<int> molStampIds_;                                /**< stamp id array of all molecules in the system */
532 <    std::vector<MoleculeStamp*> moleculeStamps_;      /**< molecule stamps array */        
533 <        
534 <    //number of local objects
530 >    ///  Counts of local objects
531      int nAtoms_;              /**< number of atoms in local processor */
532      int nBonds_;              /**< number of bonds in local processor */
533      int nBends_;              /**< number of bends in local processor */
# Line 541 | Line 537 | namespace OpenMD{
537      int nIntegrableObjects_;  /**< number of integrable objects in local processor */
538      int nCutoffGroups_;       /**< number of cutoff groups in local processor */
539      int nConstraints_;        /**< number of constraints in local processors */
540 +        
541 +    /// Counts of global objects
542 +    int nGlobalMols_;              /**< number of molecules in the system (GLOBAL) */
543 +    int nGlobalAtoms_;             /**< number of atoms in the system (GLOBAL) */
544 +    int nGlobalCutoffGroups_;      /**< number of cutoff groups in this system (GLOBAL) */
545 +    int nGlobalIntegrableObjects_; /**< number of integrable objects in this system */
546 +    int nGlobalRigidBodies_;       /**< number of rigid bodies in this system (GLOBAL) */
547 +      
548 +    /// Degress of freedom
549 +    int ndf_;          /**< number of degress of freedom (excludes constraints) (LOCAL) */
550 +    int fdf_local;     /**< number of frozen degrees of freedom (LOCAL) */
551 +    int fdf_;          /**< number of frozen degrees of freedom (GLOBAL) */
552 +    int ndfRaw_;       /**< number of degress of freedom (includes constraints),  (LOCAL) */
553 +    int ndfTrans_;     /**< number of translation degress of freedom, (LOCAL) */
554 +    int nZconstraint_; /**< number of  z-constraint molecules (GLOBAL) */
555  
556 <    simtype fInfo_; /**< A dual struct shared by c++/fortran which indicates the atom types in simulation*/
557 <    PairList excludedInteractions_;      
558 <    PairList oneTwoInteractions_;      
559 <    PairList oneThreeInteractions_;      
560 <    PairList oneFourInteractions_;      
561 <    PropertyMap properties_;                  /**< Generic Property */
562 <    SnapshotManager* sman_;               /**< SnapshotManager */
556 >    /// logicals
557 >    bool usesPeriodicBoundaries_; /**< use periodic boundary conditions? */
558 >    bool usesDirectionalAtoms_;   /**< are there atoms with position AND orientation? */
559 >    bool usesMetallicAtoms_;      /**< are there transition metal atoms? */
560 >    bool usesElectrostaticAtoms_; /**< are there electrostatic atoms? */
561 >    bool usesAtomicVirial_;       /**< are we computing atomic virials? */
562 >    bool requiresPrepair_;        /**< does this simulation require a pre-pair loop? */
563 >    bool requiresSkipCorrection_; /**< does this simulation require a skip-correction? */
564 >    bool requiresSelfCorrection_; /**< does this simulation require a self-correction? */
565  
566 +    /// Data structures holding primary simulation objects
567 +    map<int, Molecule*>  molecules_;  /**< map holding pointers to LOCAL molecules */
568 +    simtype fInfo_;                   /**< A dual struct shared by C++
569 +                                         and Fortran to pass
570 +                                         information about what types
571 +                                         of calculation are
572 +                                         required */
573 +    
574 +    /// Stamps are templates for objects that are then used to create
575 +    /// groups of objects.  For example, a molecule stamp contains
576 +    /// information on how to build that molecule (i.e. the topology,
577 +    /// the atoms, the bonds, etc.)  Once the system is built, the
578 +    /// stamps are no longer useful.
579 +    vector<int> molStampIds_;                /**< stamp id for molecules in the system */
580 +    vector<MoleculeStamp*> moleculeStamps_;  /**< molecule stamps array */        
581 +
582 +    /**
583 +     * A vector that maps between the global index of an atom, and the
584 +     * global index of cutoff group the atom belong to.  It is filled
585 +     * by SimCreator once and only once, since it never changed during
586 +     * the simulation.  It should be nGlobalAtoms_ in size.
587 +     */
588 +    vector<int> globalGroupMembership_;
589 +
590 +    /**
591 +     * A vector that maps between the global index of an atom and the
592 +     * global index of the molecule the atom belongs to.  It is filled
593 +     * by SimCreator once and only once, since it is never changed
594 +     * during the simulation. It shoudl be nGlobalAtoms_ in size.
595 +     */
596 +    vector<int> globalMolMembership_;        
597 +              
598 +    /// lists to handle atoms needing special treatment in the non-bonded interactions
599 +    PairList excludedInteractions_;  /**< atoms excluded from interacting with each other */
600 +    PairList oneTwoInteractions_;    /**< atoms that are directly Bonded */
601 +    PairList oneThreeInteractions_;  /**< atoms sharing a Bend */    
602 +    PairList oneFourInteractions_;   /**< atoms sharing a Torsion */
603 +
604 +    PropertyMap properties_;       /**< Generic Properties can be added */
605 +    SnapshotManager* sman_;        /**< SnapshotManager (handles particle positions, etc.) */
606 +
607      /**
608 <     * The reason to have a local index manager is that when molecule is migrating to other processors,
609 <     * the atoms and the rigid-bodies will release their local indices to LocalIndexManager. Combining the
610 <     * information of molecule migrating to current processor, Migrator class can query  the LocalIndexManager
611 <     * to make a efficient data moving plan.
608 >     * The reason to have a local index manager is that when molecule
609 >     * is migrating to other processors, the atoms and the
610 >     * rigid-bodies will release their local indices to
611 >     * LocalIndexManager. Combining the information of molecule
612 >     * migrating to current processor, Migrator class can query the
613 >     * LocalIndexManager to make a efficient data moving plan.
614       */        
615      LocalIndexManager localIndexMan_;
616  
617      // unparsed MetaData block for storing in Dump and EOR files:
618 <    std::string rawMetaData_;
618 >    string rawMetaData_;
619  
620 <    //file names
621 <    std::string finalConfigFileName_;
622 <    std::string dumpFileName_;
623 <    std::string statFileName_;
624 <    std::string restFileName_;
620 >    // file names
621 >    string finalConfigFileName_;
622 >    string dumpFileName_;
623 >    string statFileName_;
624 >    string restFileName_;
625          
626 <    RealType rcut_;       /**< cutoff radius*/
627 <    RealType rsw_;        /**< radius of switching function*/
628 <    RealType rlist_;      /**< neighbor list radius */
626 >    RealType cutoffRadius_;         /**< cutoff radius for non-bonded interactions */
627 >    RealType switchingRadius_;      /**< inner radius of switching function */
628 >    RealType listRadius_;           /**< Verlet neighbor list radius */
629 >    RealType skinThickness_;        /**< Verlet neighbor list skin thickness */    
630 >    CutoffMethod cutoffMethod_;     /**< Cutoff Method for most non-bonded interactions */
631  
574    int ljsp_; /**< use shifted potential for LJ*/
575    int ljsf_; /**< use shifted force for LJ*/
576
632      bool fortranInitialized_; /** flag to indicate whether the fortran side is initialized */
633      
634      bool calcBoxDipole_; /**< flag to indicate whether or not we calculate
# Line 581 | Line 636 | namespace OpenMD{
636      
637      bool useAtomicVirial_; /**< flag to indicate whether or not we use
638                                Atomic Virials to calculate the pressure */
639 <
640 <    public:
586 <     /**
587 <      * return an integral objects by its global index. In MPI version, if the StuntDouble with specified
588 <      * global index does not belong to local processor, a NULL will be return.
589 <      */
590 <      StuntDouble* getIOIndexToIntegrableObject(int index);
591 <      void setIOIndexToIntegrableObject(const std::vector<StuntDouble*>& v);
592 <    private:
593 <      std::vector<StuntDouble*> IOIndexToIntegrableObject;
594 <  //public:
595 <    //void setStuntDoubleFromGlobalIndex(std::vector<StuntDouble*> v);
639 >    
640 >  public:
641      /**
642 <     * return a StuntDouble by its global index. In MPI version, if the StuntDouble with specified
643 <     * global index does not belong to local processor, a NULL will be return.
644 <     */
645 <    //StuntDouble* getStuntDoubleFromGlobalIndex(int index);
646 <  //private:
647 <    //std::vector<StuntDouble*> sdByGlobalIndex_;
642 >     * return an integral objects by its global index. In MPI
643 >     * version, if the StuntDouble with specified global index does
644 >      * not belong to local processor, a NULL will be return.
645 >      */
646 >    StuntDouble* getIOIndexToIntegrableObject(int index);
647 >    void setIOIndexToIntegrableObject(const vector<StuntDouble*>& v);
648      
649 <    //in Parallel version, we need MolToProc
649 >  private:
650 >    vector<StuntDouble*> IOIndexToIntegrableObject;
651 >    
652    public:
653                  
654      /**
# Line 613 | Line 660 | namespace OpenMD{
660        //assert(globalIndex < molToProcMap_.size());
661        return molToProcMap_[globalIndex];
662      }
663 <
663 >    
664      /**
665       * Set MolToProcMap array
666       * @see #SimCreator::divideMolecules
667       */
668 <    void setMolToProcMap(const std::vector<int>& molToProcMap) {
668 >    void setMolToProcMap(const vector<int>& molToProcMap) {
669        molToProcMap_ = molToProcMap;
670      }
671          
# Line 631 | Line 678 | namespace OpenMD{
678       * in the system.  It maps a molecule to the processor on which it
679       * resides. it is filled by SimCreator once and only once.
680       */        
681 <    std::vector<int> molToProcMap_;
681 >    vector<int> molToProcMap_;
682  
636
683    };
684  
685   } //namespace OpenMD

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines