def run(geo, AllDirichlet=True, f=None): with context(): from pigasus.gallery.poisson import poisson import numpy as np import matplotlib.pyplot as plt PDE = poisson(geo, AllDirichlet=True) if f is None: sin = np.sin ; pi = np.pi ; kx = 2. * pi ; ky = 2. * pi f = lambda x,y : [( kx**2 + ky**2 ) * sin ( kx * x ) * sin ( ky * y )] PDE.assembly(f=f) PDE.solve() PDE.plot() plt.colorbar(); plt.show() PDE.free()
except NameError: AllDirichlet = None else: pass try: Metric except NameError: Metric = None else: pass # ... PDE = poisson(geometry=geo, bc_dirichlet=bc_dirichlet, bc_neumann=bc_neumann, AllDirichlet=AllDirichlet, metric=Metric) PDE.assembly() PDE.solve() # getting scipy matrix A_scipy = PDE.system.get() b = np.ones(PDE.size) # ---------------------------------------------- import scipy from pyamg.aggregation import smoothed_aggregation_solver B = None # no near-null spaces guesses for SA
blue.append(111) print("blue.n = ", blue.n) for obj in blue: print(obj) # -------------------------------------- # -------------------------------------- # operator class test # -------------------------------------- print(">>> operator class test") from pigasus.gallery.poisson import poisson from pigasus.gallery.bilaplacian import bilaplacian from caid.cad_geometry import square geo = square(n=[3, 3], p=[2, 2]) PDE_1 = bilaplacian(geometry=geo) PDE_2 = poisson(geometry=geo, V=PDE_1.V) PDE_3 = poisson(geometry=geo, V=PDE_1.V) PDE_4 = poisson(geometry=geo) # print id(PDE_1.V), PDE_1.V.id # print id(PDE_2.V), PDE_2.V.id # print "---" # print PDE_1.operators # print PDE_2.operators S_1 = PDE_1.D2 S_2 = PDE_2.stiffness S_3 = PDE_3.stiffness S_4 = PDE_4.stiffness green = color_operator()
try: AllDirichlet except NameError: AllDirichlet = None else: pass try: Metric except NameError: Metric = None else: pass # ... PDE = poisson(geometry=geo, bc_dirichlet=bc_dirichlet, bc_neumann=bc_neumann, AllDirichlet=AllDirichlet, metric=Metric) PDE.assembly() PDE.solve() # getting scipy matrix A = PDE.system.get() b = np.ones(PDE.size) print "Using cg." x = cg(A, b, tol=tol, maxiter=maxiter) print "Using cgs." x = cgs(A, b, tol=tol, maxiter=maxiter) print "Using bicg."