コード例 #1
0
    def createMesh(self, color='w', opacity=0.15, silo=False):
        _colors = dict(
            w=(255, 255, 255, 255),
            k=(0, 0, 0, 255),
            gray=(175, 175, 175),
        )

        if silo:
            v.AddPlot('Mesh', "mesh")
        else:
            v.AddPlot('Mesh', "Mesh")
        ma = v.MeshAttributes()
        ma.legendFlag = 0
        ma.meshColor = _colors[color]
        ma.meshColorSource = ma.MeshCustom
        if (opacity < 1.):
            ma.opaqueMode = ma.On
            ma.opacity = opacity

        v.SetPlotOptions(ma)

        pname = v.GetPlotList().GetPlots(v.GetNumPlots() - 1).plotName
        if silo:
            plot = Plot(pname, 'mesh', ma)
        else:
            plot = Plot(pname, 'Mesh', ma)
        self.nonplots.append(plot)
        return plot
コード例 #2
0
ファイル: diagnostic.py プロジェクト: terjekv/scitools
def test_visit():
    import visit

    VISIT_ARGS = os.environ.get('VISIT_ARGS', ["-nosplash"])
    if isinstance(VISIT_ARGS, str):
        VISIT_ARGS = VISIT_ARGS.split()
    for arg in VISIT_ARGS:
        visit.AddArgument(arg)
    visit.Launch()

    print "visit is installed in", os.path.dirname(visit.__file__)
    print "visit version", visit.Version()

    visit.ResetView()
    v3D = visit.GetView3D()
    v3D.SetViewUp(0, 0, 1)
    v3D.SetViewNormal(-0.5, -0.8, 0.4)
    v3D.SetImageZoom(1.0)
    visit.SetView3D(v3D)

    aa = visit.AnnotationAttributes()
    aa.SetAxesType(2)  # outside edges
    aa.SetDatabaseInfoFlag(False)
    aa.SetUserInfoFlag(False)
    visit.SetAnnotationAttributes(aa)

    t = visit.CreateAnnotationObject("Text2D")
    t.SetText("Hello VisIt!")
    t.SetPosition(0.4, 0.9)  # (0,0) is lower left corner
    t.SetFontFamily(0)  # 0: Arial, 1: Courier, 2: Times
    t.SetWidth(0.25)  # 25%
    t.SetTextColor((0, 0, 0))
    t.SetUseForegroundForTextColor(False)
    t.SetVisible(True)

    visit.OpenDatabase("tmp_.vtk")

    visit.AddPlot("Mesh", "scalars")
    ma = visit.MeshAttributes()
    visit.SetPlotOptions(ma)
    visit.AddPlot("Pseudocolor", "scalars")
    pa = visit.PseudocolorAttributes()
    visit.SetPlotOptions(pa)

    visit.RedrawWindow()
    visit.DrawPlots()

    wait()
コード例 #3
0
def setup_visit(plot_variable_data, db_name):
    print 'Opening database...'
    # Get the complete database name including directory path, db file
    # pattern and extension, followed by the word database
    # Example: db_filename = './output*.vtk database'
    visit.OpenDatabase(db_name)

    # Getting the list of current variables
    db_meta_data = visit.GetMetaData(db_name)
    scalar_list = [
        db_meta_data.GetScalars(i).name
        for i in range(db_meta_data.GetNumScalars())
    ]
    vector_list = [
        db_meta_data.GetVectors(i).name
        for i in range(db_meta_data.GetNumVectors())
    ]
    for vec in vector_list:
        scalar_list.append(vec + '_magnitude')

    # Check if current variable name exists in the database. If no, then
    # res becomes 0. Hence, we need to define a scalar expression for the
    # current variable
    if plot_variable_data['plot variable'] in scalar_list or \
       plot_variable_data['plot variable'] in vector_list:
        visit.AddPlot(plot_variable_data['plot type'], \
            plot_variable_data['plot variable'])
    else:
        print 'No existing variable of that name'
        visit.DefineScalarExpression(plot_variable_data['plot variable'], \
          plot_variable_data['plot variable definition'])
        visit.AddPlot(plot_variable_data['plot type'], \
          plot_variable_data['plot variable'])

    # Making mesh transparent and overlaying it on the plot
    visit.AddPlot('Mesh', 'mesh')
    p = visit.MeshAttributes()
    p.SetOpacity(0.25)
    visit.SetPlotOptions(p)
コード例 #4
0
    return pr.parse_args()


if __name__ == '__main__':
    args = get_args()

    # Treat databases as time-varying
    v.SetTreatAllDBsAsTimeVarying(1)

    v.OpenDatabase(args.database + ' database')
    v.AddPlot('Volume', args.varname, 1, 1)

    if args.mesh:
        v.AddPlot('Mesh', 'mesh')
        matts = v.MeshAttributes()
        v.SetPlotOptions(matts)
    v.DrawPlots()

    # Set rendering type
    vatts = v.VolumeAttributes()
    if args.rndr == 'splatting':
        vatts.rendererType = vatts.Splatting
    elif args.rndr == 'raycast':
        vatts.rendererType = vatts.RayCasting
    elif args.rndr == 'texture':
        vatts.rendererType = vatts.Texture3D

    # Set scaling
    if args.scaling == 'lin':
        vatts.scaling = vatts.Linear
コード例 #5
0
def visit_plot_contour_3d(xdmf_path,
                          name,
                          value_range=(-5.0, 5.0),
                          p3d_paths=None,
                          config_view=None,
                          out_dir=os.getcwd(),
                          out_prefix='wake3d_',
                          figsize=(1024, 1024),
                          visit_dir=None,
                          visit_arch='linux-x86_64',
                          state=None,
                          states=None,
                          states_range=[0, None, 1]):
    # Import VisIt package.
    if visit_dir is None:
        visit_dir = os.environ.get('VISIT_DIR')
        if visit_dir is None:
            raise ValueError('Provide VisIt installation path or '
                             'set env variable VISIT_DIR')
    sys.path.append(os.path.join(visit_dir, visit_arch, 'lib',
                                 'site-packages'))
    import visit

    visit.LaunchNowin()

    # Check version of VisIt.
    visit_check_version(visit.Version())

    # Create database correlation with optional Point3D files.
    num_bodies = 0
    databases = [str(xdmf_path)]
    if p3d_paths is not None:
        num_bodies = len(p3d_paths)
        databases = [str(path) for path in p3d_paths]
        databases.append(str(xdmf_path))
    visit.CreateDatabaseCorrelation('common', databases[num_bodies:], 0)

    # Open the file with the coordinates of the immersed boundary.
    if num_bodies > 0:
        for i in range(num_bodies):
            visit.OpenDatabase(databases[i], 0, 'Point3D_1.0')
            # Add plot the mesh points.
            visit.AddPlot('Mesh', 'points', 1, 1)
            # Set attributes of the mesh plot.
            MeshAtts = visit.MeshAttributes()
            MeshAtts.legendFlag = 0
            MeshAtts.meshColor = (255, 204, 0, 1.0 * 255)
            MeshAtts.meshColorSource = MeshAtts.MeshCustom
            MeshAtts.pointSize = 0.05
            MeshAtts.pointType = MeshAtts.Point
            MeshAtts.pointSizePixels = 2
            MeshAtts.opacity = 1
            visit.SetPlotOptions(MeshAtts)

    # Open the XMF file for the z-component of the vorticity.
    visit.OpenDatabase(databases[-1], 0)
    # Add the plot of the contour of the z-component of the vorticity.
    visit.AddPlot('Contour', name, 1, 1)
    # Set attributes of the contour.
    ContourAtts = visit.ContourAttributes()
    ContourAtts.contourNLevels = 2
    ContourAtts.SetMultiColor(0, (0, 51, 102, 0.6 * 255))
    ContourAtts.SetMultiColor(1, (255, 0, 0, 0.6 * 255))
    ContourAtts.legendFlag = 1
    ContourAtts.minFlag = 1
    ContourAtts.maxFlag = 1
    ContourAtts.min = value_range[0]
    ContourAtts.max = value_range[1]
    visit.SetPlotOptions(ContourAtts)

    # Parse the 3D view configuration file.
    if config_view is not None:
        with open(str(config_view), 'r') as infile:
            config_view = yaml.load(infile, Loader=yaml.FullLoader)
            config_view = config_view['View3DAtts']
    # Set attributes of the view.
    View3DAtts = visit.View3DAttributes()
    for key, value in config_view.items():
        if type(value) is list:
            value = tuple(value)
        setattr(View3DAtts, key, value)
    visit.SetView3D(View3DAtts)

    # Remove time and user info.
    AnnotationAtts = visit.AnnotationAttributes()
    AnnotationAtts.userInfoFlag = 0
    AnnotationAtts.timeInfoFlag = 0
    AnnotationAtts.axes3D.visible = 0
    AnnotationAtts.axes3D.triadFlag = 1
    AnnotationAtts.axes3D.bboxFlag = 0
    visit.SetAnnotationAttributes(AnnotationAtts)

    visit.SetActiveWindow(1)

    visit.Source(os.path.join(visit_dir, visit_arch, 'bin', 'makemovie.py'))
    visit.ToggleCameraViewMode()

    # Create output directory if necessary.
    if not os.path.isdir(str(out_dir)):
        os.makedirs(str(out_dir))

    # Loop over the states to render and save the plots.
    if state is not None:
        states = [state]
    elif states is None:
        if states_range[1] is None:
            states_range[1] = visit.TimeSliderGetNStates()
        else:
            states_range[1] += 1
        states = range(*states_range)

    for i, state in enumerate(states):
        print('[state {}] Rendering and saving figure ...'.format(state))
        visit.SetTimeSliderState(state)

        if i == 0:
            visit.DrawPlots()

        RenderingAtts = visit.RenderingAttributes()
        visit.SetRenderingAttributes(RenderingAtts)

        SaveWindowAtts = visit.SaveWindowAttributes()
        SaveWindowAtts.outputToCurrentDirectory = 0
        SaveWindowAtts.outputDirectory = str(out_dir)
        SaveWindowAtts.fileName = '{}{:0>4}'.format(out_prefix, state)
        SaveWindowAtts.family = 0
        SaveWindowAtts.format = SaveWindowAtts.PNG
        SaveWindowAtts.width = figsize[0]
        SaveWindowAtts.height = figsize[1]
        SaveWindowAtts.quality = 100
        SaveWindowAtts.resConstraint = SaveWindowAtts.NoConstraint
        visit.SetSaveWindowAttributes(SaveWindowAtts)

        visit.SaveWindow()

    os.remove('visitlog.py')
    visit.Close()
    return
