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: 219
Joined: Fri Dec 23, 2016 9:43 am

Re: Test request: OpenFOAM solver for FemWorkbench

Postby oliveroxtoby » Fri Dec 30, 2016 8:46 am

makkemal wrote:The file is empty
Could you try closing FreeCAD and in the same terminal type the command

Code: Select all

ideasUnvToFoam -case /tmp/case /tmp/case/case.unv
and see what the output is? Unfortunately the log file doesn't capture stderr at the moment, and it looks like yours is not printing any output before failing.

Thanks
User avatar
oliveroxtoby
Posts: 219
Joined: Fri Dec 23, 2016 9:43 am

Re: Test request: OpenFOAM solver for FemWorkbench

Postby oliveroxtoby » Fri Dec 30, 2016 9:19 am

Hi Quingfeng

Oliver here, also working on this project with Johan and colleagues. Thank you for the fantastic work on the CFD workbench.
qingfeng.xia wrote: 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.
Our idea here was not to submit the code yet, but just to incorporate the CFD workbench into its own fork of FreeCAD as we understood this to be the accepted practice. We felt it would be easier to test this way as it would not be necessary to copy or link the CFD code, settings, and material properties into different parts of an existing FreeCAD build - they are already installed into the right place when you do the build. It might also avoid the ambiguity of someone running it with a different version of FreeCAD than it was tested with. We are, of course, happy to submit pull requests to you. Does this make sense? How would you like to proceed?
qingfeng.xia wrote: I fired the discussion of FluidMaterial, we will see the voting of the community on FemMaterial design.viewtopic.php?f=18&t=19401
Thank you
qingfeng.xia wrote: 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.
Thank you, we will look into this.
quingfen.xia wrote: in my code -i is used, not -l.
We changed this because we were experiencing terminal hangs on repeated runs using the interactive option. I believe -l should be the right option here as it does the sourcing of the environment but does not run an interactive terminal.
quingfen.xia wrote: why the command string is unicode? mixed bin unicode may cause error.
This is probably my mistake.

Best regards
Oliver
makkemal
Posts: 380
Joined: Wed Apr 29, 2015 12:41 pm

Re: Test request: OpenFOAM solver for FemWorkbench

Postby makkemal » Fri Dec 30, 2016 10:35 am

The output

Code: Select all

makke@ubuntu:~/FreeCAD_comp$ ideasUnvToFoam -case /tmp/case /tmp/case/case.unv
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.1                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : 4.1
Exec   : ideasUnvToFoam -case /tmp/case /tmp/case/case.unv
Date   : Dec 30 2016
Time   : 12:34:33
Host   : "ubuntu"
PID    : 11000
Case   : /tmp/case
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Processing tag:164
Starting reading units at line 3.
l:1
units:"  SI: Meter (newton)"
unitType:2
Unit factors:
    Length scale       : 1
    Force scale        : 1
    Temperature scale  : 1
    Temperature offset : 273.15


Processing tag:2420
Skipping tag 2420 on line 9
Skipping section at line 9.

Processing tag:2411
Starting reading points at line 20.
Read 6185 points.

Processing tag:2412
Starting reading cells at line 12393.
First occurrence of element type 11 for cell 1 at line 12394
First occurrence of element type 41 for cell 615 at line 14236
First occurrence of element type 111 for cell 12917 at line 38840
Read 17825 cells and 12302 boundary faces.

Processing tag:2467
Starting reading patches at line 74492.
For group 1 named inlet1 trying to read 78 patch face indices.
For group 2 named inlet2 trying to read 22 patch face indices.
For group 3 named outlet trying to read 78 patch face indices.
For group 4 named wall trying to read 1046 patch face indices.
For group 5 named slip trying to read 11078 patch face indices.

Sorting boundary faces according to group (patch)
0: inlet1 is patch
1: inlet2 is patch
2: outlet is patch
3: wall is patch
4: slip is patch

Constructing mesh with non-default patches of size:
    inlet1	78
    inlet2	22
    outlet	78
    wall	1046
    slip	11078

End
My instalation is ubuntu 16.04 with dependancies in installed with scripts as described on:
http://www.freecadweb.org/wiki/index.ph ... pileOnUnix
openfoam instalation with apt
http://openfoam.org/download/4-1-ubuntu/
and python gnuplot

Code: Select all

sudo apt-get install python-gnuplot
Last edited by makkemal on Fri Dec 30, 2016 3:25 pm, edited 1 time in total.
User avatar
yorik
Site Admin
Posts: 10706
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: Test request: OpenFOAM solver for FemWorkbench

Postby yorik » Fri Dec 30, 2016 12:18 pm

Quingfeng's CFD workbench is now part of the addons repo and can be installed/updated from the macro at https://github.com/FreeCAD/FreeCAD-addons
qingfeng.xia
Posts: 153
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: Test request: OpenFOAM solver for FemWorkbench

Postby qingfeng.xia » Fri Dec 30, 2016 7:49 pm

