def findShapeFunction(uN, dim, nCoeff, pnts, pascale, serendipity, powCombination): fop = g.PolynomialModelling(dim, nCoeff, pnts) fop.setPascalsStyle(pascale) fop.setSerendipityStyle(serendipity) fop.setPowCombinationTmp(powCombination) fop2 = g.PolynomialModelling(2, 3, pnts) fop2.setPascalsStyle(True) xy = g.RPolynomialFunction(g.RVector(fop2.polynomialFunction().size())) xy.fill(fop2.startModel()) print("xy:", xy) start = g.RVector(27) start.setVal((xy).coeff()[0:9], 0, 9) start.setVal((xy).coeff()[0:9], 9, 18) start.setVal((xy).coeff()[0:9], 18, 27) start[18 + 2] = 0 start[18 + 4] = 0 start[18 + 6] = 0 print(start) fop.setStartModel(start) # print fop.setStartModel() tmp = g.RPolynomialFunction(g.RVector(fop.polynomialFunction().size())) tmp.fill(fop.startModel()) print("base:", tmp) inv = g.RInversion(uN, fop, False, False) inv.setRelativeError(0.0) inv.setLambda(0) inv.stopAtChi1(False) inv.setCGLSTolerance(1e-40) inv.setMaxIter(20) coeff = inv.run() N = fop.polynomialFunction() return N
def findMatrix(uN, dim, nCoeff, ptns, pascale, serendipity): fop = g.PolynomialModelling(dim, nCoeff, pnts) fop.setPascalsStyle(pascale) fop.setSerendipityStyle(serendipity) tmp = g.RPolynomialFunction(g.RVector(fop.polynomialFunction().size())) tmp.fill(fop.startModel()) print("base:", tmp) G = P.zeros((len(pnts), len(tmp.elements()))) for i, p in enumerate(pnts): for j, e in enumerate(tmp.elements()): G[i, j] = e(p) GI = P.inv(G) coef = P.dot(GI, uN) print(coef) print(P.dot(G, coef)) tmp.fill(g.asvector(coef)) print(coef, tmp) return tmp
surf = ax1.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=P.cm.jet, linewidth=0) ax2.set_title(label + N.__str__()) fig.colorbar(surf) e1 = [1, -1] # 1-r e2 = [0, +1] # r E2_1R = g.RPolynomialFunction(g.asvector(e1)) E2_2R = g.RPolynomialFunction(g.asvector(e2)) E2_1S = g.RPolynomialFunction(g.RVector(), g.asvector(e1)) E2_2S = g.RPolynomialFunction(g.RVector(), g.asvector(e2)) E2_1T = g.RPolynomialFunction(g.RVector(), g.RVector(), g.asvector(e1)) E2_2T = g.RPolynomialFunction(g.RVector(), g.RVector(), g.asvector(e2)) E3_1R = E2_1R * (E2_1R - E2_2R) E3_2R = E2_2R * (E2_2R - E2_1R) E3_3R = 4. * (E2_1R * E2_2R) E3_1S = E2_1S * (E2_1S - E2_2S) E3_2S = E2_2S * (E2_2S - E2_1S) E3_3S = 4. * (E2_1S * E2_2S) E3_1T = E2_1T * (E2_1T - E2_2T)