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

Comparing:
trunk/OOPSE-3.0/src/visitors/ZconsVisitor.cpp (file contents), Revision 1625 by tim, Thu Oct 21 16:22:01 2004 UTC vs.
branches/new_design/OOPSE-3.0/src/visitors/ZconsVisitor.cpp (file contents), Revision 1702 by tim, Wed Nov 3 18:00:36 2004 UTC

# Line 15 | Line 15 | ZConsVisitor::ZConsVisitor(SimInfo* info) : BaseVisito
15    visitorName = "ZConsVisitor";
16    
17    //retrieve tolerance for z-constraint molecuels
18 <  data = info->getProperty(ZCONSTOL_ID);
18 >  data = info->getPropertyByName(ZCONSTOL_ID);
19  
20    if (!data){
21      cerr << "Can not get zconstraint tolerance from SimInfo" << endl;
# Line 36 | Line 36 | ZConsVisitor::ZConsVisitor(SimInfo* info) : BaseVisito
36    }
37  
38    //retrieve sample time of z-contraint
39 <  data = info->getProperty(ZCONSTIME_ID);
39 >  data = info->getPropertyByName(ZCONSTIME_ID);
40  
41    if (!data){
42      cerr << "Can not get zcons time  from SimInfo" << endl;
# Line 57 | Line 57 | ZConsVisitor::ZConsVisitor(SimInfo* info) : BaseVisito
57    }
58  
59    //retrieve index of z-constraint molecules
60 <  data = info->getProperty(ZCONSPARADATA_ID);
60 >  data = info->getPropertyByName(ZCONSPARADATA_ID);
61    if (!data){
62      cerr << "Can not get index of z-constraint molecules from SimInfo" << endl;
63      haveZcons = false;
# Line 95 | Line 95 | ZConsVisitor::ZConsVisitor(SimInfo* info) : BaseVisito
95    }//end  if (!data  
96    
97    //retrieve output filename of z force
98 <  data = info->getProperty(ZCONSFILENAME_ID);
98 >  data = info->getPropertyByName(ZCONSFILENAME_ID);
99    if (!data){
100      cerr << "Can not get filename of z-constraint output from SimInfo" << endl;
101      haveZcons = false;
# Line 130 | Line 130 | void ZConsVisitor::visit(Atom* atom){
130  
131   void ZConsVisitor::visit(Atom* atom){
132    string prefix;
133 <  if(isZconstraint(atom->getIndex(), prefix))
133 >  if(isZconstraint(atom->getLocalIndex(), prefix))
134      internalVisit(atom, prefix);
135   }
136  
137   void ZConsVisitor::visit(DirectionalAtom* datom){
138    string prefix;
139    
140 <  if(isZconstraint(datom->getIndex(), prefix))
140 >  if(isZconstraint(datom->getLocalIndex(), prefix))
141      internalVisit(datom, prefix);
142   }
143  
# Line 147 | Line 147 | void ZConsVisitor::visit(RigidBody* rb){
147    
148    atoms = rb->getAtoms();
149      
150 <  if(isZconstraint(atoms[0]->getIndex(), prefix))
150 >  if(isZconstraint(atoms[0]->getLocalIndex(), prefix))
151      internalVisit(rb, prefix);
152   }
153  
# Line 155 | Line 155 | Molecule* ZConsVisitor::findZconsMol(int index){
155    Molecule* mols;
156    mols = info->molecules;
157    for(int i =0; i < info->n_mol; i++)
158 <    if(index == mols[i].getMyIndex())
158 >    if(index == mols[i].getGlobalIndex())
159        return &mols[i];
160  
161    return NULL;
# Line 163 | Line 163 | void ZConsVisitor::update(){
163  
164   void ZConsVisitor::update(){
165    Molecule* mol;
166 <  double com[3];
166 >  Vector3d com;
167    ZConsState state;
168 <  Atom** atoms;
169 <  int natoms;
168 >  //Atom** atoms;
169 >  //int natoms;
170  
171    getZconsPos(info->currentTime);
172    
173    for(size_t i = 0; i < zconsMol.size(); i++){
174 <    zconsMol[i]->getCOM(com);
174 >    com = zconsMol[i]->getCom();
175  
176      if(fabs(com[2] - zconsPos[i]) < zconsTol)
177        state = zsFixed;
# Line 179 | Line 179 | void ZConsVisitor::update(){
179        state = zsMoving;
180  
181      //update the state of zconstraint atom
182 <    natoms = zconsMol[i]->getNAtoms();
183 <    atoms = zconsMol[i]->getMyAtoms();    
184 <    for(int j =0; j < natoms; j++)
185 <      zconsState[atoms[j]->getIndex()] = state;
182 >    //natoms = zconsMol[i]->getNAtoms();
183 >    //atoms = zconsMol[i]->getMyAtoms();    
184 >    //for(int j =0; j < natoms; j++)
185 >    //  zconsState[atoms[j]->getLocalIndex()] = state;
186 >
187 >    std::vector<Atom*>::iterator j;
188 >    for (Atom* atom = zconsMol[i]->beginAtom(j); atom != NULL; atom =  zconsMol[i]->nextAtom(j)) {
189 >        zconsState[atom->getLocalIndex()] = state;
190 >    }
191    }
192    
193   }
# Line 215 | Line 220 | void ZConsVisitor::internalVisit(StuntDouble* sd, cons
220  
221    
222    //if there is not atom data, just skip it
223 <  data = sd->getProperty("ATOMDATA");
223 >  data = sd->getPropertyByName("ATOMDATA");
224    if(data != NULL){
225      atomData = dynamic_cast<AtomData*>(data);  
226      if(atomData == NULL)
# Line 267 | Line 272 | const string ZConsVisitor::toString(){
272    result += buffer;
273    
274    for(size_t i = 0; i < zconsMol.size(); ++i){
275 <    sprintf(buffer ,"zconstraint molecule[%d] = %d\n", i, zconsMol[i]->getMyIndex());
275 >    sprintf(buffer ,"zconstraint molecule[%d] = %d\n", i, zconsMol[i]->getGlobalIndex());
276      result += buffer;
277  
278    }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines