CfdOFWorkbench - update patches with Geometry

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

Post Reply
AtD
Posts: 50
Joined: Mon Mar 18, 2019 7:14 am

CfdOFWorkbench - update patches with Geometry

Post by AtD »

Hey all. This is my first post here, so Hi!
First of all thanks to everyone putting time into FreeCAD, its a great tool :)

Ok, now my problem: I'm planning on setting up part of an automated cfd-analysis workflow based on freecad, snappyhexmesh and openfoam. It uses a parametric geometry and ideally pre-defined boundary patches. The output of my part shall be an stl-file with the patches available for reference in OpenFoam.
The part with the parametric geometry is solved. My model adjusts just as I change the parameters set within a spreadsheet. The obstacle is arising within the CfdOFWorkbench: the geometry of the patches are not automatically updated with the geometry by App.ActiveDocument.recompute().
I have no time to provide an example at this time (maybe tomorrow). So imagine this: I have a cube 1m x 1m x 1m. So the inlet patch (one of the faces) is 1m x 1m. Now I change the size to 2m x 2m. -> patch is not updated UNTIL: I use the GUI, double click the boundary to get into the properties. The moment the property window opens, the patch geometry is updated as desired. Unfortunately there is no Python console output belonging to that step which I could just call inside my script.

Any hints on how to tackle this issue are very much appreciated.

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16117 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: dbb4cc6415bac848a294f03b80f65e888d531742
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
chrisb
Veteran
Posts: 54302
Joined: Tue Mar 17, 2015 9:14 am

Re: CfdOFWorkbench - update patches with Geometry

Post by chrisb »

Moved to CFD forum
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
AtD
Posts: 50
Joined: Mon Mar 18, 2019 7:14 am

Re: CfdOFWorkbench - update patches with Geometry

Post by AtD »

I was able to figure out a way: the CfdFluidBoundary-Class has a method enforceRecompute. By calling it for each boundary, their recomputation is forced on the next document recompute:

Code: Select all

App.ActiveDocument.CfdFluidBoundary.enforceRecompute()
App.activeDocument().recompute()
The patch is updated according to the current geometry it is based on.
User avatar
oliveroxtoby
Posts: 840
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: CfdOFWorkbench - update patches with Geometry

Post by oliveroxtoby »

AtD wrote: Tue Aug 20, 2019 3:18 pm Hey all. This is my first post here, so Hi!
First of all thanks to everyone putting time into FreeCAD, its a great tool :)

Ok, now my problem: I'm planning on setting up part of an automated cfd-analysis workflow based on freecad, snappyhexmesh and openfoam. It uses a parametric geometry and ideally pre-defined boundary patches. The output of my part shall be an stl-file with the patches available for reference in OpenFoam.
The part with the parametric geometry is solved. My model adjusts just as I change the parameters set within a spreadsheet. The obstacle is arising within the CfdOFWorkbench: the geometry of the patches are not automatically updated with the geometry by App.ActiveDocument.recompute().
I have no time to provide an example at this time (maybe tomorrow). So imagine this: I have a cube 1m x 1m x 1m. So the inlet patch (one of the faces) is 1m x 1m. Now I change the size to 2m x 2m. -> patch is not updated UNTIL: I use the GUI, double click the boundary to get into the properties. The moment the property window opens, the patch geometry is updated as desired. Unfortunately there is no Python console output belonging to that step which I could just call inside my script.

Any hints on how to tackle this issue are very much appreciated.
Nice to see the workbench being used in this way :)

This is actually something I've been meaning to sort out for a while. My latest commit should, I hope, fix the issue without the need for your workaround.
AtD
Posts: 50
Joined: Mon Mar 18, 2019 7:14 am

Re: CfdOFWorkbench - update patches with Geometry

Post by AtD »

hi oliveroxtoby
Thanks for your effort, I will try it out at some point and give you feedback.
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: CfdOFWorkbench - update patches with Geometry

Post by qingfeng.xia »

I am also interested in automate CAE,
here is my example, different tools:

https://github.com/qingfengxia/CAE_pipeline
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
AtD
Posts: 50
Joined: Mon Mar 18, 2019 7:14 am

Re: CfdOFWorkbench - update patches with Geometry

Post by AtD »

@oliveroxtoby:
I tried it again with the recent version of the workbench and it works perfectly. Thanks!
User avatar
oliveroxtoby
Posts: 840
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: CfdOFWorkbench - update patches with Geometry

Post by oliveroxtoby »

AtD wrote: Tue Oct 01, 2019 10:56 am @oliveroxtoby:
I tried it again with the recent version of the workbench and it works perfectly. Thanks!
Great - thanks for the feedback!
Post Reply