# Contents of /trunk/escript/test/python/ArchiveTests.py

Revision 2344 - (show annotations)
Mon Mar 30 02:13:58 2009 UTC (12 years, 5 months ago) by jfenwick
File MIME type: text/x-python
File size: 3275 byte(s)
```Change __url__ to launchpad site

```
 1 2 ######################################################## 3 # 4 # Copyright (c) 2003-2008 by University of Queensland 5 # Earth Systems Science Computational Center (ESSCC) 6 7 # 8 # Primary Business: Queensland, Australia 9 # Licensed under the Open Software License version 3.0 10 11 # 12 ######################################################## 13 14 __copyright__="""Copyright (c) 2003-2008 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 20 __url__= 21 22 """ 23 24 Miscellaneous escript/Data tests. 25 26 """ 27 28 import sys 29 import unittest 30 import os 31 32 from esys.escript import * 33 from esys import bruce 34 from esys import finley 35 36 import numarray 37 from numarray import array,Float64,ones,greater 38 39 # 40 # ============================================================== 41 42 print "\n\n" 43 44 mshList=(bruce.Rectangle(), 45 bruce.Brick(), 46 finley.Rectangle(2, 5, 1, l0 = 7.0, l1 = 11.0), 47 finley.Brick(2, 5, 7, 1, l0 = 11.0, l1 = 13.0, l2 = 17.0), 48 finley.Rectangle(2, 5, 2, l0 = 7.0, l1 = 11.0), 49 finley.Brick(2, 5, 7, 2, l0 = 11.0, l1 = 13.0, l2 = 17.0)) 50 51 for msh in mshList: 52 53 print "\nX -- Continuous:" 54 archDataX = msh.getX() 55 archDataX.archiveData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archiveX") 56 exDataX=Data() 57 exDataX.extractData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archiveX",ContinuousFunction(msh)) 58 59 diff = archDataX - exDataX 60 (infdiff, supdiff) = (inf(diff), sup(diff)) 61 if infdiff != 0 or supdiff != 0: 62 print "*** ERROR: Data value discrepancies %f < X < %f" \ 63 % (infdiff, supdiff) 64 sys.exit(1) 65 66 exDataX.archiveData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archive2X"); 67 68 print "\nDataExpanded:" 69 archDataE=Data([[1.00001],[2.00001]],Function(msh),True) 70 archDataE.archiveData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archiveE") 71 exDataE=Data() 72 exDataE.extractData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archiveE",Function(msh)) 73 exDataE.archiveData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archive2E"); 74 75 print "\nDataTagged:" 76 archDataT=Data([[1.00001],[2.00001]],Function(msh)) 77 archDataT.tag() 78 archDataT.archiveData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archiveT") 79 exDataT=Data() 80 exDataT.extractData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archiveT",Function(msh)) 81 exDataT.archiveData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archive2T"); 82 83 print "\nDataConstant:" 84 archDataC=Data([1.00001], Function(msh)) 85 archDataC.archiveData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archiveC") 86 exDataC=Data() 87 exDataC.extractData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archiveC",Function(msh)) 88 exDataC.archiveData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archive2C"); 89 90 print "\nDataEmpty:" 91 archDataM=Data() 92 archDataM.archiveData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archiveE") 93 exDataM=Data() 94 exDataM.extractData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archiveE",FunctionSpace()) 95 exDataM.archiveData(os.environ['ESCRIPT_WORKING_DIR']+"/data-archive2E") 96 97 sys.exit(0) 98 # end