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
247 stars 70 forks source link

Butterfly, Rhino, and BlueCore2020? #418

Open BrendaEM opened 2 years ago

BrendaEM commented 2 years ago

Hi,

Firstly, thank you for working on Butterfly. I have seen some promising results with v0.0.05 and would like to use it for vehicle design. Right now, I am not working for anyone. It's just been a dream of mine. I've scripted OpenFoam by hand before they implemented SnappyHexMesh.

I am interested in getting Butterfly under Rhino/Grasshopper working under blueCFD-Core 2020-1. Someone graciously went through the effort to update Bluecore for us. I think that would be beneficial for people who use Bluecore if their (likely Wyldckat's ) efforts were recognized and validated, by it's use. Download Link: https://bluecfd.github.io/Core/Downloads/

I am not sure which version of Butterfly might get me closest to using a later version of Bluecore. Any advise would be welcome.

At first glance, Bluecore has changed their folder name, but it could either be changed back at the start of installation. I have seen various posts about internal configuration settings in 0.0.05. I suppose I can go though them all to find what needs to be changed. Over the last 10 years, and outside the addition of SnappyHexMesh, it seems that OpenFoam has largely been backward compatible.

Looking forward, I am also curious if the newly implemented Quad Re-Meshing added to Rhino V7 might be a better starting place for SnappyHexMesh, as the re-meshing supports symmetrical re-meshing as well as a few more features: https://docs.mcneel.com/rhino/7/help/en-us/commands/quadremesh.htm

I want to do some vehicle CFD. At some point, I would like to study learn what has been done, in order to add moving walls for a moving road to your widgets. If I can do that, surely, I would share the code.

Also, if I could get CFD working under Rhino working enough for my purposes, and while I live presently on a fixed income while I recover from health-issues, I could at least donate something for a few cups of coffee, to show my appreciation : )

Thank you for your consideration, --BrendaEM

BrendaEM commented 2 years ago

Firstly, I am in way over my head. I have no business even attempting this. This hasn't in any way been tested, yet. This will likely initiate the 3rd impact. Still, I am trying. This hasn't in any way been tested, yet. Let's see...

I see a lot of Blue-core version specific stuff in: runmanagerenv.py

Which I have changed to try to match the Bluecore 2020 contents: https://bluecfd.github.io/Core/ReleaseNotes/bluecfd-core-2020-1/#software-provided-with-installers

Most of the changes to OpenFoam and Third Party are variations of version 5 which need to be changed to version 8, except for Paraview which is 5.6.2, and MPI, which remains the same at 7.1 . The notepad major version appears to remain the same; the dot version might be different.

So far the file looks like this:


import os

def bluecfd(folder):
    """Environment variables fo blueCFD.

    The variables are based on setvars.bat file for blueCFD source.
    """
    bluecfd_env_base = {
        'AddOns_ParaView_DIR': os.path.join(folder, r'AddOns\ParaView'),
        'BLUECFDPATH': folder,
        'USER': 'ofuser',
        'USERNAME': 'ofuser',
        'WM_PROJECT': 'OpenFOAM',
        'WM_PROJECT_VERSION': '8.x',
        'FOAM_INST_DIR': folder,
        'WM_PROJECT_INST_DIR': folder,
        'WM_PROJECT_DIR': os.path.join(folder, 'OpenFOAM-8.x'),
        'WM_PROJECT_USER_DIR': os.path.join(folder, 'ofuser-of8'),
        'WM_THIRD_PARTY_DIR': os.path.join(folder, 'ThirdParty-8.x'),
        'WM_ARCH': 'mingw_w64',
        'WM_ARCH_OPTION': '64',
        'WM_CC': 'x86_64-w64-mingw32-gcc',
        'WM_COMPILER': 'Gcc',
        'WM_COMPILER_ARCH': 'x86_64-w64-mingw32',
        'WM_COMPILER_TYPE': 'system',
        'WM_COMPILE_OPTION': 'Opt',
        'WM_CXX': 'x86_64-w64-mingw32-g++',
        'WM_DIR': os.path.join(folder, 'OpenFOAM-8.x', 'wmake'),
        'WM_LABEL_OPTION': 'Int32',
        'WM_LABEL_SIZE': '32',
        'WM_LINK_LANGUAGE': 'c++',
        'WM_MPLIB': 'MSMPI71',
        'WM_OSTYPE': 'MSwindows',
        'WM_PRECISION_OPTION': 'DP',
        'WM_TARGET_ARCH': 'mingw_w64',
        'WM_OPTIONS': 'mingw_w64GccDPInt32Opt',
        'ParaView_DIR': os.path.join(folder, r'AddOns\ParaView'),
        'ParaView_MAJOR': '5.6',
        'ParaView_VERSION': '5.6.2',
        'BOOST_ARCH_PATH': os.path.join(folder, r'msys64\mingw64'),
        'CGAL_ARCH_PATH': os.path.join(folder, r'msys64\mingw64'),
        'MPI_ACCESSORY_OPTIONS': '-genvlist WM_PROJECT_DIR,MPI_BUFFER_SIZE,PATH',
        'MPI_ARCH_PATH': os.path.join(folder,
            r'ThirdParty-8.x\platforms\mingw_w64Gcc\MS-MPI-7.1'),
        'MPI_BUFFER_SIZE': '20000000',
        'FOAMY_HEX_MESH': '1',
        'FOAM_APP': os.path.join(folder, r'OpenFOAM-8.x\applications'),
        'FOAM_APPBIN': os.path.join(folder,
            r'OpenFOAM-8.x\platforms\mingw_w64GccDPInt32Opt\bin'),
        'FOAM_ETC': os.path.join(folder, r'OpenFOAM-8.x\etc'),
        'FOAM_EXT_LIBBIN': os.path.join(folder,
            r'ThirdParty-8.x\platforms\mingw_w64GccDPInt32\lib'),
        'FOAM_JOB_DIR': os.path.join(folder, r'jobControl'),
        'FOAM_LIBBIN': os.path.join(folder,
            r'OpenFOAM-8.x\platforms\mingw_w64GccDPInt32Opt\lib'),
        'FOAM_MPI': 'MS-MPI-7.1',
        'FOAM_RUN': os.path.join(folder, r'ofuser-of8\run'),
        'FOAM_SIGFPE': '1',
        'FOAM_SITE_APPBIN': os.path.join(folder,
            r'site\8.x\platforms\mingw_w64GccDPInt32Opt\bin'),
        'FOAM_SITE_LIBBIN': os.path.join(folder,
            r'site\8.x\platforms\mingw_w64GccDPInt32Opt\lib'),
        'FOAM_SOLVERS': os.path.join(folder, r'OpenFOAM-8.x\applications\solvers'),
        'FOAM_SRC': os.path.join(folder, r'OpenFOAM-8.x\src'),
        'FOAM_TUTORIALS': os.path.join(folder, r'OpenFOAM-8.x\tutorials'),
        'FOAM_USER_APPBIN': os.path.join(folder,
            r'ofuser-of8\platforms\mingw_w64GccDPInt32Opt\bin'),
        'FOAM_USER_LIBBIN': os.path.join(folder,
            r'ofuser-of8\platforms\mingw_w64GccDPInt32Opt\lib'),
        'FOAM_UTILITIES': os.path.join(folder, r'OpenFOAM-8.x\applications\utilities'),
        'PATH': ';'.join([
            os.path.join(folder, r'msys64\usr\bin'),
            os.path.join(folder, r'ThirdParty-8.x\platforms\mingw_w64Gcc\MS-MPI-7.1\bin'),
            os.path.join(folder, r'ofuser-of8\platforms\mingw_w64GccDPInt32Opt\bin'),
            os.path.join(folder, r'site\8.x\platforms\mingw_w64GccDPInt32Opt\bin'),
            os.path.join(folder, r'OpenFOAM-8.x\platforms\mingw_w64GccDPInt32Opt\bin'),
            os.path.join(folder, r'OpenFOAM-8.x\bin'),
            os.path.join(folder, r'OpenFOAM-8.x\wmake'),
            os.path.join(folder, r'msys64\mingw64\bin'),
            os.path.join(folder, r'AddOns\gnuplot\bin'),
            os.path.join(folder, r'AddOns\notepad2'),
            os.path.join(folder, r'ofuser-of8\platforms\mingw_w64GccDPInt32Opt\lib'),
            os.path.join(folder,
                r'OpenFOAM-8.x\platforms\mingw_w64GccDPInt32Opt\lib\MS-MPI-7.1'),
            os.path.join(folder,
                r'ThirdParty-8.x\platforms\mingw_w64GccDPInt32\lib\MS-MPI-7.1'),
            os.path.join(folder, r'ThirdParty-8.x\platforms\mingw_w64Gcc\MS-MPI-7.1\lib'),
            os.path.join(folder, r'site\8.x\platforms\mingw_w64GccDPInt32Opt\lib'),
            os.path.join(folder, r'OpenFOAM-8.x\platforms\mingw_w64GccDPInt32Opt\lib'),
            os.path.join(folder, r'ThirdParty-8.x\platforms\mingw_w64GccDPInt32\lib'),
            os.path.join(folder, r'OpenFOAM-8.x\platforms\mingw_w64GccDPInt32Opt\lib\dummy')
        ])
    }

    return bluecfd_env_base
BrendaEM commented 2 years ago

Searching, I get only 3 hits for Blue in case.py, which seem generic. Config.yml seems generic.

The following links in the header still work. There's would be a change in the header and another change when it's tested for: runmanager_bluecfd.py

# coding=utf-8
"""Runmanager for butterfly.

Run Butterfly on Windows using blueCFD: http://bluecfd.github.io/Core/About/

This class has not been tested against blueCFD-Core 2020-1:
http://bluecfd.github.io/Core/Downloads/
BrendaEM commented 2 years ago

This file might have to be edited: init.py

There's a line in it: 'blueCFD': r'C:\Program Files'

Which I am not sure if we need to append the folder name for BlueCFD OR is it were we expect to find the base folder?

Anyway, this is Bluecore's default folder name is: blueCFD-Core-2020

BrendaEM commented 2 years ago

In Bluecore 2020, there are 2 batch files which look version specific, but might only affect the launch of Bluecore:

DOS_Mode_OF8.bat
setvars_OF8.bat

Bluecore 2020's Openfoam has folder names named:

OpenFOAM-8
ThirdParty-8
ofuser-of8

... which I hope are handled by: runmanagerenv.py

ymg2007 commented 2 years ago

I have tried some hours for debug butterfly python code to fit BlueCFD-core-2020 . Here is the tips:

1、modify the line 194 of runmanager_bluecfd.py to envfile = os.path.join(self._blue_folder, 'setvars_OF8.bat') clipboard

2、blueCFD-core-2020 does not have the surfaceFeatureExtract exe, you should copy blueCFD-core-2017's surfaceFeatureExtract to C:\Program Files\blueCFD-Core-2020\OpenFOAM-8\platforms\mingw_w64GccDPInt32Opt\bin

clipboard3

3、BlockMesh \SnappyHexMesh\SimpleFoam can run fine without any changes

ymg2007 commented 2 years ago

Looking forward, I am also curious if the newly implemented Quad Re-Meshing added to Rhino V7 might be a better starting place for SnappyHexMesh, as the re-meshing supports symmetrical re-meshing as well as a few more features: https://docs.mcneel.com/rhino/7/help/en-us/commands/quadremesh.htm Quad Re-Meshing is used for surface remeshing, not for volume meshing for butterfly and OpenFOAM