/[escript]/trunk/pyvisi/test/python/run_datacollector.py
ViewVC logotype

Contents of /trunk/pyvisi/test/python/run_datacollector.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1148 - (show annotations)
Wed May 16 22:45:33 2007 UTC (12 years, 6 months ago) by jongui
File MIME type: text/x-python
File size: 5021 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 from esys.pyvisi import DataCollector
2 from esys.pyvisi.constant import *
3 import unittest, os
4
5 try:
6 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
7 except KeyError:
8 PYVISI_WORKDIR='.'
9 try:
10 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
11 except KeyError:
12 PYVISI_TEST_DATA_ROOT='.'
13
14 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
15 FILE_2D = "interior_2D.xml"
16 FILE_3D = "interior_3D.xml"
17
18 SCALAR_FIELD_POINT_DATA = "temperature"
19 VECTOR_FIELD_POINT_DATA = "velocity"
20 TENSOR_FIELD_POINT_DATA = "stress"
21
22 SCALAR_FIELD_CELL_DATA = "temperature_cell"
23 VECTOR_FIELD_CELL_DATA = "velocity_cell"
24 TENSOR_FIELD_CELL_DATA = "stress_cell"
25
26 class TestSourceXml:
27 def tearDown(self):
28 del self.data_collector
29
30 def setFileName(self, file):
31 self.data_collector.setFileName(file_name = \
32 os.path.join(PYVISI_TEST_MESHES_PATH, file))
33
34 def setActiveScalar(self, s):
35 self.data_collector.setActiveScalar(scalar = s)
36
37 def setActiveVector(self, v):
38 self.data_collector.setActiveVector(vector = v)
39
40 def setActiveTensor(self, t):
41 self.data_collector.setActiveTensor(tensor = t)
42
43 def checkScalarFieldPointData(self, f):
44 self.failUnlessEqual(self.data_collector._getDataCollectorOutput().GetPointData().GetScalars().GetName(), f)
45
46 def checkVectorFieldPointData(self, f):
47 self.failUnlessEqual(self.data_collector._getDataCollectorOutput().GetPointData().GetVectors().GetName(), f)
48
49 def checkTensorFieldPointData(self, f):
50 self.failUnlessEqual(self.data_collector._getDataCollectorOutput().GetPointData().GetTensors().GetName(), f)
51
52 def checkScalarFieldCellData(self, f):
53 self.failUnlessEqual(self.data_collector._getDataCollectorOutput().GetCellData().GetScalars().GetName(), f)
54
55 def checkVectorFieldCellData(self, f):
56 self.failUnlessEqual(self.data_collector._getDataCollectorOutput().GetCellData().GetVectors().GetName(), f)
57
58 def checkTensorFieldCellData(self, f):
59 self.failUnlessEqual(self.data_collector._getDataCollectorOutput().GetCellData().GetTensors().GetName(), f)
60
61
62 class TestSourceXml2DPointData(unittest.TestCase, TestSourceXml):
63 def setUp(self):
64 self.data_collector = DataCollector(source = Source.XML)
65 self.setFileName(FILE_2D)
66
67 def testSetActiveScalar(self):
68 self.setActiveScalar(SCALAR_FIELD_POINT_DATA)
69 self.checkScalarFieldPointData(SCALAR_FIELD_POINT_DATA)
70
71 def testSetActiveVector(self):
72 self.setActiveVector(VECTOR_FIELD_POINT_DATA)
73 self.checkVectorFieldPointData(VECTOR_FIELD_POINT_DATA)
74
75 def testSetActiveTensor(self):
76 self.setActiveTensor(TENSOR_FIELD_POINT_DATA)
77 self.checkTensorFieldPointData(TENSOR_FIELD_POINT_DATA)
78
79 class TestSourceXml2DCellData(unittest.TestCase, TestSourceXml):
80 def setUp(self):
81 self.data_collector = DataCollector(source = Source.XML)
82 self.setFileName(FILE_2D)
83
84 def testSetActiveScalar(self):
85 self.setActiveScalar(SCALAR_FIELD_CELL_DATA)
86 self.checkScalarFieldCellData(SCALAR_FIELD_CELL_DATA)
87
88 def testSetActiveVector(self):
89 self.setActiveVector(VECTOR_FIELD_CELL_DATA)
90 self.checkVectorFieldCellData(VECTOR_FIELD_CELL_DATA)
91
92 def testSetActiveTensor(self):
93 self.setActiveTensor(TENSOR_FIELD_CELL_DATA)
94 self.checkTensorFieldCellData(TENSOR_FIELD_CELL_DATA)
95
96 class TestSourceXml3DPointData(unittest.TestCase, TestSourceXml):
97 def setUp(self):
98 self.data_collector = DataCollector(source = Source.XML)
99 self.setFileName(FILE_3D)
100
101 def testSetActiveScalar(self):
102 self.setActiveScalar(SCALAR_FIELD_POINT_DATA)
103 self.checkScalarFieldPointData(SCALAR_FIELD_POINT_DATA)
104
105 def testSetActiveVector(self):
106 self.setActiveVector(VECTOR_FIELD_POINT_DATA)
107 self.checkVectorFieldPointData(VECTOR_FIELD_POINT_DATA)
108
109 def testSetActiveTensor(self):
110 self.setActiveTensor(TENSOR_FIELD_POINT_DATA)
111 self.checkTensorFieldPointData(TENSOR_FIELD_POINT_DATA)
112
113 class TestSourceXml3DCellData(unittest.TestCase, TestSourceXml):
114 def setUp(self):
115 self.data_collector = DataCollector(source = Source.XML)
116 self.setFileName(FILE_3D)
117
118 def testSetActiveScalar(self):
119 self.setActiveScalar(SCALAR_FIELD_CELL_DATA)
120 self.checkScalarFieldCellData(SCALAR_FIELD_CELL_DATA)
121
122 def testSetActiveVector(self):
123 self.setActiveVector(VECTOR_FIELD_CELL_DATA)
124 self.checkVectorFieldCellData(VECTOR_FIELD_CELL_DATA)
125
126 def testSetActiveTensor(self):
127 self.setActiveTensor(TENSOR_FIELD_CELL_DATA)
128 self.checkTensorFieldCellData(TENSOR_FIELD_CELL_DATA)
129
130
131 class TestSourceEscript(unittest.TestCase):
132 def setUp(self):
133 self.data_collector = DataCollector(source = Source.ESCRIPT)
134
135
136 ###############################################################################
137
138
139 if __name__ == '__main__':
140 suite = unittest.TestSuite()
141 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSourceXml2DPointData))
142 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSourceXml2DCellData))
143 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSourceXml3DPointData))
144 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSourceXml3DCellData))
145 unittest.TextTestRunner(verbosity=2).run(suite)
146

  ViewVC Help
Powered by ViewVC 1.1.26