/[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 2650 - (show annotations)
Mon Sep 7 03:38:50 2009 UTC (9 years, 8 months ago) by jfenwick
File MIME type: text/x-python
File size: 82808 byte(s)
Reducing the concentration of stupid.

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 class Test_SetDataPointValue(unittest.TestCase):
326 arg0=9.81
327 arg1=numpy.array([3.098, -3.111])
328 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]])
329 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]]])
330 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]]]])
331 def test_SetDataPointValue_Function_Rank0(self):
332 d=Data(self.arg0,Function(self.domain))
333 d.setValueOfDataPoint(0,self.arg0*2)
334 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
335 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg0)
336 d_0=numpy.array(d.getTupleForDataPoint(0))
337 d_1=numpy.array(d.getTupleForDataPoint(1))
338 self.failUnless(Lsup(d_0-self.arg0*2)<=Lsup(self.arg0*2), "wrong setting")
339 self.failUnless(Lsup(d_1-self.arg0)<=Lsup(self.arg0), "wrong setting")
340 def test_SetDataPointValue_Function_Rank1(self):
341 d=Data(self.arg1,Function(self.domain))
342 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
343 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
344 d.setValueOfDataPoint(0,self.arg1*2)
345 d_0=numpy.array(d.getTupleForDataPoint(0))
346 d_1=numpy.array(d.getTupleForDataPoint(1))
347 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
348 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
349 def test_SetDataPointValue_Function_Rank1_list(self):
350 d=Data(self.arg1,Function(self.domain))
351 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
352 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
353 d.setValueOfDataPoint(0,(self.arg1*2).tolist())
354 d_0=numpy.array(d.getTupleForDataPoint(0))
355 d_1=numpy.array(d.getTupleForDataPoint(1))
356 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
357 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
358 def test_SetDataPointValue_Function_Rank2(self):
359 d=Data(self.arg2,Function(self.domain))
360 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
361 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
362 d.setValueOfDataPoint(0,self.arg2*2)
363 d_0=numpy.array(d.getTupleForDataPoint(0))
364 d_1=numpy.array(d.getTupleForDataPoint(1))
365 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
366 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
367 def test_SetDataPointValue_Function_Rank2_list(self):
368 d=Data(self.arg2,Function(self.domain))
369 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
370 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
371 d.setValueOfDataPoint(0,(self.arg2*2).tolist())
372 d_0=numpy.array(d.getTupleForDataPoint(0))
373 d_1=numpy.array(d.getTupleForDataPoint(1))
374 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
375 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
376 def test_SetDataPointValue_Function_Rank3(self):
377 d=Data(self.arg3,Function(self.domain))
378 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
379 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
380 d.setValueOfDataPoint(0,self.arg3*2)
381 d_0=numpy.array(d.getTupleForDataPoint(0))
382 d_1=numpy.array(d.getTupleForDataPoint(1))
383 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
384 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
385 def test_SetDataPointValue_Function_Rank3_list(self):
386 d=Data(self.arg3,Function(self.domain))
387 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
388 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
389 d.setValueOfDataPoint(0,(self.arg3*2).tolist())
390 d_0=numpy.array(d.getTupleForDataPoint(0))
391 d_1=numpy.array(d.getTupleForDataPoint(1))
392 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
393 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
394 def test_SetDataPointValue_Function_Rank4(self):
395 d=Data(self.arg4,Function(self.domain))
396 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
397 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
398 d.setValueOfDataPoint(0,self.arg4*2)
399 d_0=numpy.array(d.getTupleForDataPoint(0))
400 d_1=numpy.array(d.getTupleForDataPoint(1))
401 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
402 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
403 def test_SetDataPointValue_Function_Rank4_list(self):
404 d=Data(self.arg4,Function(self.domain))
405 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
406 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
407 d.setValueOfDataPoint(0,(self.arg4*2).tolist())
408 d_0=numpy.array(d.getTupleForDataPoint(0))
409 d_1=numpy.array(d.getTupleForDataPoint(1))
410 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
411 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
412 #===========================================================================
413 def test_SetDataPointValue_ReducedFunction_Rank0(self):
414 d=Data(self.arg0,ReducedFunction(self.domain))
415 d.setValueOfDataPoint(0,self.arg0*2)
416 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
417 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg0)
418 d_0=numpy.array(d.getTupleForDataPoint(0))
419 d_1=numpy.array(d.getTupleForDataPoint(1))
420 self.failUnless(Lsup(d_0-self.arg0*2)<=Lsup(self.arg0*2), "wrong setting")
421 self.failUnless(Lsup(d_1-self.arg0)<=Lsup(self.arg0), "wrong setting")
422 def test_SetDataPointValue_ReducedFunction_Rank1(self):
423 d=Data(self.arg1,ReducedFunction(self.domain))
424 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
425 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
426 d.setValueOfDataPoint(0,self.arg1*2)
427 d_0=numpy.array(d.getTupleForDataPoint(0))
428 d_1=numpy.array(d.getTupleForDataPoint(1))
429 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
430 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
431 def test_SetDataPointValue_ReducedFunction_Rank1_list(self):
432 d=Data(self.arg1,ReducedFunction(self.domain))
433 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg2)
434 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg1)
435 d.setValueOfDataPoint(0,(self.arg1*2).tolist())
436 d_0=numpy.array(d.getTupleForDataPoint(0))
437 d_1=numpy.array(d.getTupleForDataPoint(1))
438 self.failUnless(Lsup(d_0-self.arg1*2)<=Lsup(self.arg1*2), "wrong setting")
439 self.failUnless(Lsup(d_1-self.arg1)<=Lsup(self.arg1), "wrong setting")
440 def test_SetDataPointValue_ReducedFunction_Rank2(self):
441 d=Data(self.arg2,ReducedFunction(self.domain))
442 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
443 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
444 d.setValueOfDataPoint(0,self.arg2*2)
445 d_0=numpy.array(d.getTupleForDataPoint(0))
446 d_1=numpy.array(d.getTupleForDataPoint(1))
447 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
448 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
449 def test_SetDataPointValue_ReducedFunction_Rank2_list(self):
450 d=Data(self.arg2,ReducedFunction(self.domain))
451 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
452 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg2)
453 d.setValueOfDataPoint(0,(self.arg2*2).tolist())
454 d_0=numpy.array(d.getTupleForDataPoint(0))
455 d_1=numpy.array(d.getTupleForDataPoint(1))
456 self.failUnless(Lsup(d_0-self.arg2*2)<=Lsup(self.arg2*2), "wrong setting")
457 self.failUnless(Lsup(d_1-self.arg2)<=Lsup(self.arg2), "wrong setting")
458 def test_SetDataPointValue_ReducedFunction_Rank3(self):
459 d=Data(self.arg3,ReducedFunction(self.domain))
460 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
461 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
462 d.setValueOfDataPoint(0,self.arg3*2)
463 d_0=numpy.array(d.getTupleForDataPoint(0))
464 d_1=numpy.array(d.getTupleForDataPoint(1))
465 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
466 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
467 def test_SetDataPointValue_ReducedFunction_Rank3_list(self):
468 d=Data(self.arg3,ReducedFunction(self.domain))
469 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
470 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg3)
471 d.setValueOfDataPoint(0,(self.arg3*2).tolist())
472 d_0=numpy.array(d.getTupleForDataPoint(0))
473 d_1=numpy.array(d.getTupleForDataPoint(1))
474 self.failUnless(Lsup(d_0-self.arg3*2)<=Lsup(self.arg3*2), "wrong setting")
475 self.failUnless(Lsup(d_1-self.arg3)<=Lsup(self.arg3), "wrong setting")
476 def test_SetDataPointValue_ReducedFunction_Rank4(self):
477 d=Data(self.arg4,ReducedFunction(self.domain))
478 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
479 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
480 d.setValueOfDataPoint(0,self.arg4*2)
481 d_0=numpy.array(d.getTupleForDataPoint(0))
482 d_1=numpy.array(d.getTupleForDataPoint(1))
483 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
484 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
485 def test_SetDataPointValue_ReducedFunction_Rank4_list(self):
486 d=Data(self.arg4,ReducedFunction(self.domain))
487 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, 0, self.arg1)
488 self.failUnlessRaises(RuntimeError, d.setValueOfDataPoint, -1, self.arg4)
489 d.setValueOfDataPoint(0,(self.arg4*2).tolist())
490 d_0=numpy.array(d.getTupleForDataPoint(0))
491 d_1=numpy.array(d.getTupleForDataPoint(1))
492 self.failUnless(Lsup(d_0-self.arg4*2)<=Lsup(self.arg4*2), "wrong setting")
493 self.failUnless(Lsup(d_1-self.arg4)<=Lsup(self.arg4), "wrong setting")
494
495 class Test_Dump(unittest.TestCase):
496 arg0=9.81
497 arg1=numpy.array([3.098, -3.111])
498 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]])
499 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]]])
500 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]]]])
501
502 def _diffDataObjects(self,d_ref,filemame, use_old_file=False):
503 if not use_old_file: d_ref.dump(filemame)
504 d=load(filemame, d_ref.getDomain())
505 self.failUnless(not d.isEmpty(),"data in %s are empty."%filemame)
506 self.failUnless(d_ref.getRank() == d.getRank(), "different rank in %s. "%filemame)
507 self.failUnless(d_ref.getShape() == d.getShape(), "different shape %s. "%filemame)
508 self.failUnless(d_ref.getFunctionSpace() == d.getFunctionSpace(), "wrong function space in %s."%filemame)
509 self.failUnless(Lsup(d_ref-d)<=0., "different entries %s."%filemame)
510
511 #===========================================================================
512 def test_DumpAndLoad_Constant_Solution_Rank0(self):
513 if loadIsConfigured():
514 filemame=os.path.join(self.filename_base,"constant_solution_rank0.nc")
515 d=Data(self.arg0,Solution(self.domain))
516 self._diffDataObjects(d,filemame)
517
518 def test_DumpAndLoad_Constant_Solution_Rank1(self):
519 if loadIsConfigured():
520 filemame=os.path.join(self.filename_base,"constant_solution_rank1.nc")
521 d=Data(self.arg1,Solution(self.domain))
522 self._diffDataObjects(d,filemame)
523
524 def test_DumpAndLoad_Constant_Solution_Rank2(self):
525 if loadIsConfigured():
526 filemame=os.path.join(self.filename_base,"constant_solution_rank2.nc")
527 d=Data(self.arg2,Solution(self.domain))
528 self._diffDataObjects(d,filemame)
529
530 def test_DumpAndLoad_Constant_Solution_Rank3(self):
531 if loadIsConfigured():
532 filemame=os.path.join(self.filename_base,"constant_solution_rank3.nc")
533 d=Data(self.arg3,Solution(self.domain))
534 self._diffDataObjects(d,filemame)
535
536 def test_DumpAndLoad_Constant_Solution_Rank4(self):
537 if loadIsConfigured():
538 filemame=os.path.join(self.filename_base,"constant_solution_rank4.nc")
539 d=Data(self.arg4,Solution(self.domain))
540 self._diffDataObjects(d,filemame)
541 #===========================================================================
542 def test_DumpAndLoad_Constant_ReducedSolution_Rank0(self):
543 if loadIsConfigured():
544 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank0.nc")
545 d=Data(self.arg0,ReducedSolution(self.domain))
546 self._diffDataObjects(d,filemame)
547
548 def test_DumpAndLoad_Constant_ReducedSolution_Rank1(self):
549 if loadIsConfigured():
550 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank1.nc")
551 d=Data(self.arg1,ReducedSolution(self.domain))
552 self._diffDataObjects(d,filemame)
553
554 def test_DumpAndLoad_Constant_ReducedSolution_Rank2(self):
555 if loadIsConfigured():
556 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank2.nc")
557 d=Data(self.arg2,ReducedSolution(self.domain))
558 self._diffDataObjects(d,filemame)
559
560 def test_DumpAndLoad_Constant_ReducedSolution_Rank3(self):
561 if loadIsConfigured():
562 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank3.nc")
563 d=Data(self.arg3,ReducedSolution(self.domain))
564 self._diffDataObjects(d,filemame)
565
566 def test_DumpAndLoad_Constant_ReducedSolution_Rank4(self):
567 if loadIsConfigured():
568 filemame=os.path.join(self.filename_base,"constant_reduced_solution_rank4.nc")
569 d=Data(self.arg4,ReducedSolution(self.domain))
570 self._diffDataObjects(d,filemame)
571 #===========================================================================
572 def test_DumpAndLoad_Constant_ContinuousFunction_Rank0(self):
573 if loadIsConfigured():
574 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank0.nc")
575 d=Data(self.arg0,ContinuousFunction(self.domain))
576 self._diffDataObjects(d,filemame)
577
578 def test_DumpAndLoad_Constant_ContinuousFunction_Rank1(self):
579 if loadIsConfigured():
580 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank1.nc")
581 d=Data(self.arg1,ContinuousFunction(self.domain))
582 self._diffDataObjects(d,filemame)
583
584 def test_DumpAndLoad_Constant_ContinuousFunction_Rank2(self):
585 if loadIsConfigured():
586 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank2.nc")
587 d=Data(self.arg2,ContinuousFunction(self.domain))
588 self._diffDataObjects(d,filemame)
589
590 def test_DumpAndLoad_Constant_ContinuousFunction_Rank3(self):
591 if loadIsConfigured():
592 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank3.nc")
593 d=Data(self.arg3,ContinuousFunction(self.domain))
594 self._diffDataObjects(d,filemame)
595
596 def test_DumpAndLoad_Constant_ContinuousFunction_Rank4(self):
597 if loadIsConfigured():
598 filemame=os.path.join(self.filename_base,"constant_continuous_function_rank4.nc")
599 d=Data(self.arg4,ContinuousFunction(self.domain))
600 self._diffDataObjects(d,filemame)
601
602 #===========================================================================
603 def test_DumpAndLoad_Constant_Function_Rank0(self):
604 if loadIsConfigured():
605 filemame=os.path.join(self.filename_base,"constant_function_rank0.nc")
606 d=Data(self.arg0,Function(self.domain))
607 self._diffDataObjects(d,filemame)
608
609 def test_DumpAndLoad_Constant_Function_Rank1(self):
610 if loadIsConfigured():
611 filemame=os.path.join(self.filename_base,"constant_function_rank1.nc")
612 d=Data(self.arg1,Function(self.domain))
613 self._diffDataObjects(d,filemame)
614
615 def test_DumpAndLoad_Constant_Function_Rank2(self):
616 if loadIsConfigured():
617 filemame=os.path.join(self.filename_base,"constant_function_rank2.nc")
618 d=Data(self.arg2,Function(self.domain))
619 self._diffDataObjects(d,filemame)
620
621 def test_DumpAndLoad_Constant_Function_Rank3(self):
622 if loadIsConfigured():
623 filemame=os.path.join(self.filename_base,"constant_function_rank3.nc")
624 d=Data(self.arg3,Function(self.domain))
625 self._diffDataObjects(d,filemame)
626
627 #===========================================================================
628 def test_DumpAndLoad_Constant_ReducedFunction_Rank0(self):
629 if loadIsConfigured():
630 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank0.nc")
631 d=Data(self.arg0,ReducedFunction(self.domain))
632 self._diffDataObjects(d,filemame)
633
634 def test_DumpAndLoad_Constant_ReducedFunction_Rank1(self):
635 if loadIsConfigured():
636 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank1.nc")
637 d=Data(self.arg1,ReducedFunction(self.domain))
638 self._diffDataObjects(d,filemame)
639
640 def test_DumpAndLoad_Constant_ReducedFunction_Rank2(self):
641 if loadIsConfigured():
642 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank2.nc")
643 d=Data(self.arg2,ReducedFunction(self.domain))
644 self._diffDataObjects(d,filemame)
645
646 def test_DumpAndLoad_Constant_ReducedFunction_Rank3(self):
647 if loadIsConfigured():
648 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank3.nc")
649 d=Data(self.arg3,ReducedFunction(self.domain))
650 self._diffDataObjects(d,filemame)
651 def test_DumpAndLoad_Constant_ReducedFunction_Rank4(self):
652 if loadIsConfigured():
653 filemame=os.path.join(self.filename_base,"constant_reduced_function_rank4.nc")
654 d=Data(self.arg4,ReducedFunction(self.domain))
655 self._diffDataObjects(d,filemame)
656
657 #===========================================================================
658 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank0(self):
659 if loadIsConfigured():
660 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank0.nc")
661 d=Data(self.arg0,FunctionOnBoundary(self.domain))
662 self._diffDataObjects(d,filemame)
663
664 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank1(self):
665 if loadIsConfigured():
666 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank1.nc")
667 d=Data(self.arg1,FunctionOnBoundary(self.domain))
668 self._diffDataObjects(d,filemame)
669
670 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank2(self):
671 if loadIsConfigured():
672 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank2.nc")
673 d=Data(self.arg2,FunctionOnBoundary(self.domain))
674 self._diffDataObjects(d,filemame)
675
676 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank3(self):
677 if loadIsConfigured():
678 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank3.nc")
679 d=Data(self.arg3,FunctionOnBoundary(self.domain))
680 self._diffDataObjects(d,filemame)
681
682 def test_DumpAndLoad_Constant_FunctionOnBoundary_Rank4(self):
683 if loadIsConfigured():
684 filemame=os.path.join(self.filename_base,"constant_function_on_boundary_rank4.nc")
685 d=Data(self.arg4,FunctionOnBoundary(self.domain))
686 self._diffDataObjects(d,filemame)
687
688 #===========================================================================
689 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank0(self):
690 if loadIsConfigured():
691 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank0.nc")
692 d=Data(self.arg0,FunctionOnBoundary(self.domain))
693 self._diffDataObjects(d,filemame)
694
695 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank1(self):
696 if loadIsConfigured():
697 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank1.nc")
698 d=Data(self.arg1,ReducedFunctionOnBoundary(self.domain))
699 self._diffDataObjects(d,filemame)
700
701 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank2(self):
702 if loadIsConfigured():
703 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank2.nc")
704 d=Data(self.arg2,ReducedFunctionOnBoundary(self.domain))
705 self._diffDataObjects(d,filemame)
706
707 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank3(self):
708 if loadIsConfigured():
709 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank3.nc")
710 d=Data(self.arg3,ReducedFunctionOnBoundary(self.domain))
711 self._diffDataObjects(d,filemame)
712
713 def test_DumpAndLoad_Constant_ReducedFunctionOnBoundary_Rank4(self):
714 if loadIsConfigured():
715 filemame=os.path.join(self.filename_base,"constant_reduced_function_on_boundary_rank4.nc")
716 d=Data(self.arg4,ReducedFunctionOnBoundary(self.domain))
717 self._diffDataObjects(d,filemame)
718
719 #===========================================================================
720 def test_DumpAndLoad_Expanded_Solution_Rank0(self):
721 if loadIsConfigured():
722 filemame=os.path.join(self.filename_base,"expanded_solution_rank0.nc")
723 d=Data(length(Solution(self.domain).getX())*self.arg0,Solution(self.domain))
724 self._diffDataObjects(d,filemame)
725 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
726 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
727 if getMPISizeWorld() ==1:
728 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg0,Solution(self.domain_with_different_sample_ordering))
729 self._diffDataObjects(d,filemame, use_old_file=True)
730
731 def test_DumpAndLoad_Expanded_Solution_Rank1(self):
732 if loadIsConfigured():
733 filemame=os.path.join(self.filename_base,"expanded_solution_rank1.nc")
734 d=Data(length(Solution(self.domain).getX())*self.arg1,Solution(self.domain))
735 self._diffDataObjects(d,filemame)
736 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
737 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
738 if getMPISizeWorld() ==1:
739 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg1,Solution(self.domain_with_different_sample_ordering))
740 self._diffDataObjects(d,filemame, use_old_file=True)
741
742 def test_DumpAndLoad_Expanded_Solution_Rank2(self):
743 if loadIsConfigured():
744 filemame=os.path.join(self.filename_base,"expanded_solution_rank2.nc")
745 d=Data(length(Solution(self.domain).getX())*self.arg2,Solution(self.domain))
746 self._diffDataObjects(d,filemame)
747 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
748 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
749 if getMPISizeWorld() ==1:
750 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg2,Solution(self.domain_with_different_sample_ordering))
751 self._diffDataObjects(d,filemame, use_old_file=True)
752
753 def test_DumpAndLoad_Expanded_Solution_Rank3(self):
754 if loadIsConfigured():
755 filemame=os.path.join(self.filename_base,"expanded_solution_rank3.nc")
756 d=Data(length(Solution(self.domain).getX())*self.arg3,Solution(self.domain))
757 self._diffDataObjects(d,filemame)
758 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
759 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
760 if getMPISizeWorld() ==1:
761 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg3,Solution(self.domain_with_different_sample_ordering))
762 self._diffDataObjects(d,filemame, use_old_file=True)
763
764 def test_DumpAndLoad_Expanded_Solution_Rank4(self):
765 if loadIsConfigured():
766 filemame=os.path.join(self.filename_base,"expanded_solution_rank4.nc")
767 d=Data(length(Solution(self.domain).getX())*self.arg4,Solution(self.domain))
768 self._diffDataObjects(d,filemame)
769 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
770 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
771 if getMPISizeWorld() ==1:
772 d=Data(length(Solution(self.domain_with_different_sample_ordering).getX())*self.arg4,Solution(self.domain_with_different_sample_ordering))
773 self._diffDataObjects(d,filemame, use_old_file=True)
774 #===========================================================================
775 def test_DumpAndLoad_Expanded_ReducedSolution_Rank0(self):
776 if loadIsConfigured():
777 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank0.nc")
778 d=Data(length(ReducedSolution(self.domain).getX())*self.arg0,ReducedSolution(self.domain))
779 self._diffDataObjects(d,filemame)
780 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
781 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
782 if getMPISizeWorld() ==1:
783 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg0,ReducedSolution(self.domain_with_different_sample_ordering))
784 self._diffDataObjects(d,filemame, use_old_file=True)
785
786 def test_DumpAndLoad_Expanded_ReducedSolution_Rank1(self):
787 if loadIsConfigured():
788 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank1.nc")
789 d=Data(length(ReducedSolution(self.domain).getX())*self.arg1,ReducedSolution(self.domain))
790 self._diffDataObjects(d,filemame)
791 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
792 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
793 if getMPISizeWorld() ==1:
794 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg1,ReducedSolution(self.domain_with_different_sample_ordering))
795 self._diffDataObjects(d,filemame, use_old_file=True)
796
797 def test_DumpAndLoad_Expanded_ReducedSolution_Rank2(self):
798 if loadIsConfigured():
799 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank2.nc")
800 d=Data(length(ReducedSolution(self.domain).getX())*self.arg2,ReducedSolution(self.domain))
801 self._diffDataObjects(d,filemame)
802 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
803 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
804 if getMPISizeWorld() ==1:
805 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg2,ReducedSolution(self.domain_with_different_sample_ordering))
806 self._diffDataObjects(d,filemame, use_old_file=True)
807
808 def test_DumpAndLoad_Expanded_ReducedSolution_Rank3(self):
809 if loadIsConfigured():
810 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank3.nc")
811 d=Data(length(ReducedSolution(self.domain).getX())*self.arg3,ReducedSolution(self.domain))
812 self._diffDataObjects(d,filemame)
813 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
814 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
815 if getMPISizeWorld() ==1:
816 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg3,ReducedSolution(self.domain_with_different_sample_ordering))
817 self._diffDataObjects(d,filemame, use_old_file=True)
818
819 def test_DumpAndLoad_Expanded_ReducedSolution_Rank4(self):
820 if loadIsConfigured():
821 filemame=os.path.join(self.filename_base,"expanded_reduced_solution_rank4.nc")
822 d=Data(length(ReducedSolution(self.domain).getX())*self.arg4,ReducedSolution(self.domain))
823 self._diffDataObjects(d,filemame)
824 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
825 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
826 if getMPISizeWorld() ==1:
827 d=Data(length(ReducedSolution(self.domain_with_different_sample_ordering).getX())*self.arg4,ReducedSolution(self.domain_with_different_sample_ordering))
828 self._diffDataObjects(d,filemame, use_old_file=True)
829 #===========================================================================
830 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank0(self):
831 if loadIsConfigured():
832 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank0.nc")
833 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg0,ContinuousFunction(self.domain))
834 self._diffDataObjects(d,filemame)
835 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
836 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
837 if getMPISizeWorld() ==1:
838 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg0,ContinuousFunction(self.domain_with_different_sample_ordering))
839 self._diffDataObjects(d,filemame, use_old_file=True)
840
841 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank1(self):
842 if loadIsConfigured():
843 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank1.nc")
844 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
845 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg1,ContinuousFunction(self.domain))
846 self._diffDataObjects(d,filemame)
847 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
848 if getMPISizeWorld() ==1:
849 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg1,ContinuousFunction(self.domain_with_different_sample_ordering))
850 self._diffDataObjects(d,filemame, use_old_file=True)
851
852 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank2(self):
853 if loadIsConfigured():
854 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank2.nc")
855 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg2,ContinuousFunction(self.domain))
856 self._diffDataObjects(d,filemame)
857 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
858 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
859 if getMPISizeWorld() ==1:
860 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg2,ContinuousFunction(self.domain_with_different_sample_ordering))
861 self._diffDataObjects(d,filemame, use_old_file=True)
862
863 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank3(self):
864 if loadIsConfigured():
865 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank3.nc")
866 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg3,ContinuousFunction(self.domain))
867 self._diffDataObjects(d,filemame)
868 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
869 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
870 if getMPISizeWorld() ==1:
871 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg3,ContinuousFunction(self.domain_with_different_sample_ordering))
872 self._diffDataObjects(d,filemame, use_old_file=True)
873
874 def test_DumpAndLoad_Expanded_ContinuousFunction_Rank4(self):
875 if loadIsConfigured():
876 filemame=os.path.join(self.filename_base,"expanded_continuous_function_rank4.nc")
877 d=Data(length(ContinuousFunction(self.domain).getX())*self.arg4,ContinuousFunction(self.domain))
878 self._diffDataObjects(d,filemame)
879 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
880 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
881 if getMPISizeWorld() ==1:
882 d=Data(length(ContinuousFunction(self.domain_with_different_sample_ordering).getX())*self.arg4,ContinuousFunction(self.domain_with_different_sample_ordering))
883 self._diffDataObjects(d,filemame, use_old_file=True)
884
885 #===========================================================================
886 def test_DumpAndLoad_Expanded_Function_Rank0(self):
887 if loadIsConfigured():
888 filemame=os.path.join(self.filename_base,"expanded_function_rank0.nc")
889 d=Data(length(Function(self.domain).getX())*self.arg0,Function(self.domain))
890 self._diffDataObjects(d,filemame)
891 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
892 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
893 if getMPISizeWorld() ==1:
894 d=Data(length(Function(self.domain_with_different_sample_ordering).getX())*self.arg0,Function(self.domain_with_different_sample_ordering))
895 self._diffDataObjects(d,filemame, use_old_file=True)
896
897 def test_DumpAndLoad_Expanded_Function_Rank1(self):
898 if loadIsConfigured():
899 filemame=os.path.join(self.filename_base,"expanded_function_rank1.nc")
900 d=Data(length(Function(self.domain).getX())*self.arg1,Function(self.domain))
901 self._diffDataObjects(d,filemame)
902 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
903 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
904 if getMPISizeWorld() ==1:
905 d=Data(length(Function(self.domain_with_different_sample_ordering).getX())*self.arg1,Function(self.domain_with_different_sample_ordering))
906 self._diffDataObjects(d,filemame, use_old_file=True)
907
908 def test_DumpAndLoad_Expanded_Function_Rank2(self):
909 if loadIsConfigured():
910 filemame=os.path.join(self.filename_base,"expanded_function_rank2.nc")
911 d=Data(length(Function(self.domain).getX())*self.arg2,Function(self.domain))
912 self._diffDataObjects(d,filemame)
913 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
914 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
915 if getMPISizeWorld() ==1:
916 d=Data(length(Function(self.domain_with_different_sample_ordering).getX())*self.arg2,Function(self.domain_with_different_sample_ordering))
917 self._diffDataObjects(d,filemame, use_old_file=True)
918
919 def test_DumpAndLoad_Expanded_Function_Rank3(self):
920 if loadIsConfigured():
921 filemame=os.path.join(self.filename_base,"expanded_function_rank3.nc")
922 d=Data(length(Function(self.domain).getX())*self.arg3,Function(self.domain))
923 self._diffDataObjects(d,filemame)
924 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
925 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
926 if getMPISizeWorld() ==1:
927 d=Data(length(Function(self.domain_with_different_sample_ordering).getX())*self.arg3,Function(self.domain_with_different_sample_ordering))
928 self._diffDataObjects(d,filemame, use_old_file=True)
929
930 def test_DumpAndLoad_Expanded_Function_Rank4(self):
931 if loadIsConfigured():
932 filemame=os.path.join(self.filename_base,"expanded_function_rank4.nc")
933 d=Data(length(Function(self.domain).getX())*self.arg4,Function(self.domain))
934 self._diffDataObjects(d,filemame)
935 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
936 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
937 if getMPISizeWorld() ==1:
938 d=Data(length(Function(self.domain_with_different_sample_ordering).getX())*self.arg4,Function(self.domain_with_different_sample_ordering))
939 self._diffDataObjects(d,filemame, use_old_file=True)
940
941 #===========================================================================
942 def test_DumpAndLoad_Expanded_ReducedFunction_Rank0(self):
943 if loadIsConfigured():
944 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank0.nc")
945 d=Data(length(ReducedFunction(self.domain).getX())*self.arg0,ReducedFunction(self.domain))
946 self._diffDataObjects(d,filemame)
947 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
948 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
949 if getMPISizeWorld() ==1:
950 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg0,ReducedFunction(self.domain_with_different_sample_ordering))
951 self._diffDataObjects(d,filemame, use_old_file=True)
952
953 def test_DumpAndLoad_Expanded_ReducedFunction_Rank1(self):
954 if loadIsConfigured():
955 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank1.nc")
956 d=Data(length(ReducedFunction(self.domain).getX())*self.arg1,ReducedFunction(self.domain))
957 self._diffDataObjects(d,filemame)
958 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
959 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
960 if getMPISizeWorld() ==1:
961 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg1,ReducedFunction(self.domain_with_different_sample_ordering))
962 self._diffDataObjects(d,filemame, use_old_file=True)
963
964 def test_DumpAndLoad_Expanded_ReducedFunction_Rank2(self):
965 if loadIsConfigured():
966 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank2.nc")
967 d=Data(length(ReducedFunction(self.domain).getX())*self.arg2,ReducedFunction(self.domain))
968 self._diffDataObjects(d,filemame)
969 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
970 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
971 if getMPISizeWorld() ==1:
972 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg2,ReducedFunction(self.domain_with_different_sample_ordering))
973 self._diffDataObjects(d,filemame, use_old_file=True)
974
975 def test_DumpAndLoad_Expanded_ReducedFunction_Rank3(self):
976 if loadIsConfigured():
977 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank3.nc")
978 d=Data(length(ReducedFunction(self.domain).getX())*self.arg3,ReducedFunction(self.domain))
979 self._diffDataObjects(d,filemame)
980 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
981 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
982 if getMPISizeWorld() ==1:
983 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg3,ReducedFunction(self.domain_with_different_sample_ordering))
984 self._diffDataObjects(d,filemame, use_old_file=True)
985
986 def test_DumpAndLoad_Expanded_ReducedFunction_Rank4(self):
987 if loadIsConfigured():
988 filemame=os.path.join(self.filename_base,"expanded_reduced_function_rank4.nc")
989 d=Data(length(ReducedFunction(self.domain).getX())*self.arg4,ReducedFunction(self.domain))
990 self._diffDataObjects(d,filemame)
991 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
992 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
993 if getMPISizeWorld() ==1:
994 d=Data(length(ReducedFunction(self.domain_with_different_sample_ordering).getX())*self.arg4,ReducedFunction(self.domain_with_different_sample_ordering))
995 self._diffDataObjects(d,filemame, use_old_file=True)
996
997 #===========================================================================
998 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank0(self):
999 if loadIsConfigured():
1000 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank0.nc")
1001 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg0,FunctionOnBoundary(self.domain))
1002 self._diffDataObjects(d,filemame)
1003 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1004 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1005 if getMPISizeWorld() ==1:
1006 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg0,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1007 self._diffDataObjects(d,filemame, use_old_file=True)
1008
1009 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank1(self):
1010 if loadIsConfigured():
1011 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank1.nc")
1012 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg1,FunctionOnBoundary(self.domain))
1013 self._diffDataObjects(d,filemame)
1014 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1015 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1016 if getMPISizeWorld() ==1:
1017 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg1,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1018 self._diffDataObjects(d,filemame, use_old_file=True)
1019
1020 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank2(self):
1021 if loadIsConfigured():
1022 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank2.nc")
1023 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg2,FunctionOnBoundary(self.domain))
1024 self._diffDataObjects(d,filemame)
1025 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1026 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1027 if getMPISizeWorld() ==1:
1028 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg2,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1029 self._diffDataObjects(d,filemame, use_old_file=True)
1030
1031 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank3(self):
1032 if loadIsConfigured():
1033 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank3.nc")
1034 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg3,FunctionOnBoundary(self.domain))
1035 self._diffDataObjects(d,filemame)
1036 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1037 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1038 if getMPISizeWorld() ==1:
1039 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg3,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1040 self._diffDataObjects(d,filemame, use_old_file=True)
1041
1042 def test_DumpAndLoad_Expanded_FunctionOnBoundary_Rank4(self):
1043 if loadIsConfigured():
1044 filemame=os.path.join(self.filename_base,"expanded_function_on_boundary_rank4.nc")
1045 d=Data(length(FunctionOnBoundary(self.domain).getX())*self.arg4,FunctionOnBoundary(self.domain))
1046 self._diffDataObjects(d,filemame)
1047 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1048 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1049 if getMPISizeWorld() ==1:
1050 d=Data(length(FunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg4,FunctionOnBoundary(self.domain_with_different_sample_ordering))
1051 self._diffDataObjects(d,filemame, use_old_file=True)
1052
1053 #===========================================================================
1054 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank0(self):
1055 if loadIsConfigured():
1056 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank0.nc")
1057 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg0,ReducedFunctionOnBoundary(self.domain))
1058 self._diffDataObjects(d,filemame)
1059 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1060 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1061 if getMPISizeWorld() ==1:
1062 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg0,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1063 self._diffDataObjects(d,filemame, use_old_file=True)
1064
1065 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank1(self):
1066 if loadIsConfigured():
1067 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank1.nc")
1068 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg1,ReducedFunctionOnBoundary(self.domain))
1069 self._diffDataObjects(d,filemame)
1070 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1071 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1072 if getMPISizeWorld() ==1:
1073 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg1,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1074 self._diffDataObjects(d,filemame, use_old_file=True)
1075
1076 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank2(self):
1077 if loadIsConfigured():
1078 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank2.nc")
1079 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg2,ReducedFunctionOnBoundary(self.domain))
1080 self._diffDataObjects(d,filemame)
1081 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1082 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1083 if getMPISizeWorld() ==1:
1084 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg2,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1085 self._diffDataObjects(d,filemame, use_old_file=True)
1086
1087 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank3(self):
1088 if loadIsConfigured():
1089 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank3.nc")
1090 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg3,ReducedFunctionOnBoundary(self.domain))
1091 self._diffDataObjects(d,filemame)
1092 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1093 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1094 if getMPISizeWorld() ==1:
1095 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg3,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1096 self._diffDataObjects(d,filemame, use_old_file=True)
1097
1098 def test_DumpAndLoad_Expanded_ReducedFunctionOnBoundary_Rank4(self):
1099 if loadIsConfigured():
1100 filemame=os.path.join(self.filename_base,"expanded_reduced_function_on_boundary_rank4.nc")
1101 d=Data(length(ReducedFunctionOnBoundary(self.domain).getX())*self.arg4,ReducedFunctionOnBoundary(self.domain))
1102 self._diffDataObjects(d,filemame)
1103 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_samples)
1104 self.failUnlessRaises(RuntimeError, load, filemame, self.domain_with_different_number_of_data_points_per_sample)
1105 if getMPISizeWorld() ==1:
1106 d=Data(length(ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering).getX())*self.arg4,ReducedFunctionOnBoundary(self.domain_with_different_sample_ordering))
1107 self._diffDataObjects(d,filemame, use_old_file=True)
1108
1109 #===========================================================================
1110 ## This functionspace does not currently support tags.
1111 ## Instead, we test that the canTag() function throws in test_canTag_Failures.
1112
1113 #def test_DumpAndLoad_Tagged_Solution_Rank0(self):
1114 #if loadIsConfigured():
1115 #filemame=os.path.join(self.filename_base,"tagged_solution_rank0.nc")
1116 #d=Data(self.arg0,Solution(self.domain))
1117 #d.setTaggedValue(1,self.arg0*2)
1118 #d.setTaggedValue(10,self.arg0*3)
1119 #d.setTaggedValue(100,self.arg0*4)
1120 #self._diffDataObjects(d,filemame)
1121
1122 #def test_DumpAndLoad_Tagged_Solution_Rank1(self):
1123 #if loadIsConfigured():
1124 #filemame=os.path.join(self.filename_base,"tagged_solution_rank1.nc")
1125 #d=Data(self.arg1,Solution(self.domain))
1126 #d.setTaggedValue(1,self.arg1*2)
1127 #d.setTaggedValue(10,self.arg1*3)
1128 #d.setTaggedValue(100,self.arg1*4)
1129 #self._diffDataObjects(d,filemame)
1130
1131 #def test_DumpAndLoad_Tagged_Solution_Rank2(self):
1132 #if loadIsConfigured():
1133 #filemame=os.path.join(self.filename_base,"tagged_solution_rank2.nc")
1134 #d=Data(self.arg2,Solution(self.domain))
1135 #d.setTaggedValue(1,self.arg2*2)
1136 #d.setTaggedValue(10,self.arg2*3)
1137 #d.setTaggedValue(100,self.arg2*4)
1138 #self._diffDataObjects(d,filemame)
1139
1140 #def test_DumpAndLoad_Tagged_Solution_Rank3(self):
1141 #if loadIsConfigured():
1142 #filemame=os.path.join(self.filename_base,"tagged_solution_rank3.nc")
1143 #d=Data(self.arg3,Solution(self.domain))
1144 #d.setTaggedValue(1,self.arg3*2)
1145 #d.setTaggedValue(10,self.arg3*3)
1146 #d.setTaggedValue(100,self.arg3*4)
1147 #self._diffDataObjects(d,filemame)
1148
1149 #def test_DumpAndLoad_Tagged_Solution_Rank4(self):
1150 #if loadIsConfigured():
1151 #filemame=os.path.join(self.filename_base,"tagged_solution_rank4.nc")
1152 #d=Data(self.arg4,Solution(self.domain))
1153 #d.setTaggedValue(1,self.arg4*2)
1154 #d.setTaggedValue(10,self.arg4*3)
1155 #d.setTaggedValue(100,self.arg4*4)
1156 #self._diffDataObjects(d,filemame)
1157 ##===========================================================================
1158 ## This functionspace does not currently support tags.
1159 ## Instead, we test that the canTag() function throws in test_canTag_Failures.
1160
1161 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank0(self):
1162 #if loadIsConfigured():
1163 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank0.nc")
1164 #d=Data(self.arg0,ReducedSolution(self.domain))
1165 #d.setTaggedValue(1,self.arg0*2)
1166 #d.setTaggedValue(10,self.arg0*3)
1167 #d.setTaggedValue(100,self.arg0*4)
1168 #self._diffDataObjects(d,filemame)
1169
1170 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank1(self):
1171 #if loadIsConfigured():
1172 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank1.nc")
1173 #d=Data(self.arg1,ReducedSolution(self.domain))
1174 #d.setTaggedValue(1,self.arg1*2)
1175 #d.setTaggedValue(10,self.arg1*3)
1176 #d.setTaggedValue(100,self.arg1*4)
1177 #self._diffDataObjects(d,filemame)
1178
1179 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank2(self):
1180 #if loadIsConfigured():
1181 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank2.nc")
1182 #d=Data(self.arg2,ReducedSolution(self.domain))
1183 #d.setTaggedValue(1,self.arg2*2)
1184 #d.setTaggedValue(10,self.arg2*3)
1185 #d.setTaggedValue(100,self.arg2*4)
1186 #self._diffDataObjects(d,filemame)
1187
1188 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank3(self):
1189 #if loadIsConfigured():
1190 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank3.nc")
1191 #d=Data(self.arg3,ReducedSolution(self.domain))
1192 #d.setTaggedValue(1,self.arg3*2)
1193 #d.setTaggedValue(10,self.arg3*3)
1194 #d.setTaggedValue(100,self.arg3*4)
1195 #self._diffDataObjects(d,filemame)
1196
1197 #def test_DumpAndLoad_Tagged_ReducedSolution_Rank4(self):
1198 #if loadIsConfigured():
1199 #filemame=os.path.join(self.filename_base,"tagged_reduced_solution_rank4.nc")
1200 #d=Data(self.arg4,ReducedSolution(self.domain))
1201 #d.setTaggedValue(1,self.arg4*2)
1202 #d.setTaggedValue(10,self.arg4*3)
1203 #d.setTaggedValue(100,self.arg4*4)
1204 #self._diffDataObjects(d,filemame)
1205 ##===========================================================================
1206 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank0(self):
1207 if loadIsConfigured():
1208 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank0.nc")
1209 d=Data(self.arg0,ContinuousFunction(self.domain))
1210 d.setTaggedValue(1,self.arg0*2)
1211 d.setTaggedValue(10,self.arg0*3)
1212 d.setTaggedValue(100,self.arg0*4)
1213 self._diffDataObjects(d,filemame)
1214
1215 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank1(self):
1216 if loadIsConfigured():
1217 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank1.nc")
1218 d=Data(self.arg1,ContinuousFunction(self.domain))
1219 d.setTaggedValue(1,self.arg1*2)
1220 d.setTaggedValue(10,self.arg1*3)
1221 d.setTaggedValue(100,self.arg1*4)
1222 self._diffDataObjects(d,filemame)
1223
1224 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank2(self):
1225 if loadIsConfigured():
1226 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank2.nc")
1227 d=Data(self.arg2,ContinuousFunction(self.domain))
1228 d.setTaggedValue(1,self.arg2*2)
1229 d.setTaggedValue(10,self.arg2*3)
1230 d.setTaggedValue(100,self.arg2*4)
1231 self._diffDataObjects(d,filemame)
1232
1233 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank3(self):
1234 if loadIsConfigured():
1235 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank3.nc")
1236 d=Data(self.arg3,ContinuousFunction(self.domain))
1237 d.setTaggedValue(1,self.arg3*2)
1238 d.setTaggedValue(10,self.arg3*3)
1239 d.setTaggedValue(100,self.arg3*4)
1240 self._diffDataObjects(d,filemame)
1241
1242 def test_DumpAndLoad_Tagged_ContinuousFunction_Rank4(self):
1243 if loadIsConfigured():
1244 filemame=os.path.join(self.filename_base,"tagged_continuous_function_rank4.nc")
1245 d=Data(self.arg4,ContinuousFunction(self.domain))
1246 d.setTaggedValue(1,self.arg4*2)
1247 d.setTaggedValue(10,self.arg4*3)
1248 d.setTaggedValue(100,self.arg4*4)
1249 self._diffDataObjects(d,filemame)
1250
1251 #===========================================================================
1252 def test_DumpAndLoad_Tagged_Function_Rank0(self):
1253 if loadIsConfigured():
1254 filemame=os.path.join(self.filename_base,"tagged_function_rank0.nc")
1255 d=Data(self.arg0,Function(self.domain))
1256 d.setTaggedValue(1,self.arg0*2)
1257 d.setTaggedValue(10,self.arg0*3)
1258 d.setTaggedValue(100,self.arg0*4)
1259 self._diffDataObjects(d,filemame)
1260
1261 def test_DumpAndLoad_Tagged_Function_Rank1(self):
1262 if loadIsConfigured():
1263 filemame=os.path.join(self.filename_base,"tagged_function_rank1.nc")
1264 d=Data(self.arg1,Function(self.domain))
1265 d.setTaggedValue(1,self.arg1*2)
1266 d.setTaggedValue(10,self.arg1*3)
1267 d.setTaggedValue(100,self.arg1*4)
1268 self._diffDataObjects(d,filemame)
1269
1270 def test_DumpAndLoad_Tagged_Function_Rank2(self):
1271 if loadIsConfigured():
1272 filemame=os.path.join(self.filename_base,"tagged_function_rank2.nc")
1273 d=Data(self.arg2,Function(self.domain))
1274 d.setTaggedValue(1,self.arg2*2)
1275 d.setTaggedValue(10,self.arg2*3)
1276 d.setTaggedValue(100,self.arg2*4)
1277 self._diffDataObjects(d,filemame)
1278
1279 def test_DumpAndLoad_Tagged_Function_Rank3(self):
1280 if loadIsConfigured():
1281 filemame=os.path.join(self.filename_base,"tagged_function_rank3.nc")
1282 d=Data(self.arg3,Function(self.domain))
1283 d.setTaggedValue(1,self.arg3*2)
1284 d.setTaggedValue(10,self.arg3*3)
1285 d.setTaggedValue(100,self.arg3*4)
1286 self._diffDataObjects(d,filemame)
1287
1288 def test_DumpAndLoad_Tagged_Function_Rank4(self):
1289 if loadIsConfigured():
1290 filemame=os.path.join(self.filename_base,"tagged_function_rank4.nc")
1291 d=Data(self.arg4,Function(self.domain))
1292 d.setTaggedValue(1,self.arg4*2)
1293 d.setTaggedValue(10,self.arg4*3)
1294 d.setTaggedValue(100,self.arg4*4)
1295 self._diffDataObjects(d,filemame)
1296
1297 #===========================================================================
1298 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank0(self):
1299 if loadIsConfigured():
1300 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank0.nc")
1301 d=Data(self.arg0,FunctionOnBoundary(self.domain))
1302 d.setTaggedValue(1,self.arg0*2)
1303 d.setTaggedValue(10,self.arg0*3)
1304 d.setTaggedValue(100,self.arg0*4)
1305 self._diffDataObjects(d,filemame)
1306
1307 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank1(self):
1308 if loadIsConfigured():
1309 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank1.nc")
1310 d=Data(self.arg1,FunctionOnBoundary(self.domain))
1311 d.setTaggedValue(1,self.arg1*2)
1312 d.setTaggedValue(10,self.arg1*3)
1313 d.setTaggedValue(100,self.arg1*4)
1314 self._diffDataObjects(d,filemame)
1315
1316 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank2(self):
1317 if loadIsConfigured():
1318 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank2.nc")
1319 d=Data(self.arg2,FunctionOnBoundary(self.domain))
1320 d.setTaggedValue(1,self.arg2*2)
1321 d.setTaggedValue(10,self.arg2*3)
1322 d.setTaggedValue(100,self.arg2*4)
1323 self._diffDataObjects(d,filemame)
1324
1325 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank3(self):
1326 if loadIsConfigured():
1327 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank3.nc")
1328 d=Data(self.arg3,FunctionOnBoundary(self.domain))
1329 d.setTaggedValue(1,self.arg3*2)
1330 d.setTaggedValue(10,self.arg3*3)
1331 d.setTaggedValue(100,self.arg3*4)
1332 self._diffDataObjects(d,filemame)
1333
1334 def test_DumpAndLoad_Tagged_FunctionOnBoundary_Rank4(self):
1335 if loadIsConfigured():
1336 filemame=os.path.join(self.filename_base,"tagged_function_on_boundary_rank4.nc")
1337 d=Data(self.arg4,FunctionOnBoundary(self.domain))
1338 d.setTaggedValue(1,self.arg4*2)
1339 d.setTaggedValue(10,self.arg4*3)
1340 d.setTaggedValue(100,self.arg4*4)
1341 self._diffDataObjects(d,filemame)
1342 #===========================================================================
1343 def test_DumpAndLoad_Tagged_ReducedFunction_Rank0(self):
1344 if loadIsConfigured():
1345 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank0.nc")
1346 d=Data(self.arg0,ReducedFunction(self.domain))
1347 d.setTaggedValue(1,self.arg0*2)
1348 d.setTaggedValue(10,self.arg0*3)
1349 d.setTaggedValue(100,self.arg0*4)
1350 self._diffDataObjects(d,filemame)
1351
1352 def test_DumpAndLoad_Tagged_ReducedFunction_Rank1(self):
1353 if loadIsConfigured():
1354 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank1.nc")
1355 d=Data(self.arg1,ReducedFunction(self.domain))
1356 d.setTaggedValue(1,self.arg1*2)
1357 d.setTaggedValue(10,self.arg1*3)
1358 d.setTaggedValue(100,self.arg1*4)
1359 self._diffDataObjects(d,filemame)
1360
1361 def test_DumpAndLoad_Tagged_ReducedFunction_Rank2(self):
1362 if loadIsConfigured():
1363 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank2.nc")
1364 d=Data(self.arg2,ReducedFunction(self.domain))
1365 d.setTaggedValue(1,self.arg2*2)
1366 d.setTaggedValue(10,self.arg2*3)
1367 d.setTaggedValue(100,self.arg2*4)
1368 self._diffDataObjects(d,filemame)
1369
1370 def test_DumpAndLoad_Tagged_ReducedFunction_Rank3(self):
1371 if loadIsConfigured():
1372 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank3.nc")
1373 d=Data(self.arg3,ReducedFunction(self.domain))
1374 d.setTaggedValue(1,self.arg3*2)
1375 d.setTaggedValue(10,self.arg3*3)
1376 d.setTaggedValue(100,self.arg3*4)
1377 self._diffDataObjects(d,filemame)
1378
1379 def test_DumpAndLoad_Tagged_ReducedFunction_Rank4(self):
1380 if loadIsConfigured():
1381 filemame=os.path.join(self.filename_base,"tagged_reduced_function_rank4.nc")
1382 d=Data(self.arg4,ReducedFunction(self.domain))
1383 d.setTaggedValue(1,self.arg4*2)
1384 d.setTaggedValue(10,self.arg4*3)
1385 d.setTaggedValue(100,self.arg4*4)
1386 self._diffDataObjects(d,filemame)
1387
1388 #===========================================================================
1389 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank0(self):
1390 if loadIsConfigured():
1391 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank0.nc")
1392 d=Data(self.arg0,ReducedFunctionOnBoundary(self.domain))
1393 d.setTaggedValue(1,self.arg0*2)
1394 d.setTaggedValue(10,self.arg0*3)
1395 d.setTaggedValue(100,self.arg0*4)
1396 self._diffDataObjects(d,filemame)
1397
1398 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank1(self):
1399 if loadIsConfigured():
1400 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank1.nc")
1401 d=Data(self.arg1,ReducedFunctionOnBoundary(self.domain))
1402 d.setTaggedValue(1,self.arg1*2)
1403 d.setTaggedValue(10,self.arg1*3)
1404 d.setTaggedValue(100,self.arg1*4)
1405 self._diffDataObjects(d,filemame)
1406
1407 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank2(self):
1408 if loadIsConfigured():
1409 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank2.nc")
1410 d=Data(self.arg2,ReducedFunctionOnBoundary(self.domain))
1411 d.setTaggedValue(1,self.arg2*2)
1412 d.setTaggedValue(10,self.arg2*3)
1413 d.setTaggedValue(100,self.arg2*4)
1414 self._diffDataObjects(d,filemame)
1415
1416 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank3(self):
1417 if loadIsConfigured():
1418 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank3.nc")
1419 d=Data(self.arg3,ReducedFunctionOnBoundary(self.domain))
1420 d.setTaggedValue(1,self.arg3*2)
1421 d.setTaggedValue(10,self.arg3*3)
1422 d.setTaggedValue(100,self.arg3*4)
1423 self._diffDataObjects(d,filemame)
1424
1425 def test_DumpAndLoad_Tagged_ReducedFunctionOnBoundary_Rank4(self):
1426 if loadIsConfigured():
1427 filemame=os.path.join(self.filename_base,"tagged_reduced_function_on_boundary_rank4.nc")
1428 d=Data(self.arg4,ReducedFunctionOnBoundary(self.domain))
1429 d.setTaggedValue(1,self.arg4*2)
1430 d.setTaggedValue(10,self.arg4*3)
1431 d.setTaggedValue(100,self.arg4*4)
1432 self._diffDataObjects(d,filemame)
1433
1434 def test_canTag_Failures(self):
1435 d=Data(self.arg0,Solution(self.domain))
1436 self.failUnlessRaises(RuntimeError,d.setTaggedValue,1,self.arg0*2)
1437 d=Data(self.arg0,ReducedSolution(self.domain))
1438 self.failUnlessRaises(RuntimeError,d.setTaggedValue,1,self.arg0*2)

  ViewVC Help
Powered by ViewVC 1.1.26