コード例 #6
0
import os
import visit

dirname = "/Users/uec/research/water/data/meshing/data/meshes/06010208/12"
db = os.listdir(dirname)
dbf = [os.path.join(dirname, d) for d in db]

opacity = 0.5
vmin = 100
vmax = 1000

for d in dbf:
    visit.OpenDatabase(d)
    visit.AddPlot("Mesh", "mesh")
    ma = visit.MeshAttributes()
    ma.legendFlag = 0
    ma.opaqueMode = ma.On
    ma.opacity = opacity
    visit.SetPlotOptions(ma)

    visit.DefineScalarExpression("z", "coord(mesh)[2]")
    visit.AddPlot('Pseudocolor', "z")
    pa = visit.PseudocolorAttributes()
    pa.minFlag = 1
    pa.min = vmin
    pa.maxFlag = 1
    pa.max = vmax
    visit.SetPlotOptions(pa)
    

    
コード例 #7
0
ファイル: makepoint.py プロジェクト: mkruuse/analysator
def draw_point_picture(variableName,
                       minValue,
                       maxValue,
                       inputDirectory,
                       inputFileName,
                       coordinate,
                       outputDirectory,
                       outputFileName,
                       colorTable="hot_desaturated"):
    '''
   Function for making a visit plot with a point
   
   Arguments:
   :param variableName                  Name of the variable
   :param minValue                      Minimum value of the variable
   :param maxValue                      Maximum value of the variable
   :param inputDirectory                Path to input vlsv/silo files
   :param inputFileName                Name of the file, for example \"bulk.00000.silo\"
   :param coordinates                   Coordinates corresponding to the files so for example [ [[0,0,0], [0,1,0]], [[2,1,2], [2,1,4]] ]
   :param outputDirectory               Path to output directory
   :param outputFileName                Name of the output file
   :param colorTable="hot_desaturated"  Color table for the plots
   '''
    # OPTIONS
    #################################################################

    # Input variable
    _variableName = variableName
    minVariableValue = minValue
    maxVariableValue = maxValue
    colorTableName = colorTable

    # Input directory and file names
    _outputDir = outputDirectory
    _outputFileName = outputFileName  # The file names for the png files.
    databaseName = "localhost:" + inputDirectory + inputFileName  # For navigating to the silo files
    # Note: a slice of the plot in z-axis is taken automatically
    #################################################################

    inputFileName2 = "point.vtk"
    databaseName2 = "localhost:" + os.getcwd() + "/" + inputFileName2

    currentPlot = 0

    vis.OpenDatabase(databaseName, 0)
    #vis.ActiveDatabase("localhost:" + inputDirectory + inputFileName)
    #Load settings
    visSettings.load_visit_settings()
    vis.AddPlot("Pseudocolor", _variableName, 1, 1)  #CONTINUE
    vis.SetActivePlots(currentPlot)
    vis.PseudocolorAtts = vis.PseudocolorAttributes()
    vis.PseudocolorAtts.legendFlag = 1
    vis.PseudocolorAtts.lightingFlag = 1
    vis.PseudocolorAtts.minFlag = 1
    vis.PseudocolorAtts.maxFlag = 1
    vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural  # Natural, Nodal, Zonal
    vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear  # Linear, Log, Skew
    vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot  # OriginalData, CurrentPlot
    vis.PseudocolorAtts.min = minVariableValue
    vis.PseudocolorAtts.max = maxVariableValue
    vis.PseudocolorAtts.pointSize = 0.05
    vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point  # Box, Axis, Icosahedron, Point, Sphere
    vis.PseudocolorAtts.skewFactor = 1
    vis.PseudocolorAtts.opacity = 1
    vis.PseudocolorAtts.colorTableName = colorTableName
    vis.PseudocolorAtts.invertColorTable = 0
    vis.PseudocolorAtts.smoothingLevel = 0
    vis.PseudocolorAtts.pointSizeVarEnabled = 0
    vis.PseudocolorAtts.pointSizeVar = "default"
    vis.PseudocolorAtts.pointSizePixels = 2
    vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
    vis.PseudocolorAtts.lineWidth = 0
    vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit  # Explicit, ColorTable
    vis.SetPlotOptions(vis.PseudocolorAtts)

    vis.AddOperator("Slice", 1)
    vis.SliceAtts = vis.SliceAttributes()
    vis.SliceAtts.originType = vis.SliceAtts.Intercept  # Point, Intercept, Percent, Zone, Node
    vis.SliceAtts.originPoint = (0, 0, 0)
    vis.SliceAtts.originIntercept = 0
    vis.SliceAtts.originPercent = 0
    vis.SliceAtts.originZone = 0
    vis.SliceAtts.originNode = 0
    vis.SliceAtts.normal = (0, 0, 1)
    vis.SliceAtts.axisType = vis.SliceAtts.ZAxis  # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi
    vis.SliceAtts.upAxis = (0, 1, 0)
    vis.SliceAtts.project2d = 1
    vis.SliceAtts.interactive = 1
    vis.SliceAtts.flip = 0
    vis.SliceAtts.originZoneDomain = 0
    vis.SliceAtts.originNodeDomain = 0
    vis.SliceAtts.meshName = "SpatialGrid"
    vis.SliceAtts.theta = 0
    vis.SliceAtts.phi = 90
    vis.SetOperatorOptions(vis.SliceAtts, 1)
    vis.DrawPlots()

    create_point_vtk(fileName=inputFileName2, coordinates=coordinate)
    vis.OpenDatabase(databaseName2, 0)
    currentPlot = currentPlot + 1
    vis.SetActivePlots(currentPlot)
    vis.AddPlot("Mesh", "mesh", 1, 1)
    vis.MeshAtts = vis.MeshAttributes()
    vis.MeshAtts.legendFlag = 1
    vis.MeshAtts.lineStyle = vis.MeshAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
    vis.MeshAtts.lineWidth = 0
    vis.MeshAtts.meshColor = (0, 0, 0, 255)
    vis.MeshAtts.outlineOnlyFlag = 0
    vis.MeshAtts.errorTolerance = 0.01
    vis.MeshAtts.meshColorSource = vis.MeshAtts.Foreground  # Foreground, MeshCustom
    vis.MeshAtts.opaqueColorSource = vis.MeshAtts.Background  # Background, OpaqueCustom
    vis.MeshAtts.opaqueMode = vis.MeshAtts.Auto  # Auto, On, Off
    vis.MeshAtts.pointSize = 0.05
    vis.MeshAtts.opaqueColor = (255, 255, 255, 255)
    vis.MeshAtts.smoothingLevel = vis.MeshAtts.None  # None, Fast, High
    vis.MeshAtts.pointSizeVarEnabled = 0
    vis.MeshAtts.pointSizeVar = "default"
    vis.MeshAtts.pointType = vis.MeshAtts.Point  # Box, Axis, Icosahedron, Point, Sphere
    vis.MeshAtts.showInternal = 0
    vis.MeshAtts.pointSizePixels = 25
    vis.MeshAtts.opacity = 1
    vis.SetPlotOptions(vis.MeshAtts)
    vis.DrawPlots()
    vis.SaveWindowAtts = vis.SaveWindowAttributes()
    vis.SaveWindowAtts.outputToCurrentDirectory = 0
    vis.SaveWindowAtts.outputDirectory = _outputDir
    vis.SaveWindowAtts.fileName = _outputFileName
    vis.SaveWindowAtts.family = 1
    vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG  # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY
    vis.SaveWindowAtts.width = 3000
    vis.SaveWindowAtts.height = 3000
    vis.SaveWindowAtts.screenCapture = 0
    vis.SaveWindowAtts.saveTiled = 0
    vis.SaveWindowAtts.quality = 100
    vis.SaveWindowAtts.progressive = 0
    vis.SaveWindowAtts.binary = 0
    vis.SaveWindowAtts.stereo = 0
    vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits  # None, PackBits, Jpeg, Deflate
    vis.SaveWindowAtts.forceMerge = 0
    vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions  # NoConstraint, EqualWidthHeight, ScreenProportions
    vis.SaveWindowAtts.advancedMultiWindowSave = 0
    vis.SetSaveWindowAttributes(vis.SaveWindowAtts)
    vis.SaveWindow()
    vis.SetActivePlots((0, 1))
    vis.DeleteActivePlots()
    vis.CloseDatabase(databaseName2)
    vis.CloseDatabase(databaseName)
コード例 #8
0
ファイル: makepoint.py プロジェクト: mkruuse/analysator
def create_visit_point_movie(variableName,
                             minValue,
                             maxValue,
                             inputDirectory,
                             inputFileNames,
                             coordinates,
                             outputDirectory,
                             outputFileName,
                             colorTable="hot_desaturated"):
    '''
   Function for making a movie
   
   Arguments:
   :param variableName                  Name of the variable
   :param minValue                      Minimum value of the variable
   :param maxValue                      Maximum value of the variable
   :param inputDirectory                Path to input vlsv/silo files
   :param inputFileNames                Name of the files for example [\"bulk.00000.silo\", \"bulk.00001.silo\"]
   :param coordinates                   Coordinates corresponding to the files so for example [ [[0,0,0], [0,1,0]], [[2,1,2], [2,1,4]] ]
   :param outputDirectory               Path to output directory
   :param outputFileName                Name of the output file
   :param colorTable="hot_desaturated"  Color table for the plots
   '''
    coordinates = [coordinates]

    for i in range(len(inputFileNames)):
        # OPTIONS
        #################################################################

        # Input variable
        _variableName = variableName
        minVariableValue = minValue
        maxVariableValue = maxValue
        colorTableName = colorTable

        # Input directory and file names
        #_outputDir = "/home/hannukse/MOVINGFRAME_MOVIES/AAJ_BZ_REMAKE/" # Set the output directory (Where .png s are saved)
        _outputDir = outputDirectory
        #_outputFileName = "BZ_FORESHOCK_2_" # The file names for the png files. These for ex. will be saved visit0000.png, visit0001.png, ..
        _outputFileName = outputFileName  # The file names for the png files.
        #databaseName = "localhost:/home/hannukse/meteo/stornext/field/vlasiator/2D/AAJ/silo_files/bulk.*.silo database" # For navigating to the silo files
        inputFileName = inputFileNames[i]
        databaseName = "localhost:" + inputDirectory + inputFileName  # For navigating to the silo files
        # Note: a slice of the plot in z-axis is taken automatically
        #################################################################
        # LaunchNowin(vdir=visitBinDirectory)
        #dx = speedX * frameInSeconds # Note: This is in meters per frame!
        #dy = speedY * frameInSeconds # Note: This is in meters per frame!
        #LaunchNowin(vdir="/usr/local/visit/bin")
        #Set up window and annotations
        #vis.LaunchNowin(vdir="/usr/local/visit/bin")

        inputFileName2 = "point.vtk"
        databaseName2 = "localhost:" + os.getcwd() + "/" + inputFileName2

        vis.OpenDatabase(databaseName, 0)
        #vis.ActiveDatabase("localhost:" + inputDirectory + inputFileName)
        #Load settings
        visSettings.load_visit_settings()
        vis.AddPlot("Pseudocolor", _variableName, 1, 1)  #CONTINUE
        vis.SetActivePlots(1)
        vis.PseudocolorAtts = vis.PseudocolorAttributes()
        vis.PseudocolorAtts.legendFlag = 1
        vis.PseudocolorAtts.lightingFlag = 1
        vis.PseudocolorAtts.minFlag = 1
        vis.PseudocolorAtts.maxFlag = 1
        vis.PseudocolorAtts.centering = vis.PseudocolorAtts.Natural  # Natural, Nodal, Zonal
        vis.PseudocolorAtts.scaling = vis.PseudocolorAtts.Linear  # Linear, Log, Skew
        vis.PseudocolorAtts.limitsMode = vis.PseudocolorAtts.CurrentPlot  # OriginalData, CurrentPlot
        vis.PseudocolorAtts.min = minVariableValue
        vis.PseudocolorAtts.max = maxVariableValue
        vis.PseudocolorAtts.pointSize = 0.05
        vis.PseudocolorAtts.pointType = vis.PseudocolorAtts.Point  # Box, Axis, Icosahedron, Point, Sphere
        vis.PseudocolorAtts.skewFactor = 1
        vis.PseudocolorAtts.opacity = 1
        vis.PseudocolorAtts.colorTableName = colorTableName
        vis.PseudocolorAtts.invertColorTable = 0
        vis.PseudocolorAtts.smoothingLevel = 0
        vis.PseudocolorAtts.pointSizeVarEnabled = 0
        vis.PseudocolorAtts.pointSizeVar = "default"
        vis.PseudocolorAtts.pointSizePixels = 2
        vis.PseudocolorAtts.lineStyle = vis.PseudocolorAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
        vis.PseudocolorAtts.lineWidth = 0
        vis.PseudocolorAtts.opacityType = vis.PseudocolorAtts.Explicit  # Explicit, ColorTable
        vis.SetPlotOptions(vis.PseudocolorAtts)

        vis.SetActivePlots(1)
        vis.AddOperator("Slice", 1)
        vis.SetActivePlots(1)
        vis.SliceAtts = vis.SliceAttributes()
        vis.SliceAtts.originType = vis.SliceAtts.Intercept  # Point, Intercept, Percent, Zone, Node
        vis.SliceAtts.originPoint = (0, 0, 0)
        vis.SliceAtts.originIntercept = 0
        vis.SliceAtts.originPercent = 0
        vis.SliceAtts.originZone = 0
        vis.SliceAtts.originNode = 0
        vis.SliceAtts.normal = (0, 0, 1)
        vis.SliceAtts.axisType = vis.SliceAtts.ZAxis  # XAxis, YAxis, ZAxis, Arbitrary, ThetaPhi
        vis.SliceAtts.upAxis = (0, 1, 0)
        vis.SliceAtts.project2d = 1
        vis.SliceAtts.interactive = 1
        vis.SliceAtts.flip = 0
        vis.SliceAtts.originZoneDomain = 0
        vis.SliceAtts.originNodeDomain = 0
        vis.SliceAtts.meshName = "SpatialGrid"
        vis.SliceAtts.theta = 0
        vis.SliceAtts.phi = 90
        vis.SetOperatorOptions(vis.SliceAtts, 1)
        vis.DrawPlots()
        vis.SetActivePlots(0)

        for coordinate in coordinates[i]:
            print(str(coordinate))
            create_point_vtk(fileName=inputFileName2, coordinates=coordinate)
            vis.OpenDatabase(databaseName2, 0)
            vis.AddPlot("Mesh", "mesh", 1, 1)
            vis.SetActivePlots(vis.GetNumPlots())
            vis.MeshAtts = vis.MeshAttributes()
            vis.MeshAtts.legendFlag = 1
            vis.MeshAtts.lineStyle = vis.MeshAtts.SOLID  # SOLID, DASH, DOT, DOTDASH
            vis.MeshAtts.lineWidth = 0
            vis.MeshAtts.meshColor = (0, 0, 0, 255)
            vis.MeshAtts.outlineOnlyFlag = 0
            vis.MeshAtts.errorTolerance = 0.01
            vis.MeshAtts.meshColorSource = vis.MeshAtts.Foreground  # Foreground, MeshCustom
            vis.MeshAtts.opaqueColorSource = vis.MeshAtts.Background  # Background, OpaqueCustom
            vis.MeshAtts.opaqueMode = vis.MeshAtts.Auto  # Auto, On, Off
            vis.MeshAtts.pointSize = 0.05
            vis.MeshAtts.opaqueColor = (255, 255, 255, 255)
            vis.MeshAtts.smoothingLevel = vis.MeshAtts.None  # None, Fast, High
            vis.MeshAtts.pointSizeVarEnabled = 0
            vis.MeshAtts.pointSizeVar = "default"
            vis.MeshAtts.pointType = vis.MeshAtts.Point  # Box, Axis, Icosahedron, Point, Sphere
            vis.MeshAtts.showInternal = 0
            vis.MeshAtts.pointSizePixels = 10
            vis.MeshAtts.opacity = 1
            vis.SetPlotOptions(vis.MeshAtts)
            vis.DrawPlots()
            # Iterate through frames
            vis.SaveWindowAtts = vis.SaveWindowAttributes()
            vis.SaveWindowAtts.outputToCurrentDirectory = 0
            vis.SaveWindowAtts.outputDirectory = _outputDir
            vis.SaveWindowAtts.fileName = _outputFileName
            vis.SaveWindowAtts.family = 1
            vis.SaveWindowAtts.format = vis.SaveWindowAtts.PNG  # BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, POVRAY, PPM, RGB, STL, TIFF, ULTRA, VTK, PLY
            vis.SaveWindowAtts.width = 3000
            vis.SaveWindowAtts.height = 3000
            vis.SaveWindowAtts.screenCapture = 0
            vis.SaveWindowAtts.saveTiled = 0
            vis.SaveWindowAtts.quality = 100
            vis.SaveWindowAtts.progressive = 0
            vis.SaveWindowAtts.binary = 0
            vis.SaveWindowAtts.stereo = 0
            vis.SaveWindowAtts.compression = vis.SaveWindowAtts.PackBits  # None, PackBits, Jpeg, Deflate
            vis.SaveWindowAtts.forceMerge = 0
            vis.SaveWindowAtts.resConstraint = vis.SaveWindowAtts.ScreenProportions  # NoConstraint, EqualWidthHeight, ScreenProportions
            vis.SaveWindowAtts.advancedMultiWindowSave = 0
            vis.SetSaveWindowAttributes(vis.SaveWindowAtts)
            vis.SaveWindow()
            vis.DeleteActivePlots()
        vis.DeleteActivePlots()
        vis.CloseDatabase(databaseName)
    vis.CloseDatabase(databaseName2)
    # Make the movie:
    #subprocess.call("./moviecompilescript.sh " + _outputDir + " " + _outputFileName)
    pyVisitPath = "pyVisit/"
    #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh")
    #subprocess.call(pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh " + _outputDir + " " + _outputFileName)
    framerate = "10"
    subprocess.call([
        pythonLibDirectoryPath + pyVisitPath + "moviecompilescript.sh",
        _outputDir, _outputFileName, framerate
    ])
    # Delete the point vtk file:
    os.remove(os.getcwd() + "/" + inputFileName2)
コード例 #9
0
def visit_plot_contour_3d(xdmf_path,
                          name,
                          value_range=(-5.0, 5.0),
                          p3d_paths=None,
                          config_view=None,
                          out_dir=os.getcwd(),
                          out_prefix=None,
                          figsize=(1024, 1024),
                          state=None,
                          states=None,
                          states_range=[0, None, 1]):
    visit_initialize()

    # Create database correlation with optional Point3D files.
    num_bodies = 0
    databases = [str(xdmf_path)]
    if p3d_paths is not None:
        num_bodies = len(p3d_paths)
        databases = [str(path) for path in p3d_paths]
        databases.append(str(xdmf_path))
    visit.CreateDatabaseCorrelation('common', databases[num_bodies:], 0)

    # Open the file with the coordinates of the immersed boundary.
    if num_bodies > 0:
        for i in range(num_bodies):
            visit.OpenDatabase(databases[i], 0, 'Point3D_1.0')
            # Add plot the mesh points.
            visit.AddPlot('Mesh', 'points', 1, 1)
            # Set attributes of the mesh plot.
            MeshAtts = visit.MeshAttributes()
            MeshAtts.legendFlag = 0
            MeshAtts.meshColor = (255, 204, 0, 1.0 * 255)
            MeshAtts.meshColorSource = MeshAtts.MeshCustom
            MeshAtts.pointSize = 0.05
            MeshAtts.pointType = MeshAtts.Point
            MeshAtts.pointSizePixels = 2
            MeshAtts.opacity = 1
            visit.SetPlotOptions(MeshAtts)

    # Open the XMF file for the z-component of the vorticity.
    visit.OpenDatabase(databases[-1], 0)
    # Add the plot of the contour of the z-component of the vorticity.
    visit.AddPlot('Contour', name, 1, 1)
    # Set attributes of the contour.
    ContourAtts = visit.ContourAttributes()
    ContourAtts.contourNLevels = 2
    ContourAtts.SetMultiColor(0, (0, 51, 102, 0.6 * 255))
    ContourAtts.SetMultiColor(1, (255, 0, 0, 0.6 * 255))
    ContourAtts.legendFlag = 1
    ContourAtts.minFlag = 1
    ContourAtts.maxFlag = 1
    ContourAtts.min = value_range[0]
    ContourAtts.max = value_range[1]
    visit.SetPlotOptions(ContourAtts)

    # Parse the 3D view configuration file.
    if config_view is not None:
        View3DAtts = visit_get_view(config_view, '3D')
    visit.SetView3D(View3DAtts)

    # Remove time and user info.
    AnnotationAtts = visit.AnnotationAttributes()
    AnnotationAtts.userInfoFlag = 0
    AnnotationAtts.timeInfoFlag = 0
    AnnotationAtts.axes3D.visible = 0
    AnnotationAtts.axes3D.triadFlag = 1
    AnnotationAtts.axes3D.bboxFlag = 0
    visit.SetAnnotationAttributes(AnnotationAtts)

    visit.SetActiveWindow(1)

    states = visit_get_states(state=state,
                              states=states,
                              states_range=states_range)
    if out_prefix is None:
        out_prefix = name + '_'
    visit_render_save_states(states,
                             out_dir=out_dir,
                             out_prefix=out_prefix,
                             figsize=figsize)

    visit_finalize()
    return