File: t_BoundaryMesher_std.py

package info (click to toggle)
openturns 1.24-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,204 kB
  • sloc: cpp: 256,662; python: 63,381; ansic: 4,414; javascript: 406; sh: 180; xml: 164; yacc: 123; makefile: 98; lex: 55
file content (32 lines) | stat: -rwxr-xr-x 1,177 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import openturns as ot
import openturns.testing as ott
import openturns.experimental as otexp


def compute_length(mesh2D):
    length = 0.0
    for ind in mesh2D.getSimplices():
        length += (mesh2D.getVertex(ind[0]) - mesh2D.getVertex(ind[1])).norm()
    return length


# Define the vertices of the mesh
vertices = [[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [1.5, 1.0], [3.0, 1.5], [0.5, 1.5]]
# Define the simplices of the mesh
simplices = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [2, 4, 5], [0, 2, 5]]
# Create the Mesh
mesh2D = ot.Mesh(vertices, simplices)
# Build the Mesh boundary
mesh2DBoundary = otexp.BoundaryMesher().build(mesh2D)
volume = mesh2DBoundary.getVolume()
ott.assert_almost_equal(volume, 0.0)
length = compute_length(mesh2DBoundary)
ott.assert_almost_equal(length, 7.780311648918275)
# Build a thick outside Mesh boundary
mesh2DBoundaryOutside = otexp.BoundaryMesher().build(mesh2D, 0.05)
volume = mesh2DBoundaryOutside.getVolume()
ott.assert_almost_equal(volume, 0.194508)
# Build a thick inside Mesh boundary
mesh2DBoundaryInside = otexp.BoundaryMesher().build(mesh2D, -0.05)
volume = mesh2DBoundaryInside.getVolume()
ott.assert_almost_equal(volume, 0.194508)