ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/brains/SimInfo.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-2.0/src/brains/SimInfo.cpp (file contents):
Revision 1842 by tim, Fri Dec 3 20:30:07 2004 UTC vs.
Revision 1843 by tim, Fri Dec 3 21:30:30 2004 UTC

# Line 815 | Line 815 | void SimInfo::setSnapshotManager(SnapshotManager* sman
815          }
816      }    
817      
818 + }
819 +
820 + Vector3d SimInfo::getComVel(){
821 +    SimInfo::MoleculeIterator i;
822 +    Molecule* mol;
823 +
824 +    Vector3d comVel(0.0);
825 +    double totalMass = 0.0;
826 +    
827 +
828 +    for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
829 +        double mass = mol->getMass();
830 +        totalMass += mass;
831 +        comVel += mass * mol->getComVel();
832 +    }  
833 +
834 +    comVel /= totalMass;
835 +
836 +    return comVel;
837   }
838  
839 + Vector3d SimInfo::getCom(){
840 +    SimInfo::MoleculeIterator i;
841 +    Molecule* mol;
842 +
843 +    Vector3d com(0.0);
844 +    double totalMass = 0.0;
845 +    
846 +    for (mol = beginMolecule(i); mol != NULL; mol = nextMolecule(i)) {
847 +        double mass = mol->getMass();
848 +        totalMass += mass;
849 +        com += mass * mol->getCom();
850 +    }  
851 +
852 +    com /= totalMass;
853 +
854 +    return com;
855 +
856 + }        
857 +
858   std::ostream& operator <<(std::ostream& o, SimInfo& info) {
859  
860      return o;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines