--- trunk/OOPSE/libmdtools/DUFF.cpp 2003/06/20 20:29:36 561 +++ trunk/OOPSE/libmdtools/DUFF.cpp 2003/06/24 19:57:54 564 @@ -15,6 +15,13 @@ namespace TPE { // restrict the access of the folowin #include "mpiForceField.h" #endif // is_mpi + +// define some bond Types + +#define FIXED_BOND 0 +#define HARMONIC_BOND 1 + + namespace TPE { // restrict the access of the folowing to this file only. @@ -39,10 +46,11 @@ namespace TPE { // restrict the access of the folowin typedef struct{ char nameA[15]; char nameB[15]; - char type[30]; double d0; + double k0; int last; // 0 -> default // 1 -> tells nodes to stop listening + int type; } bondStruct; @@ -172,7 +180,6 @@ namespace TPE { // restrict the access of the folowin next = NULL; nameA[0] = '\0'; nameB[0] = '\0'; - type[0] = '\0'; } ~LinkedBondType(){ if( next != NULL ) delete next; } @@ -207,8 +214,9 @@ namespace TPE { // restrict the access of the folowin next = new LinkedBondType(); strcpy(next->nameA, info.nameA); strcpy(next->nameB, info.nameB); - strcpy(next->type, info.type); + next->type = info.type; next->d0 = info.d0; + next->k0 = info.k0; } } @@ -216,8 +224,9 @@ namespace TPE { // restrict the access of the folowin void duplicate( bondStruct &info ){ strcpy(info.nameA, nameA); strcpy(info.nameB, nameB); - strcpy(info.type, type); + info.type = type; info.d0 = d0; + info.k0 = k0; info.last = 0; } @@ -226,8 +235,9 @@ namespace TPE { // restrict the access of the folowin char nameA[15]; char nameB[15]; - char type[30]; + int type; double d0; + double k0; LinkedBondType* next; }; @@ -468,7 +478,7 @@ DUFF::DUFF(){ // Init the bondStruct mpi type bondStruct bondProto; // mpiPrototype - int bondBC[3] = {60,1,1}; // block counts + int bondBC[3] = {30,2,2}; // block counts MPI_Aint bondDspls[3]; // displacements MPI_Datatype bondMbrTypes[3]; // member mpi types @@ -1189,12 +1199,28 @@ void DUFF::initializeBonds( int nBonds, Bond** bondArr simError(); } - if( !strcmp( currentBondType->type, "fixed" ) ){ - + switch( currentBondType->type ){ + + case FIXED_BOND: + bondArray[i] = new ConstrainedBond( *the_atoms[a], *the_atoms[b], currentBondType->d0 ); entry_plug->n_constraints++; + break; + + case HARMONIC_BOND: + + bondArray[i] = new HarmonicBond( *the_atoms[a], + *the_atoms[b], + currentBondType->d0, + currentBondType->k0 ); + break; + + default: + + break; + // do nothing } } } @@ -1479,6 +1505,7 @@ int TPE::parseBond( char *lineBuffer, int lineNum, bon int TPE::parseBond( char *lineBuffer, int lineNum, bondStruct &info ){ char* the_token; + char bondType[30]; the_token = strtok( lineBuffer, " \n\t,;" ); if( the_token != NULL ){ @@ -1501,9 +1528,23 @@ int TPE::parseBond( char *lineBuffer, int lineNum, bon simError(); } - strcpy( info.type, the_token ); + strcpy( bondType, the_token ); - if( !strcmp( info.type, "fixed" ) ){ + if( !strcmp( bondType, "fixed" ) ){ + info.type = FIXED_BOND; + + if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ + sprintf( painCave.errMsg, + "Error parseing BondTypes: line %d\n", lineNum ); + painCave.isFatal = 1; + simError(); + } + + info.d0 = atof( the_token ); + } + else if( !strcmp( bondType, "harmonic" ) ){ + info.type = HARMONIC_BOND; + if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ sprintf( painCave.errMsg, "Error parseing BondTypes: line %d\n", lineNum ); @@ -1512,7 +1553,17 @@ int TPE::parseBond( char *lineBuffer, int lineNum, bon } info.d0 = atof( the_token ); + + if( ( the_token = strtok( NULL, " \n\t,;" ) ) == NULL ){ + sprintf( painCave.errMsg, + "Error parseing BondTypes: line %d\n", lineNum ); + painCave.isFatal = 1; + simError(); + } + + info.k0 = atof( the_token ); } + else{ sprintf( painCave.errMsg, "Unknown DUFF bond type \"%s\" at line %d\n",