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


Python Mesh.copy方法代码示例

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


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

示例1: test_example_11

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

    # The following parameters can be changed: In particular, compare hp- and
    # h-adaptivity via the ADAPT_TYPE option, and compare the multi-mesh vs. single-mesh
    # using the MULTI parameter.
    P_INIT = 1  # Initial polynomial degree of all mesh elements.
    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.
    SAME_ORDERS = True  # SAME_ORDERS = true ... when single-mesh is used,
    # this forces the meshes for all components to be
    # identical, including the polynomial degrees of
    # corresponding elements. When multi-mesh is used,
    # this parameter is ignored.
    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.
    ADAPT_TYPE = 0  # Type of automatic adaptivity:
    # ADAPT_TYPE = 0 ... adaptive hp-FEM (default),
    # ADAPT_TYPE = 1 ... adaptive h-FEM,
    # ADAPT_TYPE = 2 ... adaptive p-FEM.
    ISO_ONLY = False  # Isotropic refinement flag (concerns quadrilateral elements only).
    # ISO_ONLY = false ... anisotropic refinement of quad elements
    # is allowed (default),
    # ISO_ONLY = true ... only isotropic refinements of quad elements
    # are allowed.
    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.
    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 = 40000  # 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.

    # Problem constants
    E = 200e9  # Young modulus for steel: 200 GPa
    nu = 0.3  # Poisson ratio
    lamda = (E * nu) / ((1 + nu) * (1 - 2 * nu))
    mu = E / (2 * (1 + nu))

    # Load the mesh
    xmesh = Mesh()
    ymesh = Mesh()
    xmesh.load(get_bracket_mesh())

    # initial mesh refinements
    xmesh.refine_element(1)
    xmesh.refine_element(4)

    # Create initial mesh for the vertical displacement component,
    # identical to the mesh for the horizontal displacement
    # (bracket.mesh becomes a master mesh)
    ymesh.copy(xmesh)

    # Initialize the shapeset and the cache
    shapeset = H1Shapeset()
    xpss = PrecalcShapeset(shapeset)
    ypss = PrecalcShapeset(shapeset)

    # Create the x displacement space
    xdisp = H1Space(xmesh, shapeset)
    set_bc(xdisp)
    xdisp.set_uniform_order(P_INIT)

    # Create the x displacement space
    ydisp = H1Space(ymesh, shapeset)
    set_bc(ydisp)
    ydisp.set_uniform_order(P_INIT)

    # Enumerate basis functions
    ndofs = xdisp.assign_dofs()
    ydisp.assign_dofs(ndofs)

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

    # Matrix solver
    solver = DummySolver()

    # adaptivity loop
    it = 1
    done = False
    cpu = 0.0

#.........这里部分代码省略.........
开发者ID:Zhonghua,项目名称:hermes2d,代码行数:103,代码来源:test_examples.py

示例2: Mesh

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import copy [as 别名]
# Problem constants
E  = 200e9               # Young modulus for steel: 200 GPa
nu = 0.3                 # Poisson ratio
lamda = (E * nu) / ((1 + nu) * (1 - 2*nu))
mu = E / (2*(1 + nu))

# Load the mesh
xmesh = Mesh()
ymesh = Mesh()
xmesh.load(get_bracket_mesh())

# Create initial mesh for the vertical displacement component,
# identical to the mesh for the horizontal displacement
# (bracket.mesh becomes a master mesh)
ymesh.copy(xmesh)

# Initialize the shapeset and the cache
shapeset = H1Shapeset()
xpss = PrecalcShapeset(shapeset)
ypss = PrecalcShapeset(shapeset)

# Create the x displacement space
xdisp = H1Space(xmesh, shapeset)
set_bc(xdisp)
xdisp.set_uniform_order(P_INIT)

# Create the x displacement space
ydisp = H1Space(ymesh, shapeset)
set_bc(ydisp)
ydisp.set_uniform_order(P_INIT)
开发者ID:Zhonghua,项目名称:hermes2d,代码行数:32,代码来源:11.py

示例3: test_example_11

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import copy [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

示例4: adaptivity

# 需要导入模块: from hermes2d import Mesh [as 别名]
# 或者: from hermes2d.Mesh import copy [as 别名]
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 views
uoview = OrderView("Coarse mesh for u", 0, 0, 360, 300)
开发者ID:B-Rich,项目名称:hermes-legacy,代码行数:33,代码来源:11.py


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