Topology optimization

About the development of the FEM module/workbench.

Moderator: bernd

shIxx
Posts: 83
Joined: Wed Mar 28, 2018 10:13 am
Location: Bavaria (Germany)

Re: Topology optimization

Post by shIxx »

fandaL wrote: Mon Sep 30, 2019 9:19 pm I’m not sure if it is intended workbenchworkflow but dirty way can be to define another cube, shift it to overlap original geometry a bit and than define a new material on the cube (which has nothing to do with a mesh object).
I have tried this way but callculix is giving an error.
Apparently, all materials must be meshed so that calculix can write the input file.

Code: Select all

0.0: Check dependencies...
4.8: Write .inp file failed!
Report view:

Code: Select all

ERROR: femelement_table != count_femelements
Count FEM elements as sum of constraints:  5302
Count FEM elements of the FreeCAD FEM Mesh:   5239
Error in get_femelement_sets -- > femelements_count_ok() failed!
Constraint fixed: FemConstraintFixed
  nodes will be retrieved by searching the appropriate nodes in the FEM mesh
  ReferenceShape ... Type: Face, Object name: Box, Object label: Solid, Element name: Face1
Constraint force: FemConstraintForce
Writing time input file: 4.76 seconds 
Problems on writing input file, check report prints.
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16131 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 3129ae4296e40ed20e7b3d460b86e6969acbe1c3
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: German/Germany (de_DE)
Attachments
NonDesignRegion_not_working.png
NonDesignRegion_not_working.png (430.31 KiB) Viewed 5053 times
fandaL
Posts: 440
Joined: Thu Jul 24, 2014 8:29 am

Re: Topology optimization

Post by fandaL »

Blaze wrote: Thu Oct 17, 2019 11:01 am Hi All,
Can anyone describe how exactly should I prepare model and mesh if I ahve a regions which i don't want to optimize ? I am trying with boolean operatons but it seems to not work.
Hi Blaze,
Ordinary FreeCAD way for multiple materials (instead of booleans like cut, union, and intersection) is to use:
Part -> Split -> Boolean Fragments
and in its property view (data) select Mode=CompSolid
https://www.freecadweb.org/wiki/Part_BooleanFragments

since when this object is meshed, sub-shapes boundaries are connected properly by nodes. Than you apply materials to the CompSolid. Later, you select material object as a design domain in optimization.

Non-design domain (i.e. rest of the model) does not have to be explicitly defined in the optimization GUI (unless you want to track stress in the non-design domain during optimization or display also non-design mesh in the results).
shIxx wrote: Thu Oct 17, 2019 7:05 pm
fandaL wrote: Mon Sep 30, 2019 9:19 pm I’m not sure if it is intended workbenchworkflow but dirty way can be to define another cube, shift it to overlap original geometry a bit and than define a new material on the cube (which has nothing to do with a mesh object).
I have tried this way but callculix is giving an error.
I got same error if I defined explicitly one material to one box, second material to second box. The error means that there are overlapping mesh selections and FreeCAD does not know which material should be in the overlapping section.
The way around is to select geometry only for the "non-design" box inside "non-desing" material object. "Design" material (i.e. original geometry which is meshed) should have empty geometry selection, which means to select automatically rest of the elements which are not selected explicitly by other material objects.
Blaze
Posts: 2
Joined: Thu Oct 17, 2019 10:58 am

Re: Topology optimization

Post by Blaze »

fandaL wrote: Thu Oct 17, 2019 9:50 pm
Blaze wrote: Thu Oct 17, 2019 11:01 am Hi All,
Can anyone describe how exactly should I prepare model and mesh if I ahve a regions which i don't want to optimize ? I am trying with boolean operatons but it seems to not work.
Hi Blaze,
Ordinary FreeCAD way for multiple materials (instead of booleans like cut, union, and intersection) is to use:
Part -> Split -> Boolean Fragments
and in its property view (data) select Mode=CompSolid
https://www.freecadweb.org/wiki/Part_BooleanFragments

since when this object is meshed, sub-shapes boundaries are connected properly by nodes. Than you apply materials to the CompSolid. Later, you select material object as a design domain in optimization.

Non-design domain (i.e. rest of the model) does not have to be explicitly defined in the optimization GUI (unless you want to track stress in the non-design domain during optimization or display also non-design mesh in the results).
THX for answer. Now I have another question. What am I doing wrong I can't define non design area as domain in BESO GUI ? I am able to show in results only optimised area. I have done intersection, I have added material to both solids, but in gui i am able to chose only one solid.
Attachments
Adnotacja 2019-10-18 140452.PNG.jpg
Adnotacja 2019-10-18 140452.PNG.jpg (136.22 KiB) Viewed 5003 times
fandaL
Posts: 440
Joined: Thu Jul 24, 2014 8:29 am

Re: Topology optimization

Post by fandaL »

There was a bug related to FC0.18. Now it should be fixed, so you can download updated file https://github.com/fandaL/beso/blob/mas ... _fc_gui.py

