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


Python Mesh.refine_towards_boundary方法代码示例

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


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

示例1: test_example_09

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import refine_towards_boundary [as 别名]
def test_example_09():
    from hermes2d.examples.c09 import set_bc, temp_ext, set_forms

    # The following parameters can be changed:
    INIT_REF_NUM = 4      # number of initial uniform mesh refinements
    INIT_REF_NUM_BDY = 1  # number of initial uniform mesh refinements towards the boundary
    P_INIT = 4            # polynomial degree of all mesh elements
    TAU = 300.0           # time step in seconds

    # Problem constants
    T_INIT = 10           # temperature of the ground (also initial temperature)
    FINAL_TIME = 86400    # length of time interval (24 hours) in seconds

    # Global variable
    TIME = 0;

    # Boundary markers.
    bdy_ground = 1
    bdy_air = 2

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

    # Perform initial mesh refinements
    for i in range(INIT_REF_NUM):
        mesh.refine_all_elements()
    mesh.refine_towards_boundary(bdy_air, INIT_REF_NUM_BDY)

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

    # Set initial condition
    tsln = Solution()
    tsln.set_const(mesh, T_INIT)

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

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

    # Time stepping
    nsteps = int(FINAL_TIME/TAU + 0.5)
    rhsonly = False;

    # Assemble and solve
    ls.assemble()
    rhsonly = True
    ls.solve_system(tsln, lib="scipy")
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:55,代码来源:test_examples.py

示例2: test_example_08

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

    set_verbose(False)

    mesh = Mesh()
    mesh.load(cylinder_mesh)
    #mesh.refine_element(0)
    #mesh.refine_all_elements()
    mesh.refine_towards_boundary(5, 3)
    shapeset = H1Shapeset()
    pss = PrecalcShapeset(shapeset)

    # create an H1 space
    xvel = H1Space(mesh, shapeset)
    yvel = H1Space(mesh, shapeset)
    press = H1Space(mesh, shapeset)
    xvel.set_uniform_order(2)
    yvel.set_uniform_order(2)
    press.set_uniform_order(1)

    set_bc(xvel, yvel, press)

    ndofs = 0
    ndofs += xvel.assign_dofs(ndofs)
    ndofs += yvel.assign_dofs(ndofs)
    ndofs += press.assign_dofs(ndofs)

    xprev = Solution()
    yprev = Solution()

    xprev.set_zero(mesh)
    yprev.set_zero(mesh)

    # initialize the discrete problem
    wf = WeakForm(3)
    set_forms(wf, xprev, yprev)

    solver = DummySolver()
    sys = LinSystem(wf, solver)
    sys.set_spaces(xvel, yvel, press)
    sys.set_pss(pss)
    #dp.set_external_fns(xprev, yprev)

    # visualize the solution

    EPS_LOW = 0.0014

    for i in range(3):
        psln = Solution()
        sys.assemble()
        sys.solve_system(xprev, yprev, psln)
开发者ID:Richardma,项目名称:hermes2d,代码行数:54,代码来源:test_examples.py

示例3: test_example_04

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

    set_verbose(False)

    mesh = Mesh()
    mesh.load(domain_mesh)
    # mesh.refine_element(0)
    # mesh.refine_all_elements()
    mesh.refine_towards_boundary(5, 3)
    shapeset = H1Shapeset()
    pss = PrecalcShapeset(shapeset)

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

    set_bc(space)

    space.assign_dofs()

    xprev = Solution()
    yprev = Solution()

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

    solver = DummySolver()
    sys = LinSystem(wf, solver)
    sys.set_spaces(space)
    sys.set_pss(pss)

    # assemble the stiffness matrix and solve the system
    sys.assemble()
    sln = Solution()
    sys.solve_system(sln)
    assert abs(sln.l2_norm() - 1.22729) < 1e-4
    assert abs(sln.h1_norm() - 2.90006) < 1e-4
开发者ID:Zhonghua,项目名称:hermes2d,代码行数:41,代码来源:test_examples.py

示例4: Mesh

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import refine_towards_boundary [as 别名]
#! /usr/bin/env python