I found a problem from freecad-daily 20161015, freecad-daily 20161223 fail to write unv mesh for my cfd.git, I will test Johan's fork, to see if their modification has solved this. I also got hung after writing. Hope to solve this bug soon.

step 1
+ bugfix: boundary mesh is not appended to unv volume mesh in CfdTools.py, due to recent femmesh code refactoring from Oct 2016 to Dec 2016. Bugfix from <https://github.com/jaheyns/FreeCAD/blob ... fdTools.py> works! And it is merged

step 2:

Code: Select all

transformPoints -case "/tmp/TestCase" -scale "(0.001 0.001 0.001)" 
still make freecad-daily stopped,
paste this command to terminal, it is successfully finished

As Oliver team have point out, change the bash option from '-i' to '-l' solve the transformPoints error in terminal mode
https://github.com/qingfengxia/Cfd/blob ... utility.py

Code: Select all

    out = subprocess.check_output(['bash', '-l', '-c', cmdline], stderr=subprocess.PIPE)
the reason seems you can not call run subprocess.check_output(['bash', '-l', '-c', cmdline]) immediately after subprocess.check_output(['bash', '-l', '-c', cmdline]

Finally, I solved this by

Code: Select all

    # this is the method works for both started in terminal and GUI launcher
    env_setup_script = "source {}/etc/bashrc".format(getFoamDir())
    #env_setup_script = "source ~/.bashrc"
    cmdline_1 = ['bash', '-c', ' '.join([env_setup_script, '&&'] + _cmd)]
    #cmdline = """bash -i -c  '{} && {}' """.format(env_setup_script, ' '.join(_cmd))
    #cmdline_1 = """bash -c ' {} && {}'""".format(env_setup_script, cmdline)
    print("Run command_1: ", cmdline_1)  # get correct command line, correct in terminal, but error in python
    out = subprocess.check_output(cmdline_1, stderr=subprocess.PIPE)
commit to qingfengxia/Cfd.git

Code: Select all

Export FemMesh to UNV format file: /tmp//TestCase/TestCase.unv
Run command:  ideasUnvToFoam -case "/tmp/TestCase" "/tmp/TestCase/TestCase.unv"
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  4.1                                   |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : 4.1
Exec   : ideasUnvToFoam -case /tmp/TestCase /tmp/TestCase/TestCase.unv
Date   : Dec 30 2016
Time   : 20:08:09
Host   : "qingfeng-ubuntu"
PID    : 12822
Case   : /tmp/TestCase
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Processing tag:164
Starting reading units at line 3.
l:1
units:"  SI: Meter (newton)"
unitType:2
Unit factors:
    Length scale       : 1
    Force scale        : 1
    Temperature scale  : 1
    Temperature offset : 273.15


Processing tag:2420
Skipping tag 2420 on line 9
Skipping section at line 9.

Processing tag:2411
Starting reading points at line 20.
Read 2012 points.

Processing tag:2412
Starting reading cells at line 4047.
First occurrence of element type 11 for cell 1 at line 4048
First occurrence of element type 41 for cell 217 at line 4696
First occurrence of element type 111 for cell 3115 at line 10492
Read 7483 cells and 2898 boundary faces.

Processing tag:2467
Starting reading patches at line 25460.
For group 1 named FluidBoundary trying to read 0 patch face indices.
--> FOAM Warning : 
    From function void readSets(Foam::IFstream&, Foam::DynamicList<Foam::word>&, Foam::DynamicList<Foam::List<int> >&)
    in file ideasUnvToFoam.C at line 553
    Reading "/tmp/TestCase/TestCase.unv" at line 25462
    When reading patches expect entity type code 8
    Skipping group code -1

Sorting boundary faces according to group (patch)

Constructing mesh with non-default patches of size:

--> FOAM Warning : 
    From function Foam::polyMesh::polyMesh(const Foam::IOobject&, const Foam::Xfer<Foam::Field<Foam::Vector<double> > >&, const cellShapeList&, const faceListList&, const wordList&, const wordList&, const Foam::word&, const Foam::word&, const wordList&, bool)
    in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 595
    Found 2898 undefined faces in mesh; adding to default patch.
End



Run command:  transformPoints -case "/tmp/TestCase" -scale "(0.001 0.001 0.001)"

[1]+  Stopped                 freecad-daily

[/quote]
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: Test request: OpenFOAM solver for FemWorkbench

Postby qingfeng.xia » Fri Dec 30, 2016 11:54 pm

copy the file FoamCaseBuilder/TestBuilder.py to somewhere writtable
please run `python2 pathtoFoamCaseBuilder/TestBuilder.py`
to test your setup.
you can also modify this __main__ a bit to test more
https://github.com/qingfengxia/Cfd/blob ... Builder.py
makkemal wrote: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
Ubuntu LTS 64bit in virtualbox, always work with latest FreeCAD git version
Mainly work on OpenFOAM + Fenics for CFD, FSI