Just a note to be sure: If you create new materials and have beso gui already opened, you should click "Update domains". But be sure to also recreate inp file from FreeCAD as if you start ordinary analysis after model modifications.
Bercebus
Posts: 9
Joined: Sun Oct 16, 2016 10:23 am

Re: Topology optimization

Post by Bercebus »

Hi fandaL,

I am very interested in your macro. I tried to use it but I can't get any results. Maybe I am not understanding something.

In the macro, I put the .inp file that it is generated by Freecad after running the calculix analysis; in the range, the double size of the element size and the rest as default and then I push the "Generate conf. file and run optimization" button.

But the output .inp file is the same as the original. In the log file I have the error: CalculiX result file not found, check your inputs.

Maybe am I using a wrong input file?

Best regards
fandaL
Posts: 440
Joined: Thu Jul 24, 2014 8:29 am

Re: Topology optimization

Post by fandaL »

Bercebus wrote: Wed Dec 11, 2019 7:41 am In the log file I have the error: CalculiX result file not found, check your inputs.
I suppose that you checked original inp file by running CalucliX from FreeCAD and checked that results are correct.

In the working directory there should be „file000.inp“ which is rewritten inp file from the original input for the 0th iteration. There could be some error runnig CaluliX on it.
To check CalculiX errors, you can run ccx manually from command line, e.g. on windows by the command

Code: Select all

C:/soft/FreeCAD_0.19.18234_x64_LP_12.1.2_PY3QT5-WinVS2015/bin/ccx.exe  C:/wording_dir/FEMMeshGmsh
where I took it according to parameters on the top of beso_conf.py, e.g.

Code: Select all

path_calculix = 'C:/soft/FreeCAD_0.19.18234_x64_LP_12.1.2_PY3QT5-WinVS2015/bin/ccx.exe'
path = 'C:/wording_dir'
file_name = 'FEMMeshGmsh.inp'
Edit:
Results in file000.frd should than contain similar results as from original analysis (drug and drop it to FreeCAD). file000.dat should contain many numbers under the heading "internal energy density..."
Bercebus
Posts: 9
Joined: Sun Oct 16, 2016 10:23 am

Re: Topology optimization

Post by Bercebus »

fandaL wrote: Wed Dec 11, 2019 2:58 pm
Bercebus wrote: Wed Dec 11, 2019 7:41 am In the log file I have the error: CalculiX result file not found, check your inputs.
I suppose that you checked original inp file by running CalucliX from FreeCAD and checked that results are correct.

In the working directory there should be „file000.inp“ which is rewritten inp file from the original input for the 0th iteration. There could be some error runnig CaluliX on it.
To check CalculiX errors, you can run ccx manually from command line, e.g. on windows by the command

Code: Select all

C:/soft/FreeCAD_0.19.18234_x64_LP_12.1.2_PY3QT5-WinVS2015/bin/ccx.exe  C:/wording_dir/FEMMeshGmsh
where I took it according to parameters on the top of beso_conf.py, e.g.

Code: Select all

path_calculix = 'C:/soft/FreeCAD_0.19.18234_x64_LP_12.1.2_PY3QT5-WinVS2015/bin/ccx.exe'
path = 'C:/wording_dir'
file_name = 'FEMMeshGmsh.inp'
Edit:
Results in file000.frd should than contain similar results as from original analysis (drug and drop it to FreeCAD). file000.dat should contain many numbers under the heading "internal energy density..."

Hi again, fandaL
It was my mistake. Although the FEM simulation was working well in Freecad, I wrote the .inp file in another folder but didn't run calculix in it. That's why the BESO macro didn't work.

Thanks and best regards
Bercebus
Posts: 9
Joined: Sun Oct 16, 2016 10:23 am

Re: Topology optimization

Post by Bercebus »

Hi, fandaL

Can I suggest a couple of features in BESO GUI?

Is it possible to put an iteration limit and/or a button to cancel the optimization process?

Best regards
fandaL
Posts: 440
Joined: Thu Jul 24, 2014 8:29 am

Re: Topology optimization

Post by fandaL »

Bercebus wrote: Thu Dec 12, 2019 6:44 am Is it possible to put an iteration limit and/or a button to cancel the optimization process?
To enforce finishing, you can terminate CalculiX process in the Task Manager so that optimization should give the error due to missing CaluliX results. Maybe later I will add a button to do something like this.

Iterations limit can be set by editing configuration file beso_conf.py by adding a line (e.g. for 10 iterations)

Code: Select all

iterations_limit = 10
Bercebus
Posts: 9
Joined: Sun Oct 16, 2016 10:23 am

Re: Topology optimization

Post by Bercebus »

Hi, fandaL

Thank you for your kind answers!

I have another question. Is it possible to convert the optimized FEM mesh into a solid infill? I can only get a hollow mesh after exporting it as a .stl and then importing it into the PART module.

Best regards
Post Reply