Skip to content

Refine tetrahedral mesh #60

Open
Open
@RubenZubrov

Description

@RubenZubrov

Hi,
Thanks for such a good package.
I'm using windows10:MeshPy‑2020.1
I'm trying to refine existing tetrahedral mesh by inserting additional points ('-i').
In https://documen.tician.de/meshpy/tri-tet.html it is said that paramteter insert_points – a MeshInfo object specifying additional points to be inserted. However, using the insert_point parameter does not give the expected result (the number of points in the grid does not change).

I use the following code:

import meshpy.tet as tet
import numpy as np

facets = [[0, 4, 5], [0, 3, 4], [0, 1, 3], [1, 2, 3], [1, 2, 8], [1, 7, 8], [2, 3, 9], [2, 8, 9],
          [3, 4, 10], [3, 9, 10], [4, 5, 11], [4, 10, 11], [0, 5, 11], [0, 6, 11], [0, 1, 6], [1, 6, 7],
          [6, 10, 11], [6, 9, 10], [6, 7, 9], [7, 8, 9]]

nodes = [[0., 0., 0.], [4., 0., 0.], [4., 2., 0.], [2., 2., 0.], [2., 6., 0.], [0., 6., 0.],
         [0., 0., 2.], [4., 0., 2.], [4., 2., 2.], [2., 2., 2.], [2., 6., 2.], [0., 6., 2.]]

inp_mesh = tet.MeshInfo()
inp_mesh.set_points(nodes)
inp_mesh.set_facets(facets)

mesh = tet.build(inp_mesh, options=tet.Options("pq"))

addin = tet.MeshInfo()
addin.set_points(np.array([[1., 1., 1.]]))

refined_mesh = tet.build(mesh, options=tet.Options("ri"), insert_points=addin)

print(mesh.points.__len__()) # 14
print(mesh.elements.__len__()) # 15

old_points = np.array(mesh.points)
old_elements = np.array(mesh.elements)
old_faces = np.array(mesh.faces)

print(refined_mesh.points.__len__()) # 14
print(refined_mesh.elements.__len__()) # 18

new_points = np.array(refined_mesh.points)
new_elements = np.array(refined_mesh.elements)
new_faces = np.array(refined_mesh.faces)

print((old_points == new_points).all()) # True

print('done')

What I'm doing wrong?
Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions