Computational Fluid Dynamics (CFD) workbench using OpenFOAM

Quick question: how does CFDFoam relate to 2459 in regards to what has been implemented?

If I understand the report correctly, we have implemented an equivalent of this in most respects:

his is a proposal to add a couple of features to ease the use of transferring Part-based geometry from FreeCAD to openFOAM. It would include basically:

  • An OpenFOAM object that can
  • hold regions (groups of faces), and associate a tag/label and a color with each region
  • display the tags in the 3D view
  • offer graphical tools to select and manage the regions

I think this is catered for by our CFD boundary conditions where groups of faces can be selected, assigned a boundary condition, and are coloured accordingly.

  • An alternative OBJ exporter that
  • scales everything in meters
  • exports the different regions as OBJ groups

In the course of the present work interfacing with the cartesian meshers cfMesh and snappyHexMesh, this has been done but using stl rather than obj format.

Just to add to Oliver, for the cut-cell Cartesian mesh generators the CFD WB write a multi-element stl which contains all the faces of the mesh object and the points are scaled to meters when the STL is written. The WB then performs a similarity check which generates a createPatchDict to rename the patches using the prescribed boundary condition names.

Back from testing 1:1 fluid dynamics :wink: I am impressed of what happened during one week.
Of cause I tried to test it out, but cartesian meshing creates some problems. It is running, but without result. A failure message is showing:

File “/home/peter/.FreeCAD/Mod/CfdFoam/_TaskPanelCfdMeshCart.py”, line 236, in meshFinished
cart_mesh.read_and_set_new_mesh() # Only read once meshing has finished
File “/home/peter/.FreeCAD/Mod/CfdFoam/CfdCartTools.py”, line 343, in read_and_set_new_mesh
mesh = Mesh.Mesh(os.path.join(self.meshCaseDir, ‘mesh_outside.stl’))
Base.FreeCADError: File does not exist: /tmp/meshCase/mesh_outside.stl

Ubuntu 16.04, FreeCAD daily version



Ah … found the failure … I thought cfMesh is already included in openfoam 4, but it is not.

Sorry, it’s not very clear at the moment. As soon as we’re done with the current development sprint we will update Readmes etc. with latest installation instructions and requirements.

Hi Oliver

that was not your fault. I have read in a CfD forum, that cfMesh would be implemented in the new openfoam, but it is not. To install cfMesh to openfoam is … tricky … perhaps it would be a good idea to give users some comments how to do it. On my Linux computer I had minor problems, on my window computer I failed.

But in general I impressed. specially the way to mesh the boundary layers with refinement. One idea would be to change from picking the single faces to picking all faces of an object and if necessary to remove single faces from the list. Would make life easier, i.e. a rudder of a sailboat has 41 faces, keel some more, the hull three faces, where I need 2, so to kill this one not necessary face is easier than to pick the huge amount of faces.

after testing and play around a little bit, I think there are some bugs:

  1. as mentioned earlier not only the figures of fluid properties are not correctly shown, if edit the values again, also the figures of turbulence etc will change due to scaling and one has to be careful, not to miss the change, otherwise the results are not correct.
  2. also mentioned earlier, to choose the references to create the mesh regions have to be clicked at the screen, no chance to use a list
  3. MAIN PROBLEM: in the boundary conditions of a non viscose wall it is possible to select from a list the faces, but one have to click one by one, not able to select a larger number in one go, thats not the real problem, but writing the case some of these faces will be stored under default faces. I have tried several ways to avoid this, i.e. collecting the different parts in one boundary (keel, rudder, hull), creating single boundary conditions for keel, hull, rudder, creating one fusion of keel, hull, rudder and having one boundary condition ... always same problem, they are stored in the boundary condition(s), but writing the case some faces will be default faces. Its not even clear why some will be default conditions… one time the port side face of the hull is in the default faces, next time, the starboard side … or faces of keel, sometimes some from port side, sometimes the bottom plate is missing, sometimes all faces exclusive bottom face … whatever.
    This is only for the boundary conditions, meshing is working perfect, even if its a problem to select the references. But one time collected references, it is cool to turn the boat, to trim or to heel the boat, re- mesh and be happy with the result. Thats perfect. Of cause I am aware that simple foam is not a real solution to look for a cfd problem on a boat, but if boundary conditions and meshing is working, I think there will be less problems to go for interfoam or other solvers.

For near wall boundary layer refining, I once consider using GMSH, but I do not know how to reference the face by number in the solid (which seems exported as brep file). I stuck there without any progress.

https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Fem/FemGmshTools.py

I disagree. The problem is not the meshing, that works fine, with the exception of difficult way of clicking on each face. The problem is the boundary condition, where i.e. vessels hull starboard side as one face, connected with the upper boundary of the box, will be placed as default boundary condition instead of hull with non viscose boundary condition. In the meshing itself this wall works fine, but if placed in the boundary conditions I think the main problem is the numbering of the faces, because they are only named face… but clicking on a face it`s called rumpf.face98. So maybe one solution could be to change the numbering i.e. the box in the BooleanFragments would get the no. 1000 and faces of this box, face1001, face1002 … the hull i.e. would get the 2000 … with face2001, face2002 … instead of i.e. Part__Feature002:Face1, which is ok for FreeCAD but not for openfoam. In this case the numbers should be clear. Only one idea to solve this problem.

Tomorrow there should be new commits in master to make this easy via a button in the Preferences page for CFD. Under blueCFD some transformations are needed to the source and this is catered for automatically.

But in general I impressed. specially the way to mesh the boundary layers with refinement. One idea would be to change from picking the single faces to picking all faces of an object and if necessary to remove single faces from the list. Would make life easier, i.e. a rudder of a sailboat has 41 faces, keel some more, the hull three faces, where I need 2, so to kill this one not necessary face is easier than to pick the huge amount of faces.

An excellent idea, we’ll put that on the list. Probably won’t get to it very soon so you are welcome to submit a patch if you would like to.

I’ve been looking at this a bit and it looks like there is a way to sort it out, thanks to Werner.

  1. also mentioned earlier, to choose the references to create the mesh regions have to be clicked at the screen, no chance to use a list

Again a good point, but we probably can’t prioritise this for a bit, so a contribution would be great.

  1. MAIN PROBLEM: in the boundary conditions of a non viscose wall it is possible to select from a list the faces, but one have to click one by one, not able to select a larger number in one go, thats not the real problem, but writing the case some of these faces will be stored under default faces. I have tried several ways to avoid this, i.e. collecting the different parts in one boundary (keel, rudder, hull), creating single boundary conditions for keel, hull, rudder, creating one fusion of keel, hull, rudder and having one boundary condition ... always same problem, they are stored in the boundary condition(s), but writing the case some faces will be default faces. Its not even clear why some will be default conditions… one time the port side face of the hull is in the default faces, next time, the starboard side … or faces of keel, sometimes some from port side, sometimes the bottom plate is missing, sometimes all faces exclusive bottom face … whatever.

This is odd. First question: With which mesher are you having this problem?

Hi Oliver,

with the Cartesian mesher. But once again, not the mesher is the problem. The mesher is working excellent. In the file “createPatchDict” faces which were defined as i.e. “hull” were suddenly defined as “default Faces”. And that is what I do not understand. In the refinement with the region tool all faces belonging to the “hull” were recognized and the refining was done properly.

The mesher selected has some influence on the method of detecting the boundaries. If you can can share a minimal example that demonstrates the bug, we will have a look.

Hi Oliver,

please note attached file. I had to delete the meshing due to size.
test.fcstd (798 KB)
Result of this model, Keel and rudder are defined as hull, port and starboard side of hull, are placed in the default faces.

here a summery of “createPatchDict”

name hull;

patchInfo
{
type wall;
}

constructFrom patches;

patches ( face6 face7 face8 face9 face10 face11 face12 face13 face14 face15 face17 face18 face19 face20 face21 face22 face23 face24 face25 face26 face27 face28 face29 face30 face31 face32 face33 face34 face35 face36 face37 face38 face39 face41 face42 face43 face44 face45 face46 face47 face48 face49 face50 face51 face53 face55 face56 face57 face58 face59 face60 face61 face62 face63 face64 face65 face68 face69 face70 face71 face72 face73 face74 face75 face76 face77 face78 face79 face80 face81 face82 face83 face84 face85 face86 face87 face88 face89 face90 face91 face92 face93 face94 face95 face96 face97 face98 face99 face100 face101 face102 face103 face104 face105 );
}

{
name defaultFaces;

patchInfo
{
type patch;
}

constructFrom patches;

patches ( face16 face40 face52 face54 face66 face67 );
}

Hi,

I am a linux user and here some first impressions of my first installation and simulation-run.

I installed openfoam 4.0 from “https://openfoam.org/download/4-1-ubuntu/” and upgraded to 4.1 as described.
After that I added gnuplot from the repo with

sudo apt-get install gnuplot python-gnuplot

After that I had some problems with your preferences-dialog for your workbench in FC.
I would like to have the possibility to manually set file paths. This enables e.g. the use of an installed version of gmsh and in parallel the use of a downloaded version. The standard gmsh verion in the repo is to old and the official from gmsh.info comes as .tgz and can be run after unzipping.

I do not know if the prerequirements-checker is working on Linux. Should it work or is it only for WIN?
The installation of cfMesh from the FC-Preferences page results in "

Error downloading cfMesh: [Errno 2] No such file or directory: '/home/username/OpenFOAM/username-4.1/cfMesh-v1.1.2.tar.gz'

".

I tried the elbow example from https://github.com/opensimsa/opensim/tree/master/TestCases/CFD/Elbow and it did work with gmesh and without cfMesh. The only setting I had to change was the max. mesh size was set to 0.0 otherwise I got “Error : Self intersecting surface mesh, computing intersections (this could take a while)”.

Do you plan to give some parts of your work back to FEM-wb? I like your ‘advanced’ dialog for selecting boundary conditions and would love to see it in FEM-wb!!!

Looking forward to see more if this. :sunglasses:

BR,
HoWil

OS: Ubuntu 16.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.11283 (Git)
Build type: None
Branch: master
Hash: dd48cc5f2b017a3cfd2374933441d6b5bf96cabf
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.1.0

@HoWil FYI if you find anymore prerequisite dependency checker issues, please also post them to: https://github.com/FreeCAD/FreeCAD-addons/issues/29

Edit: removed typo emoji that crept in to the post.

BTW thx for the very very nice tutorials for openfoam and calculix in combination with FC:
e.g.:
https://github.com/opensimsa/opensim/blob/master/Documentation/FEA/BlockWithHole/BlockWithHole.pdf
see
https://github.com/opensimsa/opensim/tree/master/Documentation

:sunglasses: why the :cry: ?
Also @oliveroxtoby ,@johan and (@abogaers) I just wondered …

  • If you could also use matplotlib instead of gnuplot.. would reduce the number of packages needed.
  • If you could also check/use the settings for gmsh in FEM-wb

BR,
HoWil

:laughing: @HoWil it was a typo! I edited the post with the hope that you wouldn’t misconstrue :blush:
Cheers!

Thank you. Very helpful for debugging. We will investigate as soon as we are able.