ladybug-tools / butterfly

:butterfly: A light python API for creating and running OpenFoam cases for CFD simulation.
http://ladybug-tools.github.io/butterfly.html
GNU General Public License v3.0
246 stars 70 forks source link

Support Windows 10 native installation #271

Open mostaphaRoudsari opened 7 years ago

mostaphaRoudsari commented 7 years ago

Windows 10 is now supporting Ubuntu natively and that gives us the option to install OpenFOAM on Windows 10 without installing docker. With all the headache of installing docker on Windows this can be a life / time saving solution for us.

I tested it today and the installation is straight forward. There is also a great video here that shows the process.

Once the installation is done one can access OpenFOAM from inside Windows using bash. Here is an example:

image

The challenges are:

  1. It will only work on Windows 10.

  2. The user need to mount the shared folder manually and also everyone end up with a different folder name. We can standardize this but my experience tells me that people don't read stuff. We can however to use bash to set this up programmatically but that needs an admin privilege.

  3. Every time that we run any commands from bash we need to source OpenFoam's bashrc which takes a couple of seconds to execute. This can end up making everything slow. I think there should be a way to have an instance of bash running in the background and make calls. But I'm worried that for any connection like that user would need admin privileges. Also see this.

  4. One more thing to support!

The advantages are:

  1. No docker installation.

  2. No VM installation.

  3. If this works fine we can also ran radiance on Ubuntu. That will open up a lot of opportunities including using parallel computation and running perl scripts.

Not sure if it does make sense to support this inside Butterfly or leave it to the advanced users to set it up on their own. They can use it next to current butterfly by mounting the butterfly folder.

rafdeangelis commented 6 years ago

Hello Great stuff. Do you suggest already using the Bash version for Butterfly?

mostaphaRoudsari commented 6 years ago

@rafdeangelis not yet! I couldn't find a solution to keep the bash open with bashrc loaded so every time you have to source it for each command. Comparing with how long does it take to run the analysis it's minor but it's just not elegant. The only limitation is that it only works on Windows 10!

FranzForsberg commented 6 years ago

Hello @mostaphaRoudsari

I have proceeded with the installation video from your second paragraph. But how to access OpenFOAM through windows? With:

C:\Users\xxx\butterfly\xxx>bash -c “source /home/xxx/OpenFOAM/OpenFOAM-v1706/etc/bashrc; simpleFoam”

?

I do not understand the process to launch OpenFOAM so the grasshopper "blockmesh" and the other components will work, With xming?

Thank you and please continue your great work,

rueckertch58521 commented 6 years ago

@mostaphaRoudsari if i understand it right, you already found a way to run OpenFOAM on Butterfly with bashrc? May it be possible to explain which steps have to be done, that i can adapt my installed Butterfly code?

For my case it doesn´t matter if bashrc isn´t contantly open.

Best regards.

leeyuan123 commented 6 years ago

Hi, @mostaphaRoudsari I've got the interest with @rueckertch58521 . I've got the ubuntu OP version installed successfully and set the shared as C:\Users\user\butterfly\outdoor_airflow to run the example file. However, it seems like the butterfly is still looking for VM and Docker. Is there a way to change it?

mostaphaRoudsari commented 6 years ago

Hi all, Sorry for the delayed reply.

There is currently no easy way to currently change that in Butterfly if you want to run it form inside Grasshopper/Dynamo. This will change soon and will be more flexible but with my current schedule I'm not sure when I get the chance to make the changes.

Meanwhile once you have the case and the solution written to your machine. You can go to the folder and run the commands yourself. Or write a simple bash file to run all the commands. The will work for meshing and well as running the solvers.

azrafazman commented 6 years ago

Hi all, new to OF,

  1. i did install OF using bash Ubuntu in windows 10 native installation. OF is running well when I run the cavity tutorial and the result is in decimal number. I try run the multiphase tutorial (driftFluxFoam-dahl case), the iteration stop at time 350. i did try to run the same tutorial case using blueCFD platform, the iteration run till the end. is there any problem running the case in bash ubuntu windows 10
  2. one other question, is the result written in binary..or normal text or decimal number. cause the result after running the case (dahl) is in binary (i think so,,)

i am running the OF using I5-7200 cpu @2.50 Ghz , 8G RAM.

do need advice..

Thanks azraf

TheodoreGalanos commented 5 years ago

