ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/dump2Xyz/Dump2XYZ.cpp
(Generate patch)

Comparing trunk/src/applications/dump2Xyz/Dump2XYZ.cpp (file contents):
Revision 291 by tim, Fri Feb 4 22:43:54 2005 UTC vs.
Revision 1283 by gezelter, Wed Jul 30 18:48:01 2008 UTC

# Line 1 | Line 1
1 < /*
1 > /*
2   * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved.
3   *
4   * The University of Notre Dame grants you ("Licensee") a
# Line 54 | Line 54
54   #include "visitors/RigidBodyVisitor.hpp"
55   #include "visitors/OtherVisitor.hpp"
56   #include "visitors/ZconsVisitor.hpp"
57 #include "visitors/SelectionVisitor.hpp"
57   #include "selection/SelectionEvaluator.hpp"
58 + #include "selection/SelectionManager.hpp"
59 + #include "visitors/LipidTransVisitor.hpp"
60 + #include "visitors/AtomNameVisitor.hpp"
61 +
62   using namespace oopse;
63  
64   int main(int argc, char* argv[]){
# Line 65 | Line 68 | int main(int argc, char* argv[]){
68    
69    gengetopt_args_info args_info;
70    std::string dumpFileName;
68  std::string mdFileName;
71    std::string xyzFileName;
72    
73    //parse the command line option
# Line 81 | Line 83 | int main(int argc, char* argv[]){
83      exit(1);
84    }
85    
84  mdFileName = dumpFileName;
85  mdFileName = mdFileName.substr(0, mdFileName.rfind(".")) + ".md";
86
86    if (args_info.output_given){
87      xyzFileName = args_info.output_arg;
88    } else {
# Line 93 | Line 92 | int main(int argc, char* argv[]){
92    
93    //parse md file and set up the system
94    SimCreator creator;
95 <  SimInfo* info = creator.createSim(mdFileName, false);
95 >  SimInfo* info = creator.createSim(dumpFileName, false);
96    
97 <  
98 <  
100 <  //creat visitor list
97 >
98 >  //create visitor list
99    CompositeVisitor* compositeVisitor = new CompositeVisitor();
102  
103  //creat ignore visitor
104  if(args_info.ignore_given ||args_info.water_flag){
100      
101 <    IgnoreVisitor* ignoreVisitor = new IgnoreVisitor(info);
107 <    
108 <    for(int i = 0; i < args_info.ignore_given; i++)
109 <      ignoreVisitor->addIgnoreType(args_info.ignore_arg[i]);
110 <    
111 <    //ignore water
112 <    if(args_info.water_flag){
113 <      ignoreVisitor->addIgnoreType("SSD");
114 <      ignoreVisitor->addIgnoreType("SSD1");
115 <      ignoreVisitor->addIgnoreType("SSD_E");
116 <      ignoreVisitor->addIgnoreType("SSD_RF");
117 <      ignoreVisitor->addIgnoreType("TIP3P_RB_0");
118 <      ignoreVisitor->addIgnoreType("TIP4P_RB_0");
119 <      ignoreVisitor->addIgnoreType("TIP5P_RB_0");
120 <      ignoreVisitor->addIgnoreType("SPCE_RB_0");      
121 <      ignoreVisitor->addIgnoreType("DPD_RB_0");
122 <    }
123 <    
124 <    compositeVisitor->addVisitor(ignoreVisitor, 1000);
125 <  }
126 <  
127 <  //creat RigidBody Visitor
101 >  //create RigidBody Visitor
102    if(args_info.rigidbody_flag){
103      RBCOMVisitor* rbCOMVisitor = new RBCOMVisitor(info);
104      compositeVisitor->addVisitor(rbCOMVisitor, 900);
105    }
106    
107 <  //create selection visitor
134 <  //if (args_info.selection_given){
135 <  //  SelectionVisitor* selectionVisitor = new SelectionVisitor(info, args_info.selection_arg);
136 <  //  compositeVisitor->addVisitor(selectionVisitor, 850);
137 <  //}
138 <
139 <  SelectionEvaluator* evaluator = NULL;
140 <  if (args_info.selection_given) {
141 <    evaluator = new SelectionEvaluator(info);
142 <    assert(evaluator);
143 <    evaluator->loadScriptString( args_info.selection_arg);
144 <          
145 <  }
146 <  
147 <  //creat SSD atom visitor
107 >  //create SSD atom visitor
108    SSDAtomVisitor* ssdVisitor = new SSDAtomVisitor(info);
109    compositeVisitor->addVisitor(ssdVisitor, 800);
110    
111    LinearAtomVisitor* linearVisitor = new LinearAtomVisitor(info);
112    compositeVisitor->addVisitor(linearVisitor, 750);
113 +  if (args_info.gb_given) {
114 +    linearVisitor->addGayBerneAtomType(args_info.gb_arg);
115 +  }
116    
117 <  //creat default atom visitor
117 >  GBLipidAtomVisitor* gbLipidVisitor = new GBLipidAtomVisitor(info);
118 >  compositeVisitor->addVisitor(gbLipidVisitor, 740);
119 >
120 >  Ring5gbAtomVisitor* ring5Visitor = new Ring5gbAtomVisitor(info);
121 >  compositeVisitor->addVisitor(ring5Visitor, 730);
122 >
123 >  HeadAtomVisitor* headVisitor = new HeadAtomVisitor(info);
124 >  compositeVisitor->addVisitor(headVisitor, 720);
125 >
126 >  //create default atom visitor
127    DefaultAtomVisitor* defaultAtomVisitor = new DefaultAtomVisitor(info);
128    compositeVisitor->addVisitor(defaultAtomVisitor, 700);
129    
130 <  //creat waterType visitor
130 >  //create waterType visitor
131    if(args_info.watertype_flag){
132      WaterTypeVisitor* waterTypeVisitor = new WaterTypeVisitor;
133      compositeVisitor->addVisitor(waterTypeVisitor, 600);
134    }
135 +
136 +  if (args_info.basetype_flag) {
137 +      AtomNameVisitor* atomNameVisitor = new AtomNameVisitor(info);
138 +      compositeVisitor->addVisitor(atomNameVisitor, 550);
139 +
140 +  }
141    
142    //create ZconsVisitor
143    if(args_info.zconstraint_flag){
# Line 173 | Line 151 | int main(int argc, char* argv[]){
151      }
152    }
153    
154 <  //creat wrapping visitor
154 >  //create wrapping visitor
155    
156 <  if(args_info.periodicBox_flag){
157 <    WrappingVisitor* wrappingVisitor = new WrappingVisitor(info);
158 <    compositeVisitor->addVisitor(wrappingVisitor, 400);
159 <  }
160 <  
161 <  //creat replicate visitor
156 >  //if(args_info.periodicBox_flag){
157 >  //  WrappingVisitor* wrappingVisitor = new WrappingVisitor(info);
158 >  //  compositeVisitor->addVisitor(wrappingVisitor, 400);
159 >  //}
160 >
161 >  //create replicate visitor
162    if(args_info.repeatX_given > 0 || args_info.repeatY_given > 0 ||args_info.repeatY_given > 0){
163      Vector3i replicateOpt(args_info.repeatX_arg, args_info.repeatY_arg, args_info.repeatZ_arg);
164      ReplicateVisitor* replicateVisitor = new ReplicateVisitor(info, replicateOpt);
165      compositeVisitor->addVisitor(replicateVisitor, 300);
166    }
167 <  
168 <  //creat xyzVisitor
169 <  XYZVisitor* xyzVisitor = new XYZVisitor(info);
167 >
168 >
169 >  //create rotation visitor
170 >  if (args_info.refsele_given&& args_info.originsele_given) {
171 >    compositeVisitor->addVisitor(new LipidTransVisitor(info, args_info.originsele_arg, args_info.refsele_arg), 250);
172 >  } else if (args_info.refsele_given || args_info.originsele_given) {
173 >    std::cerr << "Both of --refsele and --originsele should appear by pair" << std::endl;
174 >    exit(1);
175 >  }
176 >    
177 >  //create xyzVisitor
178 >  XYZVisitor* xyzVisitor;
179 >
180 >  if (args_info.selection_given) {
181 >    xyzVisitor = new XYZVisitor(info, args_info.selection_arg);
182 >  } else {
183 >    xyzVisitor = new XYZVisitor(info);
184 >  }
185 >
186 >  if(args_info.printPosOnly_flag){
187 >    bool posOnly = true;
188 >    xyzVisitor->setPosOnly(posOnly);
189 >  }
190 >
191    compositeVisitor->addVisitor(xyzVisitor, 200);
192    
193    std::cout << compositeVisitor->toString();
194    
195 <  //creat prepareVisitor
195 >  //create prepareVisitor
196    PrepareVisitor* prepareVisitor = new PrepareVisitor();
197    
198    //open dump file
# Line 201 | Line 200 | int main(int argc, char* argv[]){
200    int nframes = dumpReader->getNFrames();
201    
202    
203 <  std::ofstream xyzStream;    
205 <  xyzStream .open(xyzFileName.c_str());
203 >  std::ofstream xyzStream(xyzFileName.c_str());
204    
207  
205    SimInfo::MoleculeIterator miter;
206    Molecule::IntegrableObjectIterator  iiter;
207    Molecule::RigidBodyIterator rbIter;
208    Molecule* mol;
209    StuntDouble* integrableObject;
210    RigidBody* rb;
211 <
212 <  if (evaluator && !evaluator->isDynamic()) {
213 <    info->getSelectionManager()->setSelectionSet(evaluator->evaluate());
214 <  }
215 <  
211 >  Vector3d molCom;
212 >  Vector3d newMolCom;
213 >  Vector3d displacement;
214 >  Mat3x3d hmat;
215 >  Snapshot* currentSnapshot;
216 >      
217    for (int i = 0; i < nframes; i += args_info.frame_arg){
218      dumpReader->readFrame(i);
219 <    
219 >
220 >    //wrapping the molecule
221 >    if(args_info.periodicBox_flag) {
222 >      currentSnapshot = info->getSnapshotManager()->getCurrentSnapshot();    
223 >      for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
224 >          molCom = mol->getCom();
225 >          newMolCom = molCom;
226 >          currentSnapshot->wrapVector(newMolCom);
227 >          displacement = newMolCom - molCom;
228 >        for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL;
229 >             integrableObject = mol->nextIntegrableObject(iiter)) {  
230 >          integrableObject->setPos(integrableObject->getPos() + displacement);
231 >        }
232 >      }    
233 >    }
234      //update atoms of rigidbody
235      for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
236        
# Line 239 | Line 251 | int main(int argc, char* argv[]){
251      //update visitor
252      compositeVisitor->update();
253  
254 <    //if dynamic, we need to re-evaluate the selection
243 <    if (evaluator && evaluator->isDynamic()) {
244 <      info->getSelectionManager()->setSelectionSet(evaluator->evaluate());
245 <    }
246 <    
254 >
255      //visit stuntdouble
256      for (mol = info->beginMolecule(miter); mol != NULL; mol = info->nextMolecule(miter)) {
257        for (integrableObject = mol->beginIntegrableObject(iiter); integrableObject != NULL;
# Line 256 | Line 264 | int main(int argc, char* argv[]){
264      xyzVisitor->clear();
265      
266    }//end for (int i = 0; i < nframes; i += args_info.frame_arg)
267 <  
267 >
268    xyzStream.close();
269 <  
262 <  
269 >  delete prepareVisitor;
270    delete compositeVisitor;
271    delete info;
265  
272   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines