int CXXSurface::assignAtom (mmdb::PManager allAtomsManager_in, int selHnd){ void **pointerBuffer; mmdb::PPAtom selAtom; int nSelAtoms; double minDistSq; allAtomsManager_in->GetSelIndex(selHnd, selAtom, nSelAtoms); pointerBuffer = new void* [vertices.size()]; // Loop over all vertices for (int i=0; i< int(vertices.size()); i++){ const CXXCoord &vertex = coordRef(vectors["vertices"], i); int j; for (j = 0, minDistSq=1e30; j<nSelAtoms; j++){ CXXCoord atom (selAtom[j]->x, selAtom[j]->y, selAtom[j]->z); CXXCoord diff = atom - vertex; double dxsq = diff.x() * diff.x(); if (dxsq<minDistSq){ double dysq = diff.y() * diff.y(); if (dysq<minDistSq){ double dzsq = diff.z() * diff.z(); if (dzsq<minDistSq){ if (dxsq + dysq + dzsq < minDistSq){ pointerBuffer[i] = (void *) selAtom[j]; minDistSq = dxsq + dysq + dzsq; } } } } } } addPerVertexPointer ("atom", pointerBuffer); delete [] pointerBuffer; return 0; }
int CXXSurface::getCoord(const int type, const int iVertex, double *buffer) { if (type>=0 && type <= int(vectors.size())){ const CXXCoord &theCoord = coordRef(type, iVertex); for (int i=0; i<4; i++){ buffer[i] = theCoord.element(i); } return 0; } else return 1; }
std::string CXXSurface::report(){ double area = 0.; double pMin, pMax, pMean; int i; CXXCoord AB, AC, ABxAC; std::ostringstream output; output << "This surface has " << vertices.size() << " vertices and " << nTriangles << " triangles\n"; if (vectors.find("vertices") != vectors.end()){ for (i=0, area = 0.; i<nTriangles; i++){ const CXXCoord &coordA = coordRef(vectors["vertices"], i, 0); const CXXCoord &coordB = coordRef(vectors["vertices"], i, 1); const CXXCoord &coordC = coordRef(vectors["vertices"], i, 2); AB = coordA - coordB; AC = coordC - coordB; ABxAC = AB ^ AC; area += 0.5 * fabs(ABxAC.get3DLength()); } output << "The Molecular surface area is " << area << endl; } if (vectors.find("accessibles") != vectors.end()){ for (i=0, area = 0.; i<nTriangles; i++){ const CXXCoord &coordA = coordRef(vectors["accessibles"], i, 0); const CXXCoord &coordB = coordRef(vectors["accessibles"], i, 1); const CXXCoord &coordC = coordRef(vectors["accessibles"], i, 2); AB = coordA - coordB; AC = coordC - coordB; ABxAC = AB ^ AC; area += 0.5 * fabs(ABxAC.get3DLength()); } output << "The Solvent Accessible surface area is " << area << endl; } map<string, int>::iterator scalar; int j; for (scalar = scalars.begin(), j=0; scalar != scalars.end(); ++scalar, j++){ double potential; for (i=0, pMin = 1e30, pMax = -1e30, pMean = 0.; i<int(vertices.size()); i++){ potential = vertices[i].scalar(scalars[scalar->first]); pMin = (potential<pMin?potential:pMin); pMax = (potential>pMax?potential:pMax); pMean += potential; } pMean /= vertices.size(); output << "Property Number " << scalar->second //<< " name " << scalar->first << " Range " << pMin << " to " << pMax << " mean " << pMean << endl; } return output.str(); }
void NineFourNodeQuadUP::globalShapeFunction(double *dvol, double *w, int nint, int nen, int mode) { static double coord[2][9], xs[2][2], det, temp; int i, j, k, m; for (i=0; i<3; i++) { for (j=0; j<nen; j++) { for (k=0; k<nint; k++) { if (mode==0) shgu[i][j][k] = shlu[i][j][k]; if (mode==1) shgp[i][j][k] = shlp[i][j][k]; if (mode==2) shgq[i][j][k] = shlq[i][j][k]; } } } for (i=0; i<nen; i++) { const Vector &coordRef = theNodes[i]->getCrds(); coord[0][i] = coordRef(0); coord[1][i] = coordRef(1); } for (m=0; m<nint; m++) { for (i=0; i<2; i++) { for (j=0; j<2; j++) { xs[i][j] = 0.0; for (k=0; k<nen; k++) { if (mode==0) xs[i][j] += coord[j][k]*shgu[i][k][m]; if (mode==1) xs[i][j] += coord[j][k]*shgp[i][k][m]; if (mode==2) xs[i][j] += coord[j][k]*shgq[i][k][m]; } } } det = xs[0][0]*xs[1][1] - xs[0][1]*xs[1][0]; if (det < 0.0) { opserr << "WARNING NineFourNodeQuadUP: Determinant<=0 in tag " << this->getTag(); exit(-1); } for (i=0; i<nen; i++) { if (mode==0) { temp = (shgu[0][i][m]*xs[1][1] - shgu[1][i][m]*xs[0][1])/det; shgu[1][i][m] = (-shgu[0][i][m]*xs[1][0] + shgu[1][i][m]*xs[0][0])/det; shgu[0][i][m] = temp; } if (mode==1) { temp = (shgp[0][i][m]*xs[1][1] - shgp[1][i][m]*xs[0][1])/det; shgp[1][i][m] = (-shgp[0][i][m]*xs[1][0] + shgp[1][i][m]*xs[0][0])/det; shgp[0][i][m] = temp; } if (mode==2) { temp = (shgq[0][i][m]*xs[1][1] - shgq[1][i][m]*xs[0][1])/det; shgq[1][i][m] = (-shgq[0][i][m]*xs[1][0] + shgq[1][i][m]*xs[0][0])/det; shgq[0][i][m] = temp; } } dvol[m] = w[m]*thickness*det; } //end of m loop }