/[escript]/trunk/ripley/test/python/run_customAssemblers.py
ViewVC logotype

Contents of /trunk/ripley/test/python/run_customAssemblers.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4984 - (show annotations)
Mon Jun 2 02:50:34 2014 UTC (5 years, 2 months ago) by sshaw
File MIME type: text/x-python
File size: 3097 byte(s)
revamping testrunners, now uses automated discovery and allows running specific tests without modifying files (see escriptcore/py_src/testing.py for more info/examples)

1
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2014 by 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
18
19 __copyright__="""Copyright (c) 2003-2014 by 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, sys
27 import esys.escriptcore.utestselect as unittest
28 from esys.escriptcore.testing import *
29 from esys.escript import *
30 from esys.ripley import Rectangle, Brick
31 from esys.escript.linearPDEs import LameEquation
32
33 try:
34 RIPLEY_WORKDIR=os.environ['RIPLEY_WORKDIR']
35 except KeyError:
36 RIPLEY_WORKDIR='.'
37
38 EXPANDED, SCALAR, CONSTANT = range(3)
39
40 def run_lame(domain, fast, test_type, mu=3, lamb=50):
41 d=domain.getDim()
42 mypde=LameEquation(domain, useFast=fast)
43 cf=ContinuousFunction(domain)
44 x=cf.getX()
45 u_ex=x
46 msk=Vector(0.,cf)
47 for i in range(d):
48 msk[i]=whereZero(x[i])
49 if test_type != CONSTANT:
50 mu = Scalar(mu, cf)
51 lamb = Scalar(lamb, cf)
52 if test_type == EXPANDED:
53 mu.expand()
54 lamb.expand()
55 mypde.setValue(q=msk,r=u_ex,lame_mu=mu,lame_lambda=lamb,f=(2*3+50*d)*FunctionOnBoundary(domain).getNormal())
56 return mypde.getSolution()
57
58 class Test_CustomAssemblers(unittest.TestCase):
59 def setUp(self):
60 pass
61
62 def tearDown(self):
63 pass
64
65 def test_lame(self):
66 labels = ["expanded", "scalar", "constant"]
67 for test_type in [EXPANDED, SCALAR, CONSTANT]:
68 for dom, dim in [(Brick(10,10,10), "3D"), (Rectangle(20,20), "2D")]:
69 #check default and lame assemblers agree
70 dom = Brick(10,10,10)
71 default = run_lame(dom, False, test_type)
72 lame = run_lame(dom, True, test_type)
73 self.assertLess(Lsup(default - lame), 1e-8,
74 "Default and Lame " + dim + "assembler solutions " \
75 "differ for %s data"%labels[test_type])
76 #reverse order, ensure default assembler still operational
77 lame = run_lame(dom, True, test_type, mu=7, lamb=40)
78 default = run_lame(dom, False, test_type, mu=7, lamb=40)
79 self.assertLess(Lsup(default - lame), 1e-8,
80 "Default and Lame " + dim + "assembler solutions " \
81 "differ for %s data"%labels[test_type])
82
83
84 if __name__ == '__main__':
85 run_tests(__name__, exit_on_failure=True)
86

  ViewVC Help
Powered by ViewVC 1.1.26