/[escript]/trunk/escript/test/python/test_objects.py
ViewVC logotype

Contents of /trunk/escript/test/python/test_objects.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3390 - (show annotations)
Thu Dec 2 00:34:37 2010 UTC (8 years, 8 months ago) by jfenwick
File MIME type: text/x-python
File size: 88222 byte(s)
RandomData added

1
2 ########################################################
3 #
4 # Copyright (c) 2003-2010 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2010 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 """
23 Test suite for data objects. at the moment for dump and load only.
24
25 The tests must be linked with some function space class object in the setUp method:
26 to run the use:
27
28 from esys.dudley import Brick
29 class Test_DumpOnDudley(Test_Dump):
30 def setUp(self):
31 self.domain =Rectangle(NE,NE+1,2)
32 self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1,2)
33 self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,2,integrationOrder=2)
34 self.domain_with_different_sample_ordering =Rectangle(1,(NE+1)*NE,2)
35 self.filename_base="."
36
37 suite = unittest.TestSuite()
38 suite.addTest(unittest.makeSuite(Test_DumpOnDudley))
39 unittest.TextTestRunner(verbosity=2).run(suite)
40
41 :var __author__: name of author
42 :var __copyright__: copyrights
43 :var __license__: licence agreement
44 :var __url__: url entry point on documentation
45 :var __version__: version
46 :var __date__: date of the version
47 """
48
49 __author__="Lutz Gross, l.gross@uq.edu.au"
50
51 import unittest
52 import os
53 import numpy
54 from esys.escript import *
55
56 try:
57 ESCRIPT_WORKDIR=os.environ['ESCRIPT_WORKDIR']
58 except KeyError:
59 ESCRIPT_WORKDIR='.'
60
61 class Test_TableInterpolation(unittest.TestCase):
62 RES_TOL=1.e-7 # RES_TOLerance to compare results
63
64
65 def test_NullFunctionSpace(self):
66 arL=[[0, -1, -2, -3, -4], [1, 1, -2, -3, -4], [2, 2, 2, -3, -4], [3, 3, 3, 3, -4], [4, 4, 4, 4, 4]]
67 arn=numpy.array(arL)
68 ars=[arL,arn]
69 d0=Data(0)
70 d1=Data(1)
71 d2=Data(2)
72 d35=Data(3.5)
73 d4=Data(4)
74 dm05=Data(-0.5)
75 d175=Data(1.75)
76 d225=Data(2.25)
77 for arr in ars:
78 self.failUnless(Lsup(d1.interpolateTable(arL,0, 1, d2, 0, 1, 100)+2)<self.RES_TOL)
79 self.failUnless(Lsup(d1.interpolateTable(arL,0, 1, d35, 0, 1, 100)+3.5)<self.RES_TOL)
80 self.failUnless(Lsup(d35.interpolateTable(arL,0,1, d2, 0, 1, 100)-3.5)<self.RES_TOL)
81 self.failUnless(Lsup(d175.interpolateTable(arL,0,1,d225,0,1, 100)-0)<self.RES_TOL)
82 # Point out of bounds
83 self.failUnlessRaises(RuntimeError, d1.interpolateTable,arL,0, 1, d4, 0, 0.5, 100, check_boundaries=True )
84 self.failUnlessRaises(RuntimeError, d4.interpolateTable, arL,0, 0.5, d1, 0, 1, 100, check_boundaries=True )
85 self.failUnlessRaises(RuntimeError, dm05.interpolateTable, arL,0,1, d1 , 0,1, 100, check_boundaries=True )
86 self.failUnlessRaises(RuntimeError, d1.interpolateTable, arL,0,1, dm05 , 0,1, 100,check_boundaries=True )
87 #Test to ensure not check_boundaries does not throw in the above cases
88 d1.interpolateTable(arL,0, 1, d4, 0, 0.5, 100, check_boundaries=False)
89 d4.interpolateTable( arL,0, 0.5, d1, 0, 1, 100, check_boundaries=False )
90 dm05.interpolateTable( arL,0,1, d1 , 0,1, 100, check_boundaries=False )
91 d1.interpolateTable( arL,0,1, dm05 , 0,1, 100,check_boundaries=False )
92
93 # interpolated value too large
94 self.failUnlessRaises(RuntimeError, d2.interpolateTable, arL, 0, 1, d2, 0, 1, 1 )
95
96
97 def test_FunctionSpace3D(self):
98 vs=[(1,3,5,7,11,13,17,19), (-1,1,-1,1,-1,1,-1,1), (0.5, 17, 0.25, 42, 0.125, 35, 0.625, 49)] #There is no particular significance to these numbers
99 for fs in self.functionspaces:
100 points=fs.getX()
101 for t in vs:
102 v0, v1, v2, v3, v4, v5, v6, v7 =t
103 x=points[0]
104 y=points[1]
105 z=points[2]
106 xmax=sup(x)
107 xmin=inf(x)
108 ymax=sup(y)
109 ymin=inf(y)
110 zmax=sup(z)
111 zmin=inf(z)
112 xwidth=(xmax-xmin)/(self.xn-1)
113 ywidth=(ymax-ymin)/(self.yn-1)
114 zwidth=(zmax-zmin)/(self.zn-1)
115 table=[]
116 for k in xrange(self.zn):
117 face=[]
118 for j in xrange(self.yn):
119 row=[]
120 for i in xrange(self.xn):
121 row.append(v0+v1*xwidth*i+v2*ywidth*j+v3*i*j*xwidth*ywidth)
122 face.append(row)
123 table.append(face)
124 ref=v0+v1*(x-xmin)+v2*(y-ymin)+v3*(x-xmin)*(y-ymin)
125 lsupref=Lsup(ref)
126 if lsupref!=0 and xwidth>0: #This will happen in cases where there are no samples on this rank
127 res=interpolateTable(table, points, (xmin, ymin, zmin), (xwidth, ywidth, zwidth),900)
128 self.failUnless(Lsup(res-ref)/Lsup(ref)<self.RES_TOL,"Failed for %s"%str(fs))
129 # Test undef
130 self.failUnlessRaises(RuntimeError, interpolateTable, table, points, (xmin, ymin, zmin), (xwidth, ywidth, zwidth), -1)
131 # Test bounds checking
132 self.failUnlessRaises(RuntimeError, interpolateTable, table, points, (xmin, ymin, zmin), (xwidth/3, ywidth, zwidth), 900,True)
133 self.failUnlessRaises(RuntimeError, interpolateTable, table, points, (xmin, ymin, zmin), (xwidth, ywidth/3, zwidth), 900, True)
134 self.failUnlessRaises(RuntimeError, interpolateTable, table, points, (xmin, ymin, zmin), (xwidth, ywidth, zwidth/3), 900, True)
135
136 def test_FunctionSpace2D(self):
137 vs=[(1,3,5,7), (-1,1,-1,1), (0.5, 17, 0.25, 42)] #There is no particular significance to these numbers
138 for fs in self.functionspaces:
139 points=fs.getX()
140 for t in vs:
141 v0, v1, v2, v3 =t
142 x=points[0]
143 y=points[1]
144 xmax=sup(x)
145 xmin=inf(x)
146 ymax=sup(y)
147 ymin=inf(y)
148 xwidth=(xmax-xmin)/(self.xn-1)
149 ywidth=(ymax-ymin)/(self.yn-1)
150 table=[]
151 for j in xrange(self.yn):
152 row=[]
153 for i in xrange(self.xn):
154 row.append(v0+v1*xwidth*i+v2*ywidth*j+v3*i*j*xwidth*ywidth)
155 table.append(row)
156 ref=v0+v1*(x-xmin)+v2*(y-ymin)+v3*(x-xmin)*(y-ymin)
157 lsupref=Lsup(ref)
158 if lsupref!=0 and xwidth>0: #This will happen in cases where there are no samples on this rank
159 res=y.interpolateTable(table,ymin,ywidth,x, xmin, xwidth,500)
160 self.failUnless(Lsup(res-ref)/Lsup(ref)<self.RES_TOL,"Failed for %s"%str(fs))
161 #Now we try for the new interface
162 res=interpolateTable(table,points[0:2], (xmin, ymin), (xwidth, ywidth),500)
163 self.failUnless(Lsup(res-ref)/Lsup(ref)<self.RES_TOL,"Failed for %s under unified call."%str(fs))
164
165
166
167 def test_FunctionSpace1D(self):
168 vs=[(1,3), (-1,1), (0.5, 17)] #There is no particular significance to these numbers
169 for fs in self.functionspaces:
170 points=fs.getX()
171 for t in vs:
172 v0, v1 =t
173 x=points[0]
174 xmax=sup(x)
175 xmin=inf(x)
176 xwidth=(xmax-xmin)/(self.xn-1)
177 table=[]
178 for i in xrange(self.xn):
179 table.append(v0+v1*xwidth*i)
180 ref=v0+v1*(x-xmin)
181 lsupref=Lsup(ref)
182 if lsupref!=0 and xwidth>0: #This will happen in cases where there are no samples on this rank
183 res=x.interpolateTable(table, xmin, xwidth,500)
184 self.failUnless(Lsup(res-ref)/lsupref<self.RES_TOL,"Failed for %s"%str(fs))
185 #Now we try for the new interface
186 res=interpolateTable(table,points[0:1], (xmin,), (xwidth, ),500)
187 self.failUnless(Lsup(res-ref)/Lsup(ref)<self.RES_TOL,"Failed for %s under unified call."%str(fs))
188 res=interpolateTable(table,points[0:1], xmin, xwidth,500)
189 self.failUnless(Lsup(res-ref)/Lsup(ref)<self.RES_TOL,"Failed for %s under unified call (no tuple)."%str(fs))
190
191 class Test_saveCSV(unittest.TestCase):
192
193 def test_save1(self):
194 X=self.domain.getX()
195 X0=X[0]
196 fname=os.path.join(ESCRIPT_WORKDIR, "test_save1.csv")
197 saveDataCSV(fname,C=X, D=X0)
198 saveDataCSV(fname,append=True, J=X0, H=X)
199 self.failUnless(os.path.exists(fname), "test file not created")
200 f=open(fname,'r')
201 line=f.readline()
202 self.failUnless(line=="C_0, C_1, D\n") #This tests both separator strings
203 #Now we find out how many rows it has
204 linecount=0
205 while line != '':
206 linecount+=1
207 line=f.readline()
208 self.failUnless(linecount==self.linecount1*2)
209 f.close()
210 #Now to other output
211 T2=Tensor(7,X.getFunctionSpace())
212 T3=Tensor3(8,X.getFunctionSpace())
213 T4=Tensor4(9,X.getFunctionSpace())
214 saveDataCSV(fname,A=T2,B=T3,C=T4)
215 f=open(fname,'r')
216 line=f.readline()
217 self.failUnless(line=='A_0_0, A_1_0, A_0_1, A_1_1, B_0_0_0, B_0_0_1, B_1_0_0, B_1_0_1, B_0_1_0, B_0_1_1, B_1_1_0, B_1_1_1, C_0_0_0_0, C_0_0_0_1, C_0_0_1_0, C_0_0_1_1, C_1_0_0_0, C_1_0_0_1, C_1_0_1_0, C_1_0_1_1, C_0_1_0_0, C_0_1_0_1, C_0_1_1_0, C_0_1_1_1, C_1_1_0_0, C_1_1_0_1, C_1_1_1_0, C_1_1_1_1\n')
218 line=f.readline()
219 line_expected=[7.]*4+[8.]*8+[9.]*16
220 line_got=[float(elt) for elt in line.split(',')]
221 self.failUnless(line_got==line_expected)
222 linecount=1
223 while line != '':
224 linecount+=1
225 line=f.readline()
226 self.failUnless(linecount==self.linecount1)
227 f.close()
228 #Now to test separators and mask
229 saveDataCSV(fname, sep="|",csep="/", U=X, V=X0, mask=X0)
230 f=open(fname,'r')
231 line=f.readline()
232 self.failUnless(line=='U/0|U/1|V\n')
233 line=f.readline()
234 line_got=[float(elt) for elt in line.split('|')]
235 self.failUnless(self.line_expected==line_got)
236 linecount=1
237 while line!='':
238 linecount+=1
239 line=f.readline()
240 self.failUnless(linecount==self.linecount2)
241
242
243 class Test_Domain(unittest.TestCase):
244
245 def test_getListOfTags(self): # requires self.boundary_tag_list
246 tags=FunctionOnBoundary(self.domain).getListOfTags()
247 self.failUnless(len(self.boundary_tag_list) == len(tags), "tag list length does not match")
248 for i in self.boundary_tag_list:
249 self.failUnless(i in tags, "tag %s is missing."%i)
250
251 def test_RandomData(self):
252 fs=Function(self.domain) # The choice of functionspace is arbitrary
253 dat=RandomData((2,2,2,2),fs,8) # Choice of seed is arbitrary
254 self.failUnless(Lsup(dat-1)<1.0001)
255
256 def test_Factories(self):
257 fs=Function(self.domain) # The choice of functionspace is arbitrary
258 dime=self.domain.getDim()
259 if dime>0:
260 z=[]
261 bad=[]
262 for i in range(dime):
263 z+=[i]
264 bad+=[i]
265 bad+=[i]
266 d=Vector(z,fs)
267 self.failUnless(d.getShape()==(dime,))
268 self.failUnlessRaises(RuntimeError, Vector, bad,fs) #test wrong shape
269 y=[]
270 bad=[]
271 for i in range(dime):
272 y+=[z]
273 bad+=[z]
274 bad+=[z]
275 z=y
276 d=Tensor(z,fs)
277 self.failUnless(d.getShape()==(dime,dime))
278 try:
279 Tensor(bad,fs)
280 except RuntimeError:
281 pass
282 else:
283 self.fail("Tensor should have rejected bad shape")
284 y=[]
285 bad=[]
286 for i in range(dime):
287 y+=[z]
288 bad+=[z]
289 bad+=[z]
290 z=y
291 d=Tensor3(z,fs)
292 self.failUnless(d.getShape()==(dime,dime,dime))
293 try:
294 Tensor3(bad,fs)
295 except RuntimeError:
296 pass
297 else:
298 self.fail("Tensor3 should have rejected bad shape")
299 y=[]
300 bad=[]
301 for i in range(dime):
302 y+=[z]
303 bad+=[z]
304 bad+=[z]
305 z=y
306 d=Tensor4(z,fs)
307 self.failUnless(d.getShape()==(dime,dime,dime,dime))
308 try:
309 Tensor4(bad,fs)
310 except RuntimeError:
311 pass
312 else:
313 self.fail("Tensor4 should have rejected bad shape")
314
315
316 def test_addTags(self):
317 tag1="A"
318 tag2="B"
319 tag3="C"
320 self.domain.setTagMap(tag1,1)
321 self.failUnless(self.domain.isValidTagName(tag1))
322 self.failUnless(not self.domain.isValidTagName(tag2))
323 self.domain.setTagMap(tag2,2)
324 self.failUnless(self.domain.isValidTagName(tag1))
325 self.failUnless(self.domain.isValidTagName(tag2))
326 self.failUnless(not self.domain.isValidTagName(tag3))
327 self.failUnless(self.domain.getTag(tag1)==1)
328 self.failUnless(self.domain.getTag(tag2)==2)
329 self.failUnlessRaises(RuntimeError,self.domain.getTag,tag3)
330
331 # set tag:
332 s=Scalar(0,Function(self.domain))
333 r=Scalar(0,Function(self.domain))
334 s.setTaggedValue(tag1,1.)
335 r.setTaggedValue(1,1.)
336 s.setTaggedValue(tag2,2.)
337 r.setTaggedValue(2,2.)
338 self.failUnlessRaises(RuntimeError,s.setTaggedValue,tag3,3.) #tag3 does not exist
339 self.failUnless(Lsup(s-r)<=0.)
340 # get tag:
341 names=getTagNames(self.domain)
342 self.failUnless(len(names) == 6)
343 self.failUnless( tag1 in names )
344 self.failUnless( tag2 in names )
345 self.failUnless(self.domain.isValidTagName(tag1))
346 self.failUnless(self.domain.isValidTagName(tag2))
347 # insert tag shortcut:
348 s2=insertTaggedValues(Scalar(0,Function(self.domain)),**{ tag1 : 1., tag2 : 2.})
349 self.failUnless(Lsup(s2-r)<=0.)
350 def test_functionspace_ContinuousFunction(self):
351 fs=ContinuousFunction(self.domain)
352 self.failUnless(fs.getDomain()==self.domain)
353 self.failUnless(self.domain.getDim() == fs.getDim())
354 x=fs.getX()
355 self.failUnless(x.getFunctionSpace() == fs)
356 self.failUnless(x.getShape() == (fs.getDim(),))
357 self.failUnless(inf(x[0])>=0.)
358 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
359 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
360 self.failUnless(sup(x[0])<=1.)
361 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
362 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
363
364 def test_functionspace_Solution(self):
365 fs=Solution(self.domain)
366 self.failUnless(fs.getDomain()==self.domain)
367 self.failUnless(self.domain.getDim() == fs.getDim())
368 x=fs.getX()
369 self.failUnless(x.getFunctionSpace() == fs)
370 self.failUnless(x.getShape() == (fs.getDim(),))
371 self.failUnless(inf(x[0])>=0.)
372 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
373 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
374 self.failUnless(sup(x[0])<=1.)
375 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
376 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
377
378 def test_functionspace_ReducedSolution(self):
379 fs=ReducedSolution(self.domain)
380 self.failUnless(fs.getDomain()==self.domain)
381 self.failUnless(self.domain.getDim() == fs.getDim())
382 x=fs.getX()
383 self.failUnless(x.getFunctionSpace() == fs)
384 self.failUnless(x.getShape() == (fs.getDim(),))
385 self.failUnless(inf(x[0])>=0.)
386 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
387 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
388 self.failUnless(sup(x[0])<=1.)
389 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
390 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
391
392 def test_functionspace_Function(self):
393 fs=Function(self.domain)
394 self.failUnless(fs.getDomain()==self.domain)
395 self.failUnless(self.domain.getDim() == fs.getDim())
396 x=fs.getX()
397 self.failUnless(x.getFunctionSpace() == fs)
398 self.failUnless(x.getShape() == (fs.getDim(),))
399 self.failUnless(inf(x[0])>=0.)
400 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
401 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
402 self.failUnless(sup(x[0])<=1.)
403 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
404 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
405
406 def test_functionspace_ReducedFunction(self):
407 fs=ReducedFunction(self.domain)
408 self.failUnless(fs.getDomain()==self.domain)
409 self.failUnless(self.domain.getDim() == fs.getDim())
410 x=fs.getX()
411 self.failUnless(x.getFunctionSpace() == fs)
412 self.failUnless(x.getShape() == (fs.getDim(),))
413 self.failUnless(inf(x[0])>=0.)
414 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
415 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
416 self.failUnless(sup(x[0])<=1.)
417 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
418 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
419 def test_functionspace_FunctionOnBoundary(self):
420 fs=FunctionOnBoundary(self.domain)
421 self.failUnless(fs.getDomain()==self.domain)
422 self.failUnless(self.domain.getDim() == fs.getDim())
423 x=fs.getX()
424 self.failUnless(x.getFunctionSpace() == fs)
425 self.failUnless(x.getShape() == (fs.getDim(),))
426 self.failUnless(inf(x[0])>=0.)
427 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
428 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
429 self.failUnless(sup(x[0])<=1.)
430 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
431 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
432
433 def test_functionspace_ReducedFunctionOnBoundary(self):
434 fs=ReducedFunctionOnBoundary(self.domain)
435 self.failUnless(fs.getDomain()==self.domain)
436 self.failUnless(self.domain.getDim() == fs.getDim())
437 x=fs.getX()
438 self.failUnless(x.getFunctionSpace() == fs)
439 self.failUnless(x.getShape() == (fs.getDim(),))
440 self.failUnless(inf(x[0])>=0.)
441 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
442 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
443 self.failUnless(sup(x[0])<=1.)
444 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
445 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
446 #===========================================================================
447
448 class Test_GlobalMinMax(unittest.TestCase):
449 def test_GlobalMinMax(self):
450 myrank=getMPIRankWorld()
451 d=Data(myrank,Function(self.domain))
452 minproc=inf(d)
453 maxproc=sup(d) #This tells us where to expect values to be
454 if d.getNumberOfDataPoints()>0:
455 d.setValueOfDataPoint(0,myrank-0.001);
456 p,n=d.minGlobalDataPoint()
457 self.failUnless(p==minproc,"Incorrect process indentified as holding min")
458 self.failUnless(n==0,"Incorrect position for min")
459 if d.getNumberOfDataPoints()>0:
460 d.setValueOfDataPoint(0,myrank+0.001)
461 p,n=d.maxGlobalDataPoint()
462 self.failUnless(p==maxproc,"Incorrect process indentified as holding min")
463 self.failUnless(n==0,"Incorrect position for min")
464
465
466
467 class Test_SetDataPointValue(unittest.TestCase):
468 arg0=9.81
469 arg1=numpy.array([3.098, -3.111])
470 arg2=numpy.array([[3.82, -3.81, -0.957, 0.892, -1.367], [-4.589, -1.835, -2.679, -1.517, -4.2515], [-4.909, 1.634, -2.883, -2.135, 1.187], [0.6431, 4.638, -4.616, -0.196, -4.370]])
471 arg3=numpy.array([[[-2.3667, -0.040], [-4.7398, -3.2412]], [[-2.125, -2.240], [2.237, -4.279]], [[0.68720, 2.4059], [-2.4964, 3.17453]], [[-4.907, -4.9431], [-0.3604, 0.4269]], [[1.4179, 3.326], [1.356, -0.4610]], [[3.378, 2.0902], [-2.6857, 1.3585]]])
472 arg4=numpy.array([[[[-3.810, -1.3597, -1.5307, 1.099], [-1.828, 0.2526, -1.4429, 2.326], [4.9732, -2.063, 1.3153, -3.809]], [[-4.8902, -4.714, 1.520, -1.931], [-3.8847, 4.3867, 1.894030, 2.432], [-1.2082, -0.8304, 2.2612, 4.6399]]], [[[-4.5922, -3.309, -0.8171, -0.7210], [2.8051, -4.93047, 0.08450, 4.3824], [0.43204, 2.1908, 4.512633, -1.8218]], [[2.2493, -4.190, -2.3893, -4.147], [-2.104, -4.635, -4.2767, -3.53151], [-2.351, -1.6614, 2.9385, 4.099]]], [[[1.710, 0.2235, -3.4917, 0.8713], [-0.2881, 4.6278, 3.603, -2.1211], [-0.565, 4.294, -2.210827, -0.37651]], [[0.6578, -2.869, -2.490, -4.789], [3.232, 2.483, 0.9531, 2.260], [-1.785, 0.42156, -1.8379, 4.212]]]])
473 def test_SetDataPointValue_Function_Rank0(self):
474 d=Data(self.arg0,Function(self.domain))
475 d.setValueOfDataPoint(0,self.arg0*2)
476 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
477 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg0)
478 d_0=numpy.array(d.getTupleForDataPoint(0))
479 d_1=numpy.array(d.getTupleForDataPoint(1))
480 self.failUnless(Lsup(d_0-self.arg0*2)<=Lsup(self.arg0*2), "wrong setting")
481 self.failUnless(Lsup(d_1-self.arg0)<=Lsup(self.arg0), "wrong setting")
482 def test_SetDataPointValue_Function_Rank1(self):
483 d=Data(self.arg1,Function(self.domain))
484 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
485 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
486 d.setValueOfDataPoint(0,self.arg1*2)
487 d_0=numpy.array(d.getTupleForDataPoint(0))
488 d_1=numpy.array(d.getTupleForDataPoint(1))
489 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
490 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
491 def test_SetDataPointValue_Function_Rank1_list(self):
492 d=Data(self.arg1,Function(self.domain))
493 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
494 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
495 d.setValueOfDataPoint(0,(self.arg1*2).tolist())
496 d_0=numpy.array(d.getTupleForDataPoint(0))
497 d_1=numpy.array(d.getTupleForDataPoint(1))
498 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
499 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
500 def test_SetDataPointValue_Function_Rank2(self):
501 d=Data(self.arg2,Function(self.domain))
502 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
503 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
504 d.setValueOfDataPoint(0,self.arg2*2)
505 d_0=numpy.array(d.getTupleForDataPoint(0))
506 d_1=numpy.array(d.getTupleForDataPoint(1))
507 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
508 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
509 def test_SetDataPointValue_Function_Rank2_list(self):
510 d=Data(self.arg2,Function(self.domain))
511 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
512 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
513 d.setValueOfDataPoint(0,(self.arg2*2).tolist())
514 d_0=numpy.array(d.getTupleForDataPoint(0))
515 d_1=numpy.array(d.getTupleForDataPoint(1))
516 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
517 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
518 def test_SetDataPointValue_Function_Rank3(self):
519 d=Data(self.arg3,Function(self.domain))
520 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
521 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
522 d.setValueOfDataPoint(0,self.arg3*2)
523 d_0=numpy.array(d.getTupleForDataPoint(0))
524 d_1=numpy.array(d.getTupleForDataPoint(1))
525 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
526 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
527 def test_SetDataPointValue_Function_Rank3_list(self):
528 d=Data(self.arg3,Function(self.domain))
529 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
530 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
531 d.setValueOfDataPoint(0,(self.arg3*2).tolist())
532 d_0=numpy.array(d.getTupleForDataPoint(0))
533 d_1=numpy.array(d.getTupleForDataPoint(1))
534 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
535 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
536 def test_SetDataPointValue_Function_Rank4(self):
537 d=Data(self.arg4,Function(self.domain))
538 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
539 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
540 d.setValueOfDataPoint(0,self.arg4*2)
541 d_0=numpy.array(d.getTupleForDataPoint(0))
542 d_1=numpy.array(d.getTupleForDataPoint(1))
543 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
544 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
545 def test_SetDataPointValue_Function_Rank4_list(self):
546 d=Data(self.arg4,Function(self.domain))
547 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
548 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
549 d.setValueOfDataPoint(0,(self.arg4*2).tolist())
550 d_0=numpy.array(d.getTupleForDataPoint(0))
551 d_1=numpy.array(d.getTupleForDataPoint(1))
552 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
553 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
554 #===========================================================================
555 def test_SetDataPointValue_ReducedFunction_Rank0(self):
556 d=Data(self.arg0,ReducedFunction(self.domain))
557 d.setValueOfDataPoint(0,self.arg0*2)
558 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
559 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg0)
560 d_0=numpy.array(d.getTupleForDataPoint(0))
561 d_1=numpy.array(d.getTupleForDataPoint(1))
562 self.failUnless(Lsup(d_0-self.arg0*2)<=Lsup(self.arg0*2), "wrong setting")
563 self.failUnless(Lsup(d_1-self.arg0)<=Lsup(self.arg0), "wrong setting")
564 def test_SetDataPointValue_ReducedFunction_Rank1(self):
565 d=Data(self.arg1,ReducedFunction(self.domain))
566 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
567 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
568 d.setValueOfDataPoint(0,self.arg1*2)
569 d_0=numpy.array(d.getTupleForDataPoint(0))
570 d_1=numpy.array(d.getTupleForDataPoint(1))
571 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
572 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
573 def test_SetDataPointValue_ReducedFunction_Rank1_list(self):
574 d=Data(self.arg1,ReducedFunction(self.domain))
575 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
576 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
577 d.setValueOfDataPoint(0,(self.arg1*2).tolist())
578 d_0=numpy.array(d.getTupleForDataPoint(0))
579 d_1=numpy.array(d.getTupleForDataPoint(1))
580 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
581 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
582 def test_SetDataPointValue_ReducedFunction_Rank2(self):
583 d=Data(self.arg2,ReducedFunction(self.domain))
584 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
585 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
586 d.setValueOfDataPoint(0,self.arg2*2)
587 d_0=numpy.array(d.getTupleForDataPoint(0))
588 d_1=numpy.array(d.getTupleForDataPoint(1))
589 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
590 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
591 def test_SetDataPointValue_ReducedFunction_Rank2_list(self):
592 d=Data(self.arg2,ReducedFunction(self.domain))
593 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
594 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
595 d.setValueOfDataPoint(0,(self.arg2*2).tolist())
596 d_0=numpy.array(d.getTupleForDataPoint(0))
597 d_1=numpy.array(d.getTupleForDataPoint(1))
598 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
599 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
600 def test_SetDataPointValue_ReducedFunction_Rank3(self):
601 d=Data(self.arg3,ReducedFunction(self.domain))
602 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
603 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
604 d.setValueOfDataPoint(0,self.arg3*2)
605 d_0=numpy.array(d.getTupleForDataPoint(0))
606 d_1=numpy.array(d.getTupleForDataPoint(1))
607 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
608 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
609 def test_SetDataPointValue_ReducedFunction_Rank3_list(self):
610 d=Data(self.arg3,ReducedFunction(self.domain))
611 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
612 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
613 d.setValueOfDataPoint(0,(self.arg3*2).tolist())
614 d_0=numpy.array(d.getTupleForDataPoint(0))
615 d_1=numpy.array(d.getTupleForDataPoint(1))
616 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
617 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
618 def test_SetDataPointValue_ReducedFunction_Rank4(self):
619 d=Data(self.arg4,ReducedFunction(self.domain))
620 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
621 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
622 d.setValueOfDataPoint(0,self.arg4*2)
623 d_0=numpy.array(d.getTupleForDataPoint(0))
624 d_1=numpy.array(d.getTupleForDataPoint(1))
625 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
626 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
627 def test_SetDataPointValue_ReducedFunction_Rank4_list(self):
628 d=Data(self.arg4,ReducedFunction(self.domain))
629 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
630 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
631 d.setValueOfDataPoint(0,(self.arg4*2).tolist())
632 d_0=numpy.array(d.getTupleForDataPoint(0))
633 d_1=numpy.array(d.getTupleForDataPoint(1))
634 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
635 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
636
637 class Test_Dump(unittest.TestCase):
638 arg0=9.81
639 arg1=numpy.array([3.098, -3.111])
640 arg2=numpy.array([[3.82, -3.81, -0.957, 0.892, -1.367], [-4.589, -1.835, -2.679, -1.517, -4.2515], [-4.909, 1.634, -2.883, -2.135, 1.187], [0.6431, 4.638, -4.616, -0.196, -4.370]])
641 arg3=numpy.array([[[-2.3667, -0.040], [-4.7398, -3.2412]], [[-2.125, -2.240], [2.237, -4.279]], [[0.68720, 2.4059], [-2.4964, 3.17453]], [[-4.907, -4.9431], [-0.3604, 0.4269]], [[1.4179, 3.326], [1.356, -0.4610]], [[3.378, 2.0902], [-2.6857, 1.3585]]])
642 arg4=numpy.array([[[[-3.810, -1.3597, -1.5307, 1.099], [-1.828, 0.2526, -1.4429, 2.326], [4.9732, -2.063, 1.3153, -3.809]], [[-4.8902, -4.714, 1.520, -1.931], [-3.8847, 4.3867, 1.894030, 2.432], [-1.2082, -0.8304, 2.2612, 4.6399]]], [[[-4.5922, -3.309, -0.8171, -0.7210], [2.8051, -4.93047, 0.08450, 4.3824], [0.43204, 2.1908, 4.512633, -1.8218]], [[2.2493, -4.190, -2.3893, -4.147], [-2.104, -4.635, -4.2767, -3.53151], [-2.351, -1.6614, 2.9385, 4.099]]], [[[1.710, 0.2235, -3.4917, 0.8713], [-0.2881, 4.6278, 3.603, -2.1211], [-0.565, 4.294, -2.210827, -0.37651]], [[0.6578, -2.869, -2.490, -4.789], [3.232, 2.483, 0.9531, 2.260], [-1.785, 0.42156, -1.8379, 4.212]]]])
643
644 def _diffDataObjects(self,d_ref,filemame, use_old_file=False):
645 if not use_old_file: d_ref.dump(filemame)
646 d=load(filemame, d_ref.getDomain())
647 self.failUnless(not d.isEmpty(),"data in %s are empty."%filemame)
648 self.failUnless(d_ref.getRank() == d.getRank(), "different rank in %s. "%filemame)
649 self.failUnless(d_ref.getShape() == d.getShape(), "different shape %s. "%filemame)
650 self.failUnless(d_ref.getFunctionSpace() == d.getFunctionSpace(), "wrong function space in %s."%filemame)
651 self.failUnless(Lsup(d_ref-d)<=0., "different entries %s."%filemame)
652
653 #===========================================================================
654 def test_DumpAndLoad_Constant_Solution_Rank0(self):
655 if loadIsConfigured():
656 filemame=os.path.join(self.filename_base,"constant_solution_rank0.nc")
657 d=Data(self.arg0,Solution(self.domain))
658 self._diffDataObjects(d,filemame)
659
660 def test_DumpAndLoad_Constant_Solution_Rank1(self):
661 if loadIsConfigured():
662 filemame=os.path.join(self.filename_base,"constant_solution_rank1.nc")
663 d=Data(self.arg1,Solution(self.domain))
664 self._diffDataObjects(d,filemame)
665
666 def test_DumpAndLoad_Constant_Solution_Rank2(self):
667 if loadIsConfigured():
668 filemame=os.path.join(self.filename_base,"constant_solution_rank2.nc")
669 d=Data(self.arg2,Solution(self.domain))
670 self._diffDataObjects(d,filemame)
671
672 def test_DumpAndLoad_Constant_Solution_Rank3(self):
673 if loadIsConfigured():
674 filemame=os.path.join(self.filename_base,"constant_solution_rank3.nc")
675 d=Data(self.arg3,Solution(self.domain))
676 self._diffDataObjects(d,filemame)
677
678 def test_DumpAndLoad_Constant_Solution_Rank4(self):
679 if loadIsConfigured():
680 filemame=os.path.join(self.filename_base,"constant_solution_rank4.nc")
681 d=Data(self.arg4,Solution(self.domain))
682 self._diffDataObjects(d,filemame)
683 #===========================================================================
684 def test_DumpAndLoad_Constant_ReducedSolution_Rank0(self):
685 if loadIsConfigured():
686 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank0.nc")
687 d=Data(self.arg0,ReducedSolution(self.domain))
688 self._diffDataObjects(d,filemame)
689
690 def test_DumpAndLoad_Constant_ReducedSolution_Rank1(self):
691 if loadIsConfigured():
692 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank1.nc")
693 d=Data(self.arg1,ReducedSolution(self.domain))
694 self._diffDataObjects(d,filemame)
695
696 def test_DumpAndLoad_Constant_ReducedSolution_Rank2(self):
697 if loadIsConfigured():
698 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank2.nc")
699 d=Data(self.arg2,ReducedSolution(self.domain))
700 self._diffDataObjects(d,filemame)
701
702 def test_DumpAndLoad_Constant_ReducedSolution_Rank3(self):
703 if loadIsConfigured():
704 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank3.nc")
705 d=Data(self.arg3,ReducedSolution(self.domain))
706 self._diffDataObjects(d,filemame)
707
708 def test_DumpAndLoad_Constant_ReducedSolution_Rank4(self):
709 if loadIsConfigured():
710 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank4.nc")
711 d=Data(self.arg4,ReducedSolution(self.domain))
712 self._diffDataObjects(d,filemame)
713 #===========================================================================
714 def test_DumpAndLoad_Constant_ContinuousFunction_Rank0(self):
715 if loadIsConfigured():
716 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank0.nc")
717 d=Data(self.arg0,ContinuousFunction(self.domain))
718 self._diffDataObjects(d,filemame)
719
720 def test_DumpAndLoad_Constant_ContinuousFunction_Rank1(self):
721 if loadIsConfigured():
722 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank1.nc")
723 d=Data(self.arg1,ContinuousFunction(self.domain))
724 self._diffDataObjects(d,filemame)
725
726 def test_DumpAndLoad_Constant_ContinuousFunction_Rank2(self):
727 if loadIsConfigured():
728 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank2.nc")
729 d=Data(self.arg2,ContinuousFunction(self.domain))
730 self._diffDataObjects(d,filemame)
731
732 def test_DumpAndLoad_Constant_ContinuousFunction_Rank3(self):
733 if loadIsConfigured():
734 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank3.nc")
735 d=Data(self.arg3,ContinuousFunction(self.domain))
736 self._diffDataObjects(d,filemame)
737
738 def test_DumpAndLoad_Constant_ContinuousFunction_Rank4(self):
739 if loadIsConfigured():
740 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank4.nc")
741 d=Data(self.arg4,ContinuousFunction(self.domain))
742 self._diffDataObjects(d,filemame)
743
744 #===========================================================================
745 def test_DumpAndLoad_Constant_Function_Rank0(self):
746 if loadIsConfigured():
747 filemame=os.path.join(self.filename_base,"constant_function_rank0.nc")
748 d=Data(self.arg0,Function(self.domain))
749 self._diffDataObjects(d,filemame)
750
751 def test_DumpAndLoad_Constant_Function_Rank1(self):
752 if loadIsConfigured():
753 filemame=os.path.join(self.filename_base,"constant_function_rank1.nc")
754 d=Data(self.arg1,Function(self.domain))
755 self._diffDataObjects(d,filemame)
756
757 def test_DumpAndLoad_Constant_Function_Rank2(self):
758 if loadIsConfigured():
759 filemame=os.path.join(self.filename_base,"constant_function_rank2.nc")
760 d=Data(self.arg2,Function(self.domain))
761 self._diffDataObjects(d,filemame)
762
763 def test_DumpAndLoad_Constant_Function_Rank3(self):
764 if loadIsConfigured():
765 filemame=os.path.join(self.filename_base,"constant_function_rank3.nc")
766 d=Data(self.arg3,Function(self.domain))
767 self._diffDataObjects(d,filemame)
768
769 #===========================================================================
770 def test_DumpAndLoad_Constant_ReducedFunction_Rank0(self):
771 if loadIsConfigured():
772 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank0.nc")
773 d=Data(self.arg0,ReducedFunction(self.domain))
774 self._diffDataObjects(d,filemame)
775
776 def test_DumpAndLoad_Constant_ReducedFunction_Rank1(self):
777 if loadIsConfigured():
778 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank1.nc")
779 d=Data(self.arg1,ReducedFunction(self.domain))
780 self._diffDataObjects(d,filemame)
781
782 def test_DumpAndLoad_Constant_ReducedFunction_Rank2(self):
783 if loadIsConfigured():
784 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank2.nc")
785 d=Data(self.arg2,ReducedFunction(self.domain))
786 self._diffDataObjects(d,filemame)
787
788 def test_DumpAndLoad_Constant_ReducedFunction_Rank3(self):
789 if loadIsConfigured():
790 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank3.nc")
791 d=Data(self.arg3,ReducedFunction(self.domain))
792 self._diffDataObjects(d,filemame)
793 def test_DumpAndLoad_Constant_ReducedFunction_Rank4(self):
794 if loadIsConfigured():
795 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank4.nc")
796 d=Data(self.arg4,ReducedFunction(self.domain))
797 self._diffDataObjects(d,filemame)
798
799 #===========================================================================
800 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank0(self):
801 if loadIsConfigured():
802 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank0.nc")
803 d=Data(self.arg0,FunctionOnBoundary(self.domain))
804 self._diffDataObjects(d,filemame)
805
806 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank1(self):
807 if loadIsConfigured():
808 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank1.nc")
809 d=Data(self.arg1,FunctionOnBoundary(self.domain))
810 self._diffDataObjects(d,filemame)
811
812 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank2(self):
813 if loadIsConfigured():
814 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank2.nc")
815 d=Data(self.arg2,FunctionOnBoundary(self.domain))
816 self._diffDataObjects(d,filemame)
817
818 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank3(self):
819 if loadIsConfigured():
820 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank3.nc")
821 d=Data(self.arg3,FunctionOnBoundary(self.domain))
822 self._diffDataObjects(d,filemame)
823
824 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank4(self):
825 if loadIsConfigured():
826 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank4.nc")
827 d=Data(self.arg4,FunctionOnBoundary(self.domain))
828 self._diffDataObjects(d,filemame)
829
830 #===========================================================================
831 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank0(self):
832 if loadIsConfigured():
833 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank0.nc")
834 d=Data(self.arg0,FunctionOnBoundary(self.domain))
835 self._diffDataObjects(d,filemame)
836
837 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank1(self):
838 if loadIsConfigured():
839 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank1.nc")
840 d=Data(self.arg1,ReducedFunctionOnBoundary(self.domain))
841 self._diffDataObjects(d,filemame)
842
843 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank2(self):
844 if loadIsConfigured():
845 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank2.nc")
846 d=Data(self.arg2,ReducedFunctionOnBoundary(self.domain))
847 self._diffDataObjects(d,filemame)
848
849 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank3(self):
850 if loadIsConfigured():
851 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank3.nc")
852 d=Data(self.arg3,ReducedFunctionOnBoundary(self.domain))
853 self._diffDataObjects(d,filemame)
854
855 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank4(self):
856 if loadIsConfigured():
857 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank4.nc")
858 d=Data(self.arg4,ReducedFunctionOnBoundary(self.domain))
859 self._diffDataObjects(d,filemame)
860
861 #===========================================================================
862 def test_DumpAndLoad_Expanded_Solution_Rank0(self):
863 if loadIsConfigured():
864 filemame=os.path.join(self.filename_base,"expanded_solution_rank0.nc")
865 d=Data(length(Solution(self.domain).getX())*self.arg0,Solution(self.domain))
866 self._diffDataObjects(d,filemame)
867 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
868 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
869 if getMPISizeWorld() ==1:
870 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg0,Solution(self.domain_with_different_sample_ordering))
871 self._diffDataObjects(d,filemame, use_old_file=True)
872
873 def test_DumpAndLoad_Expanded_Solution_Rank1(self):
874 if loadIsConfigured():
875 filemame=os.path.join(self.filename_base,"expanded_solution_rank1.nc")
876 d=Data(length(Solution(self.domain).getX())*self.arg1,Solution(self.domain))
877 self._diffDataObjects(d,filemame)
878 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
879 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
880 if getMPISizeWorld() ==1:
881 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg1,Solution(self.domain_with_different_sample_ordering))
882 self._diffDataObjects(d,filemame, use_old_file=True)
883
884 def test_DumpAndLoad_Expanded_Solution_Rank2(self):
885 if loadIsConfigured():
886 filemame=os.path.join(self.filename_base,"expanded_solution_rank2.nc")
887 d=Data(length(Solution(self.domain).getX())*self.arg2,Solution(self.domain))
888 self._diffDataObjects(d,filemame)
889 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
890 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
891 if getMPISizeWorld() ==1:
892 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg2,Solution(self.domain_with_different_sample_ordering))
893 self._diffDataObjects(d,filemame, use_old_file=True)
894
895 def test_DumpAndLoad_Expanded_Solution_Rank3(self):
896 if loadIsConfigured():
897 filemame=os.path.join(self.filename_base,"expanded_solution_rank3.nc")
898 d=Data(length(Solution(self.domain).getX())*self.arg3,Solution(self.domain))
899 self._diffDataObjects(d,filemame)
900 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
901 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
902 if getMPISizeWorld() ==1:
903 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg3,Solution(self.domain_with_different_sample_ordering))
904 self._diffDataObjects(d,filemame, use_old_file=True)
905
906 def test_DumpAndLoad_Expanded_Solution_Rank4(self):
907 if loadIsConfigured():
908 filemame=os.path.join(self.filename_base,"expanded_solution_rank4.nc")
909 d=Data(length(Solution(self.domain).getX())*self.arg4,Solution(self.domain))
910 self._diffDataObjects(d,filemame)
911 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
912 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
913 if getMPISizeWorld() ==1:
914 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg4,Solution(self.domain_with_different_sample_ordering))
915 self._diffDataObjects(d,filemame, use_old_file=True)
916 #===========================================================================
917 def test_DumpAndLoad_Expanded_ReducedSolution_Rank0(self):
918 if loadIsConfigured():
919 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank0.nc")
920 d=Data(length(ReducedSolution(self.domain).getX())*self.arg0,ReducedSolution(self.domain))
921 self._diffDataObjects(d,filemame)
922 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
923 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
924 if getMPISizeWorld() ==1:
925 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg0,ReducedSolution(self.domain_with_different_sample_ordering))
926 self._diffDataObjects(d,filemame, use_old_file=True)
927
928 def test_DumpAndLoad_Expanded_ReducedSolution_Rank1(self):
929 if loadIsConfigured():
930 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank1.nc")
931 d=Data(length(ReducedSolution(self.domain).getX())*self.arg1,ReducedSolution(self.domain))
932 self._diffDataObjects(d,filemame)
933 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
934 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
935 if getMPISizeWorld() ==1:
936 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg1,ReducedSolution(self.domain_with_different_sample_ordering))
937 self._diffDataObjects(d,filemame, use_old_file=True)
938
939 def test_DumpAndLoad_Expanded_ReducedSolution_Rank2(self):
940 if loadIsConfigured():
941 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank2.nc")
942 d=Data(length(ReducedSolution(self.domain).getX())*self.arg2,ReducedSolution(self.domain))
943 self._diffDataObjects(d,filemame)
944 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
945 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
946 if getMPISizeWorld() ==1:
947 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg2,ReducedSolution(self.domain_with_different_sample_ordering))
948 self._diffDataObjects(d,filemame, use_old_file=True)
949
950 def test_DumpAndLoad_Expanded_ReducedSolution_Rank3(self):
951 if loadIsConfigured():
952 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank3.nc")
953 d=Data(length(ReducedSolution(self.domain).getX())*self.arg3,ReducedSolution(self.domain))
954 self._diffDataObjects(d,filemame)
955 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
956 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
957 if getMPISizeWorld() ==1:
958 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg3,ReducedSolution(self.domain_with_different_sample_ordering))
959 self._diffDataObjects(d,filemame, use_old_file=True)
960
961 def test_DumpAndLoad_Expanded_ReducedSolution_Rank4(self):
962 if loadIsConfigured():
963 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank4.nc")
964 d=Data(length(ReducedSolution(self.domain).getX())*self.arg4,ReducedSolution(self.domain))
965 self._diffDataObjects(d,filemame)
966 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
967 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
968 if getMPISizeWorld() ==1:
969 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg4,ReducedSolution(self.domain_with_different_sample_ordering))
970 self._diffDataObjects(d,filemame, use_old_file=True)
971 #===========================================================================
972 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank0(self):
973 if loadIsConfigured():
974 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank0.nc")
975 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg0,ContinuousFunction(self.domain))
976 self._diffDataObjects(d,filemame)
977 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
978 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
979 if getMPISizeWorld() ==1:
980 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg0,ContinuousFunction(self.domain_with_different_sample_ordering))
981 self._diffDataObjects(d,filemame, use_old_file=True)
982
983 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank1(self):
984 if loadIsConfigured():
985 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank1.nc")
986 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
987 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg1,ContinuousFunction(self.domain))
988 self._diffDataObjects(d,filemame)
989 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
990 if getMPISizeWorld() ==1:
991 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg1,ContinuousFunction(self.domain_with_different_sample_ordering))
992 self._diffDataObjects(d,filemame, use_old_file=True)
993
994 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank2(self):
995 if loadIsConfigured():
996 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank2.nc")
997 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg2,ContinuousFunction(self.domain))
998 self._diffDataObjects(d,filemame)
999 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1000 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1001 if getMPISizeWorld() ==1:
1002 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg2,ContinuousFunction(self.domain_with_different_sample_ordering))
1003 self._diffDataObjects(d,filemame, use_old_file=True)
1004
1005 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank3(self):
1006 if loadIsConfigured():
1007 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank3.nc")
1008 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg3,ContinuousFunction(self.domain))
1009 self._diffDataObjects(d,filemame)
1010 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1011 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1012 if getMPISizeWorld() ==1:
1013 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg3,ContinuousFunction(self.domain_with_different_sample_ordering))
1014 self._diffDataObjects(d,filemame, use_old_file=True)
1015
1016 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank4(self):
1017 if loadIsConfigured():
1018 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank4.nc")
1019 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg4,ContinuousFunction(self.domain))
1020 self._diffDataObjects(d,filemame)
1021 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1022 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1023 if getMPISizeWorld() ==1:
1024 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg4,ContinuousFunction(self.domain_with_different_sample_ordering))
1025 self._diffDataObjects(d,filemame, use_old_file=True)
1026
1027 #===========================================================================
1028 def test_DumpAndLoad_Expanded_Function_Rank0(self):
1029 if loadIsConfigured():
1030 filemame=os.path.join(self.filename_base,"expanded_function_rank0.nc")
1031 d=Data(length(Function(self.domain).getX())*self.arg0,Function(self.domain))
1032 self._diffDataObjects(d,filemame)
1033 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1034 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1035 if getMPISizeWorld() ==1:
1036 d=Data(length(Function(self.domain_with_different_sample_ordering).getX())*self.arg0,Function(self.domain_with_different_sample_ordering))
1037 self._diffDataObjects(d,filemame, use_old_file=True)
1038
1039 def test_DumpAndLoad_Expanded_Function_Rank1(self):
1040 if loadIsConfigured():
1041 filemame=os.path.join(self.filename_base,"expanded_function_rank1.nc")
1042 d=Data(length(Function(self.domain).getX())*self.arg1,Function(self.domain))
1043 self._diffDataObjects(d,filemame)
1044 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1045 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1046 if getMPISizeWorld() ==1:
1047 d=Data(length(Function(self.domain_with_different_sample_ordering).getX())*self.arg1,Function(self.domain_with_different_sample_ordering))
1048 self._diffDataObjects(d,filemame, use_old_file=True)
1049
1050 def test_DumpAndLoad_Expanded_Function_Rank2(self):
1051 if loadIsConfigured():
1052 filemame=os.path.join(self.filename_base,"expanded_function_rank2.nc")
1053 d=Data(length(Function(self.domain).getX())*self.arg2,Function(self.domain))
1054 self._diffDataObjects(d,filemame)
1055 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1056 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1057 if getMPISizeWorld() ==1:
1058 d=Data(length(Function(self.domain_with_different_sample_ordering).getX())*self.arg2,Function(self.domain_with_different_sample_ordering))
1059 self._diffDataObjects(d,filemame, use_old_file=True)
1060
1061 def test_DumpAndLoad_Expanded_Function_Rank3(self):
1062 if loadIsConfigured():
1063 filemame=os.path.join(self.filename_base,"expanded_function_rank3.nc")
1064 d=Data(length(Function(self.domain).getX())*self.arg3,Function(self.domain))
1065 self._diffDataObjects(d,filemame)
1066 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1067 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1068 if getMPISizeWorld() ==1:
1069 d=Data(length(Function(self.domain_with_different_sample_ordering).getX())*self.arg3,Function(self.domain_with_different_sample_ordering))
1070 self._diffDataObjects(d,filemame, use_old_file=True)
1071
1072 def test_DumpAndLoad_Expanded_Function_Rank4(self):
1073 if loadIsConfigured():
1074 filemame=os.path.join(self.filename_base,"expanded_function_rank4.nc")
1075 d=Data(length(Function(self.domain).getX())*self.arg4,Function(self.domain))
1076 self._diffDataObjects(d,filemame)
1077 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1078 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1079 if getMPISizeWorld() ==1:
1080 d=Data(length(Function(self.domain_with_different_sample_ordering).getX())*self.arg4,Function(self.domain_with_different_sample_ordering))
1081 self._diffDataObjects(d,filemame, use_old_file=True)
1082
1083 #===========================================================================
1084 def test_DumpAndLoad_Expanded_ReducedFunction_Rank0(self):
1085 if loadIsConfigured():
1086 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank0.nc")
1087 d=Data(length(ReducedFunction(self.domain).getX())*self.arg0,ReducedFunction(self.domain))
1088 self._diffDataObjects(d,filemame)
1089 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1090 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1091 if getMPISizeWorld() ==1:
1092 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg0,ReducedFunction(self.domain_with_different_sample_ordering))
1093 self._diffDataObjects(d,filemame, use_old_file=True)
1094
1095 def test_DumpAndLoad_Expanded_ReducedFunction_Rank1(self):
1096 if loadIsConfigured():
1097 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank1.nc")
1098 d=Data(length(ReducedFunction(self.domain).getX())*self.arg1,ReducedFunction(self.domain))
1099 self._diffDataObjects(d,filemame)
1100 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1101 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1102 if getMPISizeWorld() ==1:
1103 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg1,ReducedFunction(self.domain_with_different_sample_ordering))
1104 self._diffDataObjects(d,filemame, use_old_file=True)
1105
1106 def test_DumpAndLoad_Expanded_ReducedFunction_Rank2(self):
1107 if loadIsConfigured():
1108 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank2.nc")
1109 d=Data(length(ReducedFunction(self.domain).getX())*self.arg2,ReducedFunction(self.domain))
1110 self._diffDataObjects(d,filemame)
1111 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1112 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1113 if getMPISizeWorld() ==1:
1114 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg2,ReducedFunction(self.domain_with_different_sample_ordering))
1115 self._diffDataObjects(d,filemame, use_old_file=True)
1116
1117 def test_DumpAndLoad_Expanded_ReducedFunction_Rank3(self):
1118 if loadIsConfigured():
1119 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank3.nc")
1120 d=Data(length(ReducedFunction(self.domain).getX())*self.arg3,ReducedFunction(self.domain))
1121 self._diffDataObjects(d,filemame)
1122 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1123 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1124 if getMPISizeWorld() ==1:
1125 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg3,ReducedFunction(self.domain_with_different_sample_ordering))
1126 self._diffDataObjects(d,filemame, use_old_file=True)
1127
1128 def test_DumpAndLoad_Expanded_ReducedFunction_Rank4(self):
1129 if loadIsConfigured():
1130 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank4.nc")
1131 d=Data(length(ReducedFunction(self.domain).getX())*self.arg4,ReducedFunction(self.domain))
1132 self._diffDataObjects(d,filemame)
1133 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1134 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1135 if getMPISizeWorld() ==1:
1136 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg4,ReducedFunction(self.domain_with_different_sample_ordering))
1137 self._diffDataObjects(d,filemame, use_old_file=True)
1138
1139 #===========================================================================
1140 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank0(self):
1141 if loadIsConfigured():
1142 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank0.nc")
1143 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg0,FunctionOnBoundary(self.domain))
1144 self._diffDataObjects(d,filemame)
1145 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1146 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1147 if getMPISizeWorld() ==1:
1148 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg0,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1149 self._diffDataObjects(d,filemame, use_old_file=True)
1150
1151 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank1(self):
1152 if loadIsConfigured():
1153 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank1.nc")
1154 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg1,FunctionOnBoundary(self.domain))
1155 self._diffDataObjects(d,filemame)
1156 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1157 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1158 if getMPISizeWorld() ==1:
1159 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg1,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1160 self._diffDataObjects(d,filemame, use_old_file=True)
1161
1162 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank2(self):
1163 if loadIsConfigured():
1164 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank2.nc")
1165 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg2,FunctionOnBoundary(self.domain))
1166 self._diffDataObjects(d,filemame)
1167 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1168 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1169 if getMPISizeWorld() ==1:
1170 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg2,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1171 self._diffDataObjects(d,filemame, use_old_file=True)
1172
1173 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank3(self):
1174 if loadIsConfigured():
1175 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank3.nc")
1176 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg3,FunctionOnBoundary(self.domain))
1177 self._diffDataObjects(d,filemame)
1178 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1179 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1180 if getMPISizeWorld() ==1:
1181 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg3,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1182 self._diffDataObjects(d,filemame, use_old_file=True)
1183
1184 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank4(self):
1185 if loadIsConfigured():
1186 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank4.nc")
1187 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg4,FunctionOnBoundary(self.domain))
1188 self._diffDataObjects(d,filemame)
1189 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1190 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1191 if getMPISizeWorld() ==1:
1192 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg4,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1193 self._diffDataObjects(d,filemame, use_old_file=True)
1194
1195 #===========================================================================
1196 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank0(self):
1197 if loadIsConfigured():
1198 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank0.nc")
1199 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg0,ReducedFunctionOnBoundary(self.domain))
1200 self._diffDataObjects(d,filemame)
1201 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1202 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1203 if getMPISizeWorld() ==1:
1204 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg0,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1205 self._diffDataObjects(d,filemame, use_old_file=True)
1206
1207 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank1(self):
1208 if loadIsConfigured():
1209 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank1.nc")
1210 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg1,ReducedFunctionOnBoundary(self.domain))
1211 self._diffDataObjects(d,filemame)
1212 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1213 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1214 if getMPISizeWorld() ==1:
1215 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg1,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1216 self._diffDataObjects(d,filemame, use_old_file=True)
1217
1218 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank2(self):
1219 if loadIsConfigured():
1220 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank2.nc")
1221 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg2,ReducedFunctionOnBoundary(self.domain))
1222 self._diffDataObjects(d,filemame)
1223 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1224 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1225 if getMPISizeWorld() ==1:
1226 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg2,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1227 self._diffDataObjects(d,filemame, use_old_file=True)
1228
1229 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank3(self):
1230 if loadIsConfigured():
1231 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank3.nc")
1232 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg3,ReducedFunctionOnBoundary(self.domain))
1233 self._diffDataObjects(d,filemame)
1234 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1235 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1236 if getMPISizeWorld() ==1:
1237 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg3,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1238 self._diffDataObjects(d,filemame, use_old_file=True)
1239
1240 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank4(self):
1241 if loadIsConfigured():
1242 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank4.nc")
1243 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg4,ReducedFunctionOnBoundary(self.domain))
1244 self._diffDataObjects(d,filemame)
1245 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1246 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1247 if getMPISizeWorld() ==1:
1248 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg4,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1249 self._diffDataObjects(d,filemame, use_old_file=True)
1250
1251 #===========================================================================
1252 ## This functionspace does not currently support tags.
1253 ## Instead, we test that the canTag() function throws in test_canTag_Failures.
1254
1255 #def test_DumpAndLoad_Tagged_Solution_Rank0(self):
1256 #if loadIsConfigured():
1257 #filemame=os.path.join(self.filename_base,"tagged_solution_rank0.nc")
1258 #d=Data(self.arg0,Solution(self.domain))
1259 #d.setTaggedValue(1,self.arg0*2)
1260 #d.setTaggedValue(10,self.arg0*3)
1261 #d.setTaggedValue(100,self.arg0*4)
1262 #self._diffDataObjects(d,filemame)
1263
1264 #def test_DumpAndLoad_Tagged_Solution_Rank1(self):
1265 #if loadIsConfigured():
1266 #filemame=os.path.join(self.filename_base,"tagged_solution_rank1.nc")
1267 #d=Data(self.arg1,Solution(self.domain))
1268 #d.setTaggedValue(1,self.arg1*2)
1269 #d.setTaggedValue(10,self.arg1*3)
1270 #d.setTaggedValue(100,self.arg1*4)
1271 #self._diffDataObjects(d,filemame)
1272
1273 #def test_DumpAndLoad_Tagged_Solution_Rank2(self):
1274 #if loadIsConfigured():
1275 #filemame=os.path.join(self.filename_base,"tagged_solution_rank2.nc")
1276 #d=Data(self.arg2,Solution(self.domain))
1277 #d.setTaggedValue(1,self.arg2*2)
1278 #d.setTaggedValue(10,self.arg2*3)
1279 #d.setTaggedValue(100,self.arg2*4)
1280 #self._diffDataObjects(d,filemame)
1281
1282 #def test_DumpAndLoad_Tagged_Solution_Rank3(self):
1283 #if loadIsConfigured():
1284 #filemame=os.path.join(self.filename_base,"tagged_solution_rank3.nc")
1285 #d=Data(self.arg3,Solution(self.domain))
1286 #d.setTaggedValue(1,self.arg3*2)
1287 #d.setTaggedValue(10,self.arg3*3)
1288 #d.setTaggedValue(100,self.arg3*4)
1289 #self._diffDataObjects(d,filemame)
1290
1291 #def test_DumpAndLoad_Tagged_Solution_Rank4(self):
1292 #if loadIsConfigured():
1293 #filemame=os.path.join(self.filename_base,"tagged_solution_rank4.nc")
1294 #d=Data(self.arg4,Solution(self.domain))
1295 #d.setTaggedValue(1,self.arg4*2)
1296 #d.setTaggedValue(10,self.arg4*3)
1297 #d.setTaggedValue(100,self.arg4*4)
1298 #self._diffDataObjects(d,filemame)
1299 ##===========================================================================
1300 ## This functionspace does not currently support tags.
1301 ## Instead, we test that the canTag() function throws in test_canTag_Failures.
1302
1303 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank0(self):
1304 #if loadIsConfigured():
1305 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank0.nc")
1306 #d=Data(self.arg0,ReducedSolution(self.domain))
1307 #d.setTaggedValue(1,self.arg0*2)
1308 #d.setTaggedValue(10,self.arg0*3)
1309 #d.setTaggedValue(100,self.arg0*4)
1310 #self._diffDataObjects(d,filemame)
1311
1312 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank1(self):
1313 #if loadIsConfigured():
1314 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank1.nc")
1315 #d=Data(self.arg1,ReducedSolution(self.domain))
1316 #d.setTaggedValue(1,self.arg1*2)
1317 #d.setTaggedValue(10,self.arg1*3)
1318 #d.setTaggedValue(100,self.arg1*4)
1319 #self._diffDataObjects(d,filemame)
1320
1321 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank2(self):
1322 #if loadIsConfigured():
1323 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank2.nc")
1324 #d=Data(self.arg2,ReducedSolution(self.domain))
1325 #d.setTaggedValue(1,self.arg2*2)
1326 #d.setTaggedValue(10,self.arg2*3)
1327 #d.setTaggedValue(100,self.arg2*4)
1328 #self._diffDataObjects(d,filemame)
1329
1330 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank3(self):
1331 #if loadIsConfigured():
1332 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank3.nc")
1333 #d=Data(self.arg3,ReducedSolution(self.domain))
1334 #d.setTaggedValue(1,self.arg3*2)
1335 #d.setTaggedValue(10,self.arg3*3)
1336 #d.setTaggedValue(100,self.arg3*4)
1337 #self._diffDataObjects(d,filemame)
1338
1339 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank4(self):
1340 #if loadIsConfigured():
1341 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank4.nc")
1342 #d=Data(self.arg4,ReducedSolution(self.domain))
1343 #d.setTaggedValue(1,self.arg4*2)
1344 #d.setTaggedValue(10,self.arg4*3)
1345 #d.setTaggedValue(100,self.arg4*4)
1346 #self._diffDataObjects(d,filemame)
1347 ##===========================================================================
1348 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank0(self):
1349 if loadIsConfigured():
1350 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank0.nc")
1351 d=Data(self.arg0,ContinuousFunction(self.domain))
1352 d.setTaggedValue(1,self.arg0*2)
1353 d.setTaggedValue(10,self.arg0*3)
1354 d.setTaggedValue(100,self.arg0*4)
1355 self._diffDataObjects(d,filemame)
1356
1357 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank1(self):
1358 if loadIsConfigured():
1359 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank1.nc")
1360 d=Data(self.arg1,ContinuousFunction(self.domain))
1361 d.setTaggedValue(1,self.arg1*2)
1362 d.setTaggedValue(10,self.arg1*3)
1363 d.setTaggedValue(100,self.arg1*4)
1364 self._diffDataObjects(d,filemame)
1365
1366 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank2(self):
1367 if loadIsConfigured():
1368 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank2.nc")
1369 d=Data(self.arg2,ContinuousFunction(self.domain))
1370 d.setTaggedValue(1,self.arg2*2)
1371 d.setTaggedValue(10,self.arg2*3)
1372 d.setTaggedValue(100,self.arg2*4)
1373 self._diffDataObjects(d,filemame)
1374
1375 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank3(self):
1376 if loadIsConfigured():
1377 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank3.nc")
1378 d=Data(self.arg3,ContinuousFunction(self.domain))
1379 d.setTaggedValue(1,self.arg3*2)
1380 d.setTaggedValue(10,self.arg3*3)
1381 d.setTaggedValue(100,self.arg3*4)
1382 self._diffDataObjects(d,filemame)
1383
1384 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank4(self):
1385 if loadIsConfigured():
1386 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank4.nc")
1387 d=Data(self.arg4,ContinuousFunction(self.domain))
1388 d.setTaggedValue(1,self.arg4*2)
1389 d.setTaggedValue(10,self.arg4*3)
1390 d.setTaggedValue(100,self.arg4*4)
1391 self._diffDataObjects(d,filemame)
1392
1393 #===========================================================================
1394 def test_DumpAndLoad_Tagged_Function_Rank0(self):
1395 if loadIsConfigured():
1396 filemame=os.path.join(self.filename_base,"tagged_function_rank0.nc")
1397 d=Data(self.arg0,Function(self.domain))
1398 d.setTaggedValue(1,self.arg0*2)
1399 d.setTaggedValue(10,self.arg0*3)
1400 d.setTaggedValue(100,self.arg0*4)
1401 self._diffDataObjects(d,filemame)
1402
1403 def test_DumpAndLoad_Tagged_Function_Rank1(self):
1404 if loadIsConfigured():
1405 filemame=os.path.join(self.filename_base,"tagged_function_rank1.nc")
1406 d=Data(self.arg1,Function(self.domain))
1407 d.setTaggedValue(1,self.arg1*2)
1408 d.setTaggedValue(10,self.arg1*3)
1409 d.setTaggedValue(100,self.arg1*4)
1410 self._diffDataObjects(d,filemame)
1411
1412 def test_DumpAndLoad_Tagged_Function_Rank2(self):
1413 if loadIsConfigured():
1414 filemame=os.path.join(self.filename_base,"tagged_function_rank2.nc")
1415 d=Data(self.arg2,Function(self.domain))
1416 d.setTaggedValue(1,self.arg2*2)
1417 d.setTaggedValue(10,self.arg2*3)
1418 d.setTaggedValue(100,self.arg2*4)
1419 self._diffDataObjects(d,filemame)
1420
1421 def test_DumpAndLoad_Tagged_Function_Rank3(self):
1422 if loadIsConfigured():
1423 filemame=os.path.join(self.filename_base,"tagged_function_rank3.nc")
1424 d=Data(self.arg3,Function(self.domain))
1425 d.setTaggedValue(1,self.arg3*2)
1426 d.setTaggedValue(10,self.arg3*3)
1427 d.setTaggedValue(100,self.arg3*4)
1428 self._diffDataObjects(d,filemame)
1429
1430 def test_DumpAndLoad_Tagged_Function_Rank4(self):
1431 if loadIsConfigured():
1432 filemame=os.path.join(self.filename_base,"tagged_function_rank4.nc")
1433 d=Data(self.arg4,Function(self.domain))
1434 d.setTaggedValue(1,self.arg4*2)
1435 d.setTaggedValue(10,self.arg4*3)
1436 d.setTaggedValue(100,self.arg4*4)
1437 self._diffDataObjects(d,filemame)
1438
1439 #===========================================================================
1440 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank0(self):
1441 if loadIsConfigured():
1442 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank0.nc")
1443 d=Data(self.arg0,FunctionOnBoundary(self.domain))
1444 d.setTaggedValue(1,self.arg0*2)
1445 d.setTaggedValue(10,self.arg0*3)
1446 d.setTaggedValue(100,self.arg0*4)
1447 self._diffDataObjects(d,filemame)
1448
1449 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank1(self):
1450 if loadIsConfigured():
1451 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank1.nc")
1452 d=Data(self.arg1,FunctionOnBoundary(self.domain))
1453 d.setTaggedValue(1,self.arg1*2)
1454 d.setTaggedValue(10,self.arg1*3)
1455 d.setTaggedValue(100,self.arg1*4)
1456 self._diffDataObjects(d,filemame)
1457
1458 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank2(self):
1459 if loadIsConfigured():
1460 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank2.nc")
1461 d=Data(self.arg2,FunctionOnBoundary(self.domain))
1462 d.setTaggedValue(1,self.arg2*2)
1463 d.setTaggedValue(10,self.arg2*3)
1464 d.setTaggedValue(100,self.arg2*4)
1465 self._diffDataObjects(d,filemame)
1466
1467 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank3(self):
1468 if loadIsConfigured():
1469 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank3.nc")
1470 d=Data(self.arg3,FunctionOnBoundary(self.domain))
1471 d.setTaggedValue(1,self.arg3*2)
1472 d.setTaggedValue(10,self.arg3*3)
1473 d.setTaggedValue(100,self.arg3*4)
1474 self._diffDataObjects(d,filemame)
1475
1476 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank4(self):
1477 if loadIsConfigured():
1478 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank4.nc")
1479 d=Data(self.arg4,FunctionOnBoundary(self.domain))
1480 d.setTaggedValue(1,self.arg4*2)
1481 d.setTaggedValue(10,self.arg4*3)
1482 d.setTaggedValue(100,self.arg4*4)
1483 self._diffDataObjects(d,filemame)
1484 #===========================================================================
1485 def test_DumpAndLoad_Tagged_ReducedFunction_Rank0(self):
1486 if loadIsConfigured():
1487 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank0.nc")
1488 d=Data(self.arg0,ReducedFunction(self.domain))
1489 d.setTaggedValue(1,self.arg0*2)
1490 d.setTaggedValue(10,self.arg0*3)
1491 d.setTaggedValue(100,self.arg0*4)
1492 self._diffDataObjects(d,filemame)
1493
1494 def test_DumpAndLoad_Tagged_ReducedFunction_Rank1(self):
1495 if loadIsConfigured():
1496 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank1.nc")
1497 d=Data(self.arg1,ReducedFunction(self.domain))
1498 d.setTaggedValue(1,self.arg1*2)
1499 d.setTaggedValue(10,self.arg1*3)
1500 d.setTaggedValue(100,self.arg1*4)
1501 self._diffDataObjects(d,filemame)
1502
1503 def test_DumpAndLoad_Tagged_ReducedFunction_Rank2(self):
1504 if loadIsConfigured():
1505 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank2.nc")
1506 d=Data(self.arg2,ReducedFunction(self.domain))
1507 d.setTaggedValue(1,self.arg2*2)
1508 d.setTaggedValue(10,self.arg2*3)
1509 d.setTaggedValue(100,self.arg2*4)
1510 self._diffDataObjects(d,filemame)
1511
1512 def test_DumpAndLoad_Tagged_ReducedFunction_Rank3(self):
1513 if loadIsConfigured():
1514 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank3.nc")
1515 d=Data(self.arg3,ReducedFunction(self.domain))
1516 d.setTaggedValue(1,self.arg3*2)
1517 d.setTaggedValue(10,self.arg3*3)
1518 d.setTaggedValue(100,self.arg3*4)
1519 self._diffDataObjects(d,filemame)
1520
1521 def test_DumpAndLoad_Tagged_ReducedFunction_Rank4(self):
1522 if loadIsConfigured():
1523 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank4.nc")
1524 d=Data(self.arg4,ReducedFunction(self.domain))
1525 d.setTaggedValue(1,self.arg4*2)
1526 d.setTaggedValue(10,self.arg4*3)
1527 d.setTaggedValue(100,self.arg4*4)
1528 self._diffDataObjects(d,filemame)
1529
1530 #===========================================================================
1531 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank0(self):
1532 if loadIsConfigured():
1533 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank0.nc")
1534 d=Data(self.arg0,ReducedFunctionOnBoundary(self.domain))
1535 d.setTaggedValue(1,self.arg0*2)
1536 d.setTaggedValue(10,self.arg0*3)
1537 d.setTaggedValue(100,self.arg0*4)
1538 self._diffDataObjects(d,filemame)
1539
1540 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank1(self):
1541 if loadIsConfigured():
1542 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank1.nc")
1543 d=Data(self.arg1,ReducedFunctionOnBoundary(self.domain))
1544 d.setTaggedValue(1,self.arg1*2)
1545 d.setTaggedValue(10,self.arg1*3)
1546 d.setTaggedValue(100,self.arg1*4)
1547 self._diffDataObjects(d,filemame)
1548
1549 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank2(self):
1550 if loadIsConfigured():
1551 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank2.nc")
1552 d=Data(self.arg2,ReducedFunctionOnBoundary(self.domain))
1553 d.setTaggedValue(1,self.arg2*2)
1554 d.setTaggedValue(10,self.arg2*3)
1555 d.setTaggedValue(100,self.arg2*4)
1556 self._diffDataObjects(d,filemame)
1557
1558 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank3(self):
1559 if loadIsConfigured():
1560 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank3.nc")
1561 d=Data(self.arg3,ReducedFunctionOnBoundary(self.domain))
1562 d.setTaggedValue(1,self.arg3*2)
1563 d.setTaggedValue(10,self.arg3*3)
1564 d.setTaggedValue(100,self.arg3*4)
1565 self._diffDataObjects(d,filemame)
1566
1567 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank4(self):
1568 if loadIsConfigured():
1569 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank4.nc")
1570 d=Data(self.arg4,ReducedFunctionOnBoundary(self.domain))
1571 d.setTaggedValue(1,self.arg4*2)
1572 d.setTaggedValue(10,self.arg4*3)
1573 d.setTaggedValue(100,self.arg4*4)
1574 self._diffDataObjects(d,filemame)
1575
1576 def test_canTag_Failures(self):
1577 d=Data(self.arg0,Solution(self.domain))
1578 self.failUnlessRaises(RuntimeError,d.setTaggedValue,1,self.arg0*2)
1579 d=Data(self.arg0,ReducedSolution(self.domain))
1580 self.failUnlessRaises(RuntimeError,d.setTaggedValue,1,self.arg0*2)
1581
1582 class Test_Lazy(unittest.TestCase):
1583 def makeLazyObj(self):
1584 d=delay(Data(1,self.mainfs,True))
1585 e=delay(Data(2,self.mainfs,True))
1586 p=(d+e*d)/e
1587 q=p/(3*d)
1588 r1=q*q
1589 r2=q+q
1590 r3=q/4
1591 f=delay(Data(4,self.otherfs,True))
1592 t=Data(4,self.mainfs)
1593 t.tag()
1594 t=delay(t)
1595 t=t*2
1596 return r1,r2,r3,f,t
1597
1598 def test_GroupRes(self):
1599 rr1,rr2,rr3,rf,rt=self.makeLazyObj()
1600 rr1=resolve(rr1)
1601 rr2=resolve(rr2)
1602 rr3=resolve(rr3)
1603 rf=resolve(rf)
1604 rt=resolve(rt)
1605 r1,r2,r3,f,t=self.makeLazyObj()
1606 resolveGroup((r1,r2,r3))
1607 err=Lsup(rr1-r1)+Lsup(rr2-r2)+Lsup(rr3-r3)
1608 self.failUnless(err<0.001, "Same functionspace group resolve")
1609 r1,r2,r3,f,t=self.makeLazyObj()
1610 resolveGroup((r1,r2,r3,rt))
1611 err=Lsup(rr1-r1)+Lsup(rr2-r2)+Lsup(rr3-r3)+Lsup(rt-t)
1612 self.failUnless(err<0.001, "Same functionspace group resolve with early collapse")
1613 r1,r2,r3,f,t=self.makeLazyObj()
1614 err=Lsup(rr1-r1)+Lsup(rr2-r2)+Lsup(rr3-r3)+Lsup(rt-t)+Lsup(rf-f)
1615 self.failUnless(err<0.001, "Same functionspace group resolve with mixed functionspaces")
1616
1617

  ViewVC Help
Powered by ViewVC 1.1.26