Installation CfdOf / HiSA

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

Geefer
Posts: 17
Joined: Mon Feb 01, 2021 4:10 pm

Re: Installation CfdOf / HiSA

Postby Geefer » Sat Feb 06, 2021 12:20 pm

oliveroxtoby wrote: Fri Feb 05, 2021 8:08 pm These sound great for a production environment. Personally I am trying to find the most basic possible option in terms of usability and maintenance as I don't have much time for this project, however, if you or someone else wants to take on this task I would be very happy with that!
Sadly I also don't have time to take on this either.

I did create a simple Dockerfile that grabs the OpenFOAM docker image and then compiles cfMesh and HiSA into it and then downloads and untars the gmsh tarfile. It would make the process very simple - a single line to "build" the docker image specific to Cdf_Of then the same two docker commands used currently to create the container instance and then run commands within it.

Unfortunately the latest gmsh executable provided by the tarfile is compiled with C++ library versions not in the docker image from OpenFOAM and also has missing shared library dependencies. I'm not sure what Linux distro it is meant to be used with but it seems unusable here without loads of work. So I'm no further and don't have the time to start trying to build gmsh from scratch given the list of dependencies that seem to be listed in their build instructions.

Given that, what is the recommended way to go to get a fully working Cfd_of installation? Do I actually need gmsh? If not I am already sorted. If it is recommended then should I go down the BlueCFD route?
Geefer
Posts: 17
Joined: Mon Feb 01, 2021 4:10 pm

Re: Installation CfdOf / HiSA

Postby Geefer » Sat Feb 06, 2021 5:30 pm

Geefer wrote: Sat Feb 06, 2021 12:20 pm Unfortunately the latest gmsh executable provided by the tarfile is compiled with C++ library versions not in the docker image from OpenFOAM and also has missing shared library dependencies. I'm not sure what Linux distro it is meant to be used with but it seems unusable here without loads of work. So I'm no further and don't have the time to start trying to build gmsh from scratch given the list of dependencies that seem to be listed in their build instructions.
Actually by going back to an earlier version of gmsh and updating the dockerfile to install a few needed system libraries I have managed to create a dockerfile that builds an image including OpenFOAM, cfMesh, HiSA and gmsh that appear to work. By hacking the relevant bits of CfdTools.py I have also managed to make the dependency checker pass by calling gmsh inside the docker container as a Linux executable like cfMesh - instead of trying to call it in Windows.

I will try and run through a simple tutorial to see if I can get gmsh to run properly within the CfdOf environment next - when I get time.

I am totally new to CFD and do not know enough to really test things out - and if the preferred approach is to use BlueCFD anyway I might be better learning to use that. The question in my mind is whether this docker approach is worth pursuing?

By the way, thanks to the developers for building this Workbench. It seems to be the most accessible way to use CFD with FreeCAD that I have found so far and I certainly hope to learn enough using it to make progress.
thschrader
Posts: 2145
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: Installation CfdOf / HiSA

Postby thschrader » Sat Feb 06, 2021 6:02 pm

Geefer wrote: Sat Feb 06, 2021 5:30 pm I will try and run through a simple tutorial to see if I can get gmsh to run properly within the CfdOf environment next - when I get time.

I am totally new to CFD and do not know enough to really test things out - and if the preferred approach is to use BlueCFD anyway I might be better learning to use that. The question in my mind is whether this docker approach is worth pursuing?
Geefer, thanks for your work, but dont waste your time with gmsh.
You need cfmesh for running turbulent flow with cfdof because of boundary-layers.
90% of all meshing with cfdof is done with cfmesh.

As a beginner you should start with bluecfd. Its from 2017, ok, but believe me, you can learn a lot
about cfd. bluecfd runs in a separate console too (like a mini linux), you can do the most linux based YT-tutorials
via console.

Learning cfd is a loooot amount of work, I spent endless hours and I am still a newbee...
thschrader
Posts: 2145
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: Installation CfdOf / HiSA

