Addition of docker openfoam install option

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

markrmau
Posts: 12
Joined: Fri Jan 03, 2020 4:03 am

Addition of docker openfoam install option

Post by markrmau »

Hi all,

Has anyone done any work on getting this to work with openfoam running in docker? It probably is possible using commands like

Code: Select all

docker container exec
etc.

I could probably help with this but wouldn't be able to start for a month or so.

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

Re: Addition of docker openfoam install option

Post by oliveroxtoby »

markrmau wrote: Sat Jan 04, 2020 10:34 pm Hi all,

Has anyone done any work on getting this to work with openfoam running in docker? It probably is possible using commands like

Code: Select all

docker container exec
etc.

I could probably help with this but wouldn't be able to start for a month or so.

Regards,
Mark
Hi Mark

Not yet. I am looking forward to your pull request ;-)
markrmau
Posts: 12
Joined: Fri Jan 03, 2020 4:03 am

Re: Addition of docker openfoam install option

Post by markrmau »

No problems!

I've had a look at things and thought I'd outline my approach - so that developers can provide input if they don't like my approach.

a) in preferences add a 'Use docker' qcheckbox. I think initially make the docker option only available under macos and linux as there is already a good working solution for windows (bluecfd).

b) have entry for the Docker image name / runscript (default openfoam/openfoam7-paraview56 / openfoam7-linux/-macos)

c) first time a container is required we run it and keep it running until freecad closes down. Subsequent commands can be easily run in the already running container. I haven't investigated any stdout/stderr redirect problems at this point, but they should be solvable if there are any.

d) Retain the openfoam install directory even though we will not be using the same way (if running docker, some of the validity checking code needs to be modified). This will be used to compile hisa and cfmesh-cfdof.

openfoam7-paraview56 doesn't come with unzip by default. So both will need to be unziped outside the container and compiled inside the container. They can stay in the platform directory under openfoam (which will stay present betwen container image creations). I haven't looked to see if I need to add the platform bin and lib paths but shouldn't be a problem if need to.

e) /tmp - Unfortunately the standard openfoam7-xxx scripts don't allow us to mount two directories at once.

So there are a few options -
i) modify the standard script so we mount the separate tmp directory (a second -v),
ii) simply state that the temporary directory needs to be in the openfoam install directory
iii) while cfmesh-cfdof could be installed outside the container, I'm guessing hisa needs to be accessable by openfoam (but I haven't checked this) So I don't think we could get away from needing 2nd (non-tmp) directory. You wouldn't want to recompile hisa each time tmp directory was deleted.

For the sake of simplicity and cleanliness I guess ii) would be better. However some people might object to needing a large home directory. So it might be best to use i).

Comments welcome.

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

Re: Addition of docker openfoam install option

Post by oliveroxtoby »

Hi Mark

Thanks - looks good. A couple of comments:
markrmau wrote: Thu Jan 09, 2020 5:02 am No problems!

I've had a look at things and thought I'd outline my approach - so that developers can provide input if they don't like my approach.

a) in preferences add a 'Use docker' qcheckbox. I think initially make the docker option only available under macos and linux as there is already a good working solution for windows (bluecfd).
It would actually be great to support the Windows docker-based installation (https://www.openfoam.com/download/insta ... indows.php) since blueCFD hasn't been updated since version 5, which is getting quite old now.

d) Retain the openfoam install directory even though we will not be using the same way (if running docker, some of the validity checking code needs to be modified). This will be used to compile hisa and cfmesh-cfdof.

openfoam7-paraview56 doesn't come with unzip by default. So both will need to be unziped outside the container and compiled inside the container. They can stay in the platform directory under openfoam (which will stay present betwen container image creations). I haven't looked to see if I need to add the platform bin and lib paths but shouldn't be a problem if need to.

e) /tmp - Unfortunately the standard openfoam7-xxx scripts don't allow us to mount two directories at once.

So there are a few options -
i) modify the standard script so we mount the separate tmp directory (a second -v),
ii) simply state that the temporary directory needs to be in the openfoam install directory
iii) while cfmesh-cfdof could be installed outside the container, I'm guessing hisa needs to be accessable by openfoam (but I haven't checked this) So I don't think we could get away from needing 2nd (non-tmp) directory. You wouldn't want to recompile hisa each time tmp directory was deleted.
When they are compiled, hisa and cfMesh will install in the $FOAM_USER_LIBBIN and $FOAM_USER_APPBIN directories where they will be found by OpenFOAM (these variables should be defined inside the OpenFOAM environment). As long as these directories persist, it doesn't really matter if the source disappears.
markrmau
Posts: 12
Joined: Fri Jan 03, 2020 4:03 am

Re: Addition of docker openfoam install option

Post by markrmau »

Morning all, I have got something working but I don't think it is a particularly good implementation at the moment so perhaps not ready for a pull request.

It can be reviewed here:

https://github.com/mmcker/CfdOF

I left the windows implementation to one side for the moment - this can be tested and issues resolved hopefully without too much fuss (the use docker button won't be visible on windows unless some trivial hide code is removed).

Regarding a better way of integrating docker like bluecfd and bashwsl - should those two stay? Or is it better to remove them and move everything to docker as we should be able to get it working on windows, linux and mac?

In this, paraview from the docker distribution is used so that all the environment variables are set correctly.

Hopefully this impementation doesn't mangle the existing code too much.

Note the report view gives strange error messsages while foam is running, but the simulation seems to be running correctly.

In summary, to do:
a) Test / make work on windows
b) Test I haven't broken anything on non-docker running
c) Clean up the integration so it is like bluecfd and doesn't use the Dockercontainer.usedocker bit (or is this ok and delete the bluecfd?)
d) Fix the error messages while running foam process

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

Re: Addition of docker openfoam install option

Post by oliveroxtoby »

markrmau wrote: Thu Jan 30, 2020 12:34 am Morning all, I have got something working but I don't think it is a particularly good implementation at the moment so perhaps not ready for a pull request.

It can be reviewed here:

https://github.com/mmcker/CfdOF

I left the windows implementation to one side for the moment - this can be tested and issues resolved hopefully without too much fuss (the use docker button won't be visible on windows unless some trivial hide code is removed).

Regarding a better way of integrating docker like bluecfd and bashwsl - should those two stay? Or is it better to remove them and move everything to docker as we should be able to get it working on windows, linux and mac?

In this, paraview from the docker distribution is used so that all the environment variables are set correctly.

Hopefully this impementation doesn't mangle the existing code too much.

Note the report view gives strange error messsages while foam is running, but the simulation seems to be running correctly.

In summary, to do:
a) Test / make work on windows
b) Test I haven't broken anything on non-docker running
c) Clean up the integration so it is like bluecfd and doesn't use the Dockercontainer.usedocker bit (or is this ok and delete the bluecfd?)
d) Fix the error messages while running foam process

Regards
Mark
Thank you very much for this! I will try to give it a look in the next week or so :)
markrmau
Posts: 12
Joined: Fri Jan 03, 2020 4:03 am

Re: Addition of docker openfoam install option

Post by markrmau »

No problems! just in relation to the error messages, it seems to be the same as this one:

https://bugs.openfoam.org/view.php?id=3163

I'll have to make sure I have latest issue
markrmau
Posts: 12
Joined: Fri Jan 03, 2020 4:03 am

Re: Addition of docker openfoam install option

Post by markrmau »

Adding the docker on windows isn't quite as straightforward as I expected.

https://docs.docker.com/docker-for-windows/install/ needs windows 10 Pro so probably shouldn't base it on this.

So it looks like we would need to do something like this:

https://golb.hplar.ch/2019/01/docker-on ... ratch.html [*]

I used the openfoam.org docker image for linux version as it comes with paraview which I thought would make things easier

We could move to the openfoam.com installation and run paraview striaght from windows. This method automates the process described in * so is probably easier.

Or we could continue using the openfoam.org docker image and install it using the process described in the link above - *. Paraview could then be run straight from windows or from the docker image pointing to an x-server.

I guess the first question however is - what about staying with the bash-wsl implementation? Or is this too bloated / complex?

Thoughts appreciated
adrianinsaval
Veteran
Posts: 3194
Joined: Thu Apr 05, 2018 5:15 pm

Re: Addition of docker openfoam install option

Post by adrianinsaval »

is openfoam on wsl supported in cfd-of? I tought it wasn't
markrmau
Posts: 12
Joined: Fri Jan 03, 2020 4:03 am

Re: Addition of docker openfoam install option

Post by markrmau »

Ahh, quite right. I saw some code in there and assumed it was working.

I'll implement the docker install on windows. The user would have to install virtualbox and the xserver first.

https://sourceforge.net/projects/vcxsrv/

Again, it will probably be another 4 weeks.
Post Reply