00001 #include <algorithm>
00002 #include "CompressPsf.h"
00003 #include "strlib.h"
00004 #include "Molecule.h"
00005 #include "Parameters.h"
00006 #include "SimParameters.h"
00007 #include "InfoStream.h"
00008 #include "UniqueSet.h"
00009 #include "UniqueSetIter.h"
00010
00011 using namespace std;
00012
00031
00032 Molecule *g_mol = NULL;
00033 Parameters *g_param = NULL;
00034 SimParameters *g_simParam = NULL;
00035 ConfigList *g_cfgList = NULL;
00036
00037 struct BasicAtomInfo
00038 {
00039 Index segNameIdx;
00040 Index resNameIdx;
00041 Index atomNameIdx;
00042 Index atomTypeIdx;
00043 Index chargeIdx;
00044 Index massIdx;
00045 Index atomSigIdx;
00046 Index exclSigIdx;
00047 int resID;
00048 };
00049
00050 void OutputAtomRecord::flip(){
00051 flipNum((char *)&sSet, sizeof(short), sizeof(sSet)/sizeof(short));
00052 flipNum((char *)&iSet, sizeof(int), sizeof(iSet)/sizeof(int));
00053 flipNum((char *)&fSet, sizeof(float), sizeof(fSet)/sizeof(float));
00054 }
00055
00056 struct AtomSigInfo
00057 {
00058 vector<SigIndex> bondSigIndices;
00059 vector<SigIndex> angleSigIndices;
00060 vector<SigIndex> dihedralSigIndices;
00061 vector<SigIndex> improperSigIndices;
00062 vector<SigIndex> crosstermSigIndices;
00063
00064 AtomSigInfo()
00065 {}
00066 AtomSigInfo(const AtomSigInfo& sig)
00067 {
00068 bondSigIndices.clear();
00069 for(int i=0; i<sig.bondSigIndices.size(); i++)
00070 bondSigIndices.push_back(sig.bondSigIndices[i]);
00071
00072 angleSigIndices.clear();
00073 for(int i=0; i<sig.angleSigIndices.size(); i++)
00074 angleSigIndices.push_back(sig.angleSigIndices[i]);
00075
00076 dihedralSigIndices.clear();
00077 for(int i=0; i<sig.dihedralSigIndices.size(); i++)
00078 dihedralSigIndices.push_back(sig.dihedralSigIndices[i]);
00079
00080 improperSigIndices.clear();
00081 for(int i=0; i<sig.improperSigIndices.size(); i++)
00082 improperSigIndices.push_back(sig.improperSigIndices[i]);
00083
00084 crosstermSigIndices.clear();
00085 for(int i=0; i<sig.crosstermSigIndices.size(); i++)
00086 crosstermSigIndices.push_back(sig.crosstermSigIndices[i]);
00087 }
00088
00089 ~AtomSigInfo()
00090 {
00091 bondSigIndices.clear();
00092 angleSigIndices.clear();
00093 dihedralSigIndices.clear();
00094 improperSigIndices.clear();
00095 crosstermSigIndices.clear();
00096 }
00097
00098 void sortTupleSigIndices()
00099 {
00100 sort(bondSigIndices.begin(), bondSigIndices.end());
00101 sort(angleSigIndices.begin(), angleSigIndices.end());
00102 sort(dihedralSigIndices.begin(), dihedralSigIndices.end());
00103 sort(improperSigIndices.begin(), improperSigIndices.end());
00104 sort(crosstermSigIndices.begin(), crosstermSigIndices.end());
00105 }
00106
00107 inline CkHashCode hash() const {
00108
00109
00110
00111
00112
00113
00114 const int maxlen = 32;
00115 unsigned char keydata[maxlen+1];
00116 const int maxchar = 256;
00117 int i,j;
00118 for(j=0;j<=maxlen;j++) keydata[j] = 0;
00119 j=0;
00120 for(i=0; i<bondSigIndices.size(); i++,j++) {
00121 keydata[j % maxlen] ^= (bondSigIndices[i] % maxchar);
00122 }
00123 for(i=0; i<angleSigIndices.size(); i++,j++) {
00124 keydata[j % maxlen] ^= (angleSigIndices[i] % maxchar);
00125 }
00126 for(i=0; i<dihedralSigIndices.size(); i++,j++) {
00127 keydata[j % maxlen] ^= (dihedralSigIndices[i] % maxchar);
00128 }
00129 for(i=0; i<improperSigIndices.size(); i++,j++) {
00130 keydata[j % maxlen] ^= (improperSigIndices[i] % maxchar);
00131 }
00132 for(i=0; i<crosstermSigIndices.size(); i++,j++) {
00133 keydata[j % maxlen] ^= (crosstermSigIndices[i] % maxchar);
00134 }
00135
00136 if (j > maxlen) j = maxlen;
00137
00138
00139
00140
00141
00142 return CkHashFunction_default((const void*)keydata,(size_t)j);
00143 }
00144 };
00145
00146 int operator==(const AtomSigInfo &s1, const AtomSigInfo& s2)
00147 {
00148 if(s1.bondSigIndices.size() != s2.bondSigIndices.size())
00149 return 0;
00150 if(s1.angleSigIndices.size() != s2.angleSigIndices.size())
00151 return 0;
00152 if(s1.dihedralSigIndices.size() != s2.dihedralSigIndices.size())
00153 return 0;
00154 if(s1.improperSigIndices.size() != s2.improperSigIndices.size())
00155 return 0;
00156 if(s1.crosstermSigIndices.size() != s2.crosstermSigIndices.size())
00157 return 0;
00158
00159 int equalCnt;
00160 equalCnt=0;
00161 int bondSigCnt = s1.bondSigIndices.size();
00162 for(int i=0; i<bondSigCnt; i++)
00163 equalCnt += (s1.bondSigIndices[i]==s2.bondSigIndices[i]);
00164 if(equalCnt!=bondSigCnt)
00165 return 0;
00166
00167 equalCnt=0;
00168 int angleSigCnt = s1.angleSigIndices.size();
00169 for(int i=0; i<angleSigCnt; i++)
00170 equalCnt += (s1.angleSigIndices[i]==s2.angleSigIndices[i]);
00171 if(equalCnt!=angleSigCnt)
00172 return 0;
00173
00174 equalCnt=0;
00175 int dihedralSigCnt = s1.dihedralSigIndices.size();
00176 for(int i=0; i<dihedralSigCnt; i++)
00177 equalCnt += (s1.dihedralSigIndices[i]==s2.dihedralSigIndices[i]);
00178 if(equalCnt!=dihedralSigCnt)
00179 return 0;
00180
00181 equalCnt=0;
00182 int improperSigCnt = s1.improperSigIndices.size();
00183 for(int i=0; i<improperSigCnt; i++)
00184 equalCnt += (s1.improperSigIndices[i]==s2.improperSigIndices[i]);
00185 if(equalCnt!=improperSigCnt)
00186 return 0;
00187
00188 equalCnt=0;
00189 int crosstermSigCnt = s1.crosstermSigIndices.size();
00190 for(int i=0; i<crosstermSigCnt; i++)
00191 equalCnt += (s1.crosstermSigIndices[i]==s2.crosstermSigIndices[i]);
00192 if(equalCnt!=crosstermSigCnt)
00193 return 0;
00194
00195 return 1;
00196 }
00197
00198 struct ExclSigInfo
00199 {
00200 vector<int> fullExclOffset;
00201 vector<int> modExclOffset;
00202
00203 ExclSigInfo()
00204 {}
00205 ExclSigInfo(const ExclSigInfo& sig)
00206 {
00207 fullExclOffset.clear();
00208 for(int i=0; i<sig.fullExclOffset.size(); i++)
00209 fullExclOffset.push_back(sig.fullExclOffset[i]);
00210
00211 modExclOffset.clear();
00212 for(int i=0; i<sig.modExclOffset.size(); i++)
00213 modExclOffset.push_back(sig.modExclOffset[i]);
00214 }
00215
00216 ~ExclSigInfo()
00217 {
00218 fullExclOffset.clear();
00219 modExclOffset.clear();
00220 }
00221
00222 void sortExclOffset()
00223 {
00224 sort(fullExclOffset.begin(), fullExclOffset.end());
00225 sort(modExclOffset.begin(), modExclOffset.end());
00226 }
00227
00228 int hash() const {
00229 unsigned int code = 0x1234;
00230 unsigned int codesz = 8 * sizeof(int);
00231 const unsigned int numFoffset = fullExclOffset.size();
00232 const unsigned int numMoffset = modExclOffset.size();
00233 const unsigned int numOffsets = numFoffset + numMoffset;
00234
00235
00236 if (numOffsets == 0)
00237 return 0;
00238
00239 unsigned int shift = codesz / numOffsets;
00240 if (shift == 0) shift=1;
00241 unsigned int i;
00242 for(i=0; i < numFoffset; i++) {
00243 code = circShift(code,shift);
00244 code ^= fullExclOffset[i];
00245 }
00246 for(i=0; i < numMoffset; i++) {
00247 code = circShift(code,shift);
00248 code ^= modExclOffset[i];
00249 }
00250 return code;
00251 }
00252 };
00253 int operator==(const ExclSigInfo &s1, const ExclSigInfo &s2)
00254 {
00255 if(s1.fullExclOffset.size()!=s2.fullExclOffset.size())
00256 return 0;
00257 if(s1.modExclOffset.size()!=s2.modExclOffset.size())
00258 return 0;
00259
00260 for(int i=0; i<s1.fullExclOffset.size(); i++)
00261 {
00262 if(s1.fullExclOffset[i] != s2.fullExclOffset[i])
00263 return 0;
00264 }
00265
00266 for(int i=0; i<s1.modExclOffset.size(); i++)
00267 {
00268 if(s1.modExclOffset[i] != s2.modExclOffset[i])
00269 return 0;
00270 }
00271 return 1;
00272 }
00273
00274 class HashString : public string {
00275 public:
00276 int hash() const {
00277 const char* d = this->c_str();
00278 int ret=0;
00279 for (int i=0;d[i]!=0;i++) {
00280 int shift1=((5*i)%16)+0;
00281 int shift2=((6*i)%16)+8;
00282 ret+=((0xa5^d[i])<<shift2)+(d[i]<<shift1);
00283 }
00284 return ret;
00285 }
00286 };
00287
00288 class HashReal {
00289 Real val;
00290 public:
00291 HashReal(Real v) : val(v) {}
00292 operator Real & () { return val; }
00293 operator const Real & () const { return val; }
00294
00295 int hash() const {
00296 const char* d = (const char *)&val;
00297 int ret=0;
00298 for (int i=0;i < sizeof(Real);i++) {
00299 int shift1=((5*i)%16)+0;
00300 int shift2=((6*i)%16)+8;
00301 ret+=((0xa5^d[i])<<shift2)+(d[i]<<shift1);
00302 }
00303 return ret;
00304 };
00305 };
00306
00307 HashPool<HashString> segNamePool;
00308 HashPool<HashString> resNamePool;
00309 HashPool<HashString> atomNamePool;
00310 HashPool<HashString> atomTypePool;
00311 HashPool<HashReal> chargePool;
00312 HashPool<HashReal> massPool;
00313 HashPool<AtomSigInfo> atomSigPool;
00314 BasicAtomInfo *atomData;
00315
00316
00317 int *eachAtomClusterID = NULL;
00318 vector<int> eachClusterSize;
00319 vector<int> eachClusterID;
00320 int g_numClusters = 0;
00321
00322 HashPool<TupleSignature> sigsOfBonds;
00323 HashPool<TupleSignature> sigsOfAngles;
00324 HashPool<TupleSignature> sigsOfDihedrals;
00325 HashPool<TupleSignature> sigsOfImpropers;
00326 HashPool<TupleSignature> sigsOfCrossterms;
00327 AtomSigInfo *eachAtomSigs;
00328
00329 HashPool<ExclSigInfo> sigsOfExclusions;
00330 ExclSigInfo *eachAtomExclSigs;
00331
00332
00333 vector<Bond> extraBonds;
00334 vector<Angle> extraAngles;
00335 vector<Dihedral> extraDihedrals;
00336 vector<Improper> extraImpropers;
00337
00338 vector<BondValue> extraBondParams;
00339 vector<AngleValue> extraAngleParams;
00340 vector<DihedralValue> extraDihedralParams;
00341 vector<ImproperValue> extraImproperParams;
00342
00343 int operator==(const BondValue &b1, const BondValue &b2)
00344 {
00345 return (b1.k==b2.k) && (b1.x0==b2.x0);
00346 }
00347
00348 int operator==(const AngleValue &a1, const AngleValue &a2)
00349 {
00350 return (a1.k==a2.k) && (a1.k_ub==a2.k_ub) && (a1.r_ub==a2.r_ub) && (a1.theta0==a2.theta0);
00351 }
00352
00353 int operator!=(const FourBodyConsts& f1, const FourBodyConsts& f2)
00354 {
00355 return (f1.delta!=f2.delta) || (f1.k!=f2.k) || (f1.n!=f2.n);
00356 }
00357
00358 int operator==(const DihedralValue &d1, const DihedralValue &d2)
00359 {
00360 if(d1.multiplicity != d2.multiplicity)
00361 return 0;
00362 for(int i=0; i<MAX_MULTIPLICITY; i++)
00363 {
00364 if(d1.values[i] != d2.values[i])
00365 return 0;
00366 }
00367 return 1;
00368 }
00369
00370 int operator==(const ImproperValue &d1, const ImproperValue &d2)
00371 {
00372 if(d1.multiplicity != d2.multiplicity)
00373 return 0;
00374 for(int i=0; i<MAX_MULTIPLICITY; i++)
00375 {
00376 if(d1.values[i] != d2.values[i])
00377 return 0;
00378 }
00379 return 1;
00380 }
00381
00382 void loadMolInfo();
00383
00384 void integrateAllAtomSigs();
00385 void outputCompressedFile(FILE *txtOfp, FILE *binOfp);
00386
00387
00388 void getExtraBonds(StringList *file);
00389
00390 void buildAtomData();
00391 void buildBondData();
00392 void buildAngleData();
00393 void buildDihedralData();
00394 void buildImproperData();
00395 void buildCrosstermData();
00396
00397 void buildExclusionData();
00398
00399
00400 void buildExclusions();
00401 void build12Excls(UniqueSet<Exclusion>&, vector<int> *);
00402 void build13Excls(UniqueSet<Exclusion>&, vector<int> *);
00403 void build14Excls(UniqueSet<Exclusion>&, vector<int> *, int);
00404
00405
00406 void flipNum(char *elem, int elemSize, int numElems){
00407 int mid = elemSize/2;
00408 char *ptr = elem;
00409 for(int i=0; i<numElems; i++) {
00410 for(int j=0; j<mid; j++) {
00411 char tmp = ptr[j];
00412 ptr[j] = ptr[elemSize-1-j];
00413 ptr[elemSize-1-j] = tmp;
00414 }
00415 ptr += elemSize;
00416 }
00417 }
00418
00419 void clearGlobalVectors()
00420 {
00421 segNamePool.clear();
00422 resNamePool.clear();
00423 atomNamePool.clear();
00424 atomTypePool.clear();
00425 chargePool.clear();
00426 massPool.clear();
00427 sigsOfBonds.clear();
00428 sigsOfAngles.clear();
00429 sigsOfDihedrals.clear();
00430 sigsOfImpropers.clear();
00431 sigsOfExclusions.clear();
00432
00433 eachClusterSize.clear();
00434 }
00435
00436 void compress_molecule_info(Molecule *mol, char *psfFileName, Parameters *param, SimParameters *simParam, ConfigList* cfgList)
00437 {
00438 g_mol = mol;
00439 g_param = param;
00440 g_simParam = simParam;
00441 g_cfgList = cfgList;
00442
00443
00444
00445 loadMolInfo();
00446
00447 integrateAllAtomSigs();
00448
00449 buildExclusions();
00450
00451
00452
00453 char *outFileName = new char[strlen(psfFileName)+20];
00454 sprintf(outFileName, "%s.inter", psfFileName);
00455
00456 FILE *txtOfp = fopen(outFileName, "w");
00457 sprintf(outFileName, "%s.inter.bin", psfFileName);
00458
00459 FILE *binOfp = fopen(outFileName, "wb");
00460 delete [] outFileName;
00461
00462
00463 outputCompressedFile(txtOfp, binOfp);
00464
00465 fclose(txtOfp);
00466 fclose(binOfp);
00467 }
00468
00473 void loadMolInfo()
00474 {
00475 char err_msg[512];
00476 char buffer[512];
00477 int i;
00478 int NumTitle;
00479 int ret_code;
00480 FILE *psf_file;
00481 Parameters *params = g_param;
00482
00483 buildAtomData();
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493 eachAtomSigs = new AtomSigInfo[g_mol->numAtoms];
00494
00495 buildBondData();
00496 buildAngleData();
00497 buildDihedralData();
00498 buildImproperData();
00499 buildCrosstermData();
00500
00501
00502
00503 }
00504
00505 void integrateAllAtomSigs()
00506 {
00507 printf("Bond sigs: %d\n", (int)sigsOfBonds.size());
00508 printf("Angle sigs: %d\n", (int)sigsOfAngles.size());
00509 printf("Dihedral sigs: %d\n", (int)sigsOfDihedrals.size());
00510 printf("Improper sigs: %d\n", (int)sigsOfImpropers.size());
00511 printf("Crossterm sigs: %d\n", (int)sigsOfCrossterms.size());
00512
00513
00514 for(int i=0; i<g_mol->numAtoms; i++)
00515 {
00516 eachAtomSigs[i].sortTupleSigIndices();
00517 int poolIndex = atomSigPool.lookupCstPool(eachAtomSigs[i]);
00518 if(poolIndex==-1)
00519 {
00520 atomSigPool.push_back(eachAtomSigs[i]);
00521 poolIndex = atomSigPool.size()-1;
00522 }
00523 atomData[i].atomSigIdx = poolIndex;
00524 }
00525
00526 printf("Atom's sigs: %d\n", (int)atomSigPool.size());
00527
00528 delete[] eachAtomSigs;
00529 }
00530
00541 void outputCompressedFile(FILE *txtOfp, FILE *binOfp)
00542 {
00543 #ifndef MEM_OPT_VERSION
00544 fprintf(txtOfp, "FORMAT VERSION: %f\n", COMPRESSED_PSF_VER);
00545
00546 fprintf(txtOfp, "%d !NSEGMENTNAMES\n", segNamePool.size());
00547 for(int i=0; i<segNamePool.size(); i++)
00548 {
00549 fprintf(txtOfp, "%s\n", segNamePool[i].c_str());
00550 }
00551
00552 fprintf(txtOfp, "%d !NRESIDUENAMES\n", resNamePool.size());
00553 for(int i=0; i<resNamePool.size(); i++)
00554 {
00555 fprintf(txtOfp, "%s\n", resNamePool[i].c_str());
00556 }
00557
00558 fprintf(txtOfp, "%d !NATOMNAMES\n", atomNamePool.size());
00559 for(int i=0; i<atomNamePool.size(); i++)
00560 {
00561 fprintf(txtOfp, "%s\n", atomNamePool[i].c_str());
00562 }
00563
00564 fprintf(txtOfp, "%d !NATOMTYPES\n", atomTypePool.size());
00565 for(int i=0; i<atomTypePool.size(); i++)
00566 {
00567 fprintf(txtOfp, "%s\n", atomTypePool[i].c_str());
00568 }
00569
00570 fprintf(txtOfp, "%d !NCHARGES\n", chargePool.size());
00571 for(int i=0; i<chargePool.size(); i++)
00572 {
00573 const Real charge = chargePool[i];
00574 fprintf(txtOfp, "%f\n", charge);
00575 }
00576
00577 fprintf(txtOfp, "%d !NMASSES\n", massPool.size());
00578 for(int i=0; i<massPool.size(); i++)
00579 {
00580 const Real mass = massPool[i];
00581 fprintf(txtOfp, "%f\n", mass);
00582 }
00583
00584
00585 fprintf(txtOfp, "%d !NATOMSIGS\n", atomSigPool.size());
00586 for(int i=0; i<atomSigPool.size(); i++)
00587 {
00588 AtomSigInfo& oneAtomSig = atomSigPool[i];
00589 int oneTypeCnt = oneAtomSig.bondSigIndices.size();
00590 fprintf(txtOfp, "%d !%sSIGS\n", oneTypeCnt, "NBOND");
00591 for(int j=0; j<oneTypeCnt; j++)
00592 {
00593 SigIndex idx = oneAtomSig.bondSigIndices[j];
00594 TupleSignature& tSig = sigsOfBonds[idx];
00595 tSig.output(txtOfp);
00596 }
00597
00598 oneTypeCnt = oneAtomSig.angleSigIndices.size();
00599 fprintf(txtOfp, "%d !%sSIGS\n", oneTypeCnt, "NTHETA");
00600 for(int j=0; j<oneTypeCnt; j++)
00601 {
00602 SigIndex idx = oneAtomSig.angleSigIndices[j];
00603 TupleSignature& tSig = sigsOfAngles[idx];
00604 tSig.output(txtOfp);
00605 }
00606
00607 oneTypeCnt = oneAtomSig.dihedralSigIndices.size();
00608 fprintf(txtOfp, "%d !%sSIGS\n", oneTypeCnt, "NPHI");
00609 for(int j=0; j<oneTypeCnt; j++)
00610 {
00611 SigIndex idx = oneAtomSig.dihedralSigIndices[j];
00612 TupleSignature& tSig = sigsOfDihedrals[idx];
00613 tSig.output(txtOfp);
00614 }
00615
00616 oneTypeCnt = oneAtomSig.improperSigIndices.size();
00617 fprintf(txtOfp, "%d !%sSIGS\n", oneTypeCnt, "NIMPHI");
00618 for(int j=0; j<oneTypeCnt; j++)
00619 {
00620 SigIndex idx = oneAtomSig.improperSigIndices[j];
00621 TupleSignature& tSig = sigsOfImpropers[idx];
00622 tSig.output(txtOfp);
00623 }
00624
00625 oneTypeCnt = oneAtomSig.crosstermSigIndices.size();
00626 fprintf(txtOfp, "%d !%sSIGS\n", oneTypeCnt, "NCRTERM");
00627 for(int j=0; j<oneTypeCnt; j++)
00628 {
00629 SigIndex idx = oneAtomSig.crosstermSigIndices[j];
00630 TupleSignature& tSig = sigsOfCrossterms[idx];
00631 tSig.output(txtOfp);
00632 }
00633 }
00634
00635
00636 int exclSigCnt = sigsOfExclusions.size();
00637 fprintf(txtOfp, "%d !NEXCLSIGS\n", exclSigCnt);
00638 for(int i=0; i<exclSigCnt; i++)
00639 {
00640 ExclSigInfo *sig = &sigsOfExclusions[i];
00641
00642 fprintf(txtOfp, "%d", sig->fullExclOffset.size());
00643 for(int j=0; j<sig->fullExclOffset.size(); j++)
00644 fprintf(txtOfp, " %d", sig->fullExclOffset[j]);
00645 fprintf(txtOfp, "\n");
00646
00647
00648 fprintf(txtOfp, "%d", sig->modExclOffset.size());
00649 for(int j=0; j<sig->modExclOffset.size(); j++)
00650 fprintf(txtOfp, " %d", sig->modExclOffset[j]);
00651 fprintf(txtOfp, "\n");
00652 }
00653
00654
00655 fprintf(txtOfp, "%d !NCLUSTERS\n", g_numClusters);
00656
00657
00658 fprintf(txtOfp, "%d !NATOM\n", g_mol->numAtoms);
00659 fprintf(txtOfp, "%d !NHYDROGENGROUP\n", g_mol->numHydrogenGroups);
00660 fprintf(txtOfp, "%d !MAXHYDROGENGROUPSIZE\n", g_mol->maxHydrogenGroupSize);
00661 fprintf(txtOfp, "%d !NMIGRATIONGROUP\n", g_mol->numMigrationGroups);
00662 fprintf(txtOfp, "%d !MAXMIGRATIONGROUPSIZE\n", g_mol->maxMigrationGroupSize);
00663
00664
00665 fprintf(txtOfp, "%d !RIGIDBONDTYPE\n", g_simParam->rigidBonds);
00666 #if 0
00667 const float *atomOccupancy = g_mol->getOccupancyData();
00668 const float *atomBFactor = g_mol->getBFactorData();
00669 fprintf(txtOfp, "%d !OCCUPANCYVALID\n", (atomOccupancy==NULL)?0:1);
00670 fprintf(txtOfp, "%d !TEMPFACTORVALID\n", (atomBFactor==NULL)?0:1);
00671
00672 float *zeroFloats = NULL;
00673 if(atomOccupancy==NULL || atomBFactor==NULL) {
00674 zeroFloats = new float[g_mol->numAtoms];
00675 memset(zeroFloats, 0, sizeof(float)*g_mol->numAtoms);
00676 if(atomOccupancy==NULL) atomOccupancy = (const float *)zeroFloats;
00677 if(atomBFactor==NULL) atomBFactor = (const float *)zeroFloats;
00678 }
00679 #endif
00680
00681 Atom *atoms = g_mol->getAtoms();
00682 HydrogenGroupID *hg = g_mol->hydrogenGroup.begin();
00683
00684
00685 int magicNum = COMPRESSED_PSF_MAGICNUM;
00686 fwrite(&magicNum, sizeof(int), 1, binOfp);
00687
00688 float verNum = (float)COMPRESSED_PSF_VER;
00689 fwrite(&verNum, sizeof(float), 1, binOfp);
00690
00691 int recSize = sizeof(OutputAtomRecord);
00692 fwrite(&recSize, sizeof(int), 1, binOfp);
00693
00694 OutputAtomRecord oneRec;
00695 for(int i=0; i<g_mol->numAtoms; i++)
00696 {
00697 oneRec.sSet.segNameIdx = atomData[i].segNameIdx;
00698 oneRec.sSet.resNameIdx = atomData[i].resNameIdx;
00699 oneRec.sSet.atomNameIdx = atomData[i].atomNameIdx;
00700 oneRec.sSet.atomTypeIdx = atomData[i].atomTypeIdx;
00701 oneRec.sSet.chargeIdx = atomData[i].chargeIdx;
00702 oneRec.sSet.massIdx = atomData[i].massIdx;
00703 oneRec.iSet.atomSigIdx = atomData[i].atomSigIdx;
00704
00705 oneRec.iSet.exclSigIdx = atomData[i].exclSigIdx;
00706 oneRec.sSet.vdw_type = atoms[i].vdw_type;
00707 oneRec.iSet.resID = atomData[i].resID;
00708 int hydIdx = atoms[i].hydrogenList;
00709 oneRec.iSet.hydrogenList = hydIdx;
00710 oneRec.iSet.atomsInGroup = hg[hydIdx].atomsInGroup;
00711 oneRec.iSet.GPID = hg[hydIdx].GPID;
00712
00713 oneRec.iSet.atomsInMigrationGroup = hg[hydIdx].atomsInMigrationGroup;
00714 oneRec.iSet.MPID = hg[hydIdx].MPID;
00715
00716
00717 oneRec.fSet.rigidBondLength = g_mol->rigid_bond_length(i);
00718 fwrite(&oneRec, sizeof(OutputAtomRecord), 1, binOfp);
00719 }
00720
00721 delete[] atomData;
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732 fwrite(eachAtomClusterID, sizeof(int), g_mol->numAtoms, binOfp);
00733
00734 char *isWater = new char[g_mol->numAtoms];
00735 for(int i=0; i<g_mol->numAtoms; i++){
00736 isWater[i] = g_mol->is_water(i);
00737 }
00738 fwrite(isWater, sizeof(char), g_mol->numAtoms, binOfp);
00739 delete [] isWater;
00740 delete[] atoms;
00741 g_mol->hydrogenGroup.resize(0);
00742 delete[] eachAtomClusterID;
00743
00744
00745
00746
00747
00748
00749 fprintf(txtOfp, "!DIHEDRALPARAMARRAY\n");
00750 for(int i=0; i<g_param->NumDihedralParams; i++)
00751 {
00752 fprintf(txtOfp, "%d ", g_param->dihedral_array[i].multiplicity);
00753 }
00754 fprintf(txtOfp, "\n");
00755 fprintf(txtOfp, "!IMPROPERPARAMARRAY\n");
00756 for(int i=0; i<g_param->NumImproperParams; i++)
00757 {
00758 fprintf(txtOfp, "%d ", g_param->improper_array[i].multiplicity);
00759 }
00760 fprintf(txtOfp, "\n");
00761 #endif
00762 }
00763
00764 void buildAtomData()
00765 {
00766 #ifndef MEM_OPT_VERSION
00767 int numAtoms = g_mol->numAtoms;
00768
00769
00770 atomData = new BasicAtomInfo[numAtoms];
00771 Atom *atoms = g_mol->getAtoms();
00772 AtomNameInfo *atomNames = g_mol->getAtomNames();
00773 AtomSegResInfo *atomSegResids = g_mol->getAtomSegResInfo();
00774
00775 for(int atomID=0; atomID < numAtoms; atomID++)
00776 {
00777
00778 int poolIndex;
00779 HashString fieldName;
00780 fieldName.assign(atomSegResids[atomID].segname);
00781 poolIndex = segNamePool.lookupCstPool(fieldName);
00782 if(poolIndex==-1)
00783 {
00784 segNamePool.push_back(fieldName);
00785 poolIndex = segNamePool.size()-1;
00786 }
00787 atomData[atomID].segNameIdx = poolIndex;
00788
00789 atomData[atomID].resID = atomSegResids[atomID].resid;
00790
00791 fieldName.assign(atomNames[atomID].resname);
00792 poolIndex = resNamePool.lookupCstPool(fieldName);
00793 if(poolIndex==-1)
00794 {
00795 resNamePool.push_back(fieldName);
00796 poolIndex = resNamePool.size()-1;
00797 }
00798 atomData[atomID].resNameIdx = poolIndex;
00799
00800 fieldName.assign(atomNames[atomID].atomname);
00801 poolIndex = atomNamePool.lookupCstPool(fieldName);
00802 if(poolIndex==-1)
00803 {
00804 atomNamePool.push_back(fieldName);
00805 poolIndex = atomNamePool.size()-1;
00806 }
00807 atomData[atomID].atomNameIdx = poolIndex;
00808
00809 fieldName.assign(atomNames[atomID].atomtype);
00810 poolIndex = atomTypePool.lookupCstPool(fieldName);
00811 if(poolIndex==-1)
00812 {
00813 atomTypePool.push_back(fieldName);
00814 poolIndex = atomTypePool.size()-1;
00815 }
00816 atomData[atomID].atomTypeIdx = poolIndex;
00817
00818 poolIndex = chargePool.lookupCstPool(atoms[atomID].charge);
00819 if(poolIndex==-1)
00820 {
00821 chargePool.push_back(atoms[atomID].charge);
00822 poolIndex = chargePool.size()-1;
00823 }
00824 atomData[atomID].chargeIdx = poolIndex;
00825
00826 poolIndex = massPool.lookupCstPool(atoms[atomID].mass);
00827 if(poolIndex==-1)
00828 {
00829 massPool.push_back(atoms[atomID].mass);
00830 poolIndex = massPool.size()-1;
00831 }
00832 atomData[atomID].massIdx = poolIndex;
00833 }
00834
00835
00836
00837 delete [] atomNames;
00838 delete [] atomSegResids;
00839 #endif
00840 }
00841
00842
00843 void buildBondData()
00844 {
00845 #ifndef MEM_OPT_VERSION
00846 Bond *bonds = g_mol->getAllBonds();
00847
00848
00849 for(int i=0; i<g_mol->numBonds; i++)
00850 {
00851 Bond *b = bonds+i;
00852 TupleSignature oneSig(1,BOND,b->bond_type);
00853 oneSig.offset[0] = b->atom2 - b->atom1;
00854 oneSig.isReal = (i<g_mol->numRealBonds);
00855
00856 int poolIndex = sigsOfBonds.lookupCstPool(oneSig);
00857 int newSig=0;
00858 if(poolIndex == -1)
00859 {
00860 sigsOfBonds.push_back(oneSig);
00861 poolIndex = (SigIndex)sigsOfBonds.size()-1;
00862 newSig=1;
00863 }
00864
00865 if(!newSig)
00866 {
00867 int dupIdx = lookupCstPool(eachAtomSigs[b->atom1].bondSigIndices, (SigIndex)poolIndex);
00868 if(dupIdx!=-1)
00869 {
00870 char err_msg[128];
00871 sprintf(err_msg, "Duplicate bond %d-%d!", b->atom1+1, b->atom2+1);
00872 NAMD_die(err_msg);
00873 }
00874 }
00875 eachAtomSigs[b->atom1].bondSigIndices.push_back(poolIndex);
00876 }
00877
00878
00879 for(int i=0; i<g_mol->numBonds; i++)
00880 {
00881 Bond *b=bonds+i;
00882 int atom2 = b->atom2;
00883 int thisOffset = atom2 - b->atom1;
00884 for(int j=0; j<eachAtomSigs[atom2].bondSigIndices.size(); j++)
00885 {
00886 SigIndex atom2BondId = eachAtomSigs[atom2].bondSigIndices[j];
00887 TupleSignature *secSig = &(sigsOfBonds[atom2BondId]);
00888 if(thisOffset== -(secSig->offset[0]))
00889 {
00890 char err_msg[128];
00891 sprintf(err_msg, "Duplicate bond %d-%d because two atoms are just reversed!", b->atom1+1, atom2+1);
00892 NAMD_die(err_msg);
00893 }
00894 }
00895 }
00896
00897
00898
00899 vector<int> *atomListOfBonded = new vector<int>[g_mol->numAtoms];
00900
00901 for(int i=0; i<g_mol->numRealBonds; i++)
00902 {
00903 Bond *b=bonds+i;
00904 int atom1 = b->atom1;
00905 int atom2 = b->atom2;
00906 atomListOfBonded[atom1].push_back(atom2);
00907 atomListOfBonded[atom2].push_back(atom1);
00908 }
00909
00910 delete [] bonds;
00911
00912
00913
00914
00915
00916
00917 eachAtomClusterID = new int[g_mol->numAtoms];
00918 for(int i=0; i<g_mol->numAtoms; i++)
00919 eachAtomClusterID[i] = -1;
00920
00921
00922
00923
00924
00925
00926 for(int i=0; i<g_mol->numAtoms; i++)
00927 {
00928 int curClusterID=eachAtomClusterID[i];
00929
00930 if(curClusterID!=-1) continue;
00931
00932 curClusterID=i;
00933 deque<int> toVisitAtoms;
00934 toVisitAtoms.push_back(i);
00935 while(!toVisitAtoms.empty())
00936 {
00937 int visAtomID = toVisitAtoms.front();
00938 toVisitAtoms.pop_front();
00939 eachAtomClusterID[visAtomID] = curClusterID;
00940 for(int j=0; j<atomListOfBonded[visAtomID].size(); j++)
00941 {
00942 int otherAtom = atomListOfBonded[visAtomID][j];
00943 if(eachAtomClusterID[otherAtom]!=curClusterID)
00944 toVisitAtoms.push_back(otherAtom);
00945 }
00946 }
00947 }
00948
00949 #if 0
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975 int curClusterID;
00976 int prevClusterID = eachAtomClusterID[0];
00977 int curClusterSize = 1;
00978
00979 for(int i=1; i<g_mol->numAtoms; i++){
00980 curClusterID = eachAtomClusterID[i];
00981 if(curClusterID == prevClusterID){
00982 curClusterSize++;
00983 }else{
00984 eachClusterSize.push_back(curClusterSize);
00985 eachClusterID.push_back(prevClusterID);
00986 curClusterSize=1;
00987 }
00988 prevClusterID = curClusterID;
00989 }
00990
00991 eachClusterSize.push_back(curClusterSize);
00992 eachClusterID.push_back(prevClusterID);
00993
00994
00995
00996 g_isClusterContiguous = 1;
00997 int *newClusterIDs = new int[eachClusterID.size()];
00998 memset(newClusterIDs, 0, sizeof(int)*eachClusterID.size());
00999 prevClusterID = eachClusterID[0];
01000 int newCId = 0;
01001 newClusterIDs[0] = newCId;
01002 for(int seg=1; seg<eachClusterID.size(); seg++){
01003 curClusterID = eachClusterID[seg];
01004 if(curClusterID > prevClusterID){
01005 newClusterIDs[seg] = ++newCId;
01006 prevClusterID = curClusterID;
01007 }else{
01008
01009 g_isClusterContiguous = 0;
01010
01011
01012
01013 int jl=0, jh=seg-2;
01014 int isFound = 0;
01015 while(jh>=jl){
01016 int mid = (jl+jh)/2;
01017 if(curClusterID > eachClusterID[mid])
01018 jl = mid+1;
01019 else if(curClusterID < eachClusterID[mid])
01020 jh = mid-1;
01021 else{
01022 newClusterIDs[seg] = newClusterIDs[mid];
01023 isFound = 1;
01024 break;
01025 }
01026 }
01027 if(!isFound){
01028
01029 char errmsg[300];
01030 sprintf(errmsg, "Assumption about building cluster is broken in file %s at line %d\n", __FILE__, __LINE__);
01031 NAMD_die(errmsg);
01032 }
01033 }
01034 }
01035
01036
01037
01038
01039 g_numClusters = newCId+1;
01040 if(g_isClusterContiguous){
01041 int aid=0;
01042 for(int seg=0; seg<eachClusterSize.size(); seg++)
01043 {
01044 int curSize = eachClusterSize[seg];
01045 eachAtomClusterID[aid] = curSize;
01046 for(int i=aid+1; i<aid+curSize; i++)
01047 eachAtomClusterID[i] = -1;
01048 aid += curSize;
01049 }
01050 }else{
01051 int aid=0;
01052 for(int seg=0; seg<eachClusterSize.size(); seg++)
01053 {
01054 int curSize = eachClusterSize[seg];
01055 for(int i=aid; i<aid+curSize; i++)
01056 eachAtomClusterID[i] = newClusterIDs[seg];
01057 aid += curSize;
01058 }
01059 }
01060 free(newClusterIDs);
01061 eachClusterSize.clear();
01062 eachClusterID.clear();
01063 #endif
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073 for(int i=0; i<g_mol->numAtoms; i++)
01074 atomListOfBonded[i].clear();
01075 delete [] atomListOfBonded;
01076 #endif
01077 }
01078
01079 void buildAngleData()
01080 {
01081 #ifndef MEM_OPT_VERSION
01082 Angle *angles = g_mol->getAllAngles();
01083
01084 for(int i=0; i<g_mol->numAngles; i++)
01085 {
01086 Angle *tuple = angles+i;
01087 TupleSignature oneSig(2,ANGLE,tuple->angle_type);
01088 int offset[2];
01089 offset[0] = tuple->atom2 - tuple->atom1;
01090 offset[1] = tuple->atom3 - tuple->atom1;
01091 oneSig.setOffsets(offset);
01092
01093 int poolIndex = sigsOfAngles.lookupCstPool(oneSig);
01094 if(poolIndex == -1)
01095 {
01096 sigsOfAngles.push_back(oneSig);
01097 poolIndex = (SigIndex)sigsOfAngles.size()-1;
01098 }
01099 eachAtomSigs[tuple->atom1].angleSigIndices.push_back(poolIndex);
01100 }
01101 delete [] angles;
01102 #endif
01103 }
01104
01105 void buildDihedralData()
01106 {
01107 #ifndef MEM_OPT_VERSION
01108 Dihedral *dihedrals = g_mol->getAllDihedrals();
01109
01110
01111 for(int i=0; i<g_mol->numDihedrals; i++)
01112 {
01113 Dihedral *tuple = dihedrals+i;
01114 TupleSignature oneSig(3,DIHEDRAL,tuple->dihedral_type);
01115 int offset[3];
01116 offset[0] = tuple->atom2 - tuple->atom1;
01117 offset[1] = tuple->atom3 - tuple->atom1;
01118 offset[2] = tuple->atom4 - tuple->atom1;
01119 oneSig.setOffsets(offset);
01120
01121 int poolIndex = sigsOfDihedrals.lookupCstPool(oneSig);
01122 if(poolIndex == -1)
01123 {
01124 sigsOfDihedrals.push_back(oneSig);
01125 poolIndex = (SigIndex)sigsOfDihedrals.size()-1;
01126 }
01127 eachAtomSigs[tuple->atom1].dihedralSigIndices.push_back(poolIndex);
01128 }
01129
01130 delete[] dihedrals;
01131 #endif
01132 }
01133
01134 void buildImproperData()
01135 {
01136 #ifndef MEM_OPT_VERSION
01137 Improper *impropers=g_mol->getAllImpropers();
01138
01139
01140 for(int i=0; i<g_mol->numImpropers; i++)
01141 {
01142 Improper *tuple = impropers+i;
01143 TupleSignature oneSig(3,IMPROPER,tuple->improper_type);
01144 int offset[3];
01145 offset[0] = tuple->atom2 - tuple->atom1;
01146 offset[1] = tuple->atom3 - tuple->atom1;
01147 offset[2] = tuple->atom4 - tuple->atom1;
01148 oneSig.setOffsets(offset);
01149
01150 int poolIndex = sigsOfImpropers.lookupCstPool(oneSig);
01151 if(poolIndex == -1)
01152 {
01153 sigsOfImpropers.push_back(oneSig);
01154 poolIndex = (SigIndex)sigsOfImpropers.size()-1;
01155 }
01156 eachAtomSigs[tuple->atom1].improperSigIndices.push_back(poolIndex);
01157 }
01158
01159 delete[] impropers;
01160 #endif
01161 }
01162
01163 void buildCrosstermData()
01164 {
01165 #ifndef MEM_OPT_VERSION
01166 Crossterm *crossterms = g_mol->getAllCrossterms();
01167
01168 for(int i=0; i<g_mol->numCrossterms; i++)
01169 {
01170 Crossterm *tuple = crossterms+i;
01171 TupleSignature oneSig(7, CROSSTERM, tuple->crossterm_type);
01172 int offset[7];
01173 offset[0] = tuple->atom2 - tuple->atom1;
01174 offset[1] = tuple->atom3 - tuple->atom1;
01175 offset[2] = tuple->atom4 - tuple->atom1;
01176 offset[3] = tuple->atom5 - tuple->atom1;
01177 offset[4] = tuple->atom6 - tuple->atom1;
01178 offset[5] = tuple->atom7 - tuple->atom1;
01179 offset[6] = tuple->atom8 - tuple->atom1;
01180 oneSig.setOffsets(offset);
01181
01182 int poolIndex = sigsOfCrossterms.lookupCstPool(oneSig);
01183 if(poolIndex == -1)
01184 {
01185 sigsOfCrossterms.push_back(oneSig);
01186 poolIndex = (SigIndex)sigsOfCrossterms.size()-1;
01187 }
01188 eachAtomSigs[tuple->atom1].crosstermSigIndices.push_back(poolIndex);
01189 }
01190
01191 delete[] crossterms;
01192 #endif
01193 }
01194
01195 void buildExclusions()
01196 {
01197
01198
01199 UniqueSet<Exclusion> allExclusions;
01200
01201 int exclude_flag;
01202 exclude_flag = g_simParam->exclude;
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220 vector<int> *eachAtomNeighbors = new vector<int>[g_mol->numAtoms];
01221 for(int atom1=0; atom1<g_mol->numAtoms; atom1++)
01222 {
01223 AtomSigInfo *aSig = &atomSigPool[atomData[atom1].atomSigIdx];
01224 for(int j=0; j<aSig->bondSigIndices.size(); j++)
01225 {
01226 TupleSignature *tSig = &sigsOfBonds[aSig->bondSigIndices[j]];
01227 if(!tSig->isReal) continue;
01228 int atom2 = atom1+tSig->offset[0];
01229 eachAtomNeighbors[atom1].push_back(atom2);
01230 eachAtomNeighbors[atom2].push_back(atom1);
01231 }
01232 }
01233
01234 if (!g_simParam->amberOn || !g_simParam->readExclusions)
01235 {
01236 switch (exclude_flag)
01237 {
01238 case NONE:
01239 break;
01240 case ONETWO:
01241 build12Excls(allExclusions, eachAtomNeighbors);
01242 break;
01243 case ONETHREE:
01244 build12Excls(allExclusions, eachAtomNeighbors);
01245 build13Excls(allExclusions, eachAtomNeighbors);
01246
01247 break;
01248 case ONEFOUR:
01249 build12Excls(allExclusions, eachAtomNeighbors);
01250 build13Excls(allExclusions, eachAtomNeighbors);
01251 build14Excls(allExclusions, eachAtomNeighbors, 0);
01252
01253 break;
01254 case SCALED14:
01255 build12Excls(allExclusions, eachAtomNeighbors);
01256 build13Excls(allExclusions, eachAtomNeighbors);
01257 build14Excls(allExclusions, eachAtomNeighbors, 1);
01258
01259 break;
01260 }
01261 }
01262
01263
01264
01265
01266
01267
01268 for(int i=0; i<g_mol->numAtoms; i++)
01269 eachAtomNeighbors[i].clear();
01270 delete [] eachAtomNeighbors;
01271
01272
01273 UniqueSetIter<Exclusion> exclIter(allExclusions);
01274 eachAtomExclSigs = new ExclSigInfo[g_mol->numAtoms];
01275 for(exclIter=exclIter.begin(); exclIter!=exclIter.end(); exclIter++)
01276 {
01277 int atom1 = exclIter->atom1;
01278 int atom2 = exclIter->atom2;
01279 int offset21 = atom2-atom1;
01280 if(exclIter->modified)
01281 {
01282 eachAtomExclSigs[atom1].modExclOffset.push_back(offset21);
01283 eachAtomExclSigs[atom2].modExclOffset.push_back(-offset21);
01284 }
01285 else
01286 {
01287 eachAtomExclSigs[atom1].fullExclOffset.push_back(offset21);
01288 eachAtomExclSigs[atom2].fullExclOffset.push_back(-offset21);
01289 }
01290 }
01291 allExclusions.clear();
01292
01293
01294
01295 for(int i=0; i<g_mol->numAtoms; i++)
01296 {
01297 eachAtomExclSigs[i].sortExclOffset();
01298 int poolIndex = sigsOfExclusions.lookupCstPool(eachAtomExclSigs[i]);
01299 if(poolIndex==-1)
01300 {
01301 poolIndex = sigsOfExclusions.size();
01302 sigsOfExclusions.push_back(eachAtomExclSigs[i]);
01303 }
01304 atomData[i].exclSigIdx = poolIndex;
01305 }
01306 delete [] eachAtomExclSigs;
01307 eachAtomExclSigs = NULL;
01308 printf("Exclusion signatures: %d\n", (int)sigsOfExclusions.size());
01309 }
01310
01311 void build12Excls(UniqueSet<Exclusion>& allExcls, vector<int> *eachAtomNeighbors)
01312 {
01313 for(int atom1=0; atom1<g_mol->numAtoms; atom1++)
01314 {
01315 vector<int> *atom1List = &eachAtomNeighbors[atom1];
01316 for(int j=0; j<atom1List->size(); j++)
01317 {
01318 int atom2 = atom1List->at(j);
01319 if(atom1<atom2)
01320 allExcls.add(Exclusion(atom1, atom2));
01321 else
01322 allExcls.add(Exclusion(atom2, atom1));
01323 }
01324 }
01325 }
01326
01327 void build13Excls(UniqueSet<Exclusion>& allExcls, vector<int> *eachAtomNeighbors)
01328 {
01329 for(int atom1=0; atom1<g_mol->numAtoms; atom1++)
01330 {
01331 vector<int> *atom1List = &eachAtomNeighbors[atom1];
01332 for(int j=0; j<atom1List->size(); j++)
01333 {
01334 int atom2 = atom1List->at(j);
01335 vector<int> *atom2List = &eachAtomNeighbors[atom2];
01336 for(int k=0; k<atom2List->size(); k++)
01337 {
01338 int atom3 = atom2List->at(k);
01339
01340 if(atom3 == atom1)
01341 continue;
01342 if(atom1<atom3)
01343 allExcls.add(Exclusion(atom1, atom3));
01344 else
01345 allExcls.add(Exclusion(atom3, atom1));
01346 }
01347 }
01348 }
01349 }
01350
01351 void build14Excls(UniqueSet<Exclusion>& allExcls, vector<int> *eachAtomNeighbors, int modified)
01352 {
01353 for(int atom1=0; atom1<g_mol->numAtoms; atom1++)
01354 {
01355 vector<int> *atom1List = &eachAtomNeighbors[atom1];
01356 for(int j=0; j<atom1List->size(); j++)
01357 {
01358 int atom2 = atom1List->at(j);
01359 vector<int> *atom2List = &eachAtomNeighbors[atom2];
01360 for(int k=0; k<atom2List->size(); k++)
01361 {
01362 int atom3 = atom2List->at(k);
01363
01364 if(atom3 == atom1)
01365 continue;
01366 vector<int> *atom3List = &eachAtomNeighbors[atom3];
01367 for(int l=0; l<atom3List->size(); l++)
01368 {
01369 int atom4 = atom3List->at(l);
01370
01371 if(atom4 == atom2)
01372 continue;
01373 if(atom1<atom4)
01374 allExcls.add(Exclusion(atom1, atom4, modified));
01375 else
01376 allExcls.add(Exclusion(atom4, atom1, modified));
01377 }
01378 }
01379 }
01380 }
01381 }
01382
01383 template <class T> void HashPool<T>::dump_tables()
01384 {
01385 for(int j=0; j < pool.size(); j++) {
01386 HashPoolAdaptorT<T>* pval = pool[j];
01387 CmiPrintf("Pool[%d]=%p %p hash = %d\n",j,pool[j],pval,pval->hash());
01388 }
01389 CkHashtableIterator *iter = index_table.iterator();
01390 void *key,*indx;
01391 while (iter->hasNext()) {
01392 indx = iter->next(&key);
01393 HashPoolAdaptorT<T> *pkey = (HashPoolAdaptorT<T>*)key;
01394 CmiPrintf("key %p indx %p %d hash=%d\n",key,indx,*((int *)indx),pkey->hash());
01395 }
01396 }