/[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 1138 - (show annotations)
Mon May 14 04:15:04 2007 UTC (13 years, 6 months ago) by gross
File MIME type: text/x-python
File size: 4706 byte(s)
 * some of the sys.exit calls removed.
 * some modifications on the test (and more work needs to be done, use test/python/run_carpet.py as an example) to get them going with scons 

-> things seems to run on windows XP.
1 from esys.pyvisi import DataCollector
2 from esys.pyvisi.constant import *
3 import unittest
4
5 PYVISI_TEST_MESHES_PATH = "data_meshes"
6 FILE_2D = "interior_2D.xml"
7 FILE_3D = "interior_3D.xml"
8
9 SCALAR_FIELD_POINT_DATA = "temperature"
10 VECTOR_FIELD_POINT_DATA = "velocity"
11 TENSOR_FIELD_POINT_DATA = "stress"
12
13 SCALAR_FIELD_CELL_DATA = "temperature_cell"
14 VECTOR_FIELD_CELL_DATA = "velocity_cell"
15 TENSOR_FIELD_CELL_DATA = "stress_cell"
16
17 class TestSourceXml:
18 def tearDown(self):
19 del self.data_collector
20
21 def setFileName(self, file):
22 self.data_collector.setFileName(file_name = \
23 os.path.join(PYVISI_TEST_MESHES_PATH, file))
24
25 def setActiveScalar(self, s):
26 self.data_collector.setActiveScalar(scalar = s)
27
28 def setActiveVector(self, v):
29 self.data_collector.setActiveVector(vector = v)
30
31 def setActiveTensor(self, t):
32 self.data_collector.setActiveTensor(tensor = t)
33
34 def checkScalarFieldPointData(self, f):
35 self.failUnlessEqual(self.data_collector._getOutput().GetPointData().GetScalars().GetName(), f)
36
37 def checkVectorFieldPointData(self, f):
38 self.failUnlessEqual(self.data_collector._getOutput().GetPointData().GetVectors().GetName(), f)
39
40 def checkTensorFieldPointData(self, f):
41 self.failUnlessEqual(self.data_collector._getOutput().GetPointData().GetTensors().GetName(), f)
42
43 def checkScalarFieldCellData(self, f):
44 self.failUnlessEqual(self.data_collector._getOutput().GetCellData().GetScalars().GetName(), f)
45
46 def checkVectorFieldCellData(self, f):
47 self.failUnlessEqual(self.data_collector._getOutput().GetCellData().GetVectors().GetName(), f)
48
49 def checkTensorFieldCellData(self, f):
50 self.failUnlessEqual(self.data_collector._getOutput().GetCellData().GetTensors().GetName(), f)
51
52
53 class TestSourceXml2DPointData(unittest.TestCase, TestSourceXml):
54 def setUp(self):
55 self.data_collector = DataCollector(source = Source.XML)
56 self.setFileName(FILE_2D)
57
58 def testSetActiveScalar(self):
59 self.setActiveScalar(SCALAR_FIELD_POINT_DATA)
60 self.checkScalarFieldPointData(SCALAR_FIELD_POINT_DATA)
61
62 def testSetActiveVector(self):
63 self.setActiveVector(VECTOR_FIELD_POINT_DATA)
64 self.checkVectorFieldPointData(VECTOR_FIELD_POINT_DATA)
65
66 def testSetActiveTensor(self):
67 self.setActiveTensor(TENSOR_FIELD_POINT_DATA)
68 self.checkTensorFieldPointData(TENSOR_FIELD_POINT_DATA)
69
70 class TestSourceXml2DCellData(unittest.TestCase, TestSourceXml):
71 def setUp(self):
72 self.data_collector = DataCollector(source = Source.XML)
73 self.setFileName(FILE_2D)
74
75 def testSetActiveScalar(self):
76 self.setActiveScalar(SCALAR_FIELD_CELL_DATA)
77 self.checkScalarFieldCellData(SCALAR_FIELD_CELL_DATA)
78
79 def testSetActiveVector(self):
80 self.setActiveVector(VECTOR_FIELD_CELL_DATA)
81 self.checkVectorFieldCellData(VECTOR_FIELD_CELL_DATA)
82
83 def testSetActiveTensor(self):
84 self.setActiveTensor(TENSOR_FIELD_CELL_DATA)
85 self.checkTensorFieldCellData(TENSOR_FIELD_CELL_DATA)
86
87 class TestSourceXml3DPointData(unittest.TestCase, TestSourceXml):
88 def setUp(self):
89 self.data_collector = DataCollector(source = Source.XML)
90 self.setFileName(FILE_3D)
91
92 def testSetActiveScalar(self):
93 self.setActiveScalar(SCALAR_FIELD_POINT_DATA)
94 self.checkScalarFieldPointData(SCALAR_FIELD_POINT_DATA)
95
96 def testSetActiveVector(self):
97 self.setActiveVector(VECTOR_FIELD_POINT_DATA)
98 self.checkVectorFieldPointData(VECTOR_FIELD_POINT_DATA)
99
100 def testSetActiveTensor(self):
101 self.setActiveTensor(TENSOR_FIELD_POINT_DATA)
102 self.checkTensorFieldPointData(TENSOR_FIELD_POINT_DATA)
103
104 class TestSourceXml3DCellData(unittest.TestCase, TestSourceXml):
105 def setUp(self):
106 self.data_collector = DataCollector(source = Source.XML)
107 self.setFileName(FILE_3D)
108
109 def testSetActiveScalar(self):
110 self.setActiveScalar(SCALAR_FIELD_CELL_DATA)
111 self.checkScalarFieldCellData(SCALAR_FIELD_CELL_DATA)
112
113 def testSetActiveVector(self):
114 self.setActiveVector(VECTOR_FIELD_CELL_DATA)
115 self.checkVectorFieldCellData(VECTOR_FIELD_CELL_DATA)
116
117 def testSetActiveTensor(self):
118 self.setActiveTensor(TENSOR_FIELD_CELL_DATA)
119 self.checkTensorFieldCellData(TENSOR_FIELD_CELL_DATA)
120
121
122 class TestSourceEscript(unittest.TestCase):
123 def setUp(self):
124 self.data_collector = DataCollector(source = Source.ESCRIPT)
125
126
127 ###############################################################################
128
129
130 if __name__ == '__main__':
131 suite = unittest.TestSuite()
132 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSourceXml2DPointData))
133 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSourceXml2DCellData))
134 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSourceXml3DPointData))
135 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSourceXml3DCellData))
136 unittest.TextTestRunner(verbosity=2).run(suite)
137

  ViewVC Help
Powered by ViewVC 1.1.26