/[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 3993 - (show annotations)
Wed Sep 26 07:00:55 2012 UTC (7 years, 1 month ago) by caltinay
File MIME type: text/x-python
File size: 91220 byte(s)
Addressing mantis 651. Test for finley will fail under MPI since there is
sth wrong with the way ReducedContinuousFunction samples are interrogated.

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

  ViewVC Help
Powered by ViewVC 1.1.26