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

Comparing branches/development/src/visitors/AtomVisitor.cpp (file contents):
Revision 1665 by gezelter, Tue Nov 22 20:38:56 2011 UTC vs.
Revision 1873 by gezelter, Fri May 10 16:09:34 2013 UTC

# Line 35 | Line 35
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).          
38 > * [3]  Sun, Lin & Gezelter, J. Chem. Phys. 128, 234107 (2008).          
39   * [4]  Kuang & Gezelter,  J. Chem. Phys. 133, 164101 (2010).
40   * [5]  Vardeman, Stocker & Gezelter, J. Chem. Theory Comput. 7, 834 (2011).
41   */
# Line 44 | Line 44
44   #include "visitors/AtomVisitor.hpp"
45   #include "primitives/DirectionalAtom.hpp"
46   #include "primitives/RigidBody.hpp"
47 + #include "types/FixedChargeAdapter.hpp"
48 + #include "types/FluctuatingChargeAdapter.hpp"
49 + #include "types/MultipoleAdapter.hpp"
50 + #include "types/GayBerneAdapter.hpp"
51  
52   namespace OpenMD {
53 +
54 +  BaseAtomVisitor::BaseAtomVisitor(SimInfo* info) : BaseVisitor() {
55 +    storageLayout_ = info->getStorageLayout();
56 +  }    
57 +  
58    void BaseAtomVisitor::visit(RigidBody *rb) {
59      //vector<Atom*> myAtoms;
60      //vector<Atom*>::iterator atomIter;
# Line 79 | Line 88 | namespace OpenMD {
88    void DefaultAtomVisitor::visit(Atom *atom) {
89      AtomData *atomData;
90      AtomInfo *atomInfo;
91 <    Vector3d  pos;
92 <    Vector3d  vel;
84 <    Vector3d  frc;
85 <    Vector3d  u;
86 <    RealType  c;
87 <
91 >    AtomType* atype = atom->getAtomType();
92 >              
93      if (isVisited(atom))
94        return;
95      
96      atomInfo = new AtomInfo;
92    
93    atomData = new AtomData;
94    atomData->setID("ATOMDATA");
95    
96    pos = atom->getPos();
97    vel = atom->getVel();
98    frc = atom->getFrc();
97      atomInfo->atomTypeName = atom->getType();
98 <    atomInfo->pos[0] = pos[0];
99 <    atomInfo->pos[1] = pos[1];
100 <    atomInfo->pos[2] = pos[2];
101 <    atomInfo->vel[0] = vel[0];
104 <    atomInfo->vel[1] = vel[1];
105 <    atomInfo->vel[2] = vel[2];
98 >    atomInfo->pos = atom->getPos();
99 >    atomInfo->vel = atom->getVel();
100 >    atomInfo->frc = atom->getFrc();
101 >    atomInfo->vec = V3Zero;
102      atomInfo->hasVelocity = true;
107    atomInfo->frc[0] = frc[0];
108    atomInfo->frc[1] = frc[1];
109    atomInfo->frc[2] = frc[2];
103      atomInfo->hasForce = true;
104 <    atomInfo->vec[0] = 0.0;
105 <    atomInfo->vec[1] = 0.0;
106 <    atomInfo->vec[2] = 0.0;
104 >        
105 >    FixedChargeAdapter fca = FixedChargeAdapter(atype);
106 >    if ( fca.isFixedCharge() ) {
107 >      atomInfo->hasCharge = true;
108 >      atomInfo->charge = fca.getCharge();
109 >    }
110 >          
111 >    FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype);
112 >    if ( fqa.isFluctuatingCharge() ) {
113 >      atomInfo->hasCharge = true;
114 >      atomInfo->charge += atom->getFlucQPos();
115 >    }
116      
117 +    if ((storageLayout_ & DataStorage::dslElectricField) &&
118 +        (atype->isElectrostatic())) {
119 +      atomInfo->hasElectricField = true;
120 +      atomInfo->eField = atom->getElectricField();
121 +    }
122 +
123 +    atomData = new AtomData;
124 +    atomData->setID("ATOMDATA");  
125      atomData->addAtomInfo(atomInfo);
126      
127      atom->addProperty(atomData);
# Line 122 | Line 132 | namespace OpenMD {
132    void DefaultAtomVisitor::visit(DirectionalAtom *datom) {
133      AtomData *atomData;
134      AtomInfo *atomInfo;
135 <    Vector3d  pos;
126 <    Vector3d  vel;
127 <    Vector3d  frc;
128 <    Vector3d  u;
129 <    RealType  c;
135 >    AtomType* atype = datom->getAtomType();
136  
137      if (isVisited(datom))
138        return;
139      
134    pos = datom->getPos();
135    vel = datom->getVel();
136    frc = datom->getFrc();
137    if (datom->getAtomType()->isGayBerne()) {
138        u = datom->getA().transpose()*V3Z;        
139    } else if (datom->getAtomType()->isMultipole()) {
140        u = datom->getElectroFrame().getColumn(2);
141    }
142    atomData = new AtomData;
143    atomData->setID("ATOMDATA");
140      atomInfo = new AtomInfo;
145
141      atomInfo->atomTypeName = datom->getType();
142 <    atomInfo->pos[0] = pos[0];
143 <    atomInfo->pos[1] = pos[1];
144 <    atomInfo->pos[2] = pos[2];
150 <    atomInfo->vel[0] = vel[0];
151 <    atomInfo->vel[1] = vel[1];
152 <    atomInfo->vel[2] = vel[2];
142 >    atomInfo->pos = datom->getPos();
143 >    atomInfo->vel = datom->getVel();
144 >    atomInfo->frc = datom->getFrc();
145      atomInfo->hasVelocity = true;
154    atomInfo->frc[0] = frc[0];
155    atomInfo->frc[1] = frc[1];
156    atomInfo->frc[2] = frc[2];
146      atomInfo->hasForce = true;
158    atomInfo->vec[0] = u[0];
159    atomInfo->vec[1] = u[1];
160    atomInfo->vec[2] = u[2];
161    atomInfo->hasVector = true;
147  
148 +    FixedChargeAdapter fca = FixedChargeAdapter(atype);
149 +    if ( fca.isFixedCharge() ) {
150 +      atomInfo->hasCharge = true;
151 +      atomInfo->charge = fca.getCharge();
152 +    }
153 +          
154 +    FluctuatingChargeAdapter fqa = FluctuatingChargeAdapter(atype);
155 +    if ( fqa.isFluctuatingCharge() ) {
156 +      atomInfo->hasCharge = true;
157 +      atomInfo->charge += datom->getFlucQPos();
158 +    }
159 +
160 +    if ((storageLayout_ & DataStorage::dslElectricField) &&
161 +        (atype->isElectrostatic())) {
162 +      atomInfo->hasElectricField = true;
163 +      atomInfo->eField = datom->getElectricField();
164 +    }
165 +
166 +    GayBerneAdapter gba = GayBerneAdapter(atype);
167 +    MultipoleAdapter ma = MultipoleAdapter(atype);
168 +    
169 +    if (gba.isGayBerne()) {
170 +      atomInfo->hasVector = true;
171 +      atomInfo->vec = datom->getA().transpose()*V3Z;
172 +    } else if (ma.isDipole()) {
173 +      atomInfo->hasVector = true;
174 +      atomInfo->vec = datom->getDipole();
175 +    } else if (ma.isQuadrupole()) {
176 +      atomInfo->hasVector = true;
177 +      atomInfo->vec = datom->getA().transpose()*V3Z;
178 +    }
179 +
180 +    atomData = new AtomData;
181 +    atomData->setID("ATOMDATA");  
182      atomData->addAtomInfo(atomInfo);
183  
184      datom->addProperty(atomData);
# Line 172 | Line 191 | namespace OpenMD {
191      std::string result;
192  
193      sprintf(buffer,
194 <            "------------------------------------------------------------------\n");
194 >            "--------------------------------------------------------------\n");
195      result += buffer;
196  
197      sprintf(buffer, "Visitor name: %s\n", visitorName.c_str());
# Line 183 | Line 202 | namespace OpenMD {
202      result += buffer;
203  
204      sprintf(buffer,
205 <            "------------------------------------------------------------------\n");
205 >            "--------------------------------------------------------------\n");
206      result += buffer;
207  
208      return result;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines