forked from LLNL/LULESH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script-with-p-color.py
48 lines (37 loc) · 1.35 KB
/
script-with-p-color.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from paraview.simple import *
import os, os.path
def setup_pipeline(source, view):
"sets up a simple visualization pipeline"
# data is valid at this point so we can use data to setup pipeline
display = Show(source, view)
# change representation type
display.SetRepresentationType('Surface With Edges')
# color by pressure
ColorBy(display, ["CELLS", "p"])
def update_pipeline(source, view):
"update pipeline"
display = GetDisplayProperties(source, view)
# reset transfer function to fit current range
display.RescaleTransferFunctionToDataRange(False, True)
view.CameraPosition = [0, 0, 0]
view.CameraViewUp = [-0.5, -0.5, 0.5]
view.CameraFocalPoint = [0.5, 0.5, 0.5]
view.ResetCamera(False)
source = TrivialProducer(guiName="grid")
view = CreateRenderView()
setup_pipeline(source, view)
def _get_path():
return os.path.join(os.getcwd(), "results")
def catalyst_initialize():
# create output directory to write results
path = _get_path()
os.makedirs(path)
print("saving results in '%s'" % path)
def catalyst_execute(params):
source.UpdatePipeline(params.timestep)
update_pipeline(source, view)
Render(view)
# generate results
path = _get_path()
WriteImage(os.path.join(path,"image-%d.png" % params.cycle))
# SaveData(os.path.join(path, "data-%d.vtpd" % params.cycle))