import pyvista as pv
from dolfinx import mesh, plot
import numpy as np
from mpi4py import MPI
# Geometry and material properties
L = 120.0
W = 4.0
H = 8.0
# Create the mesh
domain = mesh.create_box(MPI.COMM_WORLD, [np.array([0, 0, 0]), np.array([L, W, H])],
[20, 6, 6], cell_type=mesh.CellType.hexahedron)
def free_end(x):
return np.isclose(x[0], L)
#fdin == 2
fdim = domain.topology.dim - 1
# Get the facets @ the free end...
free_end_facets = mesh.locate_entities_boundary(domain, fdim, free_end)
'''
array([1960, 1961, 1962, 1963, 2072, 2073, 2074, 2075, 2172, 2173, 2174,
2175, 2176, 2258, 2259, 2260, 2261, 2262, 2263, 2327, 2328, 2329,
2330, 2331, 2332, 2333, 2376, 2377, 2378, 2379, 2406, 2407, 2408,
2424, 2425, 2433], dtype=int32)
'''
# Extract the coordinates of the free end facets
free_end_coords = domain.geometry.x[free_end_facets] #<<--
'''
Traceback (most recent call last):
File "/home/prusso/dolfinx-beam_moment/main.py", line 31, in <module>
free_end_coords = domain.geometry.x[free_end_facets] #<<--
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
IndexError: index 1960 is out of bounds for axis 0 with size 1029
'''
There are free_end_facets to be had however when extracting the nodes from domain.geometry.x it seems that those indices are being reported as out of range. Why is that?