/[escript]/branches/trilinos_from_5897/dudley/test/python/run_escriptOnDudley.py
ViewVC logotype

Contents of /branches/trilinos_from_5897/dudley/test/python/run_escriptOnDudley.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6079 - (show annotations)
Mon Mar 21 12:22:38 2016 UTC (2 years, 11 months ago) by caltinay
File MIME type: text/x-python
File size: 7197 byte(s)
Big commit - making dudley much more like finley to make it more
managable. Fixed quite a few issues that had been fixed in finley.
Disposed of all ReducedNode/ReducedDOF entities that dudley never supported.
Compiles and passes tests.

1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2016 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 from __future__ import print_function, division
18
19 __copyright__="""Copyright (c) 2003-2016 by The University of Queensland
20 http://www.uq.edu.au
21 Primary Business: Queensland, Australia"""
22 __license__="""Licensed under the Open Software License version 3.0
23 http://www.opensource.org/licenses/osl-3.0.php"""
24 __url__="https://launchpad.net/escript-finley"
25
26 import os
27 import sys
28 import esys.escriptcore.utestselect as unittest
29 from esys.escriptcore.testing import *
30 from esys.escript import *
31 from esys.dudley import Rectangle, Brick
32 from test_objects import Test_Dump, Test_SetDataPointValue, Test_saveCSV, \
33 Test_TableInterpolation, Test_Domain, Test_GlobalMinMax, Test_Lazy
34 from test_shared import Test_Shared
35
36 try:
37 DUDLEY_WORKDIR=os.environ['DUDLEY_WORKDIR']
38 except KeyError:
39 DUDLEY_WORKDIR='.'
40
41 NE=max(4, getMPISizeWorld()) # number elements, must be even
42
43 class Test_SharedOnDudley(Test_Shared):
44 def setUp(self):
45 self.domain=Rectangle(NE,NE)
46 self.tol=0.001
47 def tearDown(self):
48 del self.domain
49 del self.tol
50
51 class Test_DomainOnDudley(Test_Domain):
52 def setUp(self):
53 self.boundary_tag_list = [1, 2, 10, 20]
54 self.domain =Rectangle(NE,NE+1)
55 self.rdomain=self.domain
56
57 def tearDown(self):
58 del self.domain
59 del self.rdomain
60 del self.boundary_tag_list
61
62 def test_setXError(self):
63 domain=Rectangle(NE,NE)
64 x=domain.getX()
65 z=interpolate(x, Function(domain))
66 self.assertRaises(RuntimeError, domain.setX, z)
67 del x
68 del z
69 del domain
70
71 def test_tagsContinuousFunction(self):
72 ref_tags=[0]
73 tags=ContinuousFunction(self.domain).getListOfTags()
74 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
75 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
76
77 def test_tagsFunction(self):
78 ref_tags=[0]
79 tags=Function(self.domain).getListOfTags()
80 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
81 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
82
83 def test_tagsReducedFunction(self):
84 ref_tags=[0]
85 tags=ReducedFunction(self.domain).getListOfTags()
86 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
87 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
88
89 def test_tagsFunctionOnBoundary(self):
90 ref_tags=[1, 2, 10, 20]
91 tags=FunctionOnBoundary(self.domain).getListOfTags()
92 # For an MPI-distributed domain some tags may be missing
93 if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
94 for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
95
96 def test_tagsReducedFunctionOnBoundary(self):
97 ref_tags=[1, 2, 10, 20]
98 tags=ReducedFunctionOnBoundary(self.domain).getListOfTags()
99 # For an MPI-distributed domain some tags may be missing
100 if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
101 for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
102
103 class Test_DataOpsOnDudley(Test_Dump, Test_SetDataPointValue, Test_GlobalMinMax, Test_Lazy):
104 def setUp(self):
105 self.domain =Rectangle(NE,NE+1)
106 self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1)
107 self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,integrationOrder=2)
108 self.domain_with_different_sample_ordering =Rectangle(NE,NE+1, optimize=True)
109 self.filename_base=DUDLEY_WORKDIR
110 self.mainfs=Function(self.domain)
111 self.otherfs=Solution(self.domain)
112
113 def tearDown(self):
114 del self.domain
115 del self.domain_with_different_number_of_samples
116 del self.domain_with_different_number_of_data_points_per_sample
117 del self.domain_with_different_sample_ordering
118 del self.mainfs
119 del self.otherfs
120
121
122 class Test_TableInterpolationOnDudley(Test_TableInterpolation):
123 def setUp(self):
124 self.domain=Brick(4,4,4)
125 self.functionspaces=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
126 FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain)]
127 #We aren't testing DiracDeltaFunctions
128 self.xn=5 # number of grids on x axis
129 self.yn=5 # number of grids on y axis
130 self.zn=5
131
132 def tearDown(self):
133 del self.domain
134 del self.functionspaces
135
136
137 class Test_CSVOnDudley(Test_saveCSV):
138 def setUp(self):
139 self.workdir=DUDLEY_WORKDIR
140 NE0=NE
141 NE1=NE+1
142 self.domain=Rectangle(NE0,NE1)
143 self.functionspaces=[ ContinuousFunction ]
144 # number of total data points for each function space
145 self.linecounts=[ (NE0+1)*(NE1+1)+1, (NE0+1)*(NE1+1)+1 ]
146 # number of masked points, i.e. where X[0] is non-zero
147 self.linecounts_masked=[ NE0*(NE1+1)+1, NE0*(NE1+1)+1 ]
148 # expected values in first line of masked data = [ X[:], X[0] ]
149 self.firstline=[ [1./NE0, 0., 1./NE0], [1./NE0, 0., 1./NE0] ]
150
151 if getMPISizeWorld() == 1:
152 self.functionspaces += [ Function, ReducedFunction,
153 FunctionOnBoundary, ReducedFunctionOnBoundary ]
154 self.linecounts += [ 121, 41, 37, 19 ]
155 self.linecounts_masked += [ 116, 41, 27, 14 ]
156 self.firstline += [
157 [.125, 0., .125],
158 [.16666666666666667, .0666666666666667, .166666666666667],
159 [.05283121635129676, 0., .05283121635129676],
160 [.125, 0., .125]
161 ]
162
163 def tearDown(self):
164 del self.domain
165
166 @unittest.skipIf(getMPISizeWorld() > 1, "Skipping since MPI size > 1")
167 def test_csv_multiFS(self):
168 fname=os.path.join(DUDLEY_WORKDIR, "test_multifs.csv")
169 sol=Data(8,Solution(self.domain))
170 ctsfn=Data(9,ContinuousFunction(self.domain))
171 #test line 0
172 dirac=Data(-1,DiracDeltaFunctions(self.domain))
173 saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)
174 #test line 1
175 fun=Data(5,Function(self.domain))
176 rfun=Data(3,ReducedFunction(self.domain))
177 saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)
178 #test line 2
179 bound=Data(1,FunctionOnBoundary(self.domain))
180 rbound=Data(3,ReducedFunctionOnBoundary(self.domain))
181 saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)
182
183
184 if __name__ == '__main__':
185 run_tests(__name__, exit_on_failure=True)
186

