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: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

update on FreeCAD + OpenFOAM fluid dynamic computation

Post by qingfeng.xia »

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 5210 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 5132 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 10705 times
Last edited by qingfeng.xia on Mon Jan 07, 2019 10:33 pm, edited 16 times in total.
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by triplus »

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

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by ickby »

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
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by bernd »

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: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by qingfeng.xia »

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 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by qingfeng.xia »

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 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by bernd »

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: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by qingfeng.xia »

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 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by yorik »

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: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: update on FreeCAD + OpenFOAM fluid dynamic computation

Post by qingfeng.xia »

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 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
Post Reply