ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE/libmdtools/LJ_FF.cpp
(Generate patch)

Comparing trunk/OOPSE/libmdtools/LJ_FF.cpp (file contents):
Revision 378 by mmeineke, Fri Mar 21 17:42:12 2003 UTC vs.
Revision 434 by chuckv, Fri Mar 28 19:30:59 2003 UTC

# Line 43 | Line 43 | namespace LJ_NS{
43    MPI_Datatype mpiAtomStructType;
44    
45   #endif
46 +
47 +  class LinkedAtomType {
48 +  public:
49 +    LinkedAtomType(){
50 +      next = NULL;
51 +      name[0] = '\0';
52 +    }
53 +    ~LinkedAtomType(){ if( next != NULL ) delete next; }
54 +
55 +    LinkedAtomType* find(char* key){
56 +      if( !strcmp(name, key) ) return this;
57 +      if( next != NULL ) return next->find(key);
58 +      return NULL;
59 +    }
60 +    
61 +
62 +    void add( atomStruct &info ){
63 +    
64 +      // check for duplicates
65 +      
66 +      if( !strcmp( info.name, name ) ){
67 +        sprintf( painCave.errMsg,
68 +                 "Duplicate LJ atom type \"%s\" found in "
69 +                 "the LJ_FF param file./n",
70 +                 name );
71 +        painCave.isFatal = 1;
72 +        simError();
73 +      }
74 +      
75 +      if( next != NULL ) next->add(info);
76 +      else{
77 +        next = new LinkedAtomType();
78 +        strcpy(next->name, info.name);
79 +        next->mass     = info.mass;
80 +        next->epslon   = info.epslon;
81 +        next->sigma    = info.sigma;
82 +        next->ident    = info.ident;
83 +      }
84 +    }
85 +    
86 +
87 + #ifdef IS_MPI
88 +    
89 +    void duplicate( atomStruct &info ){
90 +      strcpy(info.name, name);
91 +      info.mass     = mass;
92 +      info.epslon   = epslon;
93 +      info.sigma    = sigma;
94 +      info.ident    = ident;
95 +      info.last     = 0;
96 +    }
97 +
98 +
99 + #endif
100 +
101 +    char name[15];
102 +    double mass;
103 +    double epslon;
104 +    double sigma;
105 +    int ident;
106 +    LinkedAtomType* next;
107 +  };
108 +
109 +  LinkedAtomType* headAtomType;
110 +  LinkedAtomType* currentAtomType;
111 +
112   }
113  
114   using namespace LJ_NS;
# Line 60 | Line 126 | LJ_FF::LJ_FF(){
126    char temp[200];
127    char errMsg[1000];
128  
129 +  headAtomType = NULL;
130 +  currentAtomType = NULL;
131 +
132    // do the funtion wrapping
133    wrapMeFF( this );
134  
# Line 142 | Line 211 | LJ_FF::~LJ_FF(){
211  
212   LJ_FF::~LJ_FF(){
213  
214 +  if( headAtomType != NULL ) delete headAtomType;
215 +
216   #ifdef IS_MPI
217    if( worldRank == 0 ){
218   #endif // is_mpi
# Line 158 | Line 229 | void LJ_FF::initForceField( int ljMixRule ){
229    initFortran( ljMixRule, 0 );
230   }
231  
232 + void LJ_FF::cleanMe( void ){
233  
234 < void LJ_FF::initializeAtoms( void ){
234 > #ifdef IS_MPI
235    
236 <  class LinkedType {
165 <  public:
166 <    LinkedType(){
167 <      next = NULL;
168 <      name[0] = '\0';
169 <    }
170 <    ~LinkedType(){ if( next != NULL ) delete next; }
236 >  // keep the linked list in the mpi version
237  
238 <    LinkedType* find(char* key){
173 <      if( !strcmp(name, key) ) return this;
174 <      if( next != NULL ) return next->find(key);
175 <      return NULL;
176 <    }
177 <    
238 > #else // is_mpi
239  
240 <    void add( atomStruct &info ){
180 <    
181 <      // check for duplicates
182 <      
183 <      if( !strcmp( info.name, name ) ){
184 <        sprintf( painCave.errMsg,
185 <                 "Duplicate LJ atom type \"%s\" found in "
186 <                 "the LJ_FF param file./n",
187 <                 name );
188 <        painCave.isFatal = 1;
189 <        simError();
190 <      }
191 <      
192 <      if( next != NULL ) next->add(info);
193 <      else{
194 <        next = new LinkedType();
195 <        strcpy(next->name, info.name);
196 <        next->mass     = info.mass;
197 <        next->epslon   = info.epslon;
198 <        next->sigma    = info.sigma;
199 <        next->ident    = info.ident;
200 <      }
201 <    }
202 <    
240 >  // delete the linked list in the single processor version
241  
242 < #ifdef IS_MPI
205 <    
206 <    void duplicate( atomStruct &info ){
207 <      strcpy(info.name, name);
208 <      info.mass     = mass;
209 <      info.epslon   = epslon;
210 <      info.sigma    = sigma;
211 <      info.ident    = ident;
212 <      info.last     = 0;
213 <    }
242 >  if( headAtomType != NULL ) delete headAtomType;
243  
244 + #endif // is_mpi
245 + }
246  
247 < #endif
247 > void LJ_FF::readParams( void ){
248  
218    char name[15];
219    double mass;
220    double epslon;
221    double sigma;
222    int ident;
223    LinkedType* next;
224  };
225  
226  LinkedType* headAtomType;
227  LinkedType* currentAtomType;
249    atomStruct info;
250    info.last = 1; // initialize last to have the last set.
251                   // if things go well, last will be set to 0
# Line 232 | Line 253 | void LJ_FF::initializeAtoms( void ){
253    int i;
254    int identNum;
255    
256 <  Atom** the_atoms;
257 <  int nAtoms;
237 <  the_atoms = entry_plug->atoms;
238 <  nAtoms = entry_plug->n_atoms;
239 <  
240 <  
256 >
257 >  bigSigma = 0.0;
258   #ifdef IS_MPI
259    if( worldRank == 0 ){
260   #endif
261      
262      // read in the atom types.
263  
264 <    headAtomType = new LinkedType;
264 >    headAtomType = new LinkedAtomType;
265      
266      fastForward( "AtomTypes", "initializeAtoms" );
267  
# Line 316 | Line 333 | void LJ_FF::initializeAtoms( void ){
333      
334      MPIcheckPoint();
335  
336 <    headAtomType = new LinkedType;
336 >    headAtomType = new LinkedAtomType;
337      recieveFrcStruct( &info, mpiAtomStructType );
338      
339      while( !info.last ){
# Line 380 | Line 397 | void LJ_FF::initializeAtoms( void ){
397      currentAtomType = currentAtomType->next;
398    }
399        
400 +  entry_plug->useLJ = 1;
401 +
402   #ifdef IS_MPI
403    sprintf( checkPointMsg,
404             "LJ_FF atom structures successfully sent to fortran\n" );
405    MPIcheckPoint();
406   #endif // is_mpi
407  
408 + }
409 +
410 +
411 + void LJ_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){
412    
413 +  int i;
414  
415    // initialize the atoms
416    
417 <  double bigSigma = 0.0;
417 >
418    Atom* thisAtom;
419  
420    for( i=0; i<nAtoms; i++ ){
# Line 412 | Line 436 | void LJ_FF::initializeAtoms( void ){
436  
437      if( bigSigma < currentAtomType->sigma ) bigSigma = currentAtomType->sigma;
438    }
439 + }
440  
441 + void LJ_FF::initializeBonds( int nBonds, Bond** BondArray,
442 +                             bond_pair* the_bonds ){
443    
444 < #ifdef IS_MPI
418 <  double tempBig = bigSigma;
419 <  MPI::COMM_WORLD.Allreduce( &tempBig, &bigSigma, 1, MPI_DOUBLE, MPI_MAX );
420 < #endif  //is_mpi
421 <
422 <  //calc rCut and rList
423 <
424 <  entry_plug->rCut = 2.5 * bigSigma;
425 <  if(entry_plug->rCut > (entry_plug->box_x / 2.0))
426 <    entry_plug->rCut = entry_plug->box_x / 2.0;
427 <  if(entry_plug->rCut > (entry_plug->box_y / 2.0))
428 <    entry_plug->rCut = entry_plug->box_y / 2.0;
429 <  if(entry_plug->rCut > (entry_plug->box_z / 2.0))
430 <    entry_plug->rCut = entry_plug->box_z / 2.0;
431 <
432 <  entry_plug->rList = entry_plug->rCut + 1.0;
433 <
434 <  entry_plug->useLJ = 1;
435 <
436 <  // clean up the memory
437 <  
438 <  delete headAtomType;
439 <
440 < #ifdef IS_MPI
441 <  sprintf( checkPointMsg, "LJ_FF atoms initialized succesfully" );
442 <  MPIcheckPoint();
443 < #endif // is_mpi
444 <
445 < }
446 <
447 < void LJ_FF::initializeBonds( bond_pair* the_bonds ){
448 <  
449 <    if( entry_plug->n_bonds ){
444 >    if( nBonds ){
445        sprintf( painCave.errMsg,
446                 "LJ_FF does not support bonds.\n" );
447        painCave.isFatal = 1;
448        simError();
449      }
455 #ifdef IS_MPI
456  MPIcheckPoint();
457 #endif // is_mpi
458
450   }
451  
452 < void LJ_FF::initializeBends( bend_set* the_bends ){
452 > void LJ_FF::initializeBends( int nBends, Bend** bendArray,
453 >                             bend_set* the_bends ){
454  
455 <    if( entry_plug->n_bends ){
455 >    if( nBends ){
456        sprintf( painCave.errMsg,
457                 "LJ_FF does not support bends.\n" );
458        painCave.isFatal = 1;
459        simError();
460      }
469 #ifdef IS_MPI
470  MPIcheckPoint();
471 #endif // is_mpi
472
461   }
462  
463 < void LJ_FF::initializeTorsions( torsion_set* the_torsions ){
463 > void LJ_FF::initializeTorsions( int nTorsions, Torsion** torsionArray,
464 >                                torsion_set* the_torsions ){
465  
466 <    if( entry_plug->n_torsions ){
466 >    if( nTorsions ){
467        sprintf( painCave.errMsg,
468                 "LJ_FF does not support torsions.\n" );
469        painCave.isFatal = 1;
470        simError();
471      }
483 #ifdef IS_MPI
484  MPIcheckPoint();
485 #endif // is_mpi
486
472   }
473  
474   void LJ_FF::fastForward( char* stopText, char* searchOwner ){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines