1 |
|
2 |
######################################################## |
3 |
# |
4 |
# Copyright (c) 2003-2008 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-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 |
http://www.opensource.org/licenses/osl-3.0.php""" |
20 |
__url__="http://www.uq.edu.au/esscc/escript-finley" |
21 |
|
22 |
import unittest |
23 |
import tempfile |
24 |
|
25 |
from esys.escript import * |
26 |
from esys.finley import Rectangle |
27 |
import sys |
28 |
import os |
29 |
from test_objects import Test_Dump, Test_SetDataPointValue |
30 |
from test_objects import Test_Domain |
31 |
|
32 |
try: |
33 |
FINLEY_WORKDIR=os.environ['FINLEY_WORKDIR'] |
34 |
except KeyError: |
35 |
FINLEY_WORKDIR='.' |
36 |
|
37 |
NE=4 # number elements, must be even |
38 |
class Test_DomainOnFinley(Test_Domain): |
39 |
def setUp(self): |
40 |
self.domain =Rectangle(NE,NE+1,2) |
41 |
def tearDown(self): |
42 |
del self.domain |
43 |
|
44 |
def test_tagsContinuousFunction(self): |
45 |
ref_tags=[0] |
46 |
tags=ContinuousFunction(self.domain).getListOfTags() |
47 |
self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.") |
48 |
for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i) |
49 |
|
50 |
def test_tagsFunction(self): |
51 |
ref_tags=[0] |
52 |
tags=Function(self.domain).getListOfTags() |
53 |
self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.") |
54 |
for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i) |
55 |
def test_tagsReducedFunction(self): |
56 |
ref_tags=[0] |
57 |
tags=ReducedFunction(self.domain).getListOfTags() |
58 |
self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.") |
59 |
for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i) |
60 |
def test_tagsFunctionOnBoundary(self): |
61 |
# For MPI a subdomain may be missing some tags and this test is expected to fail |
62 |
if getMPISizeWorld() == 1: |
63 |
ref_tags=[1, 2, 10, 20] |
64 |
tags=FunctionOnBoundary(self.domain).getListOfTags() |
65 |
self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.") |
66 |
for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i) |
67 |
def test_tagsReducedFunctionOnBoundary(self): |
68 |
# For MPI a subdomain may be missing some tags and this test is expected to fail |
69 |
if getMPISizeWorld() == 1: |
70 |
ref_tags=[1, 2, 10, 20] |
71 |
tags=ReducedFunctionOnBoundary(self.domain).getListOfTags() |
72 |
self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.") |
73 |
for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i) |
74 |
def test_tagsFunctionOnContactOne(self): |
75 |
ref_tags=[] |
76 |
tags=FunctionOnContactOne(self.domain).getListOfTags() |
77 |
self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.") |
78 |
for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i) |
79 |
def test_tagsFunctionOnContactZero(self): |
80 |
ref_tags=[] |
81 |
tags=FunctionOnContactZero(self.domain).getListOfTags() |
82 |
self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.") |
83 |
for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i) |
84 |
def test_tagsReducedFunctionOnContactOne(self): |
85 |
ref_tags=[] |
86 |
tags=ReducedFunctionOnContactOne(self.domain).getListOfTags() |
87 |
self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.") |
88 |
for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i) |
89 |
def test_tagsReducedFunctionOnContactZero(self): |
90 |
ref_tags=[] |
91 |
tags=ReducedFunctionOnContactZero(self.domain).getListOfTags() |
92 |
self.failUnless(len(tags)==len(ref_tags), "tags list has wrong length.") |
93 |
for i in ref_tags: self.failUnless(i in tags,"tag %s is missing."%i) |
94 |
|
95 |
class Test_DataOpsOnFinley(Test_Dump, Test_SetDataPointValue): |
96 |
def setUp(self): |
97 |
self.domain =Rectangle(NE,NE+1,2) |
98 |
self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1,2) |
99 |
self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,2,integrationOrder=2) |
100 |
self.domain_with_different_sample_ordering =Rectangle(1,(NE+1)*NE,2) |
101 |
self.filename_base=FINLEY_WORKDIR |
102 |
|
103 |
def tearDown(self): |
104 |
del self.domain |
105 |
del self.domain_with_different_number_of_samples |
106 |
del self.domain_with_different_number_of_data_points_per_sample |
107 |
del self.domain_with_different_sample_ordering |
108 |
|
109 |
if __name__ == '__main__': |
110 |
suite = unittest.TestSuite() |
111 |
suite.addTest(unittest.makeSuite(Test_DataOpsOnFinley)) |
112 |
suite.addTest(unittest.makeSuite(Test_DomainOnFinley)) |
113 |
s=unittest.TextTestRunner(verbosity=2).run(suite) |
114 |
if not s.wasSuccessful(): sys.exit(1) |
115 |
|