update on FreeCAD + OpenFOAM fluid dynamic computation

About the development of the FEM module/workbench.
qingfeng.xia
Posts: 107
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

update on FreeCAD + OpenFOAM fluid dynamic computation

Postby qingfeng.xia » Sat Jan 02, 2016 12:37 am

Hi Everyone, Happy new year 2016

OpenFOAM for FreeCAD finishes stage II development (2016-04-17)

This is an early preview, only for people with experience of OpenFoam.
Test instruction could be found at
https://github.com/qingfengxia/FreeCAD/ ... /Readme.md

I would love to see some feedback for stage III development, see roadmap:
https://github.com/qingfengxia/FreeCAD/ ... roadmap.md

A video preview of OpenFoam plugin for FreeCAD Fem workbench
http://www.iesensor.com/FreeCADDoc/oepn ... engXIA.mp4

The code will attempt to merge with master for version 0.17 after review. However, the OpenFoam related code is independent from CalculiX, except for the Material class. I plan to developed a general FemMaterial model (not yet finished), ultimately for multiphysics modeling in FreeCAD. Rebase to master will be easier than before.

======================================

Phase 1 finishes UNV meshing writing, and a simple OpenFOAM case writing up. Various boundary conditions are not implemented by reuse the FemConstraint. I have added one essential new FemConstraint: FemConstraintsymmetry , see https://github.com/qingfengxia/FreeCAD/tree/femconstraint/src/Mod/Fem, I am not good at the C++, I hope a subtype PropertyEnumeration could be added , to distinguish the special boudnary type: symmetry, FSI, axis-symmetry, freestream, etc and give diff color.

https://github.com/qingfengxia/FreeCAD/tree/foambuilder_pre1/src/Mod/Fem
There are plenty of GUI work (left to phase II), I do not expect to complete. I will focus on text interface to build up case: FoamCaseBuilder package.

I have done phase I work, according to my roadmap. https://github.com/qingfengxia/FreeCAD/blob/foambuilder_pre1/src/Mod/Fem/FoamCaseBuilder/Readme_roadmap.md It is NOT ready to test (compilation may fail), but code preview. (After rebase on 2016-01-01, it is not fully tested even on my PC) A tutorial will needed for 3rd party test, as it is not intuitive to test the GUI code.


freecad_pipe_cfd.png
freecad_pipe_cfd.png (274.1 KiB) Viewed 2723 times
Last edited by qingfeng.xia on Sun Apr 17, 2016 3:35 pm, edited 3 times in total.
Ubuntu 0.17-dev OpenFOAM + FreeCAD
triplus
Posts: 4993
Joined: Mon Dec 12, 2011 4:45 pm

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby triplus » Sat Jan 02, 2016 9:44 am

Looking good.
ickby
Posts: 2460
Joined: Wed Oct 05, 2011 7:36 am

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby ickby » Sat Jan 02, 2016 10:19 am

Just a question: I see there is a different analysis for calculix and openfoam. Up to now I thought there is only one FEM analysis object and only the solver object is changed dependend on if one whants calculix or openfoam. On a first look it seems redundant, if there is a special openfoam analysis one does not need to decouble the solver from the analysis, or? I would be interested why you choose this layout.
User avatar
bernd
Posts: 3924
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby bernd » Sun Jan 03, 2016 4:39 pm

Does neither compile on my Debian Jessie nor on Travis (https://travis-ci.org/berndhahnebach/Fr ... s/99859181)

see https://github.com/berndhahnebach/FreeC ... diff=split for what I needed to get in compiled.

More informations after some testing later on. An example file for OpenFOAM would be cool.
qingfeng.xia
Posts: 107
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby qingfeng.xia » Mon Jan 04, 2016 1:34 am

ickby wrote:Just a question: I see there is a different analysis for calculix and openfoam. Up to now I thought there is only one FEM analysis object and only the solver object is changed dependend on if one whants calculix or openfoam. On a first look it seems redundant, if there is a special openfoam analysis one does not need to decouble the solver from the analysis, or? I would be interested why you choose this layout.


FSI (fluid structure interaction) , FEM + CFD is more interesting, but challenging. I try to make CalculiX and openFOAM share jobcontrol UI or more as possible, but I have not got time to make change to CalculiX related code any more. So my work will focus on OpenFOAM from now on. Just ignore the CalculiX analysis in the pasted fig.

Thanks
Ubuntu 0.17-dev OpenFOAM + FreeCAD
qingfeng.xia
Posts: 107
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby qingfeng.xia » Fri Jan 22, 2016 3:47 pm

bernd wrote:Does neither compile on my Debian Jessie nor on Travis (https://travis-ci.org/berndhahnebach/Fr ... s/99859181)

see https://github.com/berndhahnebach/FreeC ... diff=split for what I needed to get in compiled.

More informations after some testing later on. An example file for OpenFOAM would be cool.



I finally got a time to test compiling on another PC
https://github.com/qingfengxia/FreeCAD/ ... prerelease, this branch is compiling without error. I am not sure if all python files will be copy into places. "FoamCaseBuilder" this folder is definietely not copied to build folder, as I run from build folder without installation but test with symbolic link to that folder for quick edit.

I will restart this work in late Feb, after closing some deadlines in my work. Once I make constraint/boundary condition setup GUI , it will be usable.

A detailed installation guideline is needed to make this code + simulation working, it will be available soon.

Thanks
Last edited by qingfeng.xia on Fri Jan 22, 2016 5:07 pm, edited 1 time in total.
Ubuntu 0.17-dev OpenFOAM + FreeCAD
User avatar
bernd
Posts: 3924
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby bernd » Fri Jan 22, 2016 3:51 pm

qingfeng.xia wrote:... https://github.com/qingfengxia/FreeCAD/ ... prerelease, this branch is compiling without error.

Do you have some file or code to test the openfoam with?
qingfeng.xia
Posts: 107
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby qingfeng.xia » Sun Jan 24, 2016 2:35 pm

bernd wrote:
qingfeng.xia wrote:... https://github.com/qingfengxia/FreeCAD/ ... prerelease, this branch is compiling without error.

Do you have some file or code to test the openfoam with?



I just write a readme.md, it shows how it can be tested without GUI.
Also, I delete foamcasebuilder_prerelease branch, but keep only the latest one: foambuilder_pre1
I also list the issue I met, perhaps, someone may help me out.
https://github.com/qingfengxia/FreeCAD/ ... aseBuilder

BTW, how could I update mesh from script, after changing mesh property from "fine" -> "veryfine"?

Thanks
Ubuntu 0.17-dev OpenFOAM + FreeCAD
User avatar
yorik
Site Admin
Posts: 8670
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby yorik » Sun Jan 24, 2016 3:28 pm

By the way, I had (have) some discussion going on with the openFOAM people, I haven't had much time to work on it lately unfortunately... They were/are basically wanting better ways to use FreeCAD as a main modeller for openFOAM. Among the things they were missing:
- A way to "tag" regions of geometry
- An OBJ exporter that would use those tags, and also that would scale everything to meters

I started working on an OBJ exporter that would scale things to meters, and that would also export each color of an object as a separate OBJ region. This is what I have so far: https://gist.github.com/yorikvanhavre/8 ... f7ff6c1bc6

The idea, once that works well, would be to add a new openfoam object, with some tool to tag groups of faces.
qingfeng.xia
Posts: 107
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Postby qingfeng.xia » Mon Jan 25, 2016 10:35 am

Gmsh and netgen mesh can be found in official mesh conversion tool list
see http://www.openfoam.org/features/mesh-conversion.php

What I have done is: export mesh to UNV file as it provided by FreeCAD, while constraint face cells are not exported, manually appending this info to previous imported file. This piece of code could be found in FoamCaseWriter.py of FEM folder. write_bc_faces()
https://github.com/qingfengxia/FreeCAD/blob/foambuilder_pre1/src/Mod/Fem/FoamCaseWriter.py

using command line `IdeasUnvToFoam` to convert mesh, it also scaled the CAD to mesh by 0.001.
FreeCAD can select default unit from mm to m, but we may just leave it as default, as mm length unit is common for CAD.

For serious simulation, I would export FreeCAD to Salome for meshing, then export to UNV, then convert to openFoam mesh , simulaiton -> paraview

FreeCAD can import UNV mesh volume cells, but boundary (list of surface cells) is not imported, I suspect FemMesh Object has no data structure to hold such information. A list of such boundaryFaces would be helpful, as imported mesh as no related volume/part, so faces can not be selected any longer to apply fem constraint or CFD boundary condition.

Thanks
Ubuntu 0.17-dev OpenFOAM + FreeCAD