Created
July 10, 2017 14:24
-
-
Save TheBB/9e9e3af4f0c91a7fccdd1f2aa0b94f96 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nutils import mesh, function, plot, _ | |
import numpy as np | |
import scipy as sp | |
nelems = 10 | |
xs = np.linspace(0, 1, nelems + 1) | |
ys = np.linspace(0, 1, nelems + 1) | |
domain, grid_geom = mesh.rectilinear([xs, ys]) | |
basis = domain.basis('spline', degree=3) | |
geom = grid_geom | |
grad = basis.grad(geom) | |
outer = function.outer(grad, grad) | |
integrand = outer.sum(-1) | |
matrix = domain.integrate(integrand, geometry=geom, ischeme='gauss4') | |
cons = domain.boundary.project(1, onto=basis, geometry=geom, ischeme='gauss4') | |
I, = np.where(np.isnan(cons)) | |
mx = matrix.toarray() | |
mx = mx[np.ix_(I, I)] | |
w, v = np.linalg.eigh(mx) | |
for i in range(len(I)): | |
dd = np.zeros((len(basis),)) | |
dd[I] = v[:,i] | |
bfun = basis.dot(dd) | |
points, colors = domain.elem_eval([geom, bfun], ischeme='bezier9', separate=True) | |
with plot.PyPlot('bfun', index=i) as plt: | |
plt.mesh(points, colors) | |
plt.colorbar() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment