03-poisson

250 days ago by ondrej

from hermes2d import Mesh, H1Shapeset, PrecalcShapeset, H1Space, \ WeakForm, Solution, ScalarView, LinSystem, DummySolver from hermes2d.forms import set_forms from hermes2d.examples import get_example_mesh mesh = Mesh() mesh.load(DATA+"/domain.mesh") mesh.refine_element(0) shapeset = H1Shapeset() pss = PrecalcShapeset(shapeset) # create an H1 space space = H1Space(mesh, shapeset) space.set_uniform_order(5) space.assign_dofs() # initialize the discrete problem wf = WeakForm(1) set_forms(wf) solver = DummySolver() sys = LinSystem(wf, solver) sys.set_spaces(space) sys.set_pss(pss) # assemble the stiffness matrix and solve the system sys.assemble() A = sys.get_matrix() b = sys.get_rhs() from scipy.sparse.linalg import cg x, res = cg(A, b) sln = Solution() sln.set_fe_solution(space, pss, x) view = ScalarView("Solution") view.show(sln, lib="mayavi", notebook=True) 
       
Creating matrix sparse structure...
  (dofs: 176, nnz: 7026, size: 0.1 MB, time: 0.01 sec)
Assembling stiffness matrix...
WARNING: void warn_order(): Not enough integration rules for exact
integration.
  (stages: 1, time: 0.03 sec)
Linearizer: 89 verts, 151 tris in 0 sec