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

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines