Exemple #1
0
 def isosurfacePlot(self, stay=False, samples=100, contours=50):
     visit.AddWindow()
     returned = []
     if len(visit.ListPlots()) > 0:
         visit.SetActivePlots(0)
         visit.HideActivePlots()
     p = visit.PseudocolorAttributes()
     q = visit.ResampleAttributes()
     r = visit.IsosurfaceAttributes()
     q.samplesX = samples
     q.samplesY = samples
     q.samplesZ = samples
     r.contourNLevels = contours
     plot = visit.AddPlot("Pseudocolor", "Heat")
     visit.AddOperator("Resample")
     # visit.AddOperator("Isosurface")
     visit.SetOperatorOptions(q)
     visit.SetOperatorOptions(r)
     visit.SetPlotOptions(p)
     visit.DrawPlots()
     returned.append(visit.SaveWindow())
     count = 0
     visit.AddOperator("Isosurface")
     visit.DrawPlots()
     time.sleep(60)
     returned.append(visit.SaveWindow())
     return returned
Exemple #2
0
 def pseudocolorPlot(self):
     visit.AddWindow()
     returned = []
     if len(visit.ListPlots()) > 0:
         visit.SetActivePlots(0)
         visit.HideActivePlots()
     p = visit.PseudocolorAttributes()
     plot = visit.AddPlot("Pseudocolor", "Heat")
     visit.SetPlotOptions(p)
     visit.DrawPlots()
     return visit.SaveWindow()
Exemple #3
0
 def scatterPlot(self,
                 coords=["var00", "var01", "var02", "var03"],
                 colorTable="hot",
                 pixelSize=5,
                 stay=False):
     visit.AddWindow()
     if len(visit.ListPlots()) > 0:
         visit.SetActivePlots(0)
         visit.HideActivePlots()
     plot = visit.AddPlot("Scatter", coords[0])
     p = visit.ScatterAttributes()
     # Variables
     if coords[1]:
         p.var2 = coords[1]
     if coords[2]:
         p.var3 = coords[2]
     if coords[3]:
         p.var4 = coords[3]
     #Role Variable Roles take intergers as inputs, not strings
     p.var1Role = 0
     p.var2Role = 1
     p.var3Role = 2
     p.var4Role = 3
     p.scaleCube = 0
     #p.colorType = "ColorByColorTable"
     p.pointSizePixels = pixelSize
     p.colorTableName = colorTable
     #p.colorScaling = "Log"
     v = visit.GetView3D()
     v.viewNormal = (-0.571619, 0.405393, 0.713378)
     v.viewUp = (0.308049, 0.911853, -0.271346)
     visit.SetPlotOptions(p)
     visit.SetView3D(v)
     visit.DrawPlots()
     count = 0
     time.sleep(5)
     return visit.SaveWindow()
Exemple #4
0
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from MeshClass import *
from DataClass import *
from CaseClass import *

Loc = "OpenFoamCases/"

Files = ['elbow/', 'Coutte_Flow_40x40-FixedTemperature/', 'forwardStep/']

Loc = Loc + Files[0]

# Reading Mesh Data and Evaluating the initail points

case = Case()
case.loadOpenFoamFile(Loc)
case.print_output_vtk()

# visit
sys.path.append("/home/neo/visit/2.11.0/linux-x86_64/lib/site-packages")
import visit as vs
vs.Launch()
vs.OpenDatabase("Results/results-time-1.vtk")
vs.AddPlot("Pseudocolor", 'X-Velocity')
vs.AddPlot("Pseudocolor", "Pressure")
vs.SetActivePlots(0)
vs.HideActivePlots()
vs.DrawPlots()

d = input('Press anything to quit')
Exemple #5
0
def visit_config(geometry_file, data_file, args):
    """
    Convert geometry file to stl, convert data file to vtk, load each file
    into VisIt, and create and load a session file containing four plot windows.
        1) A cube with a slice through an octant.
        2) XY plane slice through the centroid.
        3) XZ plane slice through the centroid.
        4) YZ plane slice through the centroid.
    Each window has a mesh plot with the "STL_mesh" variable, a Pseudocolor plot
    with the "TALLY_TAG" variable, and the second, third, and fourth windows have
    Contour plots with the "ERROR_TAG" variable. If the user has indicated to,
    launch VisIt and load the session file.

    Input:
    ______
       geometry_file: h5m file
           User supplied geometry file.
       data_file: h5m or vtk file
           User supplied data file.
       args: Namespace
           User supplied geometry file location, data file location, and
           indication if the user wants images of the plot windows with a
           timestamp and the session file saved and opened in VisIt.

    Returns:
    ________
       None
    """

    # Create a list of dictionaries indicating the data, plot, and variable in VisIt.
    Files = [{
        "file_name": data_file,
        "plot_type": "Pseudocolor",
        "data_tag": "TALLY_TAG"
    }, {
        "file_name": data_file,
        "plot_type": "Contour",
        "data_tag": "ERROR_TAG"
    }, {
        "file_name": geometry_file,
        "plot_type": "Mesh",
        "data_tag": "STL_mesh"
    }]

    # Launch VisIt and add appropriate plots.
    Vi.LaunchNowin()
    for file in Files:
        Vi.OpenDatabase(file["file_name"])
        Vi.AddPlot(file["plot_type"], file["data_tag"])

    # Hide the contour plot in the first plot window.
    Vi.SetActivePlots(1)
    Vi.HideActivePlots()

    # Create the plot of the cube by activating the mesh and pseudocolor plots.
    Vi.SetActivePlots((0, 2))

    # Set the view normal to the first octant.
    v = Vi.GetView3D()
    v.viewNormal = (1, 1, 1)
    Vi.SetView3D(v)

    # Apply a clip through the first octant.
    Vi.AddOperator("Clip")
    c = Vi.ClipAttributes()
    c.plane1Origin = (40, 40, 40)
    c.plane1Normal = (1, 1, 1)
    Vi.SetOperatorOptions(c)

    # Include the CNERG logo in the bottom left corner of the plot.
    image = Vi.CreateAnnotationObject("Image")
    image.image = os.path.dirname(os.path.abspath(__file__)) + "/cnerg.jpg"
    image.position = (0.02, 0.02)
    image.width = 10
    image.height = 10

    Vi.DrawPlots()
    if args.images:
        if args.timestamp:
            attributes = Vi.GetAnnotationAttributes()
            attributes.userInfoFlag = 0
            Vi.SetAnnotationAttributes(attributes)
        Vi.SaveWindow()

    # Create the second plot of the XY plane slice.
    plane_slice_plotting(2, 2, "XY Plane", args.images, args.timestamp)

    # Create the third plot of the XZ plane slice.
    plane_slice_plotting(3, 1, "XZ Plane", args.images, args.timestamp)

    # Create the fourth plot of the YZ plane slice.
    plane_slice_plotting(4, 0, "ZY Plane", args.images, args.timestamp)

    # Display the four windows in a 2x2 grid.
    Vi.SetWindowLayout(4)

    # Save the session file with the default VisIt output to the current directory.
    visit_output = "VisitDefaultOutput.session"
    Vi.SaveSession(visit_output)
    Vi.Close()

    # Retrieve the path to the VisIt session file.
    session_file_path = os.path.join(os.getcwd(), visit_output)

    # If the user has indicated to, open the session file with the VisIt GUI.
    if args.openvisit:
        os.system("visit -sessionfile {} &".format(session_file_path))

    # If the user has indicated to, remove the session file after VisIt has opened.
    if not args.sessionfile:
        os.system("sleep 10; rm {}".format(session_file_path))