当前位置: 首页>>代码示例>>Python>>正文


Python Mesh.load方法代码示例

本文整理汇总了Python中hermes2d.Mesh.load方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.load方法的具体用法?Python Mesh.load怎么用?Python Mesh.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hermes2d.Mesh的用法示例。


在下文中一共展示了Mesh.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_example_03

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_example_03():
    from hermes2d.examples.c03 import set_bc

    set_verbose(False)

    P_INIT = 5                # Uniform polynomial degree of mesh elements.

    # Problem parameters.
    CONST_F = 2.0

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

    # Sample "manual" mesh refinement
    mesh.refine_all_elements()

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

    # Initialize the weak formulation
    wf = WeakForm(1)
    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)
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:35,代码来源:test_examples.py

示例2: test_example_08

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_example_08():
    from hermes2d.examples.c08 import set_bc, set_forms

    set_verbose(False)

    # The following parameter can be changed:
    P_INIT = 4

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

    # Perform uniform mesh refinement
    mesh.refine_all_elements()

    # Create the x- and y- displacement space using the default H1 shapeset
    xdisp = H1Space(mesh, P_INIT)
    ydisp = H1Space(mesh, P_INIT)
    set_bc(xdisp, ydisp)

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

    # Initialize the linear system.
    ls = LinSystem(wf)
    ls.set_spaces(xdisp, ydisp)

    # Assemble and solve the matrix problem
    xsln = Solution()
    ysln = Solution()
    ls.assemble()
    ls.solve_system(xsln, ysln, lib="scipy")
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:35,代码来源:test_examples.py

示例3: test_plot_mesh3c

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_plot_mesh3c():
    mesh = Mesh()
    mesh.load(domain_mesh)
    mesh.refine_all_elements()
    mesh.refine_all_elements()

    plot_mesh_mpl_simple(mesh.nodes_dict, mesh.elements, plot_nodes=False)
开发者ID:Richardma,项目名称:hermes2d,代码行数:9,代码来源:test_plots.py

示例4: test_example_07

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_example_07():
    from hermes2d.examples.c07 import set_bc, set_forms

    set_verbose(False)

    # The following parameters can be changed:
    P_INIT = 2             # Initial polynomial degree of all mesh elements.
    INIT_REF_NUM = 4       # Number of initial uniform refinements

    # Load the mesh
    mesh = Mesh()
    mesh.load(get_07_mesh())

    # Perform initial mesh refinements.
    for i in range(INIT_REF_NUM):
        mesh.refine_all_elements()

    # 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)
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:35,代码来源:test_examples.py

示例5: test_plot_mesh3e

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_plot_mesh3e():
    mesh = Mesh()
    mesh.load(domain_mesh)
    mesh.refine_all_elements()
    mesh.refine_all_elements()

    plot_mesh_mpl(mesh.nodes_dict, mesh.elements)
开发者ID:hpfem,项目名称:hermes2d,代码行数:9,代码来源:test_plots.py

示例6: test_ScalarView_mpl_unknown

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_ScalarView_mpl_unknown():
    mesh = Mesh()
    mesh.load(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")
开发者ID:hpfem,项目名称:hermes2d,代码行数:34,代码来源:test_plots.py

示例7: test_example_05

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
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)
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:34,代码来源:test_examples.py

示例8: test_matrix

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_matrix():
    set_verbose(False)

    mesh = Mesh()
    mesh.load(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
    sln = Solution()
    sys.assemble()
    A = sys.get_matrix()
开发者ID:Zhonghua,项目名称:hermes2d,代码行数:29,代码来源:test_basics.py

示例9: test_example_04

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_example_04():
    from hermes2d.examples.c04 import set_bc

    set_verbose(False)

    # Below you can play with the parameters CONST_F, P_INIT, and UNIFORM_REF_LEVEL.
    INIT_REF_NUM = 2         # number of initial uniform mesh refinements
    P_INIT = 2               # initial polynomial degree in all elements

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

    # Perform initial mesh refinements
    for i in range(INIT_REF_NUM):
        mesh.refine_all_elements()

    # 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)
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:35,代码来源:test_examples.py

示例10: test_example_03

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_example_03():
    set_verbose(False)

    mesh = Mesh()
    mesh.load(domain_mesh)
    mesh.refine_element(0)
    shapeset = H1Shapeset()
    pss = PrecalcShapeset(shapeset)

    # create an H1 space
    space = H1Space(mesh, shapeset)
    space.set_uniform_order(5)
    from hermes2d.examples.c03 import set_bc

    set_bc(space)
    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
    sln = Solution()
    sys.assemble()
    sys.solve_system(sln)
    assert abs(sln.l2_norm() - 0.25493) < 1e-4
    assert abs(sln.h1_norm() - 0.89534) < 1e-4
开发者ID:Zhonghua,项目名称:hermes2d,代码行数:34,代码来源:test_examples.py

示例11: test_plot_mesh3d

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_plot_mesh3d():
    mesh = Mesh()
    mesh.load(domain_mesh)
    mesh.refine_all_elements()
    mesh.refine_all_elements()

    view = MeshView("Solution")
    view.show(mesh, lib="mpl", method="orders", show=False)
开发者ID:hpfem,项目名称:hermes2d,代码行数:10,代码来源:test_plots.py

示例12: test_plot_mesh1b

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_plot_mesh1b():
    mesh = Mesh()
    mesh.load(domain_mesh)

    view = MeshView("Solution")
    view.show(mesh, lib="mpl", method="orders", show=False)
    plot_mesh_mpl(mesh.nodes, mesh.elements)
    plot_mesh_mpl(mesh.nodes_dict, mesh.elements)
开发者ID:hpfem,项目名称:hermes2d,代码行数:10,代码来源:test_plots.py

示例13: test_plot_mesh1a

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_plot_mesh1a():
    mesh = Mesh()
    mesh.load(domain_mesh)

    view = MeshView("Solution")
    view.show(mesh, lib="mpl", method="simple", show=False)
    plot_mesh_mpl_simple(mesh.nodes, mesh.elements)
    plot_mesh_mpl_simple(mesh.nodes_dict, mesh.elements)
    plot_mesh_mpl_simple(mesh.nodes, mesh.elements, plot_nodes=False)
    plot_mesh_mpl_simple(mesh.nodes_dict, mesh.elements, plot_nodes=False)
开发者ID:Richardma,项目名称:hermes2d,代码行数:12,代码来源:test_plots.py

示例14: test_plot_mesh2

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_plot_mesh2():
    mesh = Mesh()
    mesh.load(domain_mesh)
    mesh.refine_element(0)

    view = MeshView("Solution")
    view.show(mesh, lib="mpl", method="simple", show=False)
    plot_mesh_mpl(mesh.nodes_dict, mesh.elements)
    plot_mesh_mpl(mesh.nodes_dict, mesh.elements, plot_nodes=False)
    view.show(mesh, lib="mpl", method="orders", show=False)
    plot_mesh_mpl(mesh.nodes_dict, mesh.elements)
开发者ID:hpfem,项目名称:hermes2d,代码行数:13,代码来源:test_plots.py

示例15: test_fe_solutions

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import load [as 别名]
def test_fe_solutions():
    mesh = Mesh()
    mesh.load(domain_mesh)

    space = H1Space(mesh, 1)
    space.set_uniform_order(2)
    space.assign_dofs()

    a = array([1, 2, 3, 8, 0.1])

    sln = Solution()
开发者ID:FranzGrenvicht,项目名称:hermes,代码行数:13,代码来源:test_basics.py


注:本文中的hermes2d.Mesh.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。