from hermes2d import Mesh, 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_boundary(5, 3)
shapeset = H1Shapeset()
pss = PrecalcShapeset(shapeset)

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

set_bc(space)

space.assign_dofs()

xprev = Solution()
yprev = Solution()

# initialize the discrete problem
wf = WeakForm(1)
开发者ID:Richardma,项目名称:hermes2d,代码行数:33,代码来源:05.py

示例5: test_example_11

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import refine_towards_boundary [as 别名]
def test_example_11():
    from hermes2d.examples.c11 import set_bc, set_wf_forms, set_hp_forms

    SOLVE_ON_COARSE_MESH = True  # If true, coarse mesh FE problem is solved in every adaptivity step.
    P_INIT_U = 2             # Initial polynomial degree for u
    P_INIT_V = 2             # Initial polynomial degree for v
    INIT_REF_BDY = 3         # Number of initial boundary refinements
    MULTI = True             # MULTI = true  ... use multi-mesh,
                                # MULTI = false ... use single-mesh.
                                # Note: In the single mesh option, the meshes are
                                # forced to be geometrically the same but the
                                # polynomial degrees can still vary.
    THRESHOLD = 0.3          # This is a quantitative parameter of the adapt(...) function and
                                     # it has different meanings for various adaptive strategies (see below).
    STRATEGY = 1             # Adaptive strategy:
                                # STRATEGY = 0 ... refine elements until sqrt(THRESHOLD) times total
                                #   error is processed. If more elements have similar errors, refine
                                #   all to keep the mesh symmetric.
                                # STRATEGY = 1 ... refine all elements whose error is larger
                                #   than THRESHOLD times maximum element error.
                                # STRATEGY = 2 ... refine all elements whose error is larger
                                #   than THRESHOLD.
                                # More adaptive strategies can be created in adapt_ortho_h1.cpp.

    CAND_LIST = CandList.H2D_HP_ANISO  # Predefined list of element refinement candidates.
                            # Possible values are are attributes of the class CandList:
                            # P_ISO, P_ANISO, H_ISO, H_ANISO, HP_ISO, HP_ANISO_H, HP_ANISO_P, HP_ANISO
                            # See the Sphinx tutorial (http://hpfem.org/hermes2d/doc/src/tutorial-2.html#adaptive-h-fem-and-hp-fem) for details.

    MESH_REGULARITY = -1     # Maximum allowed level of hanging nodes:
                                # MESH_REGULARITY = -1 ... arbitrary level hangning nodes (default),
                                # MESH_REGULARITY = 1 ... at most one-level hanging nodes,
                                # MESH_REGULARITY = 2 ... at most two-level hanging nodes, etc.
                                # Note that regular meshes are not supported, this is due to
                                # their notoriously bad performance.
    CONV_EXP = 1             # Default value is 1.0. This parameter influences the selection of
                                # cancidates in hp-adaptivity. See get_optimal_refinement() for details.
    MAX_ORDER = 10           # Maximum allowed element degree
    ERR_STOP = 0.5           # Stopping criterion for adaptivity (rel. error tolerance between the
                                # fine mesh and coarse mesh solution in percent).
    NDOF_STOP = 60000        # Adaptivity process stops when the number of degrees of freedom grows over
                                # this limit. This is mainly to prevent h-adaptivity to go on forever.

    H2DRS_DEFAULT_ORDER = -1 # A default order. Used to indicate an unkonwn order or a maximum support order

    # Load the mesh
    umesh = Mesh()
    vmesh = Mesh()
    umesh.load(get_bracket_mesh())
    if MULTI == False:
        umesh.refine_towards_boundary(1, INIT_REF_BDY)
        
    # Create initial mesh (master mesh).
    vmesh.copy(umesh)

    # Initial mesh refinements in the vmesh towards the boundary
    if MULTI == True:
        vmesh.refine_towards_boundary(1, INIT_REF_BDY)

    # Create the x displacement space
    uspace = H1Space(umesh, P_INIT_U)
    vspace = H1Space(vmesh, P_INIT_V)

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

    # Initialize refinement selector
    selector = H1ProjBasedSelector(CAND_LIST, CONV_EXP, H2DRS_DEFAULT_ORDER)

    # Initialize the coarse mesh problem
    ls = LinSystem(wf)
    ls.set_spaces(uspace, vspace)

    u_sln_coarse = Solution()
    v_sln_coarse = Solution()
    u_sln_fine = Solution()
    v_sln_fine = Solution()
    
    # Assemble and Solve the fine mesh problem
    rs = RefSystem(ls)
    rs.assemble()
    rs.solve_system(u_sln_fine, v_sln_fine, lib="scipy")

    # Either solve on coarse mesh or project the fine mesh solution 
    # on the coarse mesh.
    if SOLVE_ON_COARSE_MESH:
        ls.assemble()
        ls.solve_system(u_sln_coarse, v_sln_coarse, lib="scipy")

    # Calculate element errors and total error estimate
    hp = H1Adapt(ls)
    hp.set_solutions([u_sln_coarse, v_sln_coarse], [u_sln_fine, v_sln_fine]);
    set_hp_forms(hp)
    err_est = hp.calc_error() * 100
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:97,代码来源:test_examples.py