My experiences using this:

  1. Extremely easy installation, one click from the shop is enough.

  2. Opt to install ubuntu 18.06 LTS.

  3. Upon installation we need to install openfoam (only once):

    apt update apt install openfoam

  4. There seems to be a bug in the mpirun within windows 10 (see here: https://github.com/Microsoft/WSL/issues/3397). This is resolved by the following command in the terminal to enable parallel processing (we might need to automate this through BF, apparently settings are overwritten once the terminal is restarted):

    echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

  5. We also need to set the MPI_BUFFER_SIZE for mpirun to run efficiently:

    export MPI_BUFFER_SIZE=65536

After all this, openfoam runs smoothly and much faster than the VM/Docker version (at least in tests I ran in my laptop).

Regards, Theodore.

SinaHassanli commented 5 years ago

@mostaphaRoudsari I have openfoam on WSL up and running; but do not know how to link butterfly to this and could not find any instruction here to link butterfly to WSL; Would it be possible? Do I need to manipuate a script?

Cheers, Sina

DambronOlivier commented 5 years ago

hi @SinaHassanli

You can use Butterfly to write the case, access that case folder using Ubuntu and execute Openfoam commands. These may vary depending on your case but for a generic butterfly case I use the following commands once within the case folder in Ubuntu:

  1. surfaceFeatureExtract
  2. blockMesh
  3. decomposePar
  4. mpirun -n Numberofprocessor snappyHexMesh -parallel
  5. mpirun -n Numberofprocessor renumberMesh -latestTime -parallel
  6. reconstructParMesh -latestTime -overwrite (open your case folder through Windows explorer, move the /polymesh folder from the latestTime to /0 and delete /1 /2 )
  7. decomposePar
  8. mpirun -n Numberofprocessor simpleFoam -parallel
  9. reconstructPar

You can then postprocess using Paraview or read the probe location and values back in Grasshopper Butterfly if you had set them so.

good luck Olivier

ps: have a look at basic linux commands to navigate in and out folders. (cd, ls, cp, mv, mkdir...)

SinaHassanli commented 5 years ago

thanks @DambronOlivier ; but this did not address my question. I know if you are using virtualbox/oracle with openfoam installed, butterfly would work but I installed windows subsystem for linux (WSL) on my windows 10 and installed openfoam on this. Now even when openfoam is running in the background butterfly does not recognise it. My question is how can I link the OpenFOAM installed in WSL so butterfly recognise that.

Cheers, Sina

DambronOlivier commented 5 years ago

@SinaHassanli Sorry for the confusion then. Butterfly is currently working with virtualbox/oracle and it's not YET linked to WSL. I understand @mostaphaRoudsari and @TheodoreGalanos are considering the option of using WSL, perhaps they will tell you more about it.

BrendaEM commented 5 years ago

If I might chime in....

The OpenFoam/Docker thing is terrible. I was not able to get it working on my machine. Yes virtualization was on, and even made a Admin user with no spaces.

The OpenFoam/Docker is bad for so many reasons. Most windows users have spaces in the names. It takes 10% of your performance. The file paths are as deep as an oil well. There are security issues. It's Oracle, need I state more?

I started an Anti-Docker/OpenFoam thread here: https://www.cfd-online.com/Forums/openfoam/212747-openfoam-under-windows-poor-solution.html#post722574

The producer of BlueCFD posted there. It seems like he/they put a lot of work to make it happen. I am sure you put a lot of work into making Butterfly. I was eager to try it, but I can't.

What I really want: OpenFoam support for Windows. Until then, BlueCFD might be the way to go.

It's interesting that OpenFoam is such a powerful system, but it indeed has a marked cross-platform deficiency.

Anyway, thanks for working on Butterly. I hope to try it someday.

mostaphaRoudsari commented 5 years ago

All, See https://github.com/ladybug-tools/butterfly/issues/375#issuecomment-459203175

Butterfly now supports blueCFD which should be even a better option than Windows 10 native installation. It worked smoothly on my machine. Let me know your experience if you get a chance to test it. Cheers!

dradair commented 5 years ago

Have tried looking thru Issues and Wiki. Win10, blueCFD, Revit 2019 \ Dynamo > butterfly 0.1.1 & MeshToolkit 2.0.1 blueCFD reports 'Environment is ready for use' Running thru the outdoor_study example file it is throwing errors at the blockMesh. Saw where there were issues previously with the snappyHexMesh, but this is upstream. Error is: 'docker-machine' is not recognized as internal or external command

I am in running Revit/Dynamo as admin, but my admin account is a secondary windows account than my primary account. is this possible source of issue?

mostaphaRoudsari commented 5 years ago

@dradair, we haven't updated Dynamo nodes so it won't pick up the blueCFD installation. The update is only done for the Grasshopper plugin.

dradair commented 5 years ago

@mostaphaRoudsari that actually makes me feel betterish that I wasnt missing something easy in the install - i was doing it wrong! I'll try the other install mean (native openfoam/docker) and see where that leads me. Thanks for the fast response.

dradair commented 5 years ago

@mostaphaRoudsari is it known/confirmed if the Dynamo 'flavor' of Butterfly will work with OpenFOAM v1812 or must it be OpenFOAM v1612? I have been trying to get v1612 to install (windows 10) for the better of 4 hours with little luck. Keep having issues with either OpenFOAM Environment setup or with Oracle VM VB throwing errors. This is all before Dynamo. I have references the wikis for OF for Windows and OF for Windows10 install (and uninstall) process, but no success..... Granted, was also having issues with v1812 in Dynamo, but am going to revisit to see if it was just folder paths or if there is another way around. Please let me know if this is a futile effort and v1612 is the only option. Thanks in advance.

dradair commented 5 years ago

@mostaphaRoudsari an update, for completeness. There is a detail in the written instructions that is either omitted or i had (repeatedly) missed in the install video. "Before running the meshing components you need to have the OpenFOAM docker container running otherwise you will receive an error. " I feel foolish, but wont be the last time in my life..... This appears to have resolved my issues....for now.

mostaphaRoudsari commented 5 years ago

One should check the code and see how VSCode is doing it. The idea of using a port sounds hacky and most likely will need admin account but it might be all doable.

https://code.visualstudio.com/docs/remote/wsl#_getting-started