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

Comparing trunk/OOPSE/libBASS/MoleculeStamp.cpp (file contents):
Revision 1103 by gezelter, Tue Apr 13 16:25:13 2004 UTC vs.
Revision 1153 by gezelter, Tue May 11 04:21:52 2004 UTC

# Line 14 | Line 14 | MoleculeStamp::MoleculeStamp(){
14    n_bends = 0;
15    n_torsions = 0;
16    n_rigidbodies = 0;
17 +  n_cutoffgroups = 0;
18    n_integrable = 0;
19  
20    unhandled = NULL;
# Line 22 | Line 23 | MoleculeStamp::MoleculeStamp(){
23    bends = NULL;
24    torsions = NULL;
25    rigidBodies = NULL;
26 +  cutoffGroups = NULL;
27  
28    have_name = 0;
29    have_atoms = 0;
# Line 29 | Line 31 | MoleculeStamp::MoleculeStamp(){
31    have_bends = 0;
32    have_torsions = 0;
33    have_rigidbodies = 0;
34 +  have_cutoffgroups = 0;
35  
36   }
37  
# Line 40 | Line 43 | MoleculeStamp::~MoleculeStamp(){
43    if( rigidBodies != NULL ) {
44      for( i=0; i<n_rigidbodies; i++ ) delete rigidBodies[i];
45    }
46 +
47 +  if( cutoffGroups != NULL ) {
48 +    for( i=0; i<n_cutoffgroups; i++ ) delete cutoffGroups[i];
49 +  }
50    
51    if( atoms != NULL ){
52      for( i=0; i<n_atoms; i++ ) delete atoms[i];
# Line 151 | Line 158 | char* MoleculeStamp::assignDouble( char* lhs, double r
158      for( i=0; i<n_rigidbodies; i++ ) rigidBodies[i] = NULL;
159    }
160  
161 +  else if( !strcmp( lhs, "nCutoffGroups" ) ){
162 +    n_cutoffgroups = (int)rhs;
163 +
164 +    if( have_cutoffgroups ){
165 +      sprintf( errMsg,
166 +               "MoleculeStamp error, n_cutoffgroups already declared for"
167 +               " molecule: %s\n",
168 +               name );
169 +      return strdup( errMsg );
170 +    }
171 +    have_cutoffgroups = 1;
172 +    cutoffGroups = new CutoffGroupStamp*[n_cutoffgroups];
173 +    for( i=0; i<n_cutoffgroups; i++ ) cutoffGroups[i] = NULL;
174 +  }
175 +  
176    else{
177      if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs );
178      else unhandled->add( lhs, rhs );
# Line 227 | Line 249 | char*  MoleculeStamp::assignInt( char* lhs, int rhs ){
249  
250      if( have_rigidbodies ){
251        sprintf( errMsg,
252 <               "RigidBodyStamp error, n_rigidbodies already declared for"
252 >               "MoleculeStamp error, n_rigidbodies already declared for"
253                 " molecule: %s\n",
254                 name);
255        return strdup( errMsg );
# Line 236 | Line 258 | char*  MoleculeStamp::assignInt( char* lhs, int rhs ){
258      rigidBodies = new RigidBodyStamp*[n_rigidbodies];
259      for( i=0; i<n_rigidbodies; i++ ) rigidBodies[i] = NULL;
260    }
261 +  else if( !strcmp( lhs, "nCutoffGroups" ) ){
262 +    n_cutoffgroups = rhs;
263 +
264 +    if( have_cutoffgroups ){
265 +      sprintf( errMsg,
266 +               "MoleculeStamp error, n_cutoffgroups already declared for"
267 +               " molecule: %s\n",
268 +               name);
269 +      return strdup( errMsg );
270 +    }
271 +    have_cutoffgroups = 1;
272 +    cutoffGroups = new CutoffGroupStamp*[n_cutoffgroups];
273 +    for( i=0; i<n_cutoffgroups; i++ ) cutoffGroups[i] = NULL;
274 +  }
275    else{
276      if( unhandled == NULL ) unhandled = new LinkedAssign( lhs, rhs );
277      else unhandled->add( lhs, rhs );
# Line 278 | Line 314 | char* MoleculeStamp::addRigidBody( RigidBodyStamp* the
314    return NULL;
315   }
316  
317 + char* MoleculeStamp::addCutoffGroup( CutoffGroupStamp* the_cutoffgroup,
318 +                                     int cutoffGroupIndex ){
319 +  
320 +  if( have_cutoffgroups && cutoffGroupIndex < n_cutoffgroups )
321 +    cutoffGroups[cutoffGroupIndex] = the_cutoffgroup;
322 +  else {
323 +    if( have_cutoffgroups ){
324 +      sprintf( errMsg, "MoleculeStamp error, %d out of nCutoffGroups range",
325 +               cutoffGroupIndex );
326 +      return strdup( errMsg );
327 +    }
328 +    else return strdup("MoleculeStamp error, nCutoffGroups not given before"
329 +                       " first CutoffGroup declaration." );
330 +  }
331 +  
332 +  return NULL;
333 + }
334 +
335   char* MoleculeStamp::addBond( BondStamp* the_bond, int bondIndex ){
336    
337    
# Line 333 | Line 387 | char* MoleculeStamp::checkMe( void ){
387   char* MoleculeStamp::checkMe( void ){
388    
389    int i;
390 <  short int no_atom, no_rigidbody;
390 >  short int no_atom, no_rigidbody, no_cutoffgroup;
391  
392    if( !have_name ) return strdup( "MoleculeStamp error. Molecule's name"
393                                    " was not given.\n" );
# Line 354 | Line 408 | char* MoleculeStamp::checkMe( void ){
408      return strdup( errMsg );
409    }
410  
411 +  no_cutoffgroup = 0;
412 +  for( i=0; i<n_cutoffgroups; i++ ){
413 +    if( cutoffGroups[i] == NULL ) no_cutoffgroup = 1;
414 +  }
415 +
416 +  if( no_cutoffgroup ){
417 +    sprintf( errMsg,
418 +             "MoleculeStamp error. Not all of the CutoffGroups were"
419 +             " declared in molecule \"%s\".\n", name );
420 +    return strdup( errMsg );
421 +  }
422 +  
423    no_atom = 0;
424    for( i=0; i<n_atoms; i++ ){
425      if( atoms[i] == NULL ) no_atom = 1;
# Line 366 | Line 432 | char* MoleculeStamp::checkMe( void ){
432      return strdup( errMsg );
433    }
434  
369
435    n_integrable = n_atoms;
436    for (i = 0; i < n_rigidbodies; i++)
437 <    n_integrable -= rigidBodies[i]->getNMembers();
437 >    n_integrable = n_integrable - rigidBodies[i]->getNMembers() + 1; //rigidbody is an integrable object
438    
439    if (n_integrable <= 0 || n_integrable > n_atoms) {
440      sprintf( errMsg,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines