Generate finite elments by CGX for a grid of voxels

Voxel

Let’s assume there is a 3D grid of voxels like below. Filled voxels represent a 3D model and empty voxels represent space.

2023-09-24 21_05_33-Window

2023-09-24 21_40_39-Window

Loop over voxels

Shown by this pseudocode, the iteration over voxels is done by their x, y, z index:

for x := 1, Nx;
    for y := 1, Ny;
        for z := 1, Nz;
            if voxelIsEmpty continue;
            // 3D coordinates of 8 voxel corners are floating-point values.
            voxelCornersX = [x1, x2, x3, x4, x5, x6, x7, x8];
            voxelCornersY = [y1, y2, y3, y4, y5, y6, y7, y8];
            voxelCornersZ = [z1, z2, z3, z4, z5, z6, z7, z8];
            // TODO: create a hexahedral element by the 8 corners.
        endfor
    endfor
endfor

Question

How can I create a single hex element for a filled voxel, if the voxel corner coordinates are known?

As far as I study the documentation, the CGX should be used by creating a geometry (line, surface, volume) and then creating finite elements through the geometry. The problem is that I don’t create a geometry in advance. I’m a bit confused. I appreciate any hints. Thanks.

I’m studying examples like this, to figure out how to:

Currently, I’m generating finite elements by a data structure in Golang. While iterating over the voxels, the data structure stores elements by their corner coordinates and has functions to write nodes, elements, restraints, and loads as an INP file.

But I’m thinking of replacing the Golang data structure. I can imagine writing CGX commands to an FBD file line by line while I’m iterating over the voxels. I can imagine writing any other needed command to the FBD file. Then I will generate the final INP file by calling CGX with the FBD file as a parameter. These are all imaginations. I’m not sure :roll_eyes:

The objective is leveraging the CGX to generate higher quality finite elements and also a cleaner and maintainable code :white_check_mark:

I guess I have to create volume before creating finite elements. Maybe I can make a volume for each voxel :roll_eyes:

One requirement is that I have to be able to separate sets of elements in layers along the Z-axis. I mean, the elements on the 1st layer, 2nd layer, and so on, should be separatable.

You don’t have to use cgx.

Since you already have the voxel coordinates, you could basically use those to create nodes and convert each voxel into a HE8 or HE20R element.

1 Like

Right. I guess I would stick with my current Golang data structure.

Darker lines

Another thing that motivated me to try CGX for element generation, is the fact that I’m observing darker lines on the surface of my models:

2023-09-26 10_12_17-Window

It’s suggested that the darker lines are a warning sign. So far, I couldn’t fix those darker lines.

Your model was a mixture of linear and quadratic elements.

C3D4
C3D8
C3D10
C3D20R

Those darker lines are probably disconnected midside nodes

1 Like

Right, probably that’s the case :+1: I move forward :white_check_mark: Maybe down the road, I’ll figure out a definite answer as to why.

hi there, we have a python package for CalculiX that can help you… you might want ti check it out:

documentation and manual here:
https://ciclope.readthedocs.io/en/latest/

1 Like

Thanks :+1: Interesting :white_check_mark: