update on FreeCAD + OpenFOAM fluid dynamic computation

A subforum specific to the development of the OpenFoam-based workbenches ( Cfd https://github.com/qingfengxia/Cfd and CfdOF https://github.com/jaheyns/CfdOF )

Moderator: oliveroxtoby

qingfeng.xia
Posts: 153
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, Merry Xmas and pappy new year 2016&2017&2018&2019

============ updated (2018-12-29) ==================

Cfd workbench will be in maintenance mode, I do not have enough spare time to support feature development. However, I will make Cfd workbench work in stable FreeCAD release like v0.17, and later 0.18, etc. You can fire bug at my https://www.github.com/qingfengxia/Cfd/issues, I can get email to response as I have no time to check this forum.

I hope to get resource as an academic staff soon and sponsorship from industry to complete more feature. I had a meeting with Prof Jasak, the original author of OpenFOAM. We were particularly interested in CAE automation, it will be part of my future research direction. So I spend most of time to develop a multiphysics FEM solver (https://www.github.com/qingfengxia/FenicsSolver), and coupling FEM and OpenFOAM in 2018.
automaticCAEpipeline.png
automaticCAEpipeline.png (26.23 KiB) Viewed 374 times
Last Xmas, I make some work to let Cfd work on win10 WSL. Recently in this Xmas time, I make Cfd workbench working with external meshing tools like Salome mesh, as a complementary to Gmsh integrated mesher. see http://www.iesensor.com/blog/wp-content ... _mesh.webm

I also make a new boundarycondtion in python, user can provide/edit (in QTableView) each variable boundary condition as a raw python dict, see below.
FreeCAD_CFD_OpenFOAM_boundary.png
FreeCAD_CFD_OpenFOAM_boundary.png (431.34 KiB) Viewed 296 times
Besides, I had FemInitialValue and FemBodySource feature submit to Fem Workbench, see
https://forum.freecadweb.org/viewtopic.php?f=18&t=33124
============== updated (2017-05-16) ====================

I am not available until July 2017 to work on this project. In the future I will focus on non-gui part, "FoamCaseBuilder" which can work without FreeCAD in text mode.

please refer to this post for new feature fork.
Port of CFD called CFDFoam https://forum.freecadweb.org/viewtopic.php?f=18&t=21576
https://github.com/jaheyns/CfdFoam

They have more resource than me, hopefully, they can mature this workbench asap.

Their boundary setting class is implemented in python, so it is kind of self-contained. This is a be good choice, as FEM workbench is changing very fast to maintain CFD workbench and dev in C++ is more painful.

My current day-work project is using Fenics to solve multiphysics problem, once some one can export FreeCAD fem mesh to FEnics, we can solve more physics problem easily.

==================== update on 2016-04-17 ======================

OpenFOAM for FreeCAD finishes stage II development

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 I (2015 Dec) =================

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/ ... rc/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/ ... rc/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/ ... 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 5869 times
Last edited by qingfeng.xia on Mon Jan 07, 2019 10:33 pm, edited 16 times in total.
Ubuntu LTS 64bit in virtualbox, always work with latest FreeCAD git version
Mainly work on OpenFOAM + Fenics for CFD, FSI
triplus
Posts: 8120
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: 2845
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: 7038
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: 153
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 LTS 64bit in virtualbox, always work with latest FreeCAD git version
Mainly work on OpenFOAM + Fenics for CFD, FSI
qingfeng.xia
Posts: 153
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 LTS 64bit in virtualbox, always work with latest FreeCAD git version
Mainly work on OpenFOAM + Fenics for CFD, FSI
User avatar
bernd
Posts: 7038
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: 153
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 LTS 64bit in virtualbox, always work with latest FreeCAD git version
Mainly work on OpenFOAM + Fenics for CFD, FSI
User avatar
yorik
Site Admin
Posts: 10706
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: 153
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/ ... eWriter.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 LTS 64bit in virtualbox, always work with latest FreeCAD git version
Mainly work on OpenFOAM + Fenics for CFD, FSI