Esempio n. 1
0
    def RequestData(self, request, inInfoVec, outInfoVec):
        from vtkmodules.vtkCommonDataModel import vtkTable, vtkDataSet, vtkPolyData
        from vtkmodules.vtkIOExodus import vtkExodusIIReader as e2r
        from vtkmodules.vtkFiltersVerdict import vtkMeshQuality as mq
        from vtkmodules.util.numpy_support import vtk_to_numpy as vton
        from vtkmodules.util.numpy_support import numpy_to_vtk as ntov
        import numpy as np

        ## Fetch the filter inputs and outputs:
        input0 = vtkDataSet.GetData(inInfoVec[0], 0)
        input1 = vtkDataSet.GetData(inInfoVec[1], 0)
        output = vtkDataSet.GetData(outInfoVec, 0)
        output.ShallowCopy(input1)

        ## Fetch input arrays
        cd = output.GetCellData()
        scd = input0.GetCellData()
        vmask = scd.GetArray('mask')
        vsaturation = scd.GetArray('saturation')
        if vmask == None or vsaturation == None:
            print('Error: A required array was not present.')
            return 0

        ## Get NumPy versions of each array so we can do arithmetic:
        mask = vton(vmask)
        saturation = vton(vsaturation)

        ## Find the top surface
        ext = pftools.dataCellExtent(input0)
        top = pftools.computeTopSurface(ext, mask)

        ## Compute the water table depth storage as wtd
        ## and store it as cell data.
        ps = pftools.dataPointExtent(input0) + (3, )
        xx = np.reshape(vton(input0.GetPoints().GetData()), ps)
        wtd = pftools.computeWaterTableDepth(top, saturation, xx)
        arr = ntov(wtd)
        arr.SetName('water table depth')
        output.GetCellData().AddArray(arr)

        return 1
Esempio n. 2
0
    def RequestData(self, request, inInfoVec, outInfoVec):
        from vtkmodules.vtkCommonDataModel import vtkTable, vtkDataSet, vtkPolyData
        from vtkmodules.vtkIOExodus import vtkExodusIIReader as e2r
        from vtkmodules.vtkFiltersVerdict import vtkMeshQuality as mq
        from vtkmodules.util.numpy_support import vtk_to_numpy as vton
        from vtkmodules.util.numpy_support import numpy_to_vtk as ntov
        import numpy as np

        ## Fetch the filter inputs and outputs:
        input0 = vtkDataSet.GetData(inInfoVec[0], 0)
        output = vtkDataSet.GetData(outInfoVec, 0)
        output.ShallowCopy(input0)

        ## Fetch input arrays
        cd = output.GetCellData()
        vmask = cd.GetArray('mask')
        vsaturation = cd.GetArray('saturation')
        vporosity = cd.GetArray('porosity')
        vpressure = cd.GetArray('pressure')
        vspecstor = cd.GetArray('specific storage')
        if vmask == None or vsaturation == None or \
           vporosity == None or vpressure == None or \
           vspecstor == None:
            print('Error: A required array was not present.')
            return 0

        ## Compute the volume of each cell:
        mqf = mq()
        mqf.SetHexQualityMeasureToVolume()
        mqf.SetInputDataObject(0, output)
        mqf.Update()
        volume = vton(
            mqf.GetOutputDataObject(0).GetCellData().GetArray('Quality'))

        ## Get NumPy versions of each array so we can do arithmetic:
        mask = vton(vmask)
        saturation = vton(vsaturation)
        porosity = vton(vporosity)
        pressure = vton(vpressure)
        specstor = vton(vspecstor)

        ## Compute the subsurface storage as sbs
        ## and store it as field data.
        sbs = np.sum(pftools.computeSubsurfaceStorage( \
                saturation, pressure, volume, porosity, specstor))
        arr = ntov(sbs)
        arr.SetName('subsurface storage')
        arr.GetInformation().Set(e2r.GLOBAL_TEMPORAL_VARIABLE(), 1)
        output.GetFieldData().AddArray(arr)

        return 1
Esempio n. 3
0
    def RequestData(self, request, inInfoVec, outInfoVec):
        from vtkmodules.vtkCommonDataModel import vtkTable, vtkDataSet, vtkPolyData
        from vtkmodules.vtkIOExodus import vtkExodusIIReader as e2r
        from vtkmodules.vtkFiltersVerdict import vtkMeshQuality as mq
        from vtkmodules.util.numpy_support import vtk_to_numpy as vton
        from vtkmodules.util.numpy_support import numpy_to_vtk as ntov
        import numpy as np

        ## Fetch the filter inputs and outputs:
        input0 = vtkDataSet.GetData(inInfoVec[0], 0)
        input1 = vtkDataSet.GetData(inInfoVec[1], 0)
        output = vtkDataSet.GetData(outInfoVec, 0)
        output.ShallowCopy(input0)

        ## Fetch input arrays
        cd = output.GetCellData()
        scd = input1.GetCellData()
        vmask = cd.GetArray('mask')
        vsaturation = cd.GetArray('saturation')
        vporosity = cd.GetArray('porosity')
        vpressure = cd.GetArray('pressure')
        vspecstor = cd.GetArray('specific storage')
        vslope = scd.GetArray('slope')
        vmannings = scd.GetArray('mannings')
        if vmask == None or vsaturation == None or \
           vporosity == None or vpressure == None or \
           vspecstor == None or vslope == None or \
           vmannings == None:
            print('Error: A required array was not present.')
            return 0

        ## Compute the volume of each cell:
        mqf = mq()
        mqf.SetHexQualityMeasureToVolume()
        mqf.SetInputDataObject(0, output)
        mqf.Update()
        volume = vton(
            mqf.GetOutputDataObject(0).GetCellData().GetArray('Quality'))

        ## Get NumPy versions of each array so we can do arithmetic:
        mask = vton(vmask)
        saturation = vton(vsaturation)
        porosity = vton(vporosity)
        pressure = vton(vpressure)
        specstor = vton(vspecstor)
        slope = vton(vslope)
        mannings = vton(vmannings)

        ## Compute the subsurface storage as sbs
        ## and store it as field data.
        sbs = np.sum(pftools.computeSubsurfaceStorage( \
                saturation, pressure, volume, porosity, specstor))
        arr = ntov(sbs)
        arr.SetName('subsurface storage')
        arr.GetInformation().Set(e2r.GLOBAL_TEMPORAL_VARIABLE(), 1)
        output.GetFieldData().AddArray(arr)

        ## Find the top surface
        ext = pftools.dataCellExtent(input0)
        top = pftools.computeTopSurface(ext, mask)
        itop = pftools.computeTopSurfaceIndices(top)

        ## Compute the surface storage
        ps = pftools.dataPointExtent(input0) + (3, )
        xx = np.reshape(vton(output.GetPoints().GetData()), ps)
        sus = np.sum(pftools.computeSurfaceStorage(ext, itop, xx, pressure))
        arr = ntov(sus)
        arr.SetName('surface storage')
        arr.GetInformation().Set(e2r.GLOBAL_TEMPORAL_VARIABLE(), 1)
        output.GetFieldData().AddArray(arr)

        ## Compute the surface runoff
        slope = np.reshape(slope, top.shape + (2, ))
        mannings = np.reshape(mannings, top.shape)
        sro = np.sum(
            pftools.computeSurfaceRunoff(top, xx, pressure, slope, mannings))
        arr = ntov(sro)
        arr.SetName('surface runoff')
        arr.GetInformation().Set(e2r.GLOBAL_TEMPORAL_VARIABLE(), 1)
        output.GetFieldData().AddArray(arr)

        return 1