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

  ViewVC Help
Powered by ViewVC 1.1.26