MCPcopy Create free account
hub / github.com/Kitware/VTK / SimpleTimeReader

Class SimpleTimeReader

Filters/Parallel/Testing/Python/TestResamplingInterpolator.py:23–85  ·  view source on GitHub ↗

A reader that exposes two exodus files as a time series

Source from the content-addressed store, hash-verified

21VTK_DATA_ROOT = vtkGetDataRoot()
22
23class SimpleTimeReader(VTKPythonAlgorithmBase):
24 """A reader that exposes two exodus files as a time series"""
25 def __init__(self):
26 VTKPythonAlgorithmBase.__init__(self, nInputPorts=0, nOutputPorts=1, outputType='vtkMultiBlockDataSet')
27
28 r1 = vtkExodusIIReader()
29 r1.SetFileName(VTK_DATA_ROOT + "/Data/simpleamrgrid.e-s000")
30 r1.SetElementBlockArrayStatus("Unnamed block ID: 12", 1)
31 r1.SetElementResultArrayStatus("cell_dist", 1)
32 r1.SetElementResultArrayStatus("cell_poly", 1)
33 r1.SetPointResultArrayStatus("point_dist", 1)
34 r1.SetPointResultArrayStatus("point_poly", 1)
35 r1.Update()
36
37 r2 = vtkExodusIIReader()
38 r2.SetFileName(VTK_DATA_ROOT + "/Data/simpleamrgrid.e-s001")
39 r2.SetElementBlockArrayStatus("Unnamed block ID: 12", 1)
40 r2.SetElementResultArrayStatus("cell_dist", 1)
41 r2.SetElementResultArrayStatus("cell_poly", 1)
42 r2.SetPointResultArrayStatus("point_dist", 1)
43 r2.SetPointResultArrayStatus("point_poly", 1)
44 r2.Update()
45
46 self._dataobjects = [r1.GetOutputDataObject(0), r2.GetOutputDataObject(0)]
47
48 def _get_timesteps(self):
49 return [0, 1]
50
51 def _get_update_time(self, outInfo):
52 executive = self.GetExecutive()
53 if outInfo.Has(executive.UPDATE_TIME_STEP()):
54 utime = outInfo.Get(executive.UPDATE_TIME_STEP())
55 if utime < 0.5:
56 return 0
57 else:
58 return 1
59 else:
60 return 0
61
62 def RequestInformation(self, request, inInfoVec, outInfoVec):
63 executive = self.GetExecutive()
64 outInfo = outInfoVec.GetInformationObject(0)
65 outInfo.Remove(executive.TIME_STEPS())
66 outInfo.Remove(executive.TIME_RANGE())
67
68 timesteps = self._get_timesteps()
69 if timesteps is not None:
70 for t in timesteps:
71 outInfo.Append(executive.TIME_STEPS(), t)
72 outInfo.Append(executive.TIME_RANGE(), timesteps[0])
73 outInfo.Append(executive.TIME_RANGE(), timesteps[-1])
74 return 1
75
76 def RequestData(self, request, inInfoVec, outInfoVec):
77 data_time = self._get_update_time(outInfoVec.GetInformationObject(0))
78
79 output = vtkMultiBlockDataSet.GetData(outInfoVec, 0)
80

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected