File: BoundaryMesher.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 (55 lines) | stat: -rw-r--r-- 1,737 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import openturns as ot
from openturns.viewer import View
import openturns.experimental as otexp
import matplotlib.pyplot as plt

# 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)
# Build a thick outside Mesh boundary
mesh2DBoundaryOutside = otexp.BoundaryMesher().build(mesh2D, 0.05)
# Build a thick inside Mesh boundary
mesh2DBoundaryInside = otexp.BoundaryMesher().build(mesh2D, -0.05)
# Create a Graph
graph = ot.Graph("", "", "", True, "lower right")
graph.add(mesh2D.draw())
# Then, draw it
fig = plt.figure(figsize=(16, 4))
axis = fig.add_subplot(141)
View(graph, figure=fig, axes=[axis], add_legend=True)
axis.set_xlim(auto=True)

# Create a Graph
graph = ot.Graph("", "", "", True, "lower right")
graph.add(mesh2DBoundary.draw())
# Then, draw it
axis = fig.add_subplot(142)
View(graph, figure=fig, axes=[axis], add_legend=True)
axis.set_xlim(auto=True)

# Create a Graph
graph = ot.Graph("", "", "", True, "lower right")
graph.add(mesh2DBoundaryInside.draw())
# Then, draw it
axis = fig.add_subplot(143)
View(graph, figure=fig, axes=[axis], add_legend=True)
axis.set_xlim(auto=True)

# Create a Graph
graph = ot.Graph(
    "A 2D mesh with its boundary, its inside thick boundary and its outside thick boundary",
    "",
    "",
    True,
    "lower right",
)
graph.add(mesh2DBoundaryOutside.draw())
# Then, draw it
axis = fig.add_subplot(144)
View(graph, figure=fig, axes=[axis], add_legend=True)
axis.set_xlim(auto=True)