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


Python UnitSquareMesh.move方法代码示例

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


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

示例1: test_HarmonicSmoothing

# 需要导入模块: from dolfin import UnitSquareMesh [as 别名]
# 或者: from dolfin.UnitSquareMesh import move [as 别名]
def test_HarmonicSmoothing():
    #print("Testing HarmonicSmoothing::move(Mesh& mesh, "const BoundaryMesh& new_boundary)")

    # Create some mesh and its boundary
    mesh = UnitSquareMesh(10, 10)
    boundary = BoundaryMesh(mesh, 'exterior')

    # Move boundary
    disp = Expression(("0.3*x[0]*x[1]", "0.5*(1.0-x[1])"))
    boundary.move(disp)

    # Move mesh according to given boundary
    mesh.move(boundary)

    # Check that new boundary topology corresponds to given one
    boundary_new = BoundaryMesh(mesh, 'exterior')
    assert boundary.topology().hash() == boundary_new.topology().hash()

    # Check that coordinates are almost equal
    err = sum(sum(abs(boundary.coordinates() \
                    - boundary_new.coordinates()))) / mesh.num_vertices()
    print("Current CG solver produced error in boundary coordinates", err)
    assert round(err - 0.0, 5) == 0

    # Check mesh quality
    magic_number = 0.35
    rmin = MeshQuality.radius_ratio_min_max(mesh)[0]
    assert rmin > magic_number
开发者ID:Rlahuerta,项目名称:dolfin,代码行数:30,代码来源:test_harmonic_smoothing.py

示例2: test_HarmonicSmoothing

# 需要导入模块: from dolfin import UnitSquareMesh [as 别名]
# 或者: from dolfin.UnitSquareMesh import move [as 别名]
    def test_HarmonicSmoothing(self):

        print ""
        print "Testing HarmonicSmoothing::move(Mesh& mesh, " \
              "const BoundaryMesh& new_boundary)"

        # Create some mesh and its boundary
        mesh = UnitSquareMesh(10, 10)
        boundary = BoundaryMesh(mesh, 'exterior')

        # Move boundary
        disp = Expression(("0.3*x[0]*x[1]", "0.5*(1.0-x[1])"))
        boundary.move(disp)

        # Move mesh according to given boundary
        mesh.move(boundary)

        # Check that new boundary topology corresponds to given one
        boundary_new = BoundaryMesh(mesh, 'exterior')
        self.assertEqual(boundary.topology().hash(),
                         boundary_new.topology().hash())

        # Check that coordinates are almost equal
        err = sum(sum(abs(boundary.coordinates() \
                        - boundary_new.coordinates()))) / mesh.num_vertices()
        print "Current CG solver produced error in boundary coordinates", err
        self.assertAlmostEqual(err, 0.0, places=5)

        # Check mesh quality
        magic_number = 0.35
        self.assertTrue(mesh.radius_ratio_min()>magic_number)
开发者ID:MiroK,项目名称:DolfinSurface,代码行数:33,代码来源:HarmonicSmoothing.py


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