def main(): wt = WindTunnelDS.fromGeometriesWindVectorAndParameters( _name, _BFGeometries, _windVector, _tunnelParams_, _landscape_, _meshParams_, _refWindHeight_) for region in refRegions_: wt.addRefinementRegion(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, make2dParameters=make2dParams_) print "Wind tunnel dimensions: {}, {} and {}".format( case.blockMeshDict.width, case.blockMeshDict.length, case.blockMeshDict.height) print "Number of divisions: {}, {} and {}".format( *wt.blockMeshDict.nDivXYZ) pts = (xyzToPoint(v) for v in case.blockMeshDict.vertices) return wt, pts, case
from butterfly_dynamo.geometry import xyzToPoint import butterfly_dynamo.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 = 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 # assign outputs to OUT OUT = (probes,)
# assign inputs _solution = IN[0] skippedProbes = None try: from butterfly_dynamo.geometry import xyzToPoint except ImportError as e: msg = '\nFailed to import butterfly:' if _solution: try: pts = _solution.skippedProbes() 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: skippedProbes = tuple(xyzToPoint(v) for v in pts) except: skippedProbes = pts # assign outputs to OUT OUT = (skippedProbes, )
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: yCount = 0 if case.blockMeshDict.is2dInZDirection: zCount = 0 case.blockMeshDict.expandByCellsCount(xCount, yCount, zCount) blockPts = (xyzToPoint(v) for v in case.blockMeshDict.vertices) case.save(overwrite=(_run + 1) % 2) # assign outputs to OUT OUT = blockPts, case
except ImportError as e: msg = '\nFailed to import butterfly. Did you install butterfly on your machine?' + \ '\nYou can download butterfly from package manager.' + \ '\nOpen an issue on github if you think this is a bug:' + \ ' https://github.com/ladybug-analysis-tools/butterfly/issues' 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.convertDocumentUnitsToMeters() 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 = (xyzToPoint(p, cr) for p in res.probes) if isinstance(res.values[0], float) == 1: values = res.values else: values = (xyzToVector(v) for v in res.values) # assign outputs to OUT OUT = probes, values