void HFPlanner::computeHF(gridVertex vgoal) { //initialize potential to -1 and goal to 0 setPotential(vgoal, _goalPotential); //relax potential int numneighs = _wkSpace->getDimension()*2; graph_traits<gridGraph>::vertex_iterator vi, vend; graph_traits<gridGraph>::adjacency_iterator avi, avi_end; for(int i=0; i<_hfiter; i++) { for(tie(vi,vend)=vertices(*g); vi!=vend; ++vi) { if(getPotential(*vi) == _goalPotential || getPotential(*vi) == _obstaclePotential) continue; //cout << "cell "<<*vi<< " neighs = "; KthReal p=0; int count=0; int totalcount=0; for(tie(avi,avi_end)=adjacent_vertices(*vi, *g); avi!=avi_end; ++avi) { totalcount++; //cout<<*avi<<" "; if(_dirichlet != 0) { //dirichlet count++; p+=getPotential(*avi); } else { //neumann //cout<<"("<<getPotential(*avi)<<") "; if(getPotential(*avi) != _obstaclePotential) { count++; p+=getPotential(*avi); } } } //the borders of the cspace fixed to high for(;totalcount<numneighs;totalcount++) { count++; p+=_obstaclePotential; } //cout<<" POT= "<<p<<"/"<<count<<"= "<<p/count<<endl; if(count) setPotential(*vi, p/count); } } }
CXXSpace::CXXSpace(float probeRadius, float gridSpacing, float xMin, float xMax, float yMin, float yMax, float zMin, float zMax):SolventMap(gridSpacing, probeRadius, xMin, xMax, yMin, yMax, zMin, zMax) { saltConc = 0.0; temp = 300; // WARNING dummy value - if this is not set by defineBondaryConditions will raise and Exception... dielectricBoundary = -1; // constructor calls base class constructor (solvent map constructor) generating fftw optimised conservative // discrete grid - now need to make sure the chargeGrid uses the same dimensions and is consistent with the // optimised solvnetMap grid. try { chargeGrid = new double[dim[0]*dim[1]*dim[2]]; solvationGrid = new double[dim[0]*dim[1]*dim[2]]; potentialGrid = new double[dim[0]*dim[1]*dim[2]]; dielGrid = new CXXCoord[dim[0]*dim[1]*dim[2]]; epsilonKappaSq = new double[dim[0]*dim[1]*dim[2]]; if ((chargeGrid == 0) || (potentialGrid == 0) | (dielGrid == 0)) { CXXException theException = CXXException(" ERROR: (CXXSpace::CXXSpace()) :Could not reserve suffiecent memory !\n"); throw theException; } // set all values in chargeGrid / potentialGrid and dielectric Grids to 0 for (int i = 0; i < dim[0]; i++) { for (int j = 0; j < dim[1]; j++) { for (int k = 0; k < dim[2]; k++) { setChargeGrid(i, j, k, 0.); setPotential(i,j,k,0.); setDielGrid(i,j,k,0,0.); setDielGrid(i,j,k,1,0.); setDielGrid(i,j,k,2,0.); setSolvationGrid(i,j,k,0); } } } // If we got here no problems where identified so now give a simple status report about what is happening std::cout << "Generated Space: \nReal origin x: " << originOfGrid[0] << " y: " << originOfGrid[1] << " z: " << originOfGrid[2]; std::cout << " \nGrid dimensions i: " << dim[0] << " j: " << dim[1] << " k: " << dim[2]; std::cout << " \nGrid spacing: " << gridSpacing << " \nProbeRadius: " << probeRadius << "\n"; } catch (CXXException theExeption) { theExeption.Report(); throw theExeption; } }