Ejemplo n.º 1
0
pss = PrecalcShapeset(shapeset)

# create an H1 space
space = H1Space(mesh, shapeset)
space.set_uniform_order(4)

set_bc(space)

space.assign_dofs()

xprev = Solution()
yprev = Solution()

# initialize the discrete problem
wf = WeakForm(1)
set_forms(wf, -1)
set_forms_surf(wf)

sln = Solution()
solver = DummySolver()
sys = LinSystem(wf, solver)
sys.set_spaces(space)
sys.set_pss(pss)
sys.assemble()
sys.solve_system(sln)

view = ScalarView("Solution")
view.show(sln, lib="mayavi")
# view.wait()

mview = MeshView("Hello world!", 100, 100, 500, 500)
Ejemplo n.º 2
0
CORNER_REF_LEVEL = 12                # number of mesh refinements towards the re-entrant corner

# Load the mesh file
mesh = Mesh()
mesh.load(get_example_mesh())

# Perform initial mesh refinements.
mesh.refine_towards_vertex(3, CORNER_REF_LEVEL)

# Create an H1 space with default shapeset
space = H1Space(mesh, P_INIT)
set_bc(space)

# Initialize the weak formulation
wf = WeakForm()
set_forms(wf)

# Initialize the linear system.
ls = LinSystem(wf)
ls.set_spaces(space)

# Assemble and solve the matrix problem
sln = Solution()
ls.assemble()
ls.solve_system(sln)

# Visualize the approximation
sln.plot()

# Visualize the mesh
mesh.plot(space=space)
Ejemplo n.º 3
0
mesh.load(get_example_mesh())
#mesh.refine_towards_vertex(3, CORNER_REF_LEVEL)

# Initialize the shapeset and the cache
shapeset = H1Shapeset()
pss = PrecalcShapeset(shapeset)

# Create an H1 space
space = H1Space(mesh, shapeset)
space.set_uniform_order(P_INIT)
set_bc(space)
space.assign_dofs()

# Initialize the discrete problem
wf = WeakForm(1)
set_forms(wf, CONST_F)
set_forms_surf(wf)

# Assemble the stiffness matrix and solve the system
sln = Solution()
solver = DummySolver()
sys = LinSystem(wf, solver)
sys.set_spaces(space)
sys.set_pss(pss)
sys.assemble()
sys.solve_system(sln)

# Visualize the approximation
view = ScalarView("Solution")
view.show(sln, lib="mayavi")
Ejemplo n.º 4
0
CORNER_REF_LEVEL = 12  # number of mesh refinements towards the re-entrant corner

# Load the mesh file
mesh = Mesh()
mesh.load(get_example_mesh())

# Perform initial mesh refinements.
mesh.refine_towards_vertex(3, CORNER_REF_LEVEL)

# Create an H1 space with default shapeset
space = H1Space(mesh, P_INIT)
set_bc(space)

# Initialize the weak formulation
wf = WeakForm()
set_forms(wf)

# Initialize the linear system.
ls = LinSystem(wf)
ls.set_spaces(space)

# Assemble and solve the matrix problem
sln = Solution()
ls.assemble()
ls.solve_system(sln)

# Visualize the approximation
sln.plot()

# Visualize the mesh
mesh.plot(space=space)