void refinement::adapt(const scalarField& sf) { setNewMesh(*sf.getMesh()); point P; double SLmax = sf.getMesh()->getMaxSL(); double SLmin = sf.getMesh()->getMinSL(); for (int i=0; i<nbXquads; i++) { P.X = i*h + xmin; for (int j=0; j<nbYquads; j++) { P.Y = j*h + ymin; double val = max(0.0,min(abs(sf(P.X, P.Y)),1.0)); operator()(i,j) = (1-val)*SLmax + val*SLmin; } } }
int interpolationConstants(const scalarField& f, int pos, double* con, bool useInner) { const pointSet* mesh = f.getMesh(); const point& P = mesh->P(pos); vector<int> neighb; //mesh->findPossibleNeighbours(P, neighb, useInner); for (int i=0; i<mesh->getNIDX(pos); i++) neighb.push_back(mesh->getIDX(pos,i)); int m = neighb.size(); double rhs[m]; int mi; double A[15*m]; double weight; double h2 = pow((mesh->getMaxSL()+mesh->getMinSL())/2,2); int orderFac = 15; if (m>14) orderFac = 15; else if (m>9) orderFac = 10; else if (m>5) orderFac = 6; else if (m>2) orderFac = 3; else throw mfpmExcept(20); for (int i=0; i<m; i++) { const point& Ptmp = mesh->P(neighb[i]); mi = orderFac*i; weight = exp(-2.00*P.dist2(Ptmp) / h2); A[mi+0] = weight*1.0; A[mi+1] = weight*Ptmp.X; A[mi+2] = weight*Ptmp.Y; if (orderFac>3) { A[mi+3] = weight*Ptmp.X*Ptmp.X; A[mi+4] = weight*Ptmp.X*Ptmp.Y; A[mi+5] = weight*Ptmp.Y*Ptmp.Y; } if (orderFac>6) { A[mi+6] = weight*Ptmp.X*Ptmp.X*Ptmp.X; A[mi+7] = weight*Ptmp.X*Ptmp.X*Ptmp.Y; A[mi+8] = weight*Ptmp.X*Ptmp.Y*Ptmp.Y; A[mi+9] = weight*Ptmp.Y*Ptmp.Y*Ptmp.Y; } if (orderFac>10) { A[mi+10] = weight*Ptmp.X*Ptmp.X*Ptmp.X*Ptmp.X; A[mi+11] = weight*Ptmp.X*Ptmp.X*Ptmp.X*Ptmp.Y; A[mi+12] = weight*Ptmp.X*Ptmp.X*Ptmp.Y*Ptmp.Y; A[mi+13] = weight*Ptmp.X*Ptmp.Y*Ptmp.Y*Ptmp.Y; A[mi+14] = weight*Ptmp.Y*Ptmp.Y*Ptmp.Y*Ptmp.Y; } rhs[i] = weight*f(neighb[i]); } int n = orderFac; double work[m+n]; int info, workl = m+n; int one = 1; char TN[] = "T"; dgels_(TN, &n, &m, &one, A, &n, rhs, &m, work, &workl, &info); for (int i=0; i<orderFac; i++) con[i] = rhs[i]; if (orderFac == 3) return 1; else if (orderFac == 6) return 2; else if (orderFac == 10) return 3; else if (orderFac > 10) return 4; return -1; }