Postby thschrader » Sat Feb 06, 2021 10:01 pm

thschrader wrote: Sat Feb 06, 2021 6:02 pm ...
As a beginner you should start with bluecfd.
Sorry for my vanity... ;)
https://forum.freecadweb.org/viewtopic.php?t=52381
Geefer
Posts: 17
Joined: Mon Feb 01, 2021 4:10 pm

Re: Installation CfdOf / HiSA

Postby Geefer » Sun Feb 07, 2021 8:21 pm

thschrader wrote: Sat Feb 06, 2021 6:02 pm Geefer, thanks for your work, but dont waste your time with gmsh.
Too late! :D

I managed to get gmsh meshing to work using Linux gmsh running in the Docker container. It just took a bit of time tracing through the CfdOf code to find places where paths needed converting from Windows paths to the path to access the same place from the container filesystem.

Running the OpenSim Elbow tutorial now appears to run using Gmsh. However the TestCfd testcase program fails almost immediately so I don't know if I still have some issues or not.
As a beginner you should start with bluecfd. Its from 2017, ok, but believe me, you can learn a lot
about cfd. bluecfd runs in a separate console too (like a mini linux), you can do the most linux based YT-tutorials
via console.
I have used MSys2 (which is the environment BlueCFD provides) for some years and it is a very useful tool. Docker containers also can be accessed as a terminal of course, but a full Linux one. Personally I prefer to not be tied to an OpenFOAM release that is unlikely to receive bug fixes or enhancements very quickly. Of course if OpenFOAM is essentially stable then that is less of an issue.

OpenFOAM actually lists 3 windows installation types on its website (one of which is an mingw one which I think is essentially using MSys2 also) but only two in the "Download" dropdowns (not the mingw one). At the end of the day if the WSL version works with the CfdOf Workbench I'd probably prefer that as not requiring anything apart from Windows 10 but I could not get it to work for me when I tried it. I may have another go now I have a better feel for things and the structure of the code.
Geefer
Posts: 17
Joined: Mon Feb 01, 2021 4:10 pm

Re: Installation CfdOf / HiSA

Postby Geefer » Tue Feb 09, 2021 3:07 pm

Geefer wrote: Sun Feb 07, 2021 8:21 pm [At the end of the day if the WSL version works with the CfdOf Workbench I'd probably prefer that as not requiring anything apart from Windows 10 but I could not get it to work for me when I tried it. I may have another go now I have a better feel for things and the structure of the code.
I managed to get the WSL version to work, with a little bit of persuasion:

  • Firstly the dependencies checker requires a path to the OpenFOAM installation that can be read from Windows, even though all commands are then given from the Linux system using 'converted' paths that are native Linux ones. I installed my OpenFOAM into the Linux filesystem of WSL2, as Microsoft recommends NOT using the Windows filesystem for storing user data if you are using the WSL2 environment if possible due to performance issues. I could have switched to WSL1 which apparently does not have the same problem but for other reasons I wanted to keep using WSL2. The WSL filesystem is available as a network device - \\wsl$\Ubuntu in my case - so I mapped it as a network drive allowing it to be found as U:\ in Windows which allowed it to be found by the dependency checker.
  • I had to install OpenFOAM into my WSL (Linux) home directory so that when compiling the meshers etc. there was write access as compilation of some of them failed if I did not. I may have forgotten the step in the OpenFOAM installation instructions to change ownership after installation though.
  • OpenFOAM itself requires some additional packages to be installed into the Linux Ubuntu system - bison, flex and m4. I found compiling the meshers etc that I also required unzip, make and zlibg-dev. These are all installed with sudo apt-get install ... as usual.
  • Finally I had to make minor changes to CfdTools.py to makeRunCommand and checkCfdDependencies.
Running the "Elbow" tutorial now runs fine. The TestCfd.py program fails almost immediately as it did with my Docker setup so for now I am assuming that is at fault.

So, now I have a working setup I will use the WSL2 based one for now and switch my attention to actually how to use the Workbench to solve CFD problems. I'm sure there will be useful help elsewhere on the forum if I get stuck.
User avatar
oliveroxtoby
Posts: 500
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: Installation CfdOf / HiSA

Postby oliveroxtoby » Wed Feb 10, 2021 6:03 am

Geefer wrote: Tue Feb 09, 2021 3:07 pm
  • Finally I had to make minor changes to CfdTools.py to makeRunCommand and checkCfdDependencies.
Nice, thank you for the feedback! Any chance you could submit your changes as a pull request? Thank you!
Geefer
Posts: 17
Joined: Mon Feb 01, 2021 4:10 pm

Re: Installation CfdOf / HiSA

Postby Geefer » Wed Feb 10, 2021 4:27 pm

oliveroxtoby wrote: Wed Feb 10, 2021 6:03 am
Geefer wrote: Tue Feb 09, 2021 3:07 pm
  • Finally I had to make minor changes to CfdTools.py to makeRunCommand and checkCfdDependencies.
Nice, thank you for the feedback! Any chance you could submit your changes as a pull request? Thank you!
Sadly I have now found more problems due to the templating system somehow still using Windows paths in the resultant files when Linux paths are required - which I have not yet been able to resolve.

I even tried FreeCAD and OpenFoam running inside WSL2 using an X server to render it in the Windows GUI but that failed to find the Workbenches so I must have had something wrong there too.

For now I have decided to give up (much against my nature) and use the BlueCFD installation, as I was advised to a few days ago. It works out of the box and I really need to spend some time actually learning how to use CfdOf and get onto the project I should be working on at the moment. Once I have made some progress I may be able to get back to this though
User avatar
oliveroxtoby
Posts: 500
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: Installation CfdOf / HiSA

Postby oliveroxtoby » Wed Feb 10, 2021 8:38 pm

oliveroxtoby wrote: Thu Feb 04, 2021 2:32 pm Thank you for this information. This is very helpful and confirms my growing suspicion that it was a bad idea to switch over to the Docker package as the default on Windows.

I am going to see if I can get it right to cross-compile HiSA and cfMesh so that they can be installed in the Mingw installation of OpenFOAM. If not, then either WSL or reverting to BlueCFD seem like the best bets.
On Windows, the OpenCFD MinGW package is now supported and is the new default. The Docker and BlueCFD options should still be working as well. Please report any problems here.
Geefer
Posts: 17
Joined: Mon Feb 01, 2021 4:10 pm

Re: Installation CfdOf / HiSA

Postby Geefer » Thu Feb 11, 2021 11:19 am

oliveroxtoby wrote: Wed Feb 10, 2021 8:38 pm On Windows, the OpenCFD MinGW package is now supported and is the new default. The Docker and BlueCFD options should still be working as well. Please report any problems here.
Thanks Oliver. I just updated my Workbench and installed the Mingw openfoam installation from the preferences panel. Then I ran the dependency checker and it ran horrendously slowly? It took over 3 minutes to run and tell me that OpenFoam was installed but that cfMesh and HiSA were not. Did you notice anything similar on your setup?

I did change the install directory during installation to be somewhere out of Appdata (C:\ESI-OpenCFD) as I do not want to back up the whole OpenFOAM installation whenever my personal directory is backed up, so I don't know if that caused the problem. I do not see why it would.

I noticed that the preferences form is no longer persisting the path to the OpenFOAM directory when you click apply or OK (maybe because I chose to install OpenFOAM in a different directory?) so when I tried it again it found my BlueCFD installation (it recognises it as BlueCFD2) and the dependency check then ran in 15s including running cfMesh and HiSA execution checks.

I have no idea whether this slow performance using the Mingw install is something about my system or something general.