Example #1
0
def exampleImportBndf(resultDir=None,
                      chid=None,
                      fdsFile=None,
                      fdsQuantities=['WALL TEMPERATURE'],
                      fdsUnits=['C'],
                      tStart=0,
                      tEnd=120,
                      axis=-2,
                      value=4.4,
                      qnty_mn=20,
                      qnty_mx=100):
    if (resultDir is None) and (chid is None):
        try:
            import bpy
            systemPath = os.path.dirname(bpy.context.space_data.text.filepath)
        except:
            systemPath = os.path.dirname(os.path.abspath(__file__))
        chid = "case001"
        resultDir = os.path.join(systemPath, "examples", "%s.zip" % (chid))

    if fdsFile is None:
        fdsFilePath = fds.getFileList(resultDir, chid, 'fds')[0]

    datas, times = fds.queryBndf(resultDir, chid, fdsFilePath, fdsQuantities,
                                 fdsUnits, axis, value)
    tStartInd = np.argwhere(times >= tStart)[0][0]
    tEndInd = np.argwhere(times <= tEnd)[-1][0]

    for qty, unit in zip(fdsQuantities, fdsUnits):
        for mesh in list(datas[qty].keys()):
            data = datas[qty]['DATA']
            x = datas[qty]['X']
            z = datas[qty]['Z']
        meanData = np.mean(data[:, :, tStartInd:tEndInd], axis=2)
        fig = fds.plotSlice(x,
                            z,
                            meanData,
                            axis,
                            qnty_mn=qnty_mn,
                            qnty_mx=qnty_mx,
                            clabel="%s (%s)" % (qty, unit),
                            cbarticks=[20, 40, 60, 80, 100, 120, 140])
    return datas, fig
Example #2
0
def example2dSliceToCsv(resultDir=None,
                        outDir=None,
                        chid=None,
                        quantity=None,
                        unit=None,
                        axis=None,
                        value=None,
                        time=None,
                        dt=None):
    if (resultDir is None) and (chid is None) and (outDir is None):
        try:
            import bpy
            systemPath = os.path.dirname(bpy.context.space_data.text.filepath)
        except:
            systemPath = os.path.dirname(os.path.abspath(__file__))
        chid = "case001"
        resultDir = os.path.join(systemPath, "examples", "%s.zip" % (chid))
        outDir = os.path.join(systemPath, "generated")
    try:
        os.mkdir(outDir)
    except:
        pass
    data = fds.query2dAxisValue(resultDir,
                                chid,
                                quantity,
                                axis,
                                value,
                                time=time,
                                dt=dt)
    fds.renderSliceCsvs(data, chid, outDir)
    fig, ax = fds.plotSlice(data['x'],
                            data['z'],
                            data['datas'][:, :, -1],
                            axis,
                            clabel="%s (%s)" % (quantity, unit))
    fig.savefig(
        os.path.join(
            outDir, '%s_%s_%0.0f_%0.4f_final_frame.png' %
            (chid, quantity, axis, value)))
    return data, fig
Example #3
0
def exampleExtract2dFromSlcf2d(datas,
                               fdsQuantities=['TEMPERATURE'],
                               fdsUnits=['C'],
                               axis=1,
                               value=2.5,
                               qnty_mn=20,
                               qnty_mx=150):
    datas2D = defaultdict(bool)
    for qty, unit in zip(fdsQuantities, fdsUnits):
        x, z, data_slc = fds.findSliceLocation(datas['GRID'], datas[qty], axis,
                                               value)
        datas2D[qty] = data_slc
        fig = fds.plotSlice(x,
                            z,
                            data_slc,
                            axis,
                            qnty_mn=qnty_mn,
                            qnty_mx=qnty_mx,
                            clabel="%s (%s)" % (qty, unit),
                            cbarticks=[20, 40, 60, 80, 100, 120, 140])
    datas2D['X'] = x
    datas2D['Z'] = z

    return datas2D, fig