How to generate a triangular 3D meshgrid using python

Viewed 203

I want to transform the 2D triangular mesh code below (using python) to a 3D triangular mesh:

import matplotlib.pyplot as plt
import numpy as np
import math

#all in meters!
Distance = 200
Depth = 40

nb_element_X = 20
nb_element_Y = 20

#1.1.create nodes
Nodes = []
for x in np.linspace(0, Distance, num=nb_element_X):
for y in np.linspace(0, Depth, num=nb_element_Y):

    Nodes.append([x,y])

#1.2.display nodes
points = np.array(Nodes)
plt.plot(points[:,0],points[:,1],'o')
plt.show()

#2.1.create elements
from scipy.spatial import Delaunay
tri = Delaunay(points)

#2.2.display nodes
plt.triplot(points[:,0], points[:,1], tri.simplices)
plt.plot(points[:,0], points[:,1], 'o')
plt.show()    

May you give me some hints on how to transform that code to a 3D mesh? Is it possible to refine only part of the domain? If yes, how can I do this in python?

Thank you in advance for any help!

0 Answers
Related