/[escript]/trunk/finley/test/python/run_escriptOnFinley.py
ViewVC logotype

Annotation of /trunk/finley/test/python/run_escriptOnFinley.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4963 - (hide annotations)
Fri May 23 05:12:40 2014 UTC (7 years, 2 months ago) by jfenwick
File MIME type: text/x-python
File size: 20130 byte(s)
Removed JMPI from ScriptMPI.cpp.
Changed options file to build shared libraries.
Fixed error in unit tests


1 ksteube 1809
2 jfenwick 3981 ##############################################################################
3 ksteube 1312 #
4 jfenwick 4657 # Copyright (c) 2003-2014 by University of Queensland
5 jfenwick 3981 # http://www.uq.edu.au
6 ksteube 1312 #
7 ksteube 1809 # Primary Business: Queensland, Australia
8     # Licensed under the Open Software License version 3.0
9     # http://www.opensource.org/licenses/osl-3.0.php
10 ksteube 1312 #
11 jfenwick 3981 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 # Development 2012-2013 by School of Earth Sciences
13     # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 #
15     ##############################################################################
16 gross 983
17 jfenwick 4657 __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18 jfenwick 3981 http://www.uq.edu.au
19 ksteube 1809 Primary Business: Queensland, Australia"""
20 gross 983 __license__="""Licensed under the Open Software License version 3.0
21 ksteube 1809 http://www.opensource.org/licenses/osl-3.0.php"""
22 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
23 ksteube 1809
24 caltinay 3993 import os
25     import sys
26 jfenwick 4938 import esys.escriptcore.utestselect as unittest
27 gross 983
28     from esys.escript import *
29 jfenwick 4962 from esys.finley import Rectangle, Brick, ReadMesh, ReadGmsh
30 caltinay 3993 from test_objects import Test_Dump, Test_SetDataPointValue, Test_saveCSV, \
31     Test_TableInterpolation, Test_Domain, Test_GlobalMinMax, Test_Lazy
32 jfenwick 2271 from test_shared import Test_Shared
33    
34 gross 983 try:
35     FINLEY_WORKDIR=os.environ['FINLEY_WORKDIR']
36     except KeyError:
37     FINLEY_WORKDIR='.'
38 jfenwick 4962
39    
40     try:
41     FINLEY_TEST_DATA=os.environ['FINLEY_TEST_DATA']
42     except KeyError:
43     FINLEY_TEST_DATA='.'
44 gross 983
45 jfenwick 4962 FINLEY_TEST_MESH_PATH=os.path.join(FINLEY_TEST_DATA,"data_meshes")
46    
47 caltinay 4437 mpisize=getMPISizeWorld()
48 gross 983 NE=4 # number elements, must be even
49 jfenwick 2271
50     class Test_SharedOnFinley(Test_Shared):
51     def setUp(self):
52 jfenwick 3892 self.domain=Rectangle(NE,NE)
53     self.tol=0.001
54 jfenwick 4687
55 jfenwick 2271 def tearDown(self):
56 jfenwick 3892 del self.domain
57     del self.tol
58 jfenwick 2271
59 gross 1044 class Test_DomainOnFinley(Test_Domain):
60     def setUp(self):
61 gross 2425 self.boundary_tag_list = [1, 2, 10, 20]
62 gross 1044 self.domain =Rectangle(NE,NE+1,2)
63 jfenwick 4687 self.rdomain=self.domain
64    
65 gross 1044 def tearDown(self):
66     del self.domain
67 jfenwick 4687 del self.rdomain
68 caltinay 3993 del self.boundary_tag_list
69    
70 jfenwick 3914 def test_setXError(self):
71     domain=Rectangle(NE,NE)
72 caltinay 3993 x=domain.getX()
73 jfenwick 3914 z=interpolate(x, Function(domain))
74     self.assertRaises(RuntimeError, domain.setX, z)
75     del x
76     del z
77     del domain
78 gross 1716
79     def test_tagsContinuousFunction(self):
80     ref_tags=[0]
81     tags=ContinuousFunction(self.domain).getListOfTags()
82 jfenwick 3551 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
83     for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
84 gross 1716
85     def test_tagsFunction(self):
86     ref_tags=[0]
87     tags=Function(self.domain).getListOfTags()
88 jfenwick 3551 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
89     for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
90 gross 1716 def test_tagsReducedFunction(self):
91     ref_tags=[0]
92     tags=ReducedFunction(self.domain).getListOfTags()
93 jfenwick 3551 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
94     for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
95 gross 1716 def test_tagsFunctionOnBoundary(self):
96 ksteube 1829 ref_tags=[1, 2, 10, 20]
97     tags=FunctionOnBoundary(self.domain).getListOfTags()
98     # For an MPI-distributed domain some tags may be missing
99 jfenwick 3551 if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
100     for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
101 gross 1716 def test_tagsReducedFunctionOnBoundary(self):
102 ksteube 1829 ref_tags=[1, 2, 10, 20]
103     tags=ReducedFunctionOnBoundary(self.domain).getListOfTags()
104     # For an MPI-distributed domain some tags may be missing
105 jfenwick 3551 if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
106     for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
107 gross 1716 def test_tagsFunctionOnContactOne(self):
108     ref_tags=[]
109     tags=FunctionOnContactOne(self.domain).getListOfTags()
110 jfenwick 3551 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
111     for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
112 gross 1716 def test_tagsFunctionOnContactZero(self):
113     ref_tags=[]
114     tags=FunctionOnContactZero(self.domain).getListOfTags()
115 jfenwick 3551 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
116     for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
117 gross 1716 def test_tagsReducedFunctionOnContactOne(self):
118     ref_tags=[]
119     tags=ReducedFunctionOnContactOne(self.domain).getListOfTags()
120 jfenwick 3551 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
121     for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
122 gross 1716 def test_tagsReducedFunctionOnContactZero(self):
123     ref_tags=[]
124     tags=ReducedFunctionOnContactZero(self.domain).getListOfTags()
125 jfenwick 3551 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
126     for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
127 gross 1716
128 jfenwick 2799 class Test_DataOpsOnFinley(Test_Dump, Test_SetDataPointValue, Test_GlobalMinMax, Test_Lazy):
129 gross 983 def setUp(self):
130     self.domain =Rectangle(NE,NE+1,2)
131     self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1,2)
132     self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,2,integrationOrder=2)
133 gross 1856 self.domain_with_different_sample_ordering =Rectangle(NE,NE+1,2, optimize=True)
134 gross 1141 self.filename_base=FINLEY_WORKDIR
135 jfenwick 2799 self.mainfs=Function(self.domain)
136     self.otherfs=Solution(self.domain)
137 gross 983
138     def tearDown(self):
139     del self.domain
140     del self.domain_with_different_number_of_samples
141     del self.domain_with_different_number_of_data_points_per_sample
142     del self.domain_with_different_sample_ordering
143 jfenwick 2799 del self.mainfs
144     del self.otherfs
145 gross 983
146 jfenwick 2628
147 jfenwick 2646 class Test_TableInterpolationOnFinley(Test_TableInterpolation):
148     def setUp(self):
149 jfenwick 3892 self.domain=Brick(4,4,4)
150     self.functionspaces=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
151 caltinay 3993 FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),
152 jfenwick 3892 FunctionOnContactZero(self.domain), FunctionOnContactOne(self.domain),
153     ReducedFunctionOnContactZero(self.domain), ReducedFunctionOnContactOne(self.domain)]
154     #We aren't testing DiracDeltaFunctions
155     self.xn=3 # number of grids on x axis
156     self.yn=3 # number of grids on y axis
157     self.zn=3 # number of grids on z axis
158 jfenwick 2628
159 jfenwick 2646 def tearDown(self):
160 jfenwick 3892 del self.domain
161     del self.functionspaces
162 jfenwick 2646
163 caltinay 3993
164 jfenwick 4085 #This functionality is only testes on Finley.
165     #It is not finley specific but it does need a known set of input points so I've chosen to put it here
166     class Test_OtherInterpolationOnFinley(unittest.TestCase):
167     def setUp(self):
168     self.r=Rectangle(4,1).getX()[0]+2
169     self.z=Data(2)
170    
171     def tearDown(self):
172     del self.z
173     del self.r
174    
175     def test_nonuniformint(self):
176     self.assertRaises(RuntimeError, self.z.nonuniformInterpolate, [0,1], [5,6], True)
177     self.assertRaises(RuntimeError, self.z.nonuniformInterpolate, [3,4], [5,6], True)
178     self.assertTrue(Lsup(self.z.nonuniformInterpolate([0,1], [5,6], False)-6)<0.00001, "RHS edge not fitted")
179     self.assertTrue(Lsup(self.z.nonuniformInterpolate([3,4], [5,6], False)-5)<0.00001, "LHS edge not fitted")
180     tmp=self.r.nonuniformInterpolate([2.125, 2.4, 2.5, 2.8], [1, -1, 2, 4], False)
181     self.assertTrue(Lsup(sup(tmp)-4)<0.0001, "RHS edge not fitted for Rect")
182     self.assertTrue(Lsup(inf(tmp)-0.090909)<0.00001, "Internal interpolate failed")
183     tmp=self.r.nonuniformInterpolate([2.125, 2.4, 2.5, 3.2], [1, -1, 2, 4], False)
184     self.assertTrue(Lsup(sup(tmp)-3.42857)<0.00001, "Internal interpolate failed")
185    
186     def test_nonuniformSlope(self):
187     self.assertRaises(RuntimeError, self.z.nonuniformSlope, [0,1], [5,6], True)
188     self.assertRaises(RuntimeError, self.z.nonuniformSlope, [3,4], [5,6], True)
189     self.assertTrue(Lsup(self.z.nonuniformSlope([0,1], [5,6], False))<0.00001, "RHS edge not fitted")
190     self.assertTrue(Lsup(self.z.nonuniformSlope([3,4], [5,6], False))<0.00001, "LHS edge not fitted")
191     tmp=self.r.nonuniformSlope([2.125, 2.4, 2.5, 3.2], [1, -1, 2, 4], False)
192     self.assertTrue(Lsup(sup(tmp)-30)<0.00001, "Internal interpolate failed")
193     self.assertTrue(Lsup(inf(tmp)+7.27273)<0.00001, "Internal interpolate failed")
194    
195 jfenwick 2644 class Test_CSVOnFinley(Test_saveCSV):
196 caltinay 3993 def setUp(self):
197     NE0=NE
198     NE1=NE+1
199 caltinay 3996 self.domain = Rectangle(NE0, NE1, order=2)
200     self.functionspaces = [ ContinuousFunction ]
201 caltinay 3993 # number of total data points for each function space
202 caltinay 3996 self.linecounts=[ (2*NE0+1)*(2*NE1+1)-NE0*NE1+1 ]
203 caltinay 3993 # number of masked points, i.e. where X[0] is non-zero
204 caltinay 3996 self.linecounts_masked=[ (2*NE0+1)*(2*NE1+1)-(2+NE0)*NE1 ]
205 caltinay 3993 # expected values in first line of masked data = [ X[:], X[0] ]
206 caltinay 3996 self.firstline=[ [1./(2*NE0), 0., 1./(2*NE0)] ]
207 jfenwick 2644
208 caltinay 3996 if getMPISizeWorld() == 1:
209     self.functionspaces += [ ReducedContinuousFunction, Function,
210     ReducedFunction, FunctionOnBoundary, ReducedFunctionOnBoundary ]
211     self.linecounts += [ 31, 181, 81, 55, 37 ]
212     self.linecounts_masked += [ 25, 181, 81, 40, 27 ]
213     self.firstline += [ [.25, 0., .25],
214     [.02817541634481463,.02254033307585171,.02817541634481463],
215     [.05283121635129676,.04226497308103741,.05283121635129676],
216     [.02817541634481463,0.,.02817541634481463],
217     [.05283121635129676,0.,.05283121635129676]
218     ]
219     else:
220     print("Skipping some CSV tests on finley since MPI size > 1")
221    
222 caltinay 3993 def tearDown(self):
223     del self.domain
224 jfenwick 2644
225 caltinay 4437 @unittest.skipIf(mpisize>1, "more than 1 MPI rank")
226 caltinay 3993 def test_csv_multiFS(self):
227 caltinay 4437 fname=os.path.join(FINLEY_WORKDIR, "test_multifs.csv")
228     sol=Data(8,Solution(self.domain))
229     ctsfn=Data(9,ContinuousFunction(self.domain))
230     #test line 0
231     dirac=Data(-1,DiracDeltaFunctions(self.domain))
232     saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)
233     #test line 1
234     fun=Data(5,Function(self.domain))
235     rfun=Data(3,ReducedFunction(self.domain))
236     saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)
237     #test line 2
238     bound=Data(1,FunctionOnBoundary(self.domain))
239     rbound=Data(3,ReducedFunctionOnBoundary(self.domain))
240     saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)
241     #test line 3
242     conzz=Data(7,FunctionOnContactZero(self.domain))
243     rconz=Data(8,ReducedFunctionOnContactZero(self.domain))
244     saveDataCSV(fname,A=sol,B=ctsfn, C=conzz, D=rconz)
245     #check for cross line exceptions
246     self.assertRaises(RuntimeError, saveDataCSV, fname, A=dirac, B=rfun)
247     self.assertRaises(RuntimeError, saveDataCSV, fname, A=bound, B=conzz)
248 caltinay 3993
249 jfenwick 4962
250     class Test_DiracOnFinley(unittest.TestCase):
251     def test_rectconstr(self):
252     self.assertRaises(RuntimeError, Rectangle, 4,4, diracPoints=[(0,0)])
253     self.assertRaises(RuntimeError, Rectangle, 4,4, diracPoints=[(0,0), (1,1)], diracTags=[40])
254     self.assertRaises(RuntimeError, Rectangle, 4,4, diracPoints=[(0,0), (1,1)], diracTags=[40])
255     self.assertRaises(RuntimeError, Rectangle, 4,4, diracPoints=[(0,0), (1,1)], diracTags=["cows"])
256     self.assertRaises(RuntimeError, Rectangle, 4,4, diracPoints=[(0,)], diracTags=["test"])
257     z=Rectangle(4,4, diracPoints=[(0,0), (0.25,0.25)], diracTags=[40,51])
258     z=Rectangle(4,4, diracPoints=[(0.125,0.625), (0.5,1), (0.75, 0.25), (0.89, 0.875)], diracTags=["A", "B", "A", "C"])
259     v=interpolate(z.getX(), DiracDeltaFunctions(z))
260     if mpisize==1:
261     self.assertEquals(v.toListOfTuples(),[(0.0, 0.5), (0.5, 1.0), (0.75, 0.25), (1.0, 0.75)])
262     self.assertEquals(v.getNumberOfDataPoints(), 4)
263     self.assertEquals(inf(v[0]), 0)
264     self.assertEquals(inf(v[1]), 0.25)
265     self.assertEquals(Lsup(v[0]), 1)
266     self.assertEquals(Lsup(v[1]), 1)
267     v.setTaggedValue("A",(-10,0.5))
268     self.assertEquals(inf(v[0]), -10)
269     self.assertEquals(inf(v[1]), 0.5)
270     v.setTaggedValue(500,(-100,-100)) # non-existant tag
271     self.assertEquals(inf(v[0]), -10)
272     self.assertEquals(inf(v[1]), 0.5)
273     self.assertEquals(z.showTagNames(), 'A, B, C, bottom, left, right, top')
274     self.assertEquals(z.getTag("C"), 42)
275    
276     def test_brickconstr(self):
277     self.assertRaises(RuntimeError, Brick, 4,4, diracPoints=[(0,0,0)])
278     self.assertRaises(RuntimeError, Brick, 4,4, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40])
279     self.assertRaises(RuntimeError, Brick, 4,4, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40])
280     self.assertRaises(RuntimeError, Brick, 4,4, diracPoints=[(0,0,0), (1,1,1)], diracTags=["cows"])
281     self.assertRaises(RuntimeError, Brick, 4,4, diracPoints=[(0,0)], diracTags=["test"])
282     z=Brick(4,4, diracPoints=[(0,0,0), (0.25,0.25, 0.25)], diracTags=[40,51])
283     z=Brick(4,4, diracPoints=[(0.125,0.625,0), (0.5,1,0), (0.75, 0.25, 0.51), (0.89, 0.875,1)], diracTags=["A", "B", "A", "C"])
284     v=interpolate(z.getX(), DiracDeltaFunctions(z))
285     if mpisize==1:
286     self.assertEquals(v.toListOfTuples(),[(0.0, 0.5, 0.0), (0.5, 1.0, 0.0), (0.75, 0.25, 1), (1.0, 0.75, 1.0)])
287     self.assertEquals(v.getNumberOfDataPoints(), 4)
288 jfenwick 4963 self.assertEquals(inf(v[0]), 0)
289     self.assertEquals(inf(v[1]), 0.25)
290     self.assertEquals(Lsup(v[0]), 1)
291     self.assertEquals(Lsup(v[1]), 1)
292 jfenwick 4962 v.setTaggedValue("A",(-10,0.5,-500))
293 jfenwick 4963 if mpisize==1:
294     self.assertEquals(inf(v[0]), -10)
295     self.assertEquals(inf(v[1]), 0.5)
296     self.assertEquals(inf(v[2]),-500)
297 jfenwick 4962 v.setTaggedValue(500,(-100,-100, -100)) # non-existant tag
298 jfenwick 4963 if mpisize==1:
299     self.assertEquals(inf(v[0]), -10)
300     self.assertEquals(inf(v[1]), 0.5)
301     self.assertEquals(z.showTagNames(), 'A, B, C, back, bottom, front, left, right, top')
302 jfenwick 4962 self.assertEquals(z.getTag("C"), 42)
303    
304    
305     def test_rectReadMesh(self):
306     fname=os.path.join(FINLEY_TEST_MESH_PATH,'rect_4x4.fly')
307     self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,)])
308     self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0)])
309     self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0), (1,1)], diracTags=[40])
310     self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0), (1,1)], diracTags=["cows"])
311     z=ReadMesh(fname, diracPoints=[(0,0), (0.25,0.25)], diracTags=[40,51])
312     z=ReadMesh(fname, diracPoints=[(0.125,0.625), (0.5,1), (0.75, 0.25), (0.89, 0.875)], diracTags=["A", "B", "A", "C"])
313     v=interpolate(z.getX(), DiracDeltaFunctions(z))
314     if mpisize==1:
315     self.assertEquals(v.toListOfTuples(),[(0.0, 0.5), (0.5, 1.0), (0.75, 0.25), (1.0, 0.75)])
316     self.assertEquals(v.getNumberOfDataPoints(), 4)
317     self.assertEquals(inf(v[0]), 0)
318     self.assertEquals(inf(v[1]), 0.25)
319     self.assertEquals(Lsup(v[0]), 1)
320     self.assertEquals(Lsup(v[1]), 1)
321     v.setTaggedValue("A",(-10,0.5))
322     if mpisize==1:
323     self.assertEquals(inf(v[0]), -10)
324     self.assertEquals(inf(v[1]), 0.5)
325     v.setTaggedValue(500,(-100,-100)) # non-existant tag
326     if mpisize==1:
327     self.assertEquals(inf(v[0]), -10)
328     self.assertEquals(inf(v[1]), 0.5)
329     self.assertEquals(z.showTagNames(), 'A, B, C, bottom, left, right, top')
330     self.assertEquals(z.getTag("C"), 42)
331    
332    
333     def test_brickReadMesh(self):
334     fname=os.path.join(FINLEY_TEST_MESH_PATH,'brick_4x4x4.fly')
335     self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0)])
336     self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0,0)])
337     self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40])
338     self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0,0), (1,1,1)], diracTags=["cows"])
339     z=ReadMesh(fname, diracPoints=[(0,0,1), (0.25,0.25, 0.25)], diracTags=[40,51])
340     z=ReadMesh(fname, diracPoints=[(0.125,0.625,0), (0.5,1,1), (0.75, 0.25,0), (0.89, 0.875, 0.5)], diracTags=["A", "B", "A", "C"])
341     v=interpolate(z.getX(), DiracDeltaFunctions(z))
342     if mpisize==1:
343     self.assertEquals(v.toListOfTuples(),[(0.0, 0.5, 0.0), (0.5, 1.0, 1.0), (0.75, 0.25, 0.0), (1.0, 0.75, 0.5)])
344     self.assertEquals(v.getNumberOfDataPoints(), 4)
345     self.assertEquals(inf(v[0]), 0)
346     self.assertEquals(inf(v[1]), 0.25)
347     self.assertEquals(Lsup(v[0]), 1)
348     self.assertEquals(Lsup(v[1]), 1)
349     v.setTaggedValue("A",(-10,0.5,-0.5))
350     if mpisize==1:
351     self.assertEquals(inf(v[0]), -10)
352     self.assertEquals(inf(v[1]), 0.5)
353     self.assertEquals(inf(v[2]), -0.5)
354     v.setTaggedValue(500,(-100,-100, -100)) # non-existant tag
355     if mpisize==1:
356     self.assertEquals(inf(v[0]), -10)
357     self.assertEquals(inf(v[1]), 0.5)
358     self.assertEquals(inf(v[2]), -0.5)
359     self.assertEquals(z.showTagNames(), 'A, B, C, back, bottom, front, left, right, top')
360     self.assertEquals(z.getTag("C"), 203)
361    
362    
363    
364     @unittest.skipIf(mpisize>1, "more than 1 MPI rank")
365     def test_rectReadGmsh(self):
366     fname=os.path.join(FINLEY_TEST_MESH_PATH, 'rect_test.msh')
367     self.assertRaises(RuntimeError, ReadGmsh, fname, 2, diracPoints=[(0,0)])
368     self.assertRaises(RuntimeError, ReadGmsh, fname, 2, diracPoints=[(0,0), (1,1)], diracTags=[40])
369     self.assertRaises(RuntimeError, ReadGmsh, fname, 2, diracPoints=[(0,0), (1,1)], diracTags=["cows"])
370     z=ReadGmsh(fname, 2, diracPoints=[(0,0), (1,1)], diracTags=[40,51])
371     z=ReadGmsh(fname, 2, diracPoints=[(0,0),(0,1),(1,0),(1,1)], diracTags=["A", "B", "A", "C"])
372     v=interpolate(z.getX(), DiracDeltaFunctions(z))
373     if mpisize==1:
374     self.assertEquals(v.toListOfTuples(),[(0,0), (0,1), (1,0), (1,1)])
375     self.assertEquals(v.getNumberOfDataPoints(), 4)
376     v.setTaggedValue("A",(-10,99))
377     self.assertEquals(inf(v[0]), -10)
378     self.assertEquals(Lsup(v[1]), 99)
379     v.setTaggedValue(500,(-100,-100)) # non-existant tag
380     self.assertEquals(inf(v[0]), -10)
381     self.assertEquals(Lsup(v[1]), 99)
382     self.assertEquals(z.showTagNames(), 'A, B, C')
383     self.assertEquals(z.getTag("C"), 42)
384    
385     @unittest.skipIf(mpisize>1, "more than 1 MPI rank")
386     def test_brickReadGmsh(self):
387     fname=os.path.join(FINLEY_TEST_MESH_PATH, 'brick_test.msh')
388     self.assertRaises(RuntimeError, ReadGmsh, fname, 3, diracPoints=[(0,0)])
389     self.assertRaises(RuntimeError, ReadGmsh, fname, 3, diracPoints=[(0,0,0)])
390     self.assertRaises(RuntimeError, ReadGmsh, fname, 3, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40])
391     self.assertRaises(RuntimeError, ReadGmsh, fname, 3, diracPoints=[(0,0,0), (1,1,1)], diracTags=["cows"])
392     z=ReadGmsh(fname, 3, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40,51])
393     z=ReadGmsh(fname, 3, diracPoints=[(0,0,0),(0,1,0),(1,0,1),(1,1,1)], diracTags=["A", "B", "A", "C"])
394     v=interpolate(z.getX(), DiracDeltaFunctions(z))
395     if mpisize==1:
396     self.assertEquals(v.toListOfTuples(),[(0,0,0), (0,1,0), (1,0,1), (1,1,1)])
397     self.assertEquals(v.getNumberOfDataPoints(), 4)
398     v.setTaggedValue("A",(-10,99,-98))
399     self.assertEquals(inf(v[0]), -10)
400     self.assertEquals(Lsup(v[1]), 99)
401     self.assertEquals(inf(v[2]), -98)
402     v.setTaggedValue(500,(-100,-100,-100)) # non-existant tag
403     self.assertEquals(inf(v[0]), -10)
404     self.assertEquals(Lsup(v[1]), 99)
405     self.assertEquals(z.showTagNames(), 'A, B, C')
406     self.assertEquals(z.getTag("C"), 42)
407    
408    
409 gross 983 if __name__ == '__main__':
410     suite = unittest.TestSuite()
411 jfenwick 4962 suite.addTest(unittest.makeSuite(Test_DiracOnFinley))
412 jfenwick 2271 suite.addTest(unittest.makeSuite(Test_SharedOnFinley))
413 gross 1141 suite.addTest(unittest.makeSuite(Test_DataOpsOnFinley))
414 gross 1185 suite.addTest(unittest.makeSuite(Test_DomainOnFinley))
415 jfenwick 2646 suite.addTest(unittest.makeSuite(Test_TableInterpolationOnFinley))
416 jfenwick 2644 suite.addTest(unittest.makeSuite(Test_CSVOnFinley))
417 jfenwick 4085 suite.addTest(unittest.makeSuite(Test_OtherInterpolationOnFinley))
418 gross 983 s=unittest.TextTestRunner(verbosity=2).run(suite)
419 gross 1376 if not s.wasSuccessful(): sys.exit(1)
420    

  ViewVC Help
Powered by ViewVC 1.1.26