ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/src/applications/nanoRodBuilder/nanorodBuilder.cpp
(Generate patch)

Comparing trunk/OOPSE-3.0/src/applications/nanoRodBuilder/nanorodBuilder.cpp (file contents):
Revision 2196 by chuckv, Thu Apr 14 16:10:57 2005 UTC vs.
Revision 2253 by chuckv, Tue May 31 17:34:18 2005 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 103 | Line 103 | int main(int argc, char *argv []) {
103    std::vector<Vector3d> latticePos;
104    std::vector<Vector3d> latticeOrt;
105    int numMolPerCell;
106  int curMolIndex;
106    DumpWriter *writer;
107    
108    // parse command line arguments
# Line 111 | Line 110 | int main(int argc, char *argv []) {
110      exit(1);
111    
112    
113 <        // Check for lib CGAL, if we don't have it, we should exit....
113 >  // Check for lib CGAL, if we don't have it, we should exit....
114          
115   #ifndef HAVE_CGAL
116 <                 std::cerr << "nanoRodBuilder requires libCGAL to function, please rebuild OOPSE with libCGAL."
117 <                 << std::endl;
118 <                 exit(1);
116 >  std::cerr << "nanoRodBuilder requires libCGAL to function, please rebuild OOPSE with libCGAL."
117 >            << std::endl;
118 >  exit(1);
119   #endif
120          
121          
122          
123    //get lattice type
124    latticeType = UpperCase(args_info.latticetype_arg);
125 <  
127 <  
128 <  simpleLat = LatticeFactory::getInstance()->createLattice(latticeType);
129 <  if (simpleLat == NULL) {
130 <    sprintf(painCave.errMsg, "Lattice Factory can not create %s lattice\n",
131 <            latticeType.c_str());
132 <    painCave.isFatal = 1;
133 <    simError();
134 <  }        
135 <  
125 >    
126    //get input file name
127    if (args_info.inputs_num)
128      inputFileName = args_info.inputs[0];
# Line 185 | Line 175 | int main(int argc, char *argv []) {
175    else
176      outInitFileName = getPrefix(inputFileName.c_str()) + ".in";
177    
178 +  
179 +        
180 +  
181 +  
182 +  
183    //creat Molocator
184    locator = new MoLocator(oldInfo->getMoleculeStamp(0), oldInfo->getForceField());
185    
# Line 204 | Line 199 | int main(int argc, char *argv []) {
199    
200    // Create geometry for nanocrystal
201   #ifdef HAVE_CGAL
202 <  GeometryBuilder myGeometry(rodLength,rodDiameter);
202 >  GeometryBuilder *myGeometry;
203 >  // GeometryBuilder myGeometry(rodLength,rodDiameter);
204 >  if (args_info.twinnedCrystal_flag){
205 >     myGeometry = new GeometryBuilder(rodLength,rodDiameter);
206 >  }
207 >  else{
208 >     myGeometry = new GeometryBuilder(rodLength,rodDiameter);
209 >  }
210 >  
211 >  if (args_info.genGeomview_given){
212 >     if (args_info.genGeomview_flag){
213 >        outGeomFileName = getPrefix(inputFileName.c_str()) + ".off";
214 >        myGeometry->dumpGeometry(outGeomFileName);
215 >     }
216 >  }
217 >  
218   #endif
219    
220    /*
# Line 215 | Line 225 | int main(int argc, char *argv []) {
225    
226    //place the molecules
227    
228 <  curMolIndex = 0;
228 >
229    
230    //get the orientation of the cell sites
231    //for the same type of molecule in same lattice, it will not change
232    latticeOrt = simpleLat->getLatticePointsOrt();
233    
234    
225  /*
226    void BaseLattice::getLatticePointsPos(std::vector<Vector3d>&
227    latticePos, int nx, int ny, int nz){
228    
229    latticePos.resize(nCellSites);
230                        
231    for( int i=0;i < nCellSites;i++){
232    
233    latticePos[i][0] = origin[0] + cellSitesPos[i][0] + cellLen[0] * (double(nx) - 0.5);
234    latticePos[i][1] = origin[1] + cellSitesPos[i][1] + cellLen[1] * (double(ny) - 0.5);
235    latticePos[i][2] = origin[2] + cellSitesPos[i][2] + cellLen[2] * (double(nz) - 0.5);    
236    }
237    
238  */
235    
240  
241  
242  
236    numMol = 0;
237 <  for(int i = 0; i < nx; i++) {
238 <    for(int j = 0; j < ny; j++) {
239 <      for(int k = 0; k < nz; k++) {
237 >  for(int i = -nx; i < nx; i++) {    
238 >    for(int j = -ny; j < ny; j++) {      
239 >      for(int k = -nz; k < nz; k++) {
240          //if (oldInfo->getNGlobalMolecules() != numMol) {
241          
242          
# Line 254 | Line 247 | int main(int argc, char *argv []) {
247          for(int l = 0; l < numMolPerCell; l++) {
248  
249   #ifdef HAVE_CGAL
250 <          if (myGeometry.isInsidePolyhedron(latticePos[l][0],latticePos[l][1],latticePos[l][2])){
250 >          if (myGeometry->isInsidePolyhedron(latticePos[l][0],latticePos[l][1],latticePos[l][2])){
251              numMol++;
252            }
253 + #else
254 +           numMol++;
255   #endif
256          }
257        }
258      }
259    }
260 +
261    
266  
262    // needed for writing out new md file.
263    
264    outPrefix = getPrefix(inputFileName.c_str()) + "_" + latticeType;
# Line 287 | Line 282 | int main(int argc, char *argv []) {
282    Molecule* mol;
283    SimInfo::MoleculeIterator mi;
284    mol = NewInfo->beginMolecule(mi);
290  
291  for(int i = 0; i < nx; i++) {
292    for(int j = 0; j < ny; j++) {
293      for(int k = 0; k < nz; k++) {
294        
295        //get the position of the cell sites
296        simpleLat->getLatticePointsPos(latticePos, i, j, k);
297        
298        for(int l = 0; l < numMolPerCell; l++) {
299          if (mol != NULL) {
285  
286 < #ifdef HAVE_GCAL
287 <            if (myGeometry.isInsidePolyhedron(latticePos[l][0],latticePos[l][1],latticePos[l][2])){
288 <              locator->placeMol(latticePos[l], latticeOrt[l], mol);
289 <            }          
290 < #else
291 <            
292 <            locator->placeMol(latticePos[l], latticeOrt[l], mol);
293 < #endif
294 <          } else {
295 <            std::cerr << std::endl;                    
296 <          }
297 <          mol = NewInfo->nextMolecule(mi);
286 >
287 >  for(int i = -nx; i < nx; i++) {
288 >     for(int j = -ny; j < ny; j++) {
289 >        for(int k = -nz; k < nz; k++) {
290 >          
291 >           //get the position of the cell sites
292 >           simpleLat->getLatticePointsPos(latticePos, i, j, k);
293 >          
294 >           for(int l = 0; l < numMolPerCell; l++) {
295 > #ifdef HAVE_CGAL              
296 >              if (myGeometry->isInsidePolyhedron(latticePos[l][0],latticePos[l][1],latticePos[l][2])){
297 > #endif                              
298 >                 if (mol != NULL) {
299 >                    locator->placeMol(latticePos[l], latticeOrt[l], mol);
300 >                 } else {
301 >                    std::cerr<<"Error in placing molecule " << std::endl;                    
302 >                 }
303 >                 mol = NewInfo->nextMolecule(mi);
304 > #ifdef HAVE_CGAL                
305 >              }
306 > #endif              
307 >           }
308          }
309 <      }
315 <    }
309 >     }
310    }
311    
312 +
313    
319  
314    //fill Hmat
315    hmat(0, 0)= nx * latticeConstant;
316    hmat(0, 1) = 0.0;
# Line 341 | Line 335 | int main(int argc, char *argv []) {
335    if (writer == NULL) {
336      std::cerr << "error in creating DumpWriter" << std::endl;
337      exit(1);
338 <    }
338 >  }
339    
340    writer->writeDump();
341    std::cout << "new initial configuration file: " << outInitFileName

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines