/[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 2653 - (show annotations)
Tue Sep 8 04:26:30 2009 UTC (10 years, 10 months ago) by jfenwick
File MIME type: text/x-python
File size: 83490 byte(s)
Fix bug in maxGlobalDataPoint and minGlobalDataPoint.
They now give the correct answers and the datapoint ids returned are globally
correct.

Removed some #defines from before COW
Removed hasNoSamples() - I don't trust myself to use that properly let alone anybody else.


1
2 ########################################################
3 #
4 # Copyright (c) 2003-2009 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-2009 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.finley import Brick
29 class Test_DumpOnFinley(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_DumpOnFinley))
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
57 class Test_TableInterpolation(unittest.TestCase):
58 RES_TOL=1.e-7 # RES_TOLerance to compare results
59
60
61 def test_NullFunctionSpace(self):
62 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]]
63 arn=numpy.array(arL)
64 ars=[arL,arn]
65 d0=Data(0)
66 d1=Data(1)
67 d2=Data(2)
68 d35=Data(3.5)
69 d4=Data(4)
70 dm05=Data(-0.5)
71 d175=Data(1.75)
72 d225=Data(2.25)
73 for arr in ars:
74 self.failUnless(Lsup(d1.interpolateTable(arL,0, 1, d2, 0, 1, 100)+2)<self.RES_TOL)
75 self.failUnless(Lsup(d1.interpolateTable(arL,0, 1, d35, 0, 1, 100)+3.5)<self.RES_TOL)
76 self.failUnless(Lsup(d35.interpolateTable(arL,0,1, d2, 0, 1, 100)-3.5)<self.RES_TOL)
77 self.failUnless(Lsup(d175.interpolateTable(arL,0,1,d225,0,1, 100)-0)<self.RES_TOL)
78 self.failUnless(Lsup(d2.interpolateTable(arL, 1, 4, d2, -1, 4, 100)-0.25)<self.RES_TOL)
79 # Point out of bounds
80 self.failUnlessRaises(RuntimeError, d1.interpolateTable,arL,0, 1, d4, 0, 1, 100 )
81 self.failUnlessRaises(RuntimeError, d4.interpolateTable, arL,0, 1, d1, 0, 1, 100 )
82 self.failUnlessRaises(RuntimeError, dm05.interpolateTable, arL,0,1, d1 , 0,1, 100 )
83 self.failUnlessRaises(RuntimeError, d1.interpolateTable, arL,0,1, dm05 , 0,1, 100 )
84 # interpolated value too large
85 self.failUnlessRaises(RuntimeError, d2.interpolateTable, arL, 0, 1, d2, 0, 1, 1 )
86
87
88 def test_FunctionSpace2D(self):
89 vs=[(1,3,5,7), (-1,1,-1,1), (0.5, 17, 0.25, 42)] #There is no particular significance to these numbers
90 for fs in self.functionspaces:
91 print fs
92 points=fs.getX()
93 for t in vs:
94 v0, v1, v2, v3 =t
95 x=points[0]
96 y=points[1]
97 xmax=sup(x)
98 xmin=inf(x)
99 ymax=sup(y)
100 ymin=inf(y)
101 xwidth=(xmax-xmin)/(self.xn-1)
102 ywidth=(ymax-ymin)/(self.yn-1)
103 table=[]
104 for j in xrange(self.yn+1):
105 row=[]
106 for i in xrange(self.xn+1):
107 row.append(v0+v1*xwidth*i+v2*ywidth*j+v3*i*j*xwidth*ywidth)
108 table.append(row)
109 res=y.interpolateTable(table,ymin,ywidth,x, xmin, xwidth,500)
110 ref=v0+v1*x+v2*y+v3*x*y
111 lsupref=Lsup(ref)
112 if lsupref!=0: #This will happen in cases where there are no samples on this rank
113 self.failUnless(Lsup(res-ref)/Lsup(ref)<self.RES_TOL,"Failed for %s"%str(fs))
114
115
116 def test_FunctionSpace1D(self):
117 vs=[(1,3), (-1,1), (0.5, 17)] #There is no particular significance to these numbers
118 for fs in self.functionspaces:
119 print fs
120 points=fs.getX()
121 for t in vs:
122 v0, v1 =t
123 x=points[0]
124 xmax=sup(x)
125 xmin=inf(x)
126 xwidth=(xmax-xmin)/(self.xn-1)
127 table=[]
128 for i in xrange(self.xn+1):
129 table.append(v0+v1*xwidth*i)
130 res=x.interpolateTable(table, xmin, xwidth,500)
131 ref=v0+v1*x
132 lsupref=Lsup(ref)
133 if lsupref!=0: #This will happen in cases where there are no samples on this rank
134 self.failUnless(Lsup(res-ref)/lsupref<self.RES_TOL,"Failed for %s"%str(fs))
135
136
137 class Test_saveCSV(unittest.TestCase):
138
139 def test_save1(self):
140 X=self.domain.getX()
141 X0=X[0]
142 fname="test_save1.csv"
143 saveDataCSV(fname,C=X, D=X0)
144 saveDataCSV(fname,append=True, J=X0, H=X)
145 self.failUnless(os.path.exists(fname), "test file not created")
146 f=open(fname,'r')
147 line=f.readline()
148 self.failUnless(line=="C_0, C_1, D\n") #This tests both separator strings
149 #Now we find out how many rows it has
150 linecount=0
151 while line != '':
152 linecount+=1
153 line=f.readline()
154 self.failUnless(linecount!=self.linecount1*2)
155 f.close()
156 #Now to other output
157 T2=Tensor(7,X.getFunctionSpace())
158 T3=Tensor3(8,X.getFunctionSpace())
159 T4=Tensor4(9,X.getFunctionSpace())
160 saveDataCSV(fname,A=T2,B=T3,C=T4)
161 f=open(fname,'r')
162 line=f.readline()
163 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')
164 line=f.readline()
165 self.failUnless(line=='7.000000000000000e+00, 7.000000000000000e+00, 7.000000000000000e+00, 7.000000000000000e+00, 8.000000000000000e+00, 8.000000000000000e+00, 8.000000000000000e+00, 8.000000000000000e+00, 8.000000000000000e+00, 8.000000000000000e+00, 8.000000000000000e+00, 8.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00, 9.000000000000000e+00\n')
166 linecount=1
167 while line != '':
168 linecount+=1
169 line=f.readline()
170 self.failUnless(linecount!=self.linecount1)
171 f.close()
172 #Now to test separators and mask
173 saveDataCSV(fname, sep="+",csep="/", U=X, V=X0, mask=X0)
174 f=open(fname,'r')
175 line=f.readline()
176 self.failUnless(line=='U/0+U/1+V\n')
177 line=f.readline()
178 self.failUnless(line=='1.250000000000000e-01+0.000000000000000e+00+1.250000000000000e-01\n')
179 linecount=1
180 while line!='':
181 linecount+=1
182 line=f.readline()
183 self.failUnless(linecount==self.linecount2)
184
185
186 class Test_Domain(unittest.TestCase):
187
188 def test_getListOfTags(self): # requires self.boundary_tag_list
189 tags=FunctionOnBoundary(self.domain).getListOfTags()
190 self.failUnless(len(self.boundary_tag_list) == len(tags), "tag list length does not match")
191 for i in self.boundary_tag_list:
192 self.failUnless(i in tags, "tag %s is missing."%i)
193
194 def test_addTags(self):
195 tag1="A"
196 tag2="B"
197 tag3="C"
198 self.domain.setTagMap(tag1,1)
199 self.failUnless(self.domain.isValidTagName(tag1))
200 self.failUnless(not self.domain.isValidTagName(tag2))
201 self.domain.setTagMap(tag2,2)
202 self.failUnless(self.domain.isValidTagName(tag1))
203 self.failUnless(self.domain.isValidTagName(tag2))
204 self.failUnless(not self.domain.isValidTagName(tag3))
205 self.failUnless(self.domain.getTag(tag1)==1)
206 self.failUnless(self.domain.getTag(tag2)==2)
207 self.failUnlessRaises(RuntimeError,self.domain.getTag,tag3)
208
209 # set tag:
210 s=Scalar(0,Function(self.domain))
211 r=Scalar(0,Function(self.domain))
212 s.setTaggedValue(tag1,1.)
213 r.setTaggedValue(1,1.)
214 s.setTaggedValue(tag2,2.)
215 r.setTaggedValue(2,2.)
216 self.failUnlessRaises(RuntimeError,s.setTaggedValue,tag3,3.) #tag3 does not exist
217 self.failUnless(Lsup(s-r)<=0.)
218 # get tag:
219 names=getTagNames(self.domain)
220 self.failUnless(len(names) == 6)
221 self.failUnless( tag1 in names )
222 self.failUnless( tag2 in names )
223 self.failUnless(self.domain.isValidTagName(tag1))
224 self.failUnless(self.domain.isValidTagName(tag2))
225 # insert tag shortcut:
226 s2=insertTaggedValues(Scalar(0,Function(self.domain)),**{ tag1 : 1., tag2 : 2.})
227 self.failUnless(Lsup(s2-r)<=0.)
228 def test_functionspace_ContinuousFunction(self):
229 fs=ContinuousFunction(self.domain)
230 self.failUnless(fs.getDomain()==self.domain)
231 self.failUnless(self.domain.getDim() == fs.getDim())
232 x=fs.getX()
233 self.failUnless(x.getFunctionSpace() == fs)
234 self.failUnless(x.getShape() == (fs.getDim(),))
235 self.failUnless(inf(x[0])>=0.)
236 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
237 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
238 self.failUnless(sup(x[0])<=1.)
239 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
240 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
241
242 def test_functionspace_Solution(self):
243 fs=Solution(self.domain)
244 self.failUnless(fs.getDomain()==self.domain)
245 self.failUnless(self.domain.getDim() == fs.getDim())
246 x=fs.getX()
247 self.failUnless(x.getFunctionSpace() == fs)
248 self.failUnless(x.getShape() == (fs.getDim(),))
249 self.failUnless(inf(x[0])>=0.)
250 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
251 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
252 self.failUnless(sup(x[0])<=1.)
253 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
254 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
255
256 def test_functionspace_ReducedSolution(self):
257 fs=ReducedSolution(self.domain)
258 self.failUnless(fs.getDomain()==self.domain)
259 self.failUnless(self.domain.getDim() == fs.getDim())
260 x=fs.getX()
261 self.failUnless(x.getFunctionSpace() == fs)
262 self.failUnless(x.getShape() == (fs.getDim(),))
263 self.failUnless(inf(x[0])>=0.)
264 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
265 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
266 self.failUnless(sup(x[0])<=1.)
267 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
268 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
269
270 def test_functionspace_Function(self):
271 fs=Function(self.domain)
272 self.failUnless(fs.getDomain()==self.domain)
273 self.failUnless(self.domain.getDim() == fs.getDim())
274 x=fs.getX()
275 self.failUnless(x.getFunctionSpace() == fs)
276 self.failUnless(x.getShape() == (fs.getDim(),))
277 self.failUnless(inf(x[0])>=0.)
278 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
279 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
280 self.failUnless(sup(x[0])<=1.)
281 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
282 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
283
284 def test_functionspace_ReducedFunction(self):
285 fs=ReducedFunction(self.domain)
286 self.failUnless(fs.getDomain()==self.domain)
287 self.failUnless(self.domain.getDim() == fs.getDim())
288 x=fs.getX()
289 self.failUnless(x.getFunctionSpace() == fs)
290 self.failUnless(x.getShape() == (fs.getDim(),))
291 self.failUnless(inf(x[0])>=0.)
292 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
293 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
294 self.failUnless(sup(x[0])<=1.)
295 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
296 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
297 def test_functionspace_FunctionOnBoundary(self):
298 fs=FunctionOnBoundary(self.domain)
299 self.failUnless(fs.getDomain()==self.domain)
300 self.failUnless(self.domain.getDim() == fs.getDim())
301 x=fs.getX()
302 self.failUnless(x.getFunctionSpace() == fs)
303 self.failUnless(x.getShape() == (fs.getDim(),))
304 self.failUnless(inf(x[0])>=0.)
305 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
306 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
307 self.failUnless(sup(x[0])<=1.)
308 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
309 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
310
311 def test_functionspace_ReducedFunctionOnBoundary(self):
312 fs=ReducedFunctionOnBoundary(self.domain)
313 self.failUnless(fs.getDomain()==self.domain)
314 self.failUnless(self.domain.getDim() == fs.getDim())
315 x=fs.getX()
316 self.failUnless(x.getFunctionSpace() == fs)
317 self.failUnless(x.getShape() == (fs.getDim(),))
318 self.failUnless(inf(x[0])>=0.)
319 if self.domain.getDim()>1: self.failUnless(inf(x[1])>=0.)
320 if self.domain.getDim()>2: self.failUnless(inf(x[2])>=0.)
321 self.failUnless(sup(x[0])<=1.)
322 if self.domain.getDim()>1: self.failUnless(sup(x[1])<=1.)
323 if self.domain.getDim()>2: self.failUnless(sup(x[2])<=1.)
324 #===========================================================================
325
326 class Test_GlobalMinMax(unittest.TestCase):
327 def test_GlobalMinMax(self):
328 myrank=getMPIRankWorld()
329 d=Data(myrank,Function(self.domain))
330 minproc=inf(d)
331 maxproc=sup(d) #This tells us where to expect values to be
332 if d.getNumberOfDataPoints()>0:
333 d.setValueOfDataPoint(0,myrank-0.001);
334 p,n=d.minGlobalDataPoint()
335 self.failUnless(p==minproc,"Incorrect process indentified as holding min")
336 self.failUnless(n==0,"Incorrect position for min")
337 if d.getNumberOfDataPoints()>0:
338 d.setValueOfDataPoint(0,myrank+0.001)
339 p,n=d.maxGlobalDataPoint()
340 self.failUnless(p==maxproc,"Incorrect process indentified as holding min")
341 self.failUnless(n==0,"Incorrect position for min")
342
343
344
345 class Test_SetDataPointValue(unittest.TestCase):
346 arg0=9.81
347 arg1=numpy.array([3.098, -3.111])
348 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]])
349 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]]])
350 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]]]])
351 def test_SetDataPointValue_Function_Rank0(self):
352 d=Data(self.arg0,Function(self.domain))
353 d.setValueOfDataPoint(0,self.arg0*2)
354 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
355 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg0)
356 d_0=numpy.array(d.getTupleForDataPoint(0))
357 d_1=numpy.array(d.getTupleForDataPoint(1))
358 self.failUnless(Lsup(d_0-self.arg0*2)<=Lsup(self.arg0*2), "wrong setting")
359 self.failUnless(Lsup(d_1-self.arg0)<=Lsup(self.arg0), "wrong setting")
360 def test_SetDataPointValue_Function_Rank1(self):
361 d=Data(self.arg1,Function(self.domain))
362 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
363 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
364 d.setValueOfDataPoint(0,self.arg1*2)
365 d_0=numpy.array(d.getTupleForDataPoint(0))
366 d_1=numpy.array(d.getTupleForDataPoint(1))
367 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
368 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
369 def test_SetDataPointValue_Function_Rank1_list(self):
370 d=Data(self.arg1,Function(self.domain))
371 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
372 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
373 d.setValueOfDataPoint(0,(self.arg1*2).tolist())
374 d_0=numpy.array(d.getTupleForDataPoint(0))
375 d_1=numpy.array(d.getTupleForDataPoint(1))
376 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
377 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
378 def test_SetDataPointValue_Function_Rank2(self):
379 d=Data(self.arg2,Function(self.domain))
380 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
381 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
382 d.setValueOfDataPoint(0,self.arg2*2)
383 d_0=numpy.array(d.getTupleForDataPoint(0))
384 d_1=numpy.array(d.getTupleForDataPoint(1))
385 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
386 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
387 def test_SetDataPointValue_Function_Rank2_list(self):
388 d=Data(self.arg2,Function(self.domain))
389 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
390 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
391 d.setValueOfDataPoint(0,(self.arg2*2).tolist())
392 d_0=numpy.array(d.getTupleForDataPoint(0))
393 d_1=numpy.array(d.getTupleForDataPoint(1))
394 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
395 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
396 def test_SetDataPointValue_Function_Rank3(self):
397 d=Data(self.arg3,Function(self.domain))
398 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
399 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
400 d.setValueOfDataPoint(0,self.arg3*2)
401 d_0=numpy.array(d.getTupleForDataPoint(0))
402 d_1=numpy.array(d.getTupleForDataPoint(1))
403 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
404 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
405 def test_SetDataPointValue_Function_Rank3_list(self):
406 d=Data(self.arg3,Function(self.domain))
407 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
408 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
409 d.setValueOfDataPoint(0,(self.arg3*2).tolist())
410 d_0=numpy.array(d.getTupleForDataPoint(0))
411 d_1=numpy.array(d.getTupleForDataPoint(1))
412 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
413 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
414 def test_SetDataPointValue_Function_Rank4(self):
415 d=Data(self.arg4,Function(self.domain))
416 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
417 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
418 d.setValueOfDataPoint(0,self.arg4*2)
419 d_0=numpy.array(d.getTupleForDataPoint(0))
420 d_1=numpy.array(d.getTupleForDataPoint(1))
421 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
422 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
423 def test_SetDataPointValue_Function_Rank4_list(self):
424 d=Data(self.arg4,Function(self.domain))
425 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
426 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
427 d.setValueOfDataPoint(0,(self.arg4*2).tolist())
428 d_0=numpy.array(d.getTupleForDataPoint(0))
429 d_1=numpy.array(d.getTupleForDataPoint(1))
430 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
431 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
432 #===========================================================================
433 def test_SetDataPointValue_ReducedFunction_Rank0(self):
434 d=Data(self.arg0,ReducedFunction(self.domain))
435 d.setValueOfDataPoint(0,self.arg0*2)
436 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
437 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg0)
438 d_0=numpy.array(d.getTupleForDataPoint(0))
439 d_1=numpy.array(d.getTupleForDataPoint(1))
440 self.failUnless(Lsup(d_0-self.arg0*2)<=Lsup(self.arg0*2), "wrong setting")
441 self.failUnless(Lsup(d_1-self.arg0)<=Lsup(self.arg0), "wrong setting")
442 def test_SetDataPointValue_ReducedFunction_Rank1(self):
443 d=Data(self.arg1,ReducedFunction(self.domain))
444 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
445 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
446 d.setValueOfDataPoint(0,self.arg1*2)
447 d_0=numpy.array(d.getTupleForDataPoint(0))
448 d_1=numpy.array(d.getTupleForDataPoint(1))
449 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
450 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
451 def test_SetDataPointValue_ReducedFunction_Rank1_list(self):
452 d=Data(self.arg1,ReducedFunction(self.domain))
453 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
454 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
455 d.setValueOfDataPoint(0,(self.arg1*2).tolist())
456 d_0=numpy.array(d.getTupleForDataPoint(0))
457 d_1=numpy.array(d.getTupleForDataPoint(1))
458 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
459 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
460 def test_SetDataPointValue_ReducedFunction_Rank2(self):
461 d=Data(self.arg2,ReducedFunction(self.domain))
462 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
463 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
464 d.setValueOfDataPoint(0,self.arg2*2)
465 d_0=numpy.array(d.getTupleForDataPoint(0))
466 d_1=numpy.array(d.getTupleForDataPoint(1))
467 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
468 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
469 def test_SetDataPointValue_ReducedFunction_Rank2_list(self):
470 d=Data(self.arg2,ReducedFunction(self.domain))
471 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
472 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
473 d.setValueOfDataPoint(0,(self.arg2*2).tolist())
474 d_0=numpy.array(d.getTupleForDataPoint(0))
475 d_1=numpy.array(d.getTupleForDataPoint(1))
476 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
477 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
478 def test_SetDataPointValue_ReducedFunction_Rank3(self):
479 d=Data(self.arg3,ReducedFunction(self.domain))
480 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
481 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
482 d.setValueOfDataPoint(0,self.arg3*2)
483 d_0=numpy.array(d.getTupleForDataPoint(0))
484 d_1=numpy.array(d.getTupleForDataPoint(1))
485 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
486 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
487 def test_SetDataPointValue_ReducedFunction_Rank3_list(self):
488 d=Data(self.arg3,ReducedFunction(self.domain))
489 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
490 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
491 d.setValueOfDataPoint(0,(self.arg3*2).tolist())
492 d_0=numpy.array(d.getTupleForDataPoint(0))
493 d_1=numpy.array(d.getTupleForDataPoint(1))
494 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
495 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
496 def test_SetDataPointValue_ReducedFunction_Rank4(self):
497 d=Data(self.arg4,ReducedFunction(self.domain))
498 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
499 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
500 d.setValueOfDataPoint(0,self.arg4*2)
501 d_0=numpy.array(d.getTupleForDataPoint(0))
502 d_1=numpy.array(d.getTupleForDataPoint(1))
503 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
504 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
505 def test_SetDataPointValue_ReducedFunction_Rank4_list(self):
506 d=Data(self.arg4,ReducedFunction(self.domain))
507 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
508 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
509 d.setValueOfDataPoint(0,(self.arg4*2).tolist())
510 d_0=numpy.array(d.getTupleForDataPoint(0))
511 d_1=numpy.array(d.getTupleForDataPoint(1))
512 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
513 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
514
515 class Test_Dump(unittest.TestCase):
516 arg0=9.81
517 arg1=numpy.array([3.098, -3.111])
518 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]])
519 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]]])
520 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]]]])
521
522 def _diffDataObjects(self,d_ref,filemame, use_old_file=False):
523 if not use_old_file: d_ref.dump(filemame)
524 d=load(filemame, d_ref.getDomain())
525 self.failUnless(not d.isEmpty(),"data in %s are empty."%filemame)
526 self.failUnless(d_ref.getRank() == d.getRank(), "different rank in %s. "%filemame)
527 self.failUnless(d_ref.getShape() == d.getShape(), "different shape %s. "%filemame)
528 self.failUnless(d_ref.getFunctionSpace() == d.getFunctionSpace(), "wrong function space in %s."%filemame)
529 self.failUnless(Lsup(d_ref-d)<=0., "different entries %s."%filemame)
530
531 #===========================================================================
532 def test_DumpAndLoad_Constant_Solution_Rank0(self):
533 if loadIsConfigured():
534 filemame=os.path.join(self.filename_base,"constant_solution_rank0.nc")
535 d=Data(self.arg0,Solution(self.domain))
536 self._diffDataObjects(d,filemame)
537
538 def test_DumpAndLoad_Constant_Solution_Rank1(self):
539 if loadIsConfigured():
540 filemame=os.path.join(self.filename_base,"constant_solution_rank1.nc")
541 d=Data(self.arg1,Solution(self.domain))
542 self._diffDataObjects(d,filemame)
543
544 def test_DumpAndLoad_Constant_Solution_Rank2(self):
545 if loadIsConfigured():
546 filemame=os.path.join(self.filename_base,"constant_solution_rank2.nc")
547 d=Data(self.arg2,Solution(self.domain))
548 self._diffDataObjects(d,filemame)
549
550 def test_DumpAndLoad_Constant_Solution_Rank3(self):
551 if loadIsConfigured():
552 filemame=os.path.join(self.filename_base,"constant_solution_rank3.nc")
553 d=Data(self.arg3,Solution(self.domain))
554 self._diffDataObjects(d,filemame)
555
556 def test_DumpAndLoad_Constant_Solution_Rank4(self):
557 if loadIsConfigured():
558 filemame=os.path.join(self.filename_base,"constant_solution_rank4.nc")
559 d=Data(self.arg4,Solution(self.domain))
560 self._diffDataObjects(d,filemame)
561 #===========================================================================
562 def test_DumpAndLoad_Constant_ReducedSolution_Rank0(self):
563 if loadIsConfigured():
564 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank0.nc")
565 d=Data(self.arg0,ReducedSolution(self.domain))
566 self._diffDataObjects(d,filemame)
567
568 def test_DumpAndLoad_Constant_ReducedSolution_Rank1(self):
569 if loadIsConfigured():
570 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank1.nc")
571 d=Data(self.arg1,ReducedSolution(self.domain))
572 self._diffDataObjects(d,filemame)
573
574 def test_DumpAndLoad_Constant_ReducedSolution_Rank2(self):
575 if loadIsConfigured():
576 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank2.nc")
577 d=Data(self.arg2,ReducedSolution(self.domain))
578 self._diffDataObjects(d,filemame)
579
580 def test_DumpAndLoad_Constant_ReducedSolution_Rank3(self):
581 if loadIsConfigured():
582 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank3.nc")
583 d=Data(self.arg3,ReducedSolution(self.domain))
584 self._diffDataObjects(d,filemame)
585
586 def test_DumpAndLoad_Constant_ReducedSolution_Rank4(self):
587 if loadIsConfigured():
588 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank4.nc")
589 d=Data(self.arg4,ReducedSolution(self.domain))
590 self._diffDataObjects(d,filemame)
591 #===========================================================================
592 def test_DumpAndLoad_Constant_ContinuousFunction_Rank0(self):
593 if loadIsConfigured():
594 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank0.nc")
595 d=Data(self.arg0,ContinuousFunction(self.domain))
596 self._diffDataObjects(d,filemame)
597
598 def test_DumpAndLoad_Constant_ContinuousFunction_Rank1(self):
599 if loadIsConfigured():
600 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank1.nc")
601 d=Data(self.arg1,ContinuousFunction(self.domain))
602 self._diffDataObjects(d,filemame)
603
604 def test_DumpAndLoad_Constant_ContinuousFunction_Rank2(self):
605 if loadIsConfigured():
606 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank2.nc")
607 d=Data(self.arg2,ContinuousFunction(self.domain))
608 self._diffDataObjects(d,filemame)
609
610 def test_DumpAndLoad_Constant_ContinuousFunction_Rank3(self):
611 if loadIsConfigured():
612 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank3.nc")
613 d=Data(self.arg3,ContinuousFunction(self.domain))
614 self._diffDataObjects(d,filemame)
615
616 def test_DumpAndLoad_Constant_ContinuousFunction_Rank4(self):
617 if loadIsConfigured():
618 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank4.nc")
619 d=Data(self.arg4,ContinuousFunction(self.domain))
620 self._diffDataObjects(d,filemame)
621
622 #===========================================================================
623 def test_DumpAndLoad_Constant_Function_Rank0(self):
624 if loadIsConfigured():
625 filemame=os.path.join(self.filename_base,"constant_function_rank0.nc")
626 d=Data(self.arg0,Function(self.domain))
627 self._diffDataObjects(d,filemame)
628
629 def test_DumpAndLoad_Constant_Function_Rank1(self):
630 if loadIsConfigured():
631 filemame=os.path.join(self.filename_base,"constant_function_rank1.nc")
632 d=Data(self.arg1,Function(self.domain))
633 self._diffDataObjects(d,filemame)
634
635 def test_DumpAndLoad_Constant_Function_Rank2(self):
636 if loadIsConfigured():
637 filemame=os.path.join(self.filename_base,"constant_function_rank2.nc")
638 d=Data(self.arg2,Function(self.domain))
639 self._diffDataObjects(d,filemame)
640
641 def test_DumpAndLoad_Constant_Function_Rank3(self):
642 if loadIsConfigured():
643 filemame=os.path.join(self.filename_base,"constant_function_rank3.nc")
644 d=Data(self.arg3,Function(self.domain))
645 self._diffDataObjects(d,filemame)
646
647 #===========================================================================
648 def test_DumpAndLoad_Constant_ReducedFunction_Rank0(self):
649 if loadIsConfigured():
650 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank0.nc")
651 d=Data(self.arg0,ReducedFunction(self.domain))
652 self._diffDataObjects(d,filemame)
653
654 def test_DumpAndLoad_Constant_ReducedFunction_Rank1(self):
655 if loadIsConfigured():
656 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank1.nc")
657 d=Data(self.arg1,ReducedFunction(self.domain))
658 self._diffDataObjects(d,filemame)
659
660 def test_DumpAndLoad_Constant_ReducedFunction_Rank2(self):
661 if loadIsConfigured():
662 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank2.nc")
663 d=Data(self.arg2,ReducedFunction(self.domain))
664 self._diffDataObjects(d,filemame)
665
666 def test_DumpAndLoad_Constant_ReducedFunction_Rank3(self):
667 if loadIsConfigured():
668 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank3.nc")
669 d=Data(self.arg3,ReducedFunction(self.domain))
670 self._diffDataObjects(d,filemame)
671 def test_DumpAndLoad_Constant_ReducedFunction_Rank4(self):
672 if loadIsConfigured():
673 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank4.nc")
674 d=Data(self.arg4,ReducedFunction(self.domain))
675 self._diffDataObjects(d,filemame)
676
677 #===========================================================================
678 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank0(self):
679 if loadIsConfigured():
680 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank0.nc")
681 d=Data(self.arg0,FunctionOnBoundary(self.domain))
682 self._diffDataObjects(d,filemame)
683
684 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank1(self):
685 if loadIsConfigured():
686 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank1.nc")
687 d=Data(self.arg1,FunctionOnBoundary(self.domain))
688 self._diffDataObjects(d,filemame)
689
690 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank2(self):
691 if loadIsConfigured():
692 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank2.nc")
693 d=Data(self.arg2,FunctionOnBoundary(self.domain))
694 self._diffDataObjects(d,filemame)
695
696 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank3(self):
697 if loadIsConfigured():
698 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank3.nc")
699 d=Data(self.arg3,FunctionOnBoundary(self.domain))
700 self._diffDataObjects(d,filemame)
701
702 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank4(self):
703 if loadIsConfigured():
704 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank4.nc")
705 d=Data(self.arg4,FunctionOnBoundary(self.domain))
706 self._diffDataObjects(d,filemame)
707
708 #===========================================================================
709 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank0(self):
710 if loadIsConfigured():
711 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank0.nc")
712 d=Data(self.arg0,FunctionOnBoundary(self.domain))
713 self._diffDataObjects(d,filemame)
714
715 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank1(self):
716 if loadIsConfigured():
717 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank1.nc")
718 d=Data(self.arg1,ReducedFunctionOnBoundary(self.domain))
719 self._diffDataObjects(d,filemame)
720
721 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank2(self):
722 if loadIsConfigured():
723 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank2.nc")
724 d=Data(self.arg2,ReducedFunctionOnBoundary(self.domain))
725 self._diffDataObjects(d,filemame)
726
727 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank3(self):
728 if loadIsConfigured():
729 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank3.nc")
730 d=Data(self.arg3,ReducedFunctionOnBoundary(self.domain))
731 self._diffDataObjects(d,filemame)
732
733 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank4(self):
734 if loadIsConfigured():
735 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank4.nc")
736 d=Data(self.arg4,ReducedFunctionOnBoundary(self.domain))
737 self._diffDataObjects(d,filemame)
738
739 #===========================================================================
740 def test_DumpAndLoad_Expanded_Solution_Rank0(self):
741 if loadIsConfigured():
742 filemame=os.path.join(self.filename_base,"expanded_solution_rank0.nc")
743 d=Data(length(Solution(self.domain).getX())*self.arg0,Solution(self.domain))
744 self._diffDataObjects(d,filemame)
745 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
746 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
747 if getMPISizeWorld() ==1:
748 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg0,Solution(self.domain_with_different_sample_ordering))
749 self._diffDataObjects(d,filemame, use_old_file=True)
750
751 def test_DumpAndLoad_Expanded_Solution_Rank1(self):
752 if loadIsConfigured():
753 filemame=os.path.join(self.filename_base,"expanded_solution_rank1.nc")
754 d=Data(length(Solution(self.domain).getX())*self.arg1,Solution(self.domain))
755 self._diffDataObjects(d,filemame)
756 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
757 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
758 if getMPISizeWorld() ==1:
759 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg1,Solution(self.domain_with_different_sample_ordering))
760 self._diffDataObjects(d,filemame, use_old_file=True)
761
762 def test_DumpAndLoad_Expanded_Solution_Rank2(self):
763 if loadIsConfigured():
764 filemame=os.path.join(self.filename_base,"expanded_solution_rank2.nc")
765 d=Data(length(Solution(self.domain).getX())*self.arg2,Solution(self.domain))
766 self._diffDataObjects(d,filemame)
767 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
768 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
769 if getMPISizeWorld() ==1:
770 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg2,Solution(self.domain_with_different_sample_ordering))
771 self._diffDataObjects(d,filemame, use_old_file=True)
772
773 def test_DumpAndLoad_Expanded_Solution_Rank3(self):
774 if loadIsConfigured():
775 filemame=os.path.join(self.filename_base,"expanded_solution_rank3.nc")
776 d=Data(length(Solution(self.domain).getX())*self.arg3,Solution(self.domain))
777 self._diffDataObjects(d,filemame)
778 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
779 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
780 if getMPISizeWorld() ==1:
781 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg3,Solution(self.domain_with_different_sample_ordering))
782 self._diffDataObjects(d,filemame, use_old_file=True)
783
784 def test_DumpAndLoad_Expanded_Solution_Rank4(self):
785 if loadIsConfigured():
786 filemame=os.path.join(self.filename_base,"expanded_solution_rank4.nc")
787 d=Data(length(Solution(self.domain).getX())*self.arg4,Solution(self.domain))
788 self._diffDataObjects(d,filemame)
789 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
790 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
791 if getMPISizeWorld() ==1:
792 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg4,Solution(self.domain_with_different_sample_ordering))
793 self._diffDataObjects(d,filemame, use_old_file=True)
794 #===========================================================================
795 def test_DumpAndLoad_Expanded_ReducedSolution_Rank0(self):
796 if loadIsConfigured():
797 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank0.nc")
798 d=Data(length(ReducedSolution(self.domain).getX())*self.arg0,ReducedSolution(self.domain))
799 self._diffDataObjects(d,filemame)
800 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
801 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
802 if getMPISizeWorld() ==1:
803 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg0,ReducedSolution(self.domain_with_different_sample_ordering))
804 self._diffDataObjects(d,filemame, use_old_file=True)
805
806 def test_DumpAndLoad_Expanded_ReducedSolution_Rank1(self):
807 if loadIsConfigured():
808 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank1.nc")
809 d=Data(length(ReducedSolution(self.domain).getX())*self.arg1,ReducedSolution(self.domain))
810 self._diffDataObjects(d,filemame)
811 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
812 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
813 if getMPISizeWorld() ==1:
814 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg1,ReducedSolution(self.domain_with_different_sample_ordering))
815 self._diffDataObjects(d,filemame, use_old_file=True)
816
817 def test_DumpAndLoad_Expanded_ReducedSolution_Rank2(self):
818 if loadIsConfigured():
819 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank2.nc")
820 d=Data(length(ReducedSolution(self.domain).getX())*self.arg2,ReducedSolution(self.domain))
821 self._diffDataObjects(d,filemame)
822 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
823 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
824 if getMPISizeWorld() ==1:
825 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg2,ReducedSolution(self.domain_with_different_sample_ordering))
826 self._diffDataObjects(d,filemame, use_old_file=True)
827
828 def test_DumpAndLoad_Expanded_ReducedSolution_Rank3(self):
829 if loadIsConfigured():
830 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank3.nc")
831 d=Data(length(ReducedSolution(self.domain).getX())*self.arg3,ReducedSolution(self.domain))
832 self._diffDataObjects(d,filemame)
833 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
834 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
835 if getMPISizeWorld() ==1:
836 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg3,ReducedSolution(self.domain_with_different_sample_ordering))
837 self._diffDataObjects(d,filemame, use_old_file=True)
838
839 def test_DumpAndLoad_Expanded_ReducedSolution_Rank4(self):
840 if loadIsConfigured():
841 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank4.nc")
842 d=Data(length(ReducedSolution(self.domain).getX())*self.arg4,ReducedSolution(self.domain))
843 self._diffDataObjects(d,filemame)
844 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
845 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
846 if getMPISizeWorld() ==1:
847 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg4,ReducedSolution(self.domain_with_different_sample_ordering))
848 self._diffDataObjects(d,filemame, use_old_file=True)
849 #===========================================================================
850 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank0(self):
851 if loadIsConfigured():
852 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank0.nc")
853 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg0,ContinuousFunction(self.domain))
854 self._diffDataObjects(d,filemame)
855 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
856 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
857 if getMPISizeWorld() ==1:
858 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg0,ContinuousFunction(self.domain_with_different_sample_ordering))
859 self._diffDataObjects(d,filemame, use_old_file=True)
860
861 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank1(self):
862 if loadIsConfigured():
863 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank1.nc")
864 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
865 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg1,ContinuousFunction(self.domain))
866 self._diffDataObjects(d,filemame)
867 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
868 if getMPISizeWorld() ==1:
869 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg1,ContinuousFunction(self.domain_with_different_sample_ordering))
870 self._diffDataObjects(d,filemame, use_old_file=True)
871
872 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank2(self):
873 if loadIsConfigured():
874 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank2.nc")
875 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg2,ContinuousFunction(self.domain))
876 self._diffDataObjects(d,filemame)
877 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
878 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
879 if getMPISizeWorld() ==1:
880 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg2,ContinuousFunction(self.domain_with_different_sample_ordering))
881 self._diffDataObjects(d,filemame, use_old_file=True)
882
883 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank3(self):
884 if loadIsConfigured():
885 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank3.nc")
886 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg3,ContinuousFunction(self.domain))
887 self._diffDataObjects(d,filemame)
888 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
889 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
890 if getMPISizeWorld() ==1:
891 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg3,ContinuousFunction(self.domain_with_different_sample_ordering))
892 self._diffDataObjects(d,filemame, use_old_file=True)
893
894 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank4(self):
895 if loadIsConfigured():
896 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank4.nc")
897 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg4,ContinuousFunction(self.domain))
898 self._diffDataObjects(d,filemame)
899 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
900 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
901 if getMPISizeWorld() ==1:
902 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg4,ContinuousFunction(self.domain_with_different_sample_ordering))
903 self._diffDataObjects(d,filemame, use_old_file=True)
904
905 #===========================================================================
906 def test_DumpAndLoad_Expanded_Function_Rank0(self):
907 if loadIsConfigured():
908 filemame=os.path.join(self.filename_base,"expanded_function_rank0.nc")
909 d=Data(length(Function(self.domain).getX())*self.arg0,Function(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(Function(self.domain_with_different_sample_ordering).getX())*self.arg0,Function(self.domain_with_different_sample_ordering))
915 self._diffDataObjects(d,filemame, use_old_file=True)
916
917 def test_DumpAndLoad_Expanded_Function_Rank1(self):
918 if loadIsConfigured():
919 filemame=os.path.join(self.filename_base,"expanded_function_rank1.nc")
920 d=Data(length(Function(self.domain).getX())*self.arg1,Function(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(Function(self.domain_with_different_sample_ordering).getX())*self.arg1,Function(self.domain_with_different_sample_ordering))
926 self._diffDataObjects(d,filemame, use_old_file=True)
927
928 def test_DumpAndLoad_Expanded_Function_Rank2(self):
929 if loadIsConfigured():
930 filemame=os.path.join(self.filename_base,"expanded_function_rank2.nc")
931 d=Data(length(Function(self.domain).getX())*self.arg2,Function(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(Function(self.domain_with_different_sample_ordering).getX())*self.arg2,Function(self.domain_with_different_sample_ordering))
937 self._diffDataObjects(d,filemame, use_old_file=True)
938
939 def test_DumpAndLoad_Expanded_Function_Rank3(self):
940 if loadIsConfigured():
941 filemame=os.path.join(self.filename_base,"expanded_function_rank3.nc")
942 d=Data(length(Function(self.domain).getX())*self.arg3,Function(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(Function(self.domain_with_different_sample_ordering).getX())*self.arg3,Function(self.domain_with_different_sample_ordering))
948 self._diffDataObjects(d,filemame, use_old_file=True)
949
950 def test_DumpAndLoad_Expanded_Function_Rank4(self):
951 if loadIsConfigured():
952 filemame=os.path.join(self.filename_base,"expanded_function_rank4.nc")
953 d=Data(length(Function(self.domain).getX())*self.arg4,Function(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(Function(self.domain_with_different_sample_ordering).getX())*self.arg4,Function(self.domain_with_different_sample_ordering))
959 self._diffDataObjects(d,filemame, use_old_file=True)
960
961 #===========================================================================
962 def test_DumpAndLoad_Expanded_ReducedFunction_Rank0(self):
963 if loadIsConfigured():
964 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank0.nc")
965 d=Data(length(ReducedFunction(self.domain).getX())*self.arg0,ReducedFunction(self.domain))
966 self._diffDataObjects(d,filemame)
967 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
968 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
969 if getMPISizeWorld() ==1:
970 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg0,ReducedFunction(self.domain_with_different_sample_ordering))
971 self._diffDataObjects(d,filemame, use_old_file=True)
972
973 def test_DumpAndLoad_Expanded_ReducedFunction_Rank1(self):
974 if loadIsConfigured():
975 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank1.nc")
976 d=Data(length(ReducedFunction(self.domain).getX())*self.arg1,ReducedFunction(self.domain))
977 self._diffDataObjects(d,filemame)
978 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
979 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
980 if getMPISizeWorld() ==1:
981 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg1,ReducedFunction(self.domain_with_different_sample_ordering))
982 self._diffDataObjects(d,filemame, use_old_file=True)
983
984 def test_DumpAndLoad_Expanded_ReducedFunction_Rank2(self):
985 if loadIsConfigured():
986 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank2.nc")
987 d=Data(length(ReducedFunction(self.domain).getX())*self.arg2,ReducedFunction(self.domain))
988 self._diffDataObjects(d,filemame)
989 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
990 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
991 if getMPISizeWorld() ==1:
992 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg2,ReducedFunction(self.domain_with_different_sample_ordering))
993 self._diffDataObjects(d,filemame, use_old_file=True)
994
995 def test_DumpAndLoad_Expanded_ReducedFunction_Rank3(self):
996 if loadIsConfigured():
997 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank3.nc")
998 d=Data(length(ReducedFunction(self.domain).getX())*self.arg3,ReducedFunction(self.domain))
999 self._diffDataObjects(d,filemame)
1000 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1001 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1002 if getMPISizeWorld() ==1:
1003 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg3,ReducedFunction(self.domain_with_different_sample_ordering))
1004 self._diffDataObjects(d,filemame, use_old_file=True)
1005
1006 def test_DumpAndLoad_Expanded_ReducedFunction_Rank4(self):
1007 if loadIsConfigured():
1008 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank4.nc")
1009 d=Data(length(ReducedFunction(self.domain).getX())*self.arg4,ReducedFunction(self.domain))
1010 self._diffDataObjects(d,filemame)
1011 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1012 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1013 if getMPISizeWorld() ==1:
1014 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg4,ReducedFunction(self.domain_with_different_sample_ordering))
1015 self._diffDataObjects(d,filemame, use_old_file=True)
1016
1017 #===========================================================================
1018 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank0(self):
1019 if loadIsConfigured():
1020 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank0.nc")
1021 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg0,FunctionOnBoundary(self.domain))
1022 self._diffDataObjects(d,filemame)
1023 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1024 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1025 if getMPISizeWorld() ==1:
1026 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg0,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1027 self._diffDataObjects(d,filemame, use_old_file=True)
1028
1029 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank1(self):
1030 if loadIsConfigured():
1031 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank1.nc")
1032 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg1,FunctionOnBoundary(self.domain))
1033 self._diffDataObjects(d,filemame)
1034 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1035 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1036 if getMPISizeWorld() ==1:
1037 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg1,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1038 self._diffDataObjects(d,filemame, use_old_file=True)
1039
1040 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank2(self):
1041 if loadIsConfigured():
1042 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank2.nc")
1043 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg2,FunctionOnBoundary(self.domain))
1044 self._diffDataObjects(d,filemame)
1045 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1046 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1047 if getMPISizeWorld() ==1:
1048 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg2,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1049 self._diffDataObjects(d,filemame, use_old_file=True)
1050
1051 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank3(self):
1052 if loadIsConfigured():
1053 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank3.nc")
1054 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg3,FunctionOnBoundary(self.domain))
1055 self._diffDataObjects(d,filemame)
1056 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1057 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1058 if getMPISizeWorld() ==1:
1059 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg3,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1060 self._diffDataObjects(d,filemame, use_old_file=True)
1061
1062 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank4(self):
1063 if loadIsConfigured():
1064 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank4.nc")
1065 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg4,FunctionOnBoundary(self.domain))
1066 self._diffDataObjects(d,filemame)
1067 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1068 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1069 if getMPISizeWorld() ==1:
1070 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg4,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1071 self._diffDataObjects(d,filemame, use_old_file=True)
1072
1073 #===========================================================================
1074 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank0(self):
1075 if loadIsConfigured():
1076 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank0.nc")
1077 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg0,ReducedFunctionOnBoundary(self.domain))
1078 self._diffDataObjects(d,filemame)
1079 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1080 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1081 if getMPISizeWorld() ==1:
1082 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg0,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1083 self._diffDataObjects(d,filemame, use_old_file=True)
1084
1085 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank1(self):
1086 if loadIsConfigured():
1087 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank1.nc")
1088 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg1,ReducedFunctionOnBoundary(self.domain))
1089 self._diffDataObjects(d,filemame)
1090 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1091 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1092 if getMPISizeWorld() ==1:
1093 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg1,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1094 self._diffDataObjects(d,filemame, use_old_file=True)
1095
1096 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank2(self):
1097 if loadIsConfigured():
1098 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank2.nc")
1099 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg2,ReducedFunctionOnBoundary(self.domain))
1100 self._diffDataObjects(d,filemame)
1101 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1102 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1103 if getMPISizeWorld() ==1:
1104 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg2,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1105 self._diffDataObjects(d,filemame, use_old_file=True)
1106
1107 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank3(self):
1108 if loadIsConfigured():
1109 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank3.nc")
1110 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg3,ReducedFunctionOnBoundary(self.domain))
1111 self._diffDataObjects(d,filemame)
1112 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1113 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1114 if getMPISizeWorld() ==1:
1115 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg3,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1116 self._diffDataObjects(d,filemame, use_old_file=True)
1117
1118 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank4(self):
1119 if loadIsConfigured():
1120 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank4.nc")
1121 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg4,ReducedFunctionOnBoundary(self.domain))
1122 self._diffDataObjects(d,filemame)
1123 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1124 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1125 if getMPISizeWorld() ==1:
1126 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg4,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1127 self._diffDataObjects(d,filemame, use_old_file=True)
1128
1129 #===========================================================================
1130 ## This functionspace does not currently support tags.
1131 ## Instead, we test that the canTag() function throws in test_canTag_Failures.
1132
1133 #def test_DumpAndLoad_Tagged_Solution_Rank0(self):
1134 #if loadIsConfigured():
1135 #filemame=os.path.join(self.filename_base,"tagged_solution_rank0.nc")
1136 #d=Data(self.arg0,Solution(self.domain))
1137 #d.setTaggedValue(1,self.arg0*2)
1138 #d.setTaggedValue(10,self.arg0*3)
1139 #d.setTaggedValue(100,self.arg0*4)
1140 #self._diffDataObjects(d,filemame)
1141
1142 #def test_DumpAndLoad_Tagged_Solution_Rank1(self):
1143 #if loadIsConfigured():
1144 #filemame=os.path.join(self.filename_base,"tagged_solution_rank1.nc")
1145 #d=Data(self.arg1,Solution(self.domain))
1146 #d.setTaggedValue(1,self.arg1*2)
1147 #d.setTaggedValue(10,self.arg1*3)
1148 #d.setTaggedValue(100,self.arg1*4)
1149 #self._diffDataObjects(d,filemame)
1150
1151 #def test_DumpAndLoad_Tagged_Solution_Rank2(self):
1152 #if loadIsConfigured():
1153 #filemame=os.path.join(self.filename_base,"tagged_solution_rank2.nc")
1154 #d=Data(self.arg2,Solution(self.domain))
1155 #d.setTaggedValue(1,self.arg2*2)
1156 #d.setTaggedValue(10,self.arg2*3)
1157 #d.setTaggedValue(100,self.arg2*4)
1158 #self._diffDataObjects(d,filemame)
1159
1160 #def test_DumpAndLoad_Tagged_Solution_Rank3(self):
1161 #if loadIsConfigured():
1162 #filemame=os.path.join(self.filename_base,"tagged_solution_rank3.nc")
1163 #d=Data(self.arg3,Solution(self.domain))
1164 #d.setTaggedValue(1,self.arg3*2)
1165 #d.setTaggedValue(10,self.arg3*3)
1166 #d.setTaggedValue(100,self.arg3*4)
1167 #self._diffDataObjects(d,filemame)
1168
1169 #def test_DumpAndLoad_Tagged_Solution_Rank4(self):
1170 #if loadIsConfigured():
1171 #filemame=os.path.join(self.filename_base,"tagged_solution_rank4.nc")
1172 #d=Data(self.arg4,Solution(self.domain))
1173 #d.setTaggedValue(1,self.arg4*2)
1174 #d.setTaggedValue(10,self.arg4*3)
1175 #d.setTaggedValue(100,self.arg4*4)
1176 #self._diffDataObjects(d,filemame)
1177 ##===========================================================================
1178 ## This functionspace does not currently support tags.
1179 ## Instead, we test that the canTag() function throws in test_canTag_Failures.
1180
1181 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank0(self):
1182 #if loadIsConfigured():
1183 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank0.nc")
1184 #d=Data(self.arg0,ReducedSolution(self.domain))
1185 #d.setTaggedValue(1,self.arg0*2)
1186 #d.setTaggedValue(10,self.arg0*3)
1187 #d.setTaggedValue(100,self.arg0*4)
1188 #self._diffDataObjects(d,filemame)
1189
1190 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank1(self):
1191 #if loadIsConfigured():
1192 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank1.nc")
1193 #d=Data(self.arg1,ReducedSolution(self.domain))
1194 #d.setTaggedValue(1,self.arg1*2)
1195 #d.setTaggedValue(10,self.arg1*3)
1196 #d.setTaggedValue(100,self.arg1*4)
1197 #self._diffDataObjects(d,filemame)
1198
1199 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank2(self):
1200 #if loadIsConfigured():
1201 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank2.nc")
1202 #d=Data(self.arg2,ReducedSolution(self.domain))
1203 #d.setTaggedValue(1,self.arg2*2)
1204 #d.setTaggedValue(10,self.arg2*3)
1205 #d.setTaggedValue(100,self.arg2*4)
1206 #self._diffDataObjects(d,filemame)
1207
1208 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank3(self):
1209 #if loadIsConfigured():
1210 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank3.nc")
1211 #d=Data(self.arg3,ReducedSolution(self.domain))
1212 #d.setTaggedValue(1,self.arg3*2)
1213 #d.setTaggedValue(10,self.arg3*3)
1214 #d.setTaggedValue(100,self.arg3*4)
1215 #self._diffDataObjects(d,filemame)
1216
1217 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank4(self):
1218 #if loadIsConfigured():
1219 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank4.nc")
1220 #d=Data(self.arg4,ReducedSolution(self.domain))
1221 #d.setTaggedValue(1,self.arg4*2)
1222 #d.setTaggedValue(10,self.arg4*3)
1223 #d.setTaggedValue(100,self.arg4*4)
1224 #self._diffDataObjects(d,filemame)
1225 ##===========================================================================
1226 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank0(self):
1227 if loadIsConfigured():
1228 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank0.nc")
1229 d=Data(self.arg0,ContinuousFunction(self.domain))
1230 d.setTaggedValue(1,self.arg0*2)
1231 d.setTaggedValue(10,self.arg0*3)
1232 d.setTaggedValue(100,self.arg0*4)
1233 self._diffDataObjects(d,filemame)
1234
1235 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank1(self):
1236 if loadIsConfigured():
1237 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank1.nc")
1238 d=Data(self.arg1,ContinuousFunction(self.domain))
1239 d.setTaggedValue(1,self.arg1*2)
1240 d.setTaggedValue(10,self.arg1*3)
1241 d.setTaggedValue(100,self.arg1*4)
1242 self._diffDataObjects(d,filemame)
1243
1244 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank2(self):
1245 if loadIsConfigured():
1246 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank2.nc")
1247 d=Data(self.arg2,ContinuousFunction(self.domain))
1248 d.setTaggedValue(1,self.arg2*2)
1249 d.setTaggedValue(10,self.arg2*3)
1250 d.setTaggedValue(100,self.arg2*4)
1251 self._diffDataObjects(d,filemame)
1252
1253 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank3(self):
1254 if loadIsConfigured():
1255 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank3.nc")
1256 d=Data(self.arg3,ContinuousFunction(self.domain))
1257 d.setTaggedValue(1,self.arg3*2)
1258 d.setTaggedValue(10,self.arg3*3)
1259 d.setTaggedValue(100,self.arg3*4)
1260 self._diffDataObjects(d,filemame)
1261
1262 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank4(self):
1263 if loadIsConfigured():
1264 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank4.nc")
1265 d=Data(self.arg4,ContinuousFunction(self.domain))
1266 d.setTaggedValue(1,self.arg4*2)
1267 d.setTaggedValue(10,self.arg4*3)
1268 d.setTaggedValue(100,self.arg4*4)
1269 self._diffDataObjects(d,filemame)
1270
1271 #===========================================================================
1272 def test_DumpAndLoad_Tagged_Function_Rank0(self):
1273 if loadIsConfigured():
1274 filemame=os.path.join(self.filename_base,"tagged_function_rank0.nc")
1275 d=Data(self.arg0,Function(self.domain))
1276 d.setTaggedValue(1,self.arg0*2)
1277 d.setTaggedValue(10,self.arg0*3)
1278 d.setTaggedValue(100,self.arg0*4)
1279 self._diffDataObjects(d,filemame)
1280
1281 def test_DumpAndLoad_Tagged_Function_Rank1(self):
1282 if loadIsConfigured():
1283 filemame=os.path.join(self.filename_base,"tagged_function_rank1.nc")
1284 d=Data(self.arg1,Function(self.domain))
1285 d.setTaggedValue(1,self.arg1*2)
1286 d.setTaggedValue(10,self.arg1*3)
1287 d.setTaggedValue(100,self.arg1*4)
1288 self._diffDataObjects(d,filemame)
1289
1290 def test_DumpAndLoad_Tagged_Function_Rank2(self):
1291 if loadIsConfigured():
1292 filemame=os.path.join(self.filename_base,"tagged_function_rank2.nc")
1293 d=Data(self.arg2,Function(self.domain))
1294 d.setTaggedValue(1,self.arg2*2)
1295 d.setTaggedValue(10,self.arg2*3)
1296 d.setTaggedValue(100,self.arg2*4)
1297 self._diffDataObjects(d,filemame)
1298
1299 def test_DumpAndLoad_Tagged_Function_Rank3(self):
1300 if loadIsConfigured():
1301 filemame=os.path.join(self.filename_base,"tagged_function_rank3.nc")
1302 d=Data(self.arg3,Function(self.domain))
1303 d.setTaggedValue(1,self.arg3*2)
1304 d.setTaggedValue(10,self.arg3*3)
1305 d.setTaggedValue(100,self.arg3*4)
1306 self._diffDataObjects(d,filemame)
1307
1308 def test_DumpAndLoad_Tagged_Function_Rank4(self):
1309 if loadIsConfigured():
1310 filemame=os.path.join(self.filename_base,"tagged_function_rank4.nc")
1311 d=Data(self.arg4,Function(self.domain))
1312 d.setTaggedValue(1,self.arg4*2)
1313 d.setTaggedValue(10,self.arg4*3)
1314 d.setTaggedValue(100,self.arg4*4)
1315 self._diffDataObjects(d,filemame)
1316
1317 #===========================================================================
1318 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank0(self):
1319 if loadIsConfigured():
1320 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank0.nc")
1321 d=Data(self.arg0,FunctionOnBoundary(self.domain))
1322 d.setTaggedValue(1,self.arg0*2)
1323 d.setTaggedValue(10,self.arg0*3)
1324 d.setTaggedValue(100,self.arg0*4)
1325 self._diffDataObjects(d,filemame)
1326
1327 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank1(self):
1328 if loadIsConfigured():
1329 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank1.nc")
1330 d=Data(self.arg1,FunctionOnBoundary(self.domain))
1331 d.setTaggedValue(1,self.arg1*2)
1332 d.setTaggedValue(10,self.arg1*3)
1333 d.setTaggedValue(100,self.arg1*4)
1334 self._diffDataObjects(d,filemame)
1335
1336 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank2(self):
1337 if loadIsConfigured():
1338 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank2.nc")
1339 d=Data(self.arg2,FunctionOnBoundary(self.domain))
1340 d.setTaggedValue(1,self.arg2*2)
1341 d.setTaggedValue(10,self.arg2*3)
1342 d.setTaggedValue(100,self.arg2*4)
1343 self._diffDataObjects(d,filemame)
1344
1345 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank3(self):
1346 if loadIsConfigured():
1347 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank3.nc")
1348 d=Data(self.arg3,FunctionOnBoundary(self.domain))
1349 d.setTaggedValue(1,self.arg3*2)
1350 d.setTaggedValue(10,self.arg3*3)
1351 d.setTaggedValue(100,self.arg3*4)
1352 self._diffDataObjects(d,filemame)
1353
1354 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank4(self):
1355 if loadIsConfigured():
1356 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank4.nc")
1357 d=Data(self.arg4,FunctionOnBoundary(self.domain))
1358 d.setTaggedValue(1,self.arg4*2)
1359 d.setTaggedValue(10,self.arg4*3)
1360 d.setTaggedValue(100,self.arg4*4)
1361 self._diffDataObjects(d,filemame)
1362 #===========================================================================
1363 def test_DumpAndLoad_Tagged_ReducedFunction_Rank0(self):
1364 if loadIsConfigured():
1365 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank0.nc")
1366 d=Data(self.arg0,ReducedFunction(self.domain))
1367 d.setTaggedValue(1,self.arg0*2)
1368 d.setTaggedValue(10,self.arg0*3)
1369 d.setTaggedValue(100,self.arg0*4)
1370 self._diffDataObjects(d,filemame)
1371
1372 def test_DumpAndLoad_Tagged_ReducedFunction_Rank1(self):
1373 if loadIsConfigured():
1374 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank1.nc")
1375 d=Data(self.arg1,ReducedFunction(self.domain))
1376 d.setTaggedValue(1,self.arg1*2)
1377 d.setTaggedValue(10,self.arg1*3)
1378 d.setTaggedValue(100,self.arg1*4)
1379 self._diffDataObjects(d,filemame)
1380
1381 def test_DumpAndLoad_Tagged_ReducedFunction_Rank2(self):
1382 if loadIsConfigured():
1383 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank2.nc")
1384 d=Data(self.arg2,ReducedFunction(self.domain))
1385 d.setTaggedValue(1,self.arg2*2)
1386 d.setTaggedValue(10,self.arg2*3)
1387 d.setTaggedValue(100,self.arg2*4)
1388 self._diffDataObjects(d,filemame)
1389
1390 def test_DumpAndLoad_Tagged_ReducedFunction_Rank3(self):
1391 if loadIsConfigured():
1392 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank3.nc")
1393 d=Data(self.arg3,ReducedFunction(self.domain))
1394 d.setTaggedValue(1,self.arg3*2)
1395 d.setTaggedValue(10,self.arg3*3)
1396 d.setTaggedValue(100,self.arg3*4)
1397 self._diffDataObjects(d,filemame)
1398
1399 def test_DumpAndLoad_Tagged_ReducedFunction_Rank4(self):
1400 if loadIsConfigured():
1401 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank4.nc")
1402 d=Data(self.arg4,ReducedFunction(self.domain))
1403 d.setTaggedValue(1,self.arg4*2)
1404 d.setTaggedValue(10,self.arg4*3)
1405 d.setTaggedValue(100,self.arg4*4)
1406 self._diffDataObjects(d,filemame)
1407
1408 #===========================================================================
1409 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank0(self):
1410 if loadIsConfigured():
1411 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank0.nc")
1412 d=Data(self.arg0,ReducedFunctionOnBoundary(self.domain))
1413 d.setTaggedValue(1,self.arg0*2)
1414 d.setTaggedValue(10,self.arg0*3)
1415 d.setTaggedValue(100,self.arg0*4)
1416 self._diffDataObjects(d,filemame)
1417
1418 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank1(self):
1419 if loadIsConfigured():
1420 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank1.nc")
1421 d=Data(self.arg1,ReducedFunctionOnBoundary(self.domain))
1422 d.setTaggedValue(1,self.arg1*2)
1423 d.setTaggedValue(10,self.arg1*3)
1424 d.setTaggedValue(100,self.arg1*4)
1425 self._diffDataObjects(d,filemame)
1426
1427 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank2(self):
1428 if loadIsConfigured():
1429 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank2.nc")
1430 d=Data(self.arg2,ReducedFunctionOnBoundary(self.domain))
1431 d.setTaggedValue(1,self.arg2*2)
1432 d.setTaggedValue(10,self.arg2*3)
1433 d.setTaggedValue(100,self.arg2*4)
1434 self._diffDataObjects(d,filemame)
1435
1436 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank3(self):
1437 if loadIsConfigured():
1438 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank3.nc")
1439 d=Data(self.arg3,ReducedFunctionOnBoundary(self.domain))
1440 d.setTaggedValue(1,self.arg3*2)
1441 d.setTaggedValue(10,self.arg3*3)
1442 d.setTaggedValue(100,self.arg3*4)
1443 self._diffDataObjects(d,filemame)
1444
1445 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank4(self):
1446 if loadIsConfigured():
1447 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank4.nc")
1448 d=Data(self.arg4,ReducedFunctionOnBoundary(self.domain))
1449 d.setTaggedValue(1,self.arg4*2)
1450 d.setTaggedValue(10,self.arg4*3)
1451 d.setTaggedValue(100,self.arg4*4)
1452 self._diffDataObjects(d,filemame)
1453
1454 def test_canTag_Failures(self):
1455 d=Data(self.arg0,Solution(self.domain))
1456 self.failUnlessRaises(RuntimeError,d.setTaggedValue,1,self.arg0*2)
1457 d=Data(self.arg0,ReducedSolution(self.domain))
1458 self.failUnlessRaises(RuntimeError,d.setTaggedValue,1,self.arg0*2)

  ViewVC Help
Powered by ViewVC 1.1.26