Exemple #1
0
ghenv.Component.NickName = "caseFromGeos"
ghenv.Component.Message = 'VER 0.0.04\nMAR_14_2017'
ghenv.Component.Category = "Butterfly"
ghenv.Component.SubCategory = "00::Create"
ghenv.Component.AdditionalHelpFromDocStrings = "2"

try:
    from butterfly_grasshopper.case import Case
    from butterfly_grasshopper.geometry import xyzToPoint
    import butterfly_grasshopper.unitconversion as uc
except ImportError as e:
    msg = '\nFailed to import butterfly:'

if _run and _name and _BFGeometries:
    # create OpenFoam Case
    ctm = uc.convertDocumentUnitsToMeters()

    case = Case.fromBFGeometries(_name,
                                 tuple(_BFGeometries),
                                 meshingParameters=_meshParams_,
                                 make2dParameters=make2dParams_,
                                 convertToMeters=ctm)

    for reg in refRegions_:
        case.addRefinementRegion(reg)

    if expandBlockMesh_:
        xCount, yCount, zCount = 1, 1, 1
        if case.blockMeshDict.is2dInXDirection:
            xCount = 0
        if case.blockMeshDict.is2dInYDirection:
Exemple #2
0
    from butterfly_grasshopper.geometry import xyzToPoint
    import butterfly_grasshopper.unitconversion as uc
except ImportError as e:
    msg = '\nFailed to import butterfly. Did you install butterfly on your machine?' + \
            '\nYou can download the installer file from github: ' + \
            'https://github.com/mostaphaRoudsari/Butterfly/tree/master/plugin/grasshopper/samplefiles' + \
            '\nOpen an issue on github if you think this is a bug:' + \
            ' https://github.com/mostaphaRoudsari/Butterfly/issues'

    raise ImportError('{}\n{}'.format(msg, e))

import os

if _solution and _field:
    if isinstance(_solution, str):
        projectDir = _solution.replace('\\\\', '/').replace('\\', '/')
        probesDir = os.path.join(projectDir, 'postProcessing\\probes')
        rawValues = loadProbesFromPostProcessingFile(probesDir, _field)
    else:
        assert hasattr(_solution, 'loadProbes'), \
            'Invalid Input: <{}> is not a valid Butterfly Solution.'.format(_solution)
        try:
            rawValues = _solution.loadProbes(_field)
        except Exception as e:
            raise ValueError('Failed to load probes:\n\t{}'.format(e))

    c = 1.0 / uc.convertDocumentUnitsToMeters()
    try:
        probes = tuple(xyzToPoint(v, c) for v in rawValues)
    except:
        probes = rawValues
Exemple #3
0
-

    Args:
        name_: Optional new name to change the name of the case.
        _folder: Fullpath to an OpenFoam case folder.
        _run: Create case from inputs.
    Returns:
        readMe!: Reports, errors, warnings, etc.
        case: Butterfly case.
"""

ghenv.Component.Name = "Butterfly_Create Case from Folder"
ghenv.Component.NickName = "caseFromFolder"
ghenv.Component.Message = 'VER 0.0.04\nMAR_14_2017'
ghenv.Component.Category = "Butterfly"
ghenv.Component.SubCategory = "00::Create"
ghenv.Component.AdditionalHelpFromDocStrings = "1"

try:
    from butterfly_grasshopper.case import Case
    import butterfly_grasshopper.unitconversion as uc
except ImportError as e:
    msg = '\nFailed to import butterfly:'
    raise ImportError('{}\n{}'.format(msg, e))

if _folder and _run: 
    # create OpenFoam Case
    case = Case.fromFolder(_folder, name_, 1.0 / uc.convertDocumentUnitsToMeters())
    case.save(overwrite=False)