Get hexahedral nodes and cells
Sample a 4 × 3 × 2 block into 24 linear hexahedra. Pass points per direction to create. The 4, 3 and 2 cells along the three axes need 5, 4 and 3 points respectively.
program sample_volume_mesh
use forcad, only: rk, nurbs_volume
implicit none
type(nurbs_volume) :: block
real(rk), allocatable :: points(:,:)
integer, allocatable :: cells(:,:)
call block%set_hexahedron(L=[4._rk,3._rk,2._rk], nc=[2,2,2])
if (.not. block%err%ok) error stop "Could not build the block"
call block%create(res1=5, res2=4, res3=3)
if (.not. block%err%ok) error stop "Could not sample the block"
points = block%get_Xg()
cells = block%get_elem_Xg_vis()
print '(a,2(1x,i0))', "Point array:", shape(points)
print '(a,2(1x,i0))', "Cell array: ", shape(cells)
end program
The point array has 60 rows and three coordinate columns. The cell array has 24 rows of eight node indices each. For example, points(cells(1,:),:) gives the eight corner coordinates of the first cell in connectivity order.
Export the sampled cells to VTK to inspect them in another application. For a volume assembly, set sampling counts on each member.
Studio equivalent. Mesh a volume. Enter cell counts, then check nodes and cells in the status bar.