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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6652 - (show annotations)
Wed Mar 14 08:22:11 2018 UTC (19 months ago) by jfenwick
File MIME type: text/x-python
File size: 20422 byte(s)
makeTagMap and skeleton test

The test is there and is hooked into Finley, Dudley and Ripley.
The test does not do enough.

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

  ViewVC Help
Powered by ViewVC 1.1.26