Topology Optimization (SIMP) for CalculiX - View results in PrePoMax?

Hello all,

My research focuses on topology optimization and additive manufacturing. Currently, I use Python as my main framework, but it is limited to structured homogeneous grids, or better said, all hex meshes of the same size. I am planning to implement topology optimization (SIMP method — Solid Isotropic Material with Penalization) within CalculiX. Several ideas have come to mind.

Already 12 years ago, I managed to create an ESO (Evolutionary Structural Optimization) topology based on the input (.inp) and result (.frd) files from CalculiX. At that time, my programming skills were quite limited. Here is an easy example post-processed in CGX: (see next post)

I am aware that there is a BESO (Bi-directional Evolutionary Structural Optimization) script vailable for CCX, but the limitations are known.

It seems that an implementation of the SIMP method already exists in CCX. I have been in contact with the author, who claimed that changes in the CCX version were quite challenging, resulting in a lot of work to maintain the optimization code.

Therefore, I prefer to stick as much as possible with Python and just use CalculiX as a solver. I have added approximately 50 lines of code (in Fortran and C), which mainly consist of:

  • Checking if topology optimization is enabled via a specific initialization file
  • Writing element matrices, volumes, and centers of gravity (done only once during the initialization run)
    → This is necessary for the SIMP method’s sensitivity evaluation and filtering purposes
  • Reading density values per element

That’s all. The magic happens in Python. There might be potential for improvement by splitting the sensitivity loop into chunks to utilize available CPU cores and reduce computation time. Additionally ccx works as before, if there is no initialization file for the topology optimization.

Overall, I have conducted several examples, as shown here (GE-bracket and Nacelle bracket). The properties and simulation durations are listed. Convergence was reached probably at iteration 25-ish. Shortening the duration by half, ~15 min and 1.5 hours respectively.

Further development ideas:

  • Element set definition for design and non-design regions
  • Multiple load cases
  • Compiling CCX for Windows (currently Linux with Pardiso)

REQUEST:

Currently, the results are stored in a txt file with the following format:
ElementID\tDensity
1\t1.
2\t0.5
3\t0.1239

The txt file is generated for each iteration and process it in ParaView or PyVista. In the next step, the elemental results are extrapolated to the nodes, creating a much smoother visualization. The values are then limited using the “Iso Volume” to 0.5.

Is there a possibility to perform this in PrePoMax, to view the results directly within the software instead of using the VTK file format and ParaView.

Would this be a feasible request?

Thanks and best regards,
Stoli (from Germany)

1 Like

ESO: 12 years ago

image35

GE bracket:

image25

Nacelle bracket:

image26

This is a really nice work that has been done. I plan to integrate topology optimization into PrePoMax at some point in the future, so I am very interested in this topic.

If I understand correctly, you would need the capability to import elemental densities and then use iso-surface visualization using the nodal-averaged values?

Is your code available as open-source code?

Actually, there are 2 topology optimization solutions utilizing FreeCAD as GUI and CalculiX as solver - beso (that you’ve already mentioned) and this: GitHub - Foxelmanian/ToOptixFreeCADAddon: Addon for FreeCAD using ToOptix

However, they indeed seem to be quite limited. The latter is also not actively developed anymore while beso is more up-to-date and its author (fandaL) should still be reachable.

Today, someone also shared this on the FreeCAD forum: Making sure you're not a bot!

@Matej
Thank you — especially for the great work regarding PrePoMax.

The code is not available yet. It is still not perfect and still function-oriented, in order to keep it very simple. The ability to view the results during the optimization with the pruposed method of “iso volume” would be an excellent feature for PrePoMax.
I can privately share some code snippets. Also compiling the altered ccx-src for Windows would be nice.

@FEAnalyst
Thanks for sharing ToOptix — I was not aware of that solution. The recent post on FreeCAD is also quite interesting.
All these developments highlight the demand for topology optimization, and having the ability to incorporate it into PrePoMax would be a significant benefit.

The main advantage of my approach is the manipulation of the elemental matrices within CalculiX (ccx). The input file does not change. During the iteration, the FE problem is solved based on the described density file (density-file.txt). The displacement vector is read by Python, and by looping through the elemental matrices (stored in a binary file), the sensitivities are derived. The optimizer (currently based on the optimality criterion method) then computes the new densities, which are again stored in the density file.
Again, this needs just minor interference with ccx. The python code is also quite efficient.

1 Like