def element_vector(f, phi, Omega_e, symbolic=True):
n = len(phi)
b_e = sp.zeros((n, 1))
# Make f a function of X
X = sp.Symbol('X')
if symbolic:
h = sp.Symbol('h')
else:
h = Omega_e[1] - Omega_e[0]
x = (Omega_e[0] + Omega_e[1])/2 + h/2*X # mapping
f = f.subs('x', x) # substitute mapping formula for x
detJ = h/2 # dx/dX
for r in range(n):
b_e[r] = sp.integrate(f*phi[r]*detJ, (X, -1, 1))
return b_e
Note f.subs('x', x)
: replace x
by \( x(X) \) such that f
contains X