Test request: OpenFOAM solver for FemWorkbench

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

User avatar
oliveroxtoby
Posts: 837
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: Test request: OpenFOAM solver for FemWorkbench

Post by oliveroxtoby »

At present, we require FreeCAD to be run with the OpenFOAM environment already set up (source <OpenFOAM-dir>/etc/bashrc) - this might be the issue here?

Oliver
Please provide all the information requested in this post before reporting problems with CfdOF.
User avatar
oliveroxtoby
Posts: 837
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: Test request: OpenFOAM solver for FemWorkbench

Post by oliveroxtoby »

Sorry - please disregard my last reply. I didn't notice your foamVersion output.
Was any console output produced?
Please provide all the information requested in this post before reporting problems with CfdOF.
User avatar
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: Test request: OpenFOAM solver for FemWorkbench

Post by makkemal »

No further output on console

Code: Select all

makke@ubuntu:~/FreeCAD_comp$ simpleFoam -help

Usage: simpleFoam [OPTIONS]
options:
  -case <dir>       specify alternate case directory, default is the cwd
  -noFunctionObjects
                    do not execute functionObjects
  -parallel         run in parallel
  -postProcess      Execute functionObjects only
  -roots <(dir1 .. dirN)>
                    slave root directories for distributed running
  -srcDoc           display source code in browser
  -doc              display application documentation in browser
  -help             print the usage

Using: OpenFOAM-4.1 (see www.OpenFOAM.org)
Build: 4.1


qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Test request: OpenFOAM solver for FemWorkbench

Post by qingfeng.xia »

oliveroxtoby wrote:At present, we require FreeCAD to be run with the OpenFOAM environment already set up (source <OpenFOAM-dir>/etc/bashrc) - this might be the issue here?

Oliver
Yes, for the moment, it is requested to start from comsole on Linux , and setup source foam/etc/bashrc to deal variant of foam like official or foam-extend.
we can not source oepnfoam/etc/bashrc into /etc/profile, it causes some problem during login.

it maybe possible to run FreeCAD-daily from gui luancher, instead of terminal. (29/12/2016)
PyFoam needs write perm on the current dir, if I start FreeCAD from gui launcher, the current dir is /usr/share/ ... it is not writeable.
In CfdCaseWriterFoam.py, I changed cwd to working folder, seems remove this limitation

Code: Select all

    def write_case(self, updating=False):
        """ Write_case() will collect case setings, and finally build a runnable case
        """
        FreeCAD.Console.PrintMessage("Start to write case to folder {}\n".format(self.solver_obj.WorkingDir))
        cwd = os.chdir(self.solver_obj.WorkingDir)  # pyFoam can not write to cwd if FreeCAD is started NOT from terminal
        # need to restore working dir? 
Last edited by qingfeng.xia on Thu Dec 29, 2016 3:46 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
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Test request: OpenFOAM solver for FemWorkbench

Post by qingfeng.xia »