示例6: get_optimal_refinement

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import refine_towards_boundary [as 别名]
CONV_EXP = 1             # Default value is 1.0. This parameter influences the selection of
                            # cancidates in hp-adaptivity. See get_optimal_refinement() for details.
MAX_ORDER = 10           # Maximum allowed element degree
ERR_STOP = 0.5           # Stopping criterion for adaptivity (rel. error tolerance between the
                            # fine mesh and coarse mesh solution in percent).
NDOF_STOP = 60000        # Adaptivity process stops when the number of degrees of freedom grows over
                            # this limit. This is mainly to prevent h-adaptivity to go on forever.

H2DRS_DEFAULT_ORDER = -1 # A default order. Used to indicate an unkonwn order or a maximum support order

# Load the mesh
umesh = Mesh()
vmesh = Mesh()
umesh.load(get_bracket_mesh())
if MULTI == False:
    umesh.refine_towards_boundary(1, INIT_REF_BDY)
    
# Create initial mesh (master mesh).
vmesh.copy(umesh)

# Initial mesh refinements in the vmesh towards the boundary
if MULTI == True:
    vmesh.refine_towards_boundary(1, INIT_REF_BDY)

# Create the x displacement space
uspace = H1Space(umesh, P_INIT_U)
vspace = H1Space(vmesh, P_INIT_V)

# Initialize the weak formulation
wf = WeakForm(2)
set_wf_forms(wf)
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:33,代码来源:11.py

示例7: ground

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import refine_towards_boundary [as 别名]
TAU = 300.0           # time step in seconds

# Problem constants
T_INIT = 10           # temperature of the ground (also initial temperature)
FINAL_TIME = 86400    # length of time interval (24 hours) in seconds

# Global variable
TIME = 0;

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

for i in range(INIT_REF_NUM):
    mesh.refine_all_elements()
mesh.refine_towards_boundary(2, 5)

# Set up shapeset
shapeset = H1Shapeset()
pss = PrecalcShapeset(shapeset)

# Set up spaces
space = H1Space(mesh, shapeset)
set_bc(space)
space.set_uniform_order(P_INIT)

# Enumerate basis functions
space.assign_dofs()

# Set initial condition
tsln = Solution()
开发者ID:Zhonghua,项目名称:hermes2d,代码行数:33,代码来源:09.py

示例8: Mesh

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import refine_towards_boundary [as 别名]
# Global variable
TIME = 0;

# Boundary markers.
bdy_ground = 1
bdy_air = 2

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

# Perform initial mesh refinements
for i in range(INIT_REF_NUM):
    mesh.refine_all_elements()
mesh.refine_towards_boundary(bdy_air, INIT_REF_NUM_BDY)

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

# Set initial condition
tsln = Solution()
tsln.set_const(mesh, T_INIT)

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

# Initialize the linear system.
ls = LinSystem(wf)
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:32,代码来源:09.py


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