mesh



In [ ]:
import sys
sys.path.append('../')

%matplotlib notebook

In [ ]:
from pycrest.mesh import *
from pycrest.refinement import *
from pycrest.visualize import *
from math import pi

In [ ]:
# A simple triangulation of the unit square, using two triangles
vertices = [
    (0.0, 0.0),
    (1.0, 0.0),
    (1.0, 1.0),
    (0.0, 1.0)
]
elements = [
    (3, 0, 1),
    (1, 2, 3)
]
initial_mesh = Mesh2d(vertices, elements)

In [ ]:
# Configure parameters for refinement
tolerance = 0.05
mesh = bisect_to_tolerance(initial_mesh, tolerance)

In [ ]:
plot_triangulation(mesh)

In [ ]:
mesh.num_vertices

In [ ]:
mesh.num_elements

In [ ]:
(coarse, fine) = threshold(initial_mesh, tolerance, [0, 2], [3 * pi/4, pi / 2])

In [ ]:
plot_triangulation(coarse)

In [ ]:
plot_triangulation(fine)

In [ ]:
fine.num_elements

In [ ]:
coarse.num_elements

In [ ]: