Reputation: 643
I have a rectangular parallelepiped with three dimensions (X, Y, Z): 1 x 1 x 10. I want to create a mesh with 3 x 3 x 21 nodes and 2 x 2 x 20 finite elements which are 8-nodes solid elements with 2x2x2 integrating points. How can i do this with Python and collect the coordinates of all integrating points?
(photo's credits: Anton Zaicenco)
Thanks for your attention!
Upvotes: 1
Views: 13062
Reputation:
Although I am still not entirely sure what you want, here an example using numpy.meshgrid
printing all nodes:
import numpy
x = numpy.linspace(0, 1, 3)
y = numpy.linspace(0, 1, 3)
z = numpy.linspace(0, 10, 21)
mesh = numpy.meshgrid(x, y, z)
nodes = list(zip(*(dim.flat for dim in mesh)))
for node in nodes:
print(node)
Although this can also be done as three simple loops:
for x in numpy.linsapce(0, 1, 3):
for y in numpy.linspace(0, 1, 3):
for z in numpy.linspace(0, 10, 21):
print((x, y, z))
For further information on the usage of numpy.meshgrid
see the documentation.
Upvotes: 2