# Run and time assembly t = -timeit.default_timer() A = assemble(dofmap, a, dtype=numpy.float64) t += timeit.default_timer() print('Assembly time a: {}'.format(t)) b = numpy.zeros(A.shape[0], dtype=A.dtype) x = numpy.zeros_like(b) # Set some BCs - fix bottom edge, and move top corner bc_dofs = list(range(n * 2 + 2)) + [len(b) - 2, len(b) - 1] bc_vals = numpy.zeros_like(bc_dofs, dtype=A.dtype) bc_vals[-2] = 0.01 bc_apply(bc_dofs, bc_vals, A, b) print('bnorm = ', numpy.linalg.norm(b)) print('Anorm = ', scipy.sparse.linalg.norm(A)) t = -timeit.default_timer() x = scipy.sparse.linalg.spsolve(A, b) t += timeit.default_timer() print('Solve time: {}'.format(t)) res = b - A * x print(len(res), len(b), len(x)) print("residual: ", numpy.linalg.norm(res), res.max(), res.min()) # Plotting...
for i, x in enumerate(mesh.vertices): if (x[0] == -10.0): idx = i * 3 dofs.append(idx) vals.append(0.0) dofs.append(idx + 1) vals.append(0.0) dofs.append(idx + 2) vals.append(0.0) if (x[0] == 0.0): idx = i * 3 + 1 dofs.append(idx) vals.append(0.1) bc_apply(dofs, numpy.array(vals, dtype=A.dtype), A, b) # Null space B = numpy.zeros((A.shape[0], 6), dtype=A.dtype) # Translation B[0::3, 0] = 1 B[1::3, 1] = 1 B[2::3, 2] = 1 # Rotation B[0::3, 3] = 1 B[1::3, 3] = -1 B[1::3, 4] = 1 B[2::3, 4] = -1 B[2::3, 5] = 1 B[0::3, 5] = -1 B = scipy.linalg.orth(B)