Properties

Name Value
svn:mergeinfo /branches/4.0fordebian/dudley/test/python/run_escriptOnDudley.py:5567-5588 /branches/diaplayground/dudley/test/python/run_escriptOnDudley.py:4940-5147 /branches/lapack2681/finley/test/python/run_escriptOnFinley.py:2682-2741 /branches/pasowrap/dudley/test/python/run_escriptOnDudley.py:3661-3674 /branches/py3_attempt2/dudley/test/python/run_escriptOnDudley.py:3871-3891 /branches/restext/finley/test/python/run_escriptOnFinley.py:2610-2624 /branches/ripleygmg_from_3668/dudley/test/python/run_escriptOnDudley.py:3669-3791 /branches/stage3.0/finley/test/python/run_escriptOnFinley.py:2569-2590 /branches/symbolic_from_3470/dudley/test/python/run_escriptOnDudley.py:3471-3974 /branches/symbolic_from_3470/ripley/test/python/dudley/test/python/run_escriptOnDudley.py:3517-3974 /release/3.0/finley/test/python/run_escriptOnFinley.py:2591-2601 /release/4.0/dudley/test/python/run_escriptOnDudley.py:5380-5406 /trunk/dudley/test/python/run_escriptOnDudley.py:5898-6029 /trunk/ripley/test/python/dudley/test/python/run_escriptOnDudley.py:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26