예제 #1
0
def Test3(datadir):
    reader = vtk.vtkDataSetReader()
    reader.SetFileName(datadir + "/Data/blow.vtk")
    reader.UpdateInformation();
    reader.ReadAllScalarsOn()
    reader.ReadAllVectorsOn()

    dssf = vtk.vtkDataSetSurfaceFilter()
    dssf.SetInputConnection(reader.GetOutputPort())

    stripper = vtk.vtkStripper()
    stripper.SetInputConnection(dssf.GetOutputPort())

    f = vtk.vtkIntegrateAttributes()
    f.SetInputConnection(stripper.GetOutputPort())
    f.Update()

    result = f.GetOutputDataObject(0)
    val = result.GetPointData().GetArray("displacement1").GetValue(0)
    assert (val > 463.64 and val < 463.642)

    val = result.GetPointData().GetArray("thickness3").GetValue(0)
    assert (val > 874.61 and val < 874.618)

    val = result.GetCellData().GetArray("Area").GetValue(0)
    assert (val > 1145.405 and val < 1145.415)
예제 #2
0
    def __init__(self, inp):
        try:
            self.integrator = vtk.vtkIntegrateAttributes()
        except AttributeError:
            raise Exception(
                'vtkIntegrateAttributes is currently only supported by pvpython'
            )

        if not inp.GetOutput().GetNumberOfPoints():
            raise Exception('Empty slice')

        self.integrator.SetInputData(inp.GetOutput())
        self.integrator.Update()
예제 #3
0
def Test1(datadir):
    reader = vtk.vtkXMLUnstructuredGridReader()
    reader.SetFileName(datadir + "/Data/quadraticTetra01.vtu")
    reader.UpdateInformation();
    reader.GetPointDataArraySelection().EnableAllArrays()
    reader.GetCellDataArraySelection().EnableAllArrays()

    f = vtk.vtkIntegrateAttributes()
    f.SetInputConnection(reader.GetOutputPort())
    f.Update()

    result = f.GetOutputDataObject(0)
    val = result.GetPointData().GetArray("scalars").GetValue(0)
    assert (val > 0.0162 and val < 0.01621)

    val = result.GetCellData().GetArray("Volume").GetValue(0)
    assert (val > 0.128 and val < 0.1284)
예제 #4
0
def Test2(datadir):
    reader = vtk.vtkXMLUnstructuredGridReader()
    reader.SetFileName(datadir + "/Data/elements.vtu")
    reader.UpdateInformation();
    reader.GetPointDataArraySelection().EnableAllArrays()
    reader.GetCellDataArraySelection().EnableAllArrays()

    f = vtk.vtkIntegrateAttributes()
    f.SetInputConnection(reader.GetOutputPort())
    f.Update()

    result = f.GetOutputDataObject(0)
    val = result.GetPointData().GetArray("pointScalars").GetValue(0)
    assert (val > 83.1 and val < 83.2)

    val = result.GetCellData().GetArray("Volume").GetValue(0)
    assert (val > 1.999 and val < 2.01)
예제 #5
0
def Execute(args):
    print("get average along line probes")
    cell_type = "point"

    if (cell_type == "cell"):
        vtk_process = vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS
        vtk_data_type = vtk.vtkDataObject.CELL
    else:
        vtk_process = vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS
        vtk_data_type = vtk.vtkDataObject.POINT

    reader = vmtkscripts.vmtkMeshReader()
    reader.InputFileName = args.mesh_file
    reader.Execute()
    mesh = reader.Mesh

    pass_filt = vtk.vtkPassArrays()
    pass_filt.SetInputData(mesh)
    pass_filt.AddArray(vtk_data_type, "velocity")
    pass_filt.Update()

    surf = vmtkscripts.vmtkMeshToSurface()
    surf.Mesh = pass_filt.GetOutput()
    surf.Execute()

    normals = vmtkscripts.vmtkSurfaceNormals()
    normals.Surface = surf.Surface
    #accept defaults
    normals.Execute()

    calc1 = vtk.vtkArrayCalculator()
    calc1.SetFunction(
        "velocity_X*-Normals_X+velocity_Y*-Normals_Y+velocity_Z*-Normals_Z")
    calc1.AddScalarVariable("velocity_X", "velocity_X", 0)
    calc1.AddScalarVariable("velocity_Y", "velocity_Y", 0)
    calc1.AddScalarVariable("velocity_Z", "velocity_Z", 0)
    calc1.SetResultArrayName("vdotn")
    calc1.SetInputData(normals.Surface)
    if (cell_type == "cell"):
        calc1.SetAttributeModeToUseCellData()

    else:
        calc1.SetAttributeModeToUsePointData()
    calc1.SetResultArrayType(vtk.VTK_DOUBLE)

    integrate_attrs = vtk.vtkIntegrateAttributes()
    integrate_attrs.SetInputConnection(calc1.GetOutputPort())

    integrate_attrs.UpdateData()

    area = integrate_attrs.GetCellData().GetArray(0).GetValue(0)

    D = 2.0 * np.sqrt(area / np.pi)

    calc2 = vtk.vtkArrayCalculator()
    calc2.SetFunction("vdotn*10**6*60")
    calc2.AddScalarVariable("vdotn", "vdotn", 0)
    calc2.SetResultArrayName("Q")
    calc2.SetInputConnection(integrate_attrs.GetOutputPort())
    if (cell_type == "cell"):
        calc2.SetAttributeModeToUseCellData()
    else:
        calc2.SetAttributeModeToUsePointData()
    calc2.SetResultArrayType(vtk.VTK_DOUBLE)
    calc2.UpdateData()

    calc3 = vtk.vtkArrayCalculator()
    calc3.SetFunction("vdotn/{0}*1050.0/0.0035*{1}".format(area, D))
    calc3.AddScalarVariable("vdotn", "vdotn", 0)
    calc3.SetResultArrayName("Re")
    calc3.SetInputConnection(integrate_attrs.GetOutputPort())
    if (cell_type == "cell"):
        calc3.SetAttributeModeToUseCellData()
    else:
        calc3.SetAttributeModeToUsePointData()
    calc3.SetResultArrayType(vtk.VTK_DOUBLE)

    calc3.UpdateData()

    over_time = vtk.vtkExtractDataArraysOverTime()
    over_time.SetInputConnection(calc3.GetOutputPort())

    if (cell_type == "cell"):
        over_time.SetFieldAssociation(vtk_data_type)
    else:
        over_time.SetFieldAssociation(vtk_data_type)
    over_time.UpdateData()

    writer = vtk.vtkDelimitedTextWriter()
    writer.SetInputConnection(over_time.GetOutputPort())
    writer.SetFileName(args.file_out)
    writer.Write()
예제 #6
0
import vtk

iv=vtk.vtkIntegrateAttributes()
for i in range(self.GetNumberOfInputConnections(0)):
    iv.AddInputConnection(0,self.GetInputConnection(0,i))
iv.Update()
self.GetOutput().ShallowCopy(iv.GetOutput())

예제 #7
0
import vtk

iv = vtk.vtkIntegrateAttributes()
for i in range(self.GetNumberOfInputConnections(0)):
    iv.AddInputConnection(0, self.GetInputConnection(0, i))
iv.Update()
self.GetOutput().ShallowCopy(iv.GetOutput())