-
Notifications
You must be signed in to change notification settings - Fork 43
/
vis.py
executable file
·141 lines (123 loc) · 4.78 KB
/
vis.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env pvbatch
# state file generated using paraview version 5.8.0
from paraview.simple import *
paraview.simple._DisableFirstRenderCameraReset()
import argparse
import numpy as np
import paratools
parser = argparse.ArgumentParser(
description="Renders vorticity magnitude with LAMMPS polymers")
parser.add_argument('--lammps', nargs='+', help="List of data files 'a_*.vtk'")
parser.add_argument('--aphros',
nargs='+',
help="List of data files 'omm_*.xmf'")
parser.add_argument('--force',
action="store_true",
help="Overwrite existing files")
parser.add_argument('--draft',
action="store_true",
help="Fewer samples and lower resolution")
parser.add_argument('--res',
type=list,
default=[1080, 1080],
help="Image resolution in pixels")
parser.add_argument('--samples',
type=int,
default=10,
help="Number of samples per pixel")
parser.add_argument('--colormap', type=str, default="blue_yellow_red")
args = parser.parse_args()
sources_ft = []
timearrays = []
files_omm = args.aphros
source_omm = XDMFReader(FileNames=files_omm)
source_omm.CellArrayStatus = ['omm']
source_omm.GridStatus = ['Grid_10220']
(source_omm, ), (timearray, ) = paratools.ApplyForceTime([source_omm])
sources_ft.append(source_omm)
timearrays.append(timearray)
files_polymer = args.lammps
source_polymer = LegacyVTKReader(FileNames=files_polymer)
(source_polymer, ), (timearray, ) = paratools.ApplyForceTime([source_polymer])
sources_ft.append(source_polymer)
timearrays.append(timearray)
viewsize = args.res
if args.draft:
viewsize = [max(1, s // 2) for s in viewsize]
args.samples = min(10, args.samples // 5)
renderView1 = CreateView('RenderView')
renderView1.AxesGrid = 'GridAxes3DActor'
renderView1.OrientationAxesVisibility = 0
renderView1.KeyLightWarmth = 0.5
renderView1.FillLightWarmth = 0.5
renderView1.CameraPosition = [
3.2933362831074464, 2.111426020928463, 1.6757588679166233
]
renderView1.CameraFocalPoint = [
0.502268266864121, 0.5000021504238248, 0.5027382206171751
]
renderView1.CameraViewUp = [
-0.296198132726024, -0.17101007166283444, 0.9396926207859084
]
renderView1.CameraParallelScale = 0.709257758997805
renderView1.CameraParallelProjection = 1
renderView1.ViewSize = viewsize
renderView1.EnableRayTracing = 1
renderView1.BackEnd = 'OSPRay raycaster'
renderView1.Background = [1] * 3
renderView1.SamplesPerPixel = 1 if args.draft else args.samples
tube1 = Tube(registrationName='Tube1', Input=source_polymer)
tube1.Scalars = ['POINTS', '']
tube1.Vectors = ['POINTS', '1']
tube1.Radius = 0.005
glyph1 = Glyph(registrationName='Glyph1',
Input=source_polymer,
GlyphType='Sphere')
glyph1.OrientationArray = ['POINTS', 'No orientation array']
glyph1.ScaleArray = ['POINTS', 'No scale array']
glyph1.GlyphMode = 'All Points'
glyph1.GlyphType.Radius = 0.1
glyph1.ScaleFactor = 0.09989973691408523
tube1Display = Show(tube1, renderView1, 'GeometryRepresentation')
tube1Display.Representation = 'Surface'
tube1Display.AmbientColor = [0.0, 0.0, 0.0]
tube1Display.ColorArrayName = [None, '']
tube1Display.DiffuseColor = [0.0, 0.0, 0.0]
tube1Display.Opacity = 0.5
tube1Display.Ambient = 0.25
glyph1Display = Show(glyph1, renderView1, 'GeometryRepresentation')
glyph1Display.Representation = 'Surface'
glyph1Display.ColorArrayName = [None, '']
ommDisplay = Show(source_omm, renderView1, 'UniformGridRepresentation')
ommLUT = GetColorTransferFunction('omm')
ommLUT.AutomaticRescaleRangeMode = 'Never'
ommLUT.RGBPoints = [
3.0, 0.0, 1.0, 1.0, 7.05, 0.0, 0.0, 1.0, 7.5, 0.0, 0.0, 0.501960784314,
7.95, 1.0, 0.0, 0.0, 12.0, 1.0, 1.0, 0.0
]
ommLUT.ColorSpace = 'RGB'
ommLUT.ScalarRangeInitialized = 1.0
ommPWF = GetOpacityTransferFunction('omm')
ommPWF.Points = [3.0, 0.0, 0.5, 0.0, 12.0, 1.0, 0.5, 0.0]
ommPWF.ScalarRangeInitialized = 1
ommDisplay.Representation = 'Volume'
ommDisplay.ColorArrayName = ['CELLS', 'omm']
ommDisplay.LookupTable = ommLUT
ommDisplay.SetScaleArray = [None, '']
ommDisplay.ScaleTransferFunction = 'PiecewiseFunction'
ommDisplay.OpacityArray = [None, '']
ommDisplay.OpacityTransferFunction = 'PiecewiseFunction'
ommDisplay.ScalarOpacityUnitDistance = 0.1
ommDisplay.ScalarOpacityFunction = ommPWF
ommDisplay.OpacityArrayName = ['CELLS', 'omm']
ommDisplay.Shade = 1
# FIXME: workaround, otherwise `omm` not shown in the first image
paratools.SetTimeStep(1, sources_ft, timearrays)
pattern = "a_{}.png"
steps = paratools.GetSteps(args.aphros)
paratools.SaveAnimation(steps,
renderView1,
sources_ft,
timearrays,
force=args.force,
pattern=pattern)