johan wrote:With regards to the unv file, it seems like the mesh.obj for some reason does not store the faces of the boundaries (https://github.com/qingfengxia/Cfd/blob ... fdTools.py), resulting in the zero entries when writing the boundary faces. I need to, however, check that I did not somewhere make a rookie mistake in the setup.

I was actually referring to the "Direction" of the ConstraintFluidBoundary and not the gravitational acceleration (g = 9.81 m/s^2) in the self weight constraint. Coming from a flow background, I thought the direction should be specified instead of derived from a geometric entity by selecting an edge or a face. At the moment the ConstraintFluidBoundary allows one to only select faces (not edges as with force constraints in FEM), because for flow problems BCs should only be applied to faces. It might be useful to have the option to select edges when specifying "Direction".

You are right on meshing export, meshing function in FEM does not export faces, yet implemented the named group of faces as in Ansys workbench. It is done later by (https://github.com/qingfengxia/Cfd/blob ... fdTools.py).

Direction of ConstraintFluidBoundary, I do not find any problem, but once you change direction by checkbox, GUI may not update timely, while I am not good at GUI.

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
oliveroxtoby
Posts: 837
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: Test request: OpenFOAM solver for FemWorkbench

Post by oliveroxtoby »

makkemal wrote:No further output on console
Michael, so just to be clear, are you running FreeCAD from the terminal and not receiving any output to the terminal when you click the "Write case input" button?

This is what I get:

Code: Select all

Start to write case to folder /tmp
Info: initialize solver created fields (variables):  set(['p', 'U'])
Create Allrun script 
Export FemMesh to UNV format file: /tmp/case/case.unv
Warning: ideasUnvToFoam already run on /tmp/case
Running  ideasUnvToFoam -case "/tmp/case" "/tmp/case/case.unv"

boundary `defaultFaces` not found, so boundary type is not changed
Warning: transformPoints already run on /tmp/case
Running  transformPoints -case "/tmp/case" -scale "(0.001 0.001 0.001)"

{'name': 'oneLiquid', 'kinematicViscosity': 1.5e-05}
{'name': 'laminar'}
Warning:unrecoginsed fluid properties: name
Viscosity settings in constant/transportProperties
['transportModel  Newtonian;\n', 'nu              nu [ 0 2 -1 0 0 0 0 ] 1.5e-05;\n']
 Sucessfully write /tmp case to folder 
Is the <write location>/case directory being created and do you see a log.ideasUnvToFoam and a log.transformPoints file in there? If so, could you post your contents of those files?

I understand that on some systems the python tracebacks only get printed if you did a debug build (although this is not the case for me). If you are not seeing any sign of an error on the terminal output, would you mind doing a debug build and trying again? i.e., passing

Code: Select all

-DCMAKE_BUILD_TYPE=Debug
option to cmake.

The prerequisites seem to be fine. I have tested with OpenFOAM v 3.0.1 and v4.1 and you have pyFoam as required. The gnuplot python package is also required but only when the solver is run, not for the case builder.

We really appreciate the help with debugging. Hopefully this doesn't take too long to get to the bottom of.

Thanks
Oliver
Please provide all the information requested in this post before reporting problems with CfdOF.
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Test request: OpenFOAM solver for FemWorkbench

Post by qingfeng.xia »

johan wrote:We added a couple of extensions to Qingfeng's CFD WB

https://github.com/jaheyns/FreeCAD.git

and it would it would be great to hear what you think. I have also attached the case set up that reproduce the elbow tutorial from OpenFOAM.

It is now possible to run the solver from the workbench. The view results option is still not working and one has to activate the "CfdAnalysis" (which still shows the FEM WB options) before you could setup the fluid case under "OpenFOAM".
download/file.php?id=30344
It is a good test case of elbow, I downloaded it, and changed the "working direction" in solver obj document property editor, it works.
There is a bug(kind of), if you fixed work dir to your home folder, other people can not load it. I can later alter the code to deal that.
the tolerannce is too big, it does not actually converges at the stop. For most of practical case, we need to weak the case setup manually, because it is CFD not FEM.
SIMPLE: convergence criteria
field p tolerance 0.01
field U tolerance 0.001
field "(k|h|epsilon|omega|f|v2)" tolerance 0.001
It is a bit early to commit directly to official
https://github.com/jaheyns/FreeCAD.git, please fork the cfd module and send pull request on coding style improvement to my Cfd.git we can improve the code quality to be acceptable.

I fired the discussion of FluidMaterial, we will see the voting of the community on FemMaterial design.viewtopic.php?f=18&t=19401

for Gmsh/Netgen function, there is no need to make CfdGmeshing class. we can just use meshing function in FEM workbench. femsolver has a field of category, by detecting that meshing taskpanel will know the favour of CFD and FEM , by this it will avoid the 95% code duplication. However, it makes sense to add toolbar of 'Fem_MeshNetgenFromShape', 'Fem_MeshGmshFromShape', into Cfd workbench.

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
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: Test request: OpenFOAM solver for FemWorkbench

Post by makkemal »

Thsi is where thing go wrong on my machine

Code: Select all

Traceback (most recent call last):
  File "/home/makke/Freecad/bin/Mod/Cfd/_TaskPanelCfdSolverControl.py", line 186, in write_input_file_handler
    ret = self.solver_runner.write_case()
  File "/home/makke/Freecad/bin/Mod/Cfd/CfdRunnableFoam.py", line 90, in write_case
    return self.writer.write_case()
  File "/home/makke/Freecad/bin/Mod/Cfd/CfdCaseWriterFoam.py", line 72, in write_case
    self.write_mesh()
  File "/home/makke/Freecad/bin/Mod/Cfd/CfdCaseWriterFoam.py", line 104, in write_mesh
    self.builder.setupMesh(unvMeshFile, scale)
  File "/home/makke/Freecad/bin/Mod/Cfd/FoamCaseBuilder/BasicBuilder.py", line 287, in setupMesh
    convertMesh(self._casePath, updated_mesh_path, scale)
  File "/home/makke/Freecad/bin/Mod/Cfd/FoamCaseBuilder/utility.py", line 535, in convertMesh
    runFoamApplication(cmdline,case)
  File "/home/makke/Freecad/bin/Mod/Cfd/FoamCaseBuilder/utility.py", line 518, in runFoamApplication
    out = subprocess.check_output(['bash', '-l', '-c', cmdline], stderr=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 574, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['bash', '-l', '-c', u'ideasUnvToFoam -case "/tmp/case" "/tmp/case/case.unv" > /tmp/case/log.ideasUnvToFoam']' returned non-zero exit status 127
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Test request: OpenFOAM solver for FemWorkbench

Post by qingfeng.xia »

makkemal wrote:Thsi is where thing go wrong on my machine

Code: Select all

Traceback (most recent call last):
...
subprocess.CalledProcessError: Command '['bash', '-l', '-c', u'ideasUnvToFoam -case "/tmp/case" "/tmp/case/case.unv" > /tmp/case/log.ideasUnvToFoam']' returned non-zero exit status 127
in my code -i is used, not -l.

Code: Select all

out = subprocess.check_output(['bash', '-i', '-c', cmdline], stderr=subprocess.PIPE)
if _debug: print(out)
why the command string is unicode? mixed bin unicode may cause error.
please paste the content of "/tmp/case/log.ideasUnvToFoam"

runfoamcommand is quite buggy, i will redesign to work on win10 wsl. python3, unicode
Last edited by qingfeng.xia on Thu Dec 29, 2016 12:45 pm, edited 3 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
User avatar
makkemal
Posts: 395
Joined: Wed Apr 29, 2015 12:41 pm
Location: South Africa
Contact:

Re: Test request: OpenFOAM solver for FemWorkbench

Post by makkemal »

The file is empty
Post Reply