Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine tetrahedral mesh #60

Open
RubenZubrov opened this issue Dec 3, 2020 · 5 comments
Open

Refine tetrahedral mesh #60

RubenZubrov opened this issue Dec 3, 2020 · 5 comments

Comments

@RubenZubrov
Copy link

RubenZubrov commented Dec 3, 2020

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

@inducer
Copy link
Owner

inducer commented Dec 3, 2020

FYI: Fixed the formatting on your comment.

Can you perform this operation using command-line tetgen? If so, how does command-line tetgen do this?

@RubenZubrov
Copy link
Author

I saved mesh.points and mesh.elements to L.node and L.ele files. I also created an L.a.node file that contains three additional points:

3 3 0 0
0 1.1.1.1.
1 3.1.5
2 1. 4. 0.1

Then I ran the following command:
tetgen -ri L

@inducer
Copy link
Owner

inducer commented Dec 3, 2020

Were you able to investigate how command-line tetgen drives the backend in a way that's different from meshpy?

@KMountris
Copy link

Hello,

I am new user of meshpy and I find it great, but I have some issues with the tetrahedral refinement. Is it implemented the refiniment with a mesh size function stored in an mtr file? If yes, is it available any example on how to proceed? Thank you in advance.

@ihsienlee
Copy link

I use the "load_mtr" to set mesh size function and refine mesh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants