def main():
    # meshing parameters are moved to blockMesh and snappyHexMesh components
    _meshParams_ = None

    wt = WindTunnelGH.from_geometries_wind_vector_and_parameters(
        _name, _BF_geo, _wind_vector, _tunnel_params_, _landscape_,
        _meshParams_, _ref_wind_height_)

    for region in ref_regions_:
        wt.add_refinementRegion(region)

    # save with overwrite set to False. User can clean the folder using purge if they need to.
    case = wt.save(overwrite=(_run + 1) % 2, make2d_parameters=make_2d_params_)

    print "Wind tunnel dimensions: {}, {} and {}".format(
        case.blockMeshDict.width, case.blockMeshDict.length,
        case.blockMeshDict.height)

    pts = (xyz_to_point(v) for v in case.blockMeshDict.vertices)

    return wt, pts, case
Example #2
0
        _solution: A Butterfly solution.
        
    Returns:
        skipped_probes: List of points that are skipped during the solution.
"""

ghenv.Component.Name = "Butterfly_Load Skipped Probes"
ghenv.Component.NickName = "loadSkippedProbes"
ghenv.Component.Message = 'VER 0.0.05\nJAN_12_2019'
ghenv.Component.Category = "Butterfly"
ghenv.Component.SubCategory = "07::PostProcess"
ghenv.Component.AdditionalHelpFromDocStrings = "2"


try:
    from butterfly_grasshopper.geometry import xyz_to_point
except ImportError as e:
    msg = '\nFailed to import butterfly:'

if _solution:
    try:
        pts = _solution.skipped_probes()
    except AssertionError as e:
        raise ValueError('{}.\nDid you run the solution before loading the probes?'.format(e))
    except AttributeError:
        raise ValueError('{} is not a butterfly Solution.'.format(_solution))
    try:
        skipped_probes = tuple(xyz_to_point(v) for v in pts)
    except:
        skipped_probes = pts
            cellCount in blockMesh component to set the cell count of blockMesh
            in X, Y or Z direction.
        preview: An approximation of blockMesh based on gradXYZ and cellCount.
            For accurate mesh visualization run blockMesh and visualize the
            output mesh [To be implemented!].
"""

ghenv.Component.Name = "Butterfly_wind Tunnel Grading"
ghenv.Component.NickName = "WTGrading"
ghenv.Component.Message = 'VER 0.0.04\nNOV_09_2018'
ghenv.Component.Category = "Butterfly"
ghenv.Component.SubCategory = "03::Mesh"
ghenv.Component.AdditionalHelpFromDocStrings = "3"

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

if _windTunnel:
    if areaOfInterest_:
        raise NotImplementedError(
            '\nArea of interest is not implemented yet!\nThis component uses '
            'geometry bounding box as the area of interest.\n'
            'You can use offset inputs to adjust the current bounding box.')
    gradXYZ, cell_count = _windTunnel.calculate_grading(
        _cellSize_[0], _cellToCellRatio_[0], wakeOffset_, heightOffset_)
    cellCountXYZ = xyz_to_point(cell_count)
    cellCountTot = int(cellCountXYZ.X * cellCountXYZ.Y * cellCountXYZ.Z)
ghenv.Component.AdditionalHelpFromDocStrings = "1"

try:
    from butterfly.utilities import load_probes_from_postProcessing_file
    from butterfly_grasshopper.geometry import xyz_to_point
    import butterfly_grasshopper.unitconversion as uc
except ImportError as e:
    msg = '\nFailed to import butterfly:'
    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 = load_probes_from_postProcessing_file(probesDir, _field)
    else:
        assert hasattr(_solution, 'loadProbes'), \
            'Invalid Input: <{}> is not a valid Butterfly Solution.'.format(_solution)
        try:
            rawValues = _solution.load_probes(_field)
        except Exception as e:
            raise ValueError('Failed to load probes:\n\t{}'.format(e))

    c = 1.0 / uc.convert_document_units_to_meters()
    try:
        probes = tuple(xyz_to_point(v, c) for v in rawValues)
    except:
        probes = rawValues
ghenv.Component.AdditionalHelpFromDocStrings = "1"

try:
    from butterfly.utilities import load_probes_from_postProcessing_file
    from butterfly_grasshopper.geometry import xyz_to_point, xyz_to_vector
    import butterfly_grasshopper.unitconversion as uc
except ImportError as e:
    msg = '\nFailed to import butterfly:'
    raise ImportError('{}\n{}'.format(msg, e))

import os

if _solution and _name and any(p is not None
                               for p in _points) and _field and _run:

    assert hasattr(_solution, 'sample'), \
        'Invalid Input: <{}> is not a valid Butterfly Case or Solution.'.format(_solution)
    c = uc.convert_document_units_to_meters()
    cr = 1.0 / c

    points = ((pt.X * c, pt.Y * c, pt.Z * c) for pt in _points)
    res = _solution.sample(_name, points, _field)

    if res:
        probes = (xyz_to_point(p, cr) for p in res.probes)

        if isinstance(res.values[0], float) == 1:
            values = res.values
        else:
            values = (xyz_to_vector(v) for v in res.values)
if _run and _name and _BFGeometries:
    # meshing parameters are moved to blockMesh and snappyHexMesh components
    _meshParams_ = None

    # create OpenFoam Case
    ctm = uc.convert_document_units_to_meters()

    case = Case.from_bf_geometries(_name,
                                   tuple(_BFGeometries),
                                   meshing_parameters=_meshParams_,
                                   make2d_parameters=make2dParams_,
                                   convertToMeters=ctm)

    for reg in refRegions_:
        case.add_refinement_region(reg)

    if expandBlockMesh_:
        xCount, yCount, zCount = 1, 1, 1
        if case.blockMeshDict.is2d_in_x_direction:
            xCount = 0
        if case.blockMeshDict.is2d_in_y_direction:
            yCount = 0
        if case.blockMeshDict.is2d_in_z_direction:
            zCount = 0

        case.blockMeshDict.expand_by_cells_count(xCount, yCount, zCount)

    blockPts = (xyz_to_point(v) for v in case.blockMeshDict.vertices)

    case.save(overwrite=(_run + 1) % 2)
        cell_count_tot: Number of total cells.
        preview: An approximation of blockMesh based on grad_xyz and cellCount.
            For accurate mesh visualization run blockMesh and visualize the
            output mesh [To be implemented!].
"""

ghenv.Component.Name = "Butterfly_wind Tunnel Grading"
ghenv.Component.NickName = "WTGrading"
ghenv.Component.Message = 'VER 0.0.05\nJAN_12_2019'
ghenv.Component.Category = "Butterfly"
ghenv.Component.SubCategory = "03::Mesh"
ghenv.Component.AdditionalHelpFromDocStrings = "3"

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

if _wind_tunnel:
    if area_of_interest_:
        raise NotImplementedError(
            '\nArea of interest is not implemented yet!\nThis component uses '
            'geometry bounding box as the area of interest.\n'
            'You can use offset inputs to adjust the current bounding box.')
    grad_xyz, cell_count = _wind_tunnel.calculate_grading(
        _cell_size_[0], _cell_to_cell_ratio_[0], wake_offset_, height_offset_)
    cell_count_xyz = xyz_to_point(cell_count)
    cell_count_tot = int(cell_count_xyz.X * cell_count_xyz.Y *
                         cell_count_xyz.Z)