/[escript]/trunk/modellib/test/python/run_flow.py
ViewVC logotype

Contents of /trunk/modellib/test/python/run_flow.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5288 - (show annotations)
Tue Dec 2 23:18:40 2014 UTC (4 years, 9 months ago) by sshaw
File MIME type: text/x-python
File size: 3150 byte(s)
fixing tests for cases where required domains not built
1 from __future__ import print_function
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 __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Open Software License version 3.0
21 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="https://launchpad.net/escript-finley"
23
24 #
25 # small test problem fro temperture advection:
26 #
27 # p=(x0+x1)*t
28 #
29
30 import os
31 import sys
32 if sys.version_info >= (3,0):
33 from io import StringIO
34 else:
35 #specifically to avoid non-unicode default strings
36 #being passed to a python3 style StringIO that expects unicode
37 from StringIO import StringIO
38 import esys.escriptcore.utestselect as unittest
39 from esys.escriptcore.testing import *
40 from esys.escript.modelframe import Link,Simulation
41 from esys.modellib.input import Sequencer
42 from esys.modellib.probe import Probe,EvaluateExpression
43 from esys.modellib.flow import SteadyIncompressibleFlow
44
45 try:
46 import esys.finley
47 from esys.modellib.geometry import RectangularDomain,VectorConstrainerOverBox
48 HAVE_FINLEY = True
49 except ImportError:
50 HAVE_FINLEY = False
51
52 #Link() behaves badly inside a TestCase class
53 def run(dom, stream):
54 constraints=VectorConstrainerOverBox()
55 constraints.domain=Link(dom)
56 constraints.left=[1,0,0]
57 constraints.right=[1,0,0]
58 constraints.top=[0,1,0]
59 constraints.bottom=[0,1,0]
60 constraints.front=[0,0,1]
61 constraints.back=[0,0,1]
62
63 sqe=Sequencer()
64 sqe.dt_max=0.5
65 sqe.t_end=1.
66
67 source=EvaluateExpression()
68 source.domain=Link(dom)
69 source.t=Link(sqe)
70 source.expression=["t","t"]
71
72 flow=SteadyIncompressibleFlow()
73 flow.domain=Link(dom,"domain")
74 flow.internal_force=Link(source,"out")
75 flow.location_prescribed_velocity=Link(constraints,"location_of_constraint")
76 flow.prescribed_velocity=[0.,0.]
77
78 ptest=Probe()
79 ptest.expression="(x[0]+x[1]-1.)*t"
80 ptest.t=Link(sqe)
81 ptest.value=Link(flow,"pressure")
82
83 s=Simulation([sqe,constraints,Simulation([flow],debug=True),ptest],debug=True)
84 s.writeXML(stream)
85 s.run()
86
87 class Test_RunFlow(unittest.TestCase):
88 def setUp(self):
89 import sys
90 self.old = sys.stdout
91 sys.stdout = StringIO()
92
93 def tearDown(self):
94 import sys
95 sys.stdout = self.old
96
97 @unittest.skipIf(not HAVE_FINLEY, "Finley module not available")
98 def test_order2(self):
99 dom=RectangularDomain()
100 dom.order=2
101 run(dom, sys.stdout)
102
103 if __name__ == '__main__':
104 run_tests(__name__, exit_on_failure=True)

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26