void CFactorGraph::createGroups (void) { VarSignMap varGroups; FacSignMap facGroups; unsigned nIters = 0; bool groupsHaveChanged = true; const VarNodes& varNodes = groundFg_->varNodes(); const FacNodes& facNodes = groundFg_->facNodes(); while (groupsHaveChanged || nIters == 1) { nIters ++; unsigned prevFactorGroupsSize = facGroups.size(); facGroups.clear(); // set a new color to the factors with the same signature for (unsigned i = 0; i < facNodes.size(); i++) { const Signature& signature = getSignature (facNodes[i]); FacSignMap::iterator it = facGroups.find (signature); if (it == facGroups.end()) { it = facGroups.insert (make_pair (signature, FacNodes())).first; } it->second.push_back (facNodes[i]); } for (FacSignMap::iterator it = facGroups.begin(); it != facGroups.end(); it++) { Color newColor = getFreeColor(); FacNodes& groupMembers = it->second; for (unsigned i = 0; i < groupMembers.size(); i++) { setColor (groupMembers[i], newColor); } } // set a new color to the variables with the same signature unsigned prevVarGroupsSize = varGroups.size(); varGroups.clear(); for (unsigned i = 0; i < varNodes.size(); i++) { const Signature& signature = getSignature (varNodes[i]); VarSignMap::iterator it = varGroups.find (signature); if (it == varGroups.end()) { it = varGroups.insert (make_pair (signature, VarNodes())).first; } it->second.push_back (varNodes[i]); } for (VarSignMap::iterator it = varGroups.begin(); it != varGroups.end(); it++) { Color newColor = getFreeColor(); VarNodes& groupMembers = it->second; for (unsigned i = 0; i < groupMembers.size(); i++) { setColor (groupMembers[i], newColor); } } groupsHaveChanged = prevVarGroupsSize != varGroups.size() || prevFactorGroupsSize != facGroups.size(); } printGroups (varGroups, facGroups); createClusters (varGroups, facGroups); }
//! @brief read the actual phase space information unsigned long OneCLJGenerator::readPhaseSpace(ParticleContainer* particleContainer, std::list<ChemicalPotential>* lmu, Domain* domain, DomainDecompBase* domainDecomp) { vector<double> bBoxMin; vector<double> bBoxMax; // This is rather a hack to make sure that the ids of the molecules for each process are unique _moleculeCountOffset = (2 * domainDecomp->getRank()) * _numberOfMolecules / domainDecomp->getNumProcs(); Log::global_log->info() << "MoleculeCountOffset=" << _moleculeCountOffset << endl; bBoxMin.resize(3); bBoxMax.resize(3); for (int i = 0; i < 3; i++) { bBoxMin[i] = domainDecomp->getBoundingBoxMin(i, domain); bBoxMax[i] = domainDecomp->getBoundingBoxMax(i, domain); } if (_mode == "Homogeneous") { Log::global_log->info() << "OneCLJGenerator generating molecules. mode: " << _mode << " rho " << _rho << " T " << _temperature << " #molecules " << _numberOfMolecules << endl; createHomogeneousDist(particleContainer, bBoxMin, bBoxMax, domain, domainDecomp); } else if (_mode == "Cluster") { Log::global_log->info() << "OneCLJGenerator generating cluster distribution. " << " T " << _temperature << " #molecules " << _numberOfMolecules << " rho_gas " << _gasDensity << " rho_fluid " << _fluidDensity << endl; createClusters(particleContainer, bBoxMin, bBoxMax, domain, domainDecomp); } else { Log::global_log->error() << "Unknown mode \"" << _mode << "\"!" << endl; exit(1); } vector<Component>& dcomponents = domain->getComponents(); vector<unsigned long> partsPerComp; partsPerComp.resize(1); particleContainer->update(); particleContainer->deleteOuterParticles(); domain->setglobalNumMolecules(domainDecomp->countMolecules(particleContainer, partsPerComp)); for (unsigned int i = 0; i < partsPerComp.size(); i++) { dcomponents[i].setNumMolecules(partsPerComp[i]); domain->setglobalRotDOF(partsPerComp[i] * dcomponents[i].getRotationalDegreesOfFreedom()); } domain->setglobalRho(domain->getglobalNumMolecules() / (_simBoxLength[0] * _simBoxLength[1] * _simBoxLength[2])); return domain->getglobalNumMolecules(); }
int main(int argv, char *argc[]) { int return_value; numAlignsInCluster=0; FILE *fp1, *fp2, *fp3; fp1=fopen(argc[1],"r"); fp2=fopen(argc[2],"r"); fp3=fopen(argc[3],"w"); maxSizeInst = 330; if (argv == 5) maxSizeInst=atoi(argc[4]); //fprintf(stdout, "max Insert size = %d\n", maxSizeInst); EndClusterR=0; EndClusterF=0; return_value = fscanf( fp1,"%s\t%i\n", chroName, &chroSize); if( return_value != 2) { perror( "Error on fscanf"); exit( 1); } listOfOEA=(aligns **) malloc(chroSize*sizeof(aligns*)); listOfOEA_R=(int *) malloc(chroSize*sizeof(int)); listOfOEA_F=(int *) malloc(chroSize*sizeof(int)); for (int count=0; count< chroSize; count++) { listOfOEA[count]=NULL; listOfOEA_R[count]=0; listOfOEA_F[count]=0; } // printf("%s\t%i\n", chroName, chroSize); readTheAligns(fp2); createClusters(fp3); }