numPts = input("Enter: ") print "\nWhich PDE parameter? (e.g. 1.0)" pdeParam = input("Enter: ") print "" exprTrueSol = sympy.exp(sympy.Symbol('x')) + (1 - sympy.Symbol('x')) trueSol = sympy.lambdify( (sympy.Symbol('x'), sympy.Symbol('y'), sympy.Symbol('z')), exprTrueSol, modules=['numpy']) secLapBelTps = partial(secLapBelTps4Kernel, pDeParam=pdeParam) lapBelTps = partial(lapBelTps4Kernel, pDeParam=pdeParam) ptSet = getPtsFibonacciSphere(numPts) collMtrx = buildSpecialSymCollMtrx(ptSet, ptSet, secLapBelTps, pdeParam) exprRhs = computeLapBelOp(exprTrueSol, pdeParam) rhsFct = sympy.lambdify( (sympy.Symbol('x'), sympy.Symbol('y'), sympy.Symbol('z')), exprRhs, modules=['numpy']) rhs = np.zeros(numPts + 16) for idx in range(numPts): rhs[idx] = rhsFct(ptSet[idx, 0], ptSet[idx, 1], ptSet[idx, 2]) lagCoeff = np.linalg.solve(collMtrx, rhs) numEvalPts = 250 evalPtSet = getPtsFibonacciSphere(numEvalPts, 1)
from miscFcts import locLagPrecon, gmresCounter def rhsFct(x, y, z): return np.exp(x) * (1 - x) print("\nHow many interpolation points? (e.g. 150)") numPts = int(input("Enter: ")) print("\nWhich local radius? (e.g. 7.0)") locRadius = float(input("Enter: ")) print("\nWhich GMRES tolerance? (e.g. 1e-10)") gmresTol = float(input("Enter: ")) print("") ptSet = getPtsFibonacciSphere(numPts) kdTree = scipy.spatial.KDTree(ptSet) kernelMtrx = buildKernelMtrxCond(ptSet, ptSet, tpsKernelSphere) preconMtrx, numNeighb = locLagPrecon(ptSet, kdTree, locRadius, buildKernelMtrxCond, tpsKernelSphere, 4) conditionedMtrx = kernelMtrx.dot(preconMtrx) conditionedMtrx = conditionedMtrx[0:numPts, 0:numPts] print('Number of neighbors for localisation:') print('\tn =', numNeighb) print('\nEffect of preconditioner:') print('\tcond(K) =', np.linalg.cond(kernelMtrx)) print('\tcond(KP) =', np.linalg.cond(conditionedMtrx))
from miscFcts import locLagPrecon, gmresCounter def rhsFct(x, y, z): return np.exp(x) * (1 - x) print("\nHow many interpolation points? (e.g. 150)") numPts = int(input("Enter: ")) print("\nWhich local radius? (e.g. 7.0)") locRadius = float(input("Enter: ")) print("\nWhich GMRES tolerance? (e.g. 1e-10)") gmresTol = float(input("Enter: ")) print("") ptSet = getPtsFibonacciSphere(samples=numPts) np.savetxt("ptset.txt", ptSet) kdTree = scipy.spatial.KDTree(ptSet) kernelMtrx = buildKernelMtrxCond(ptSet, ptSet, tpsKernelSphere) np.savetxt("kernelMtrxCond.txt", kernelMtrx) preconMtrx, numNeighb = locLagPrecon(ptSet, kdTree, locRadius, buildKernelMtrxCond, tpsKernelSphere, 4) pre = np.identity(numPts + 4) pre[:, 0:numPts] = preconMtrx np.savetxt("preconditioner.txt", pre) conditionedMtrx = kernelMtrx.dot(pre) conditionedMtrx = conditionedMtrx[0:numPts, 0:numPts] np.savetxt("conditionedMtrx.txt", conditionedMtrx)