def test_example_05(): from hermes2d.examples.c05 import set_bc from hermes2d.examples.c05 import set_forms as set_forms_surf set_verbose(False) P_INIT = 4 # initial polynomial degree in all elements 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)
def test_example_05(): from hermes2d.examples.c05 import set_bc from hermes2d.examples.c05 import set_forms as set_forms_surf set_verbose(False) P_INIT = 4 # initial polynomial degree in all elements 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)
def test_example_06(): from hermes2d.examples.c06 import set_bc, set_forms set_verbose(False) # The following parameters can be changed: UNIFORM_REF_LEVEL = 2 # Number of initial uniform mesh refinements. CORNER_REF_LEVEL = 12 # Number of mesh refinements towards the re-entrant corner. P_INIT = 6 # Uniform polynomial degree of all mesh elements. # Boundary markers NEWTON_BDY = 1 # Load the mesh file mesh = Mesh() mesh.load(get_example_mesh()) # Perform initial mesh refinements. for i in range(UNIFORM_REF_LEVEL): mesh.refine_all_elements() 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)
def test_example_06(): from hermes2d.examples.c06 import set_bc, set_forms set_verbose(False) # The following parameters can be changed: UNIFORM_REF_LEVEL = 2; # Number of initial uniform mesh refinements. CORNER_REF_LEVEL = 12; # Number of mesh refinements towards the re-entrant corner. P_INIT = 6; # Uniform polynomial degree of all mesh elements. # Boundary markers NEWTON_BDY = 1 # Load the mesh file mesh = Mesh() mesh.load(get_example_mesh()) # Perform initial mesh refinements. for i in range(UNIFORM_REF_LEVEL): mesh.refine_all_elements() 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)
def test_example_05(): from hermes2d.examples.c05 import set_bc from hermes2d.examples.c05 import set_forms as set_forms_surf set_verbose(False) mesh = Mesh() mesh.load(domain_mesh) mesh.refine_towards_vertex(3, 12) shapeset = H1Shapeset() 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) assert abs(sln.l2_norm() - 0.535833) < 1e-4 assert abs(sln.h1_norm() - 1.332908) < 1e-4
#! /usr/bin/env python from hermes2d import Mesh, MeshView, H1Shapeset, PrecalcShapeset, H1Space, \ LinSystem, Solution, ScalarView, WeakForm, DummySolver from hermes2d.examples.c05 import set_bc, set_forms from hermes2d.examples.c05 import set_forms as set_forms_surf from hermes2d.forms import set_forms from hermes2d.examples import get_example_mesh mesh = Mesh() mesh.load(get_example_mesh()) #mesh.refine_element(0) #mesh.refine_all_elements() mesh.refine_towards_vertex(3, 12) shapeset = H1Shapeset() 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)
CORNER_REF_LEVEL = 12 # Number of mesh refinements towards the re-entrant corner. P_INIT = 6 # Uniform polynomial degree of all mesh elements. # Boundary markers NEWTON_BDY = 1 # Load the mesh file mesh = Mesh() mesh.load(get_example_mesh()) # Perform initial mesh refinements. for i in range(UNIFORM_REF_LEVEL): mesh.refine_all_elements() 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()
UNIFORM_REF_LEVEL = 2; # Number of initial uniform mesh refinements. CORNER_REF_LEVEL = 12; # Number of mesh refinements towards the re-entrant corner. P_INIT = 6; # Uniform polynomial degree of all mesh elements. # Boundary markers NEWTON_BDY = 1 # Load the mesh file mesh = Mesh() mesh.load(get_example_mesh()) # Perform initial mesh refinements. for i in range(UNIFORM_REF_LEVEL): mesh.refine_all_elements() 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()