I am trying to use the function Delaynay
of scipy
to generate a tetrahedral mesh. From the source code provided here, I have make something as followed:
import math
import random
import numpy as np
from scipy.spatial import Delaunay
# geometry
height = 2.0
depth = 2.0
width = 2.0
# random transformations of the original mesh
random.seed(1234)
variation = .00 # as a decimal for a percent
h = 0.4
x_layer = int(width / h)+1
y_layer = int(depth / h)+1
z_layer = int(height / h)+1
points = np.zeros([x_layer*y_layer*z_layer,3])
count = 0
for orig_x in range(x_layer):
for orig_y in range(y_layer):
for orig_z in range(z_layer):
rand_pert_x = random.uniform(-variation, variation)
rand_pert_y = random.uniform(-variation, variation)
rand_pert_z = random.uniform(-variation, variation)
x = orig_x*h
y = orig_y*h
z = orig_z*h
if (x==0 or orig_x==x_layer-1) or (y==0 or orig_y==y_layer-1) or (z==0 or orig_z==z_layer-1):
points[count,:] = np.array([x,y,z])
else:
points[count,:] = np.array([x+h*rand_pert_x,y+h*rand_pert_y, z+h*rand_pert_z])
count += 1
tet = Delaunay(points, qhull_options="Qt")
i.e. the plan would be to have the points being randomly perturbed to create a low-quality mesh. For now, the variation
is set as 0.0
so the code will generate a 3D rectangular grid.
I want to test the quality of the mesh, so one thing I am looking at is the Jacobian of each element. Is there a way to compute that from the output of the Delaunay
function?
from Calculate the Jacobian of the tetrahedral mesh generated from scipy's Delaunay function
No comments:
Post a Comment