# Contents of /trunk/doc/examples/usersguide/darcy.py

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: 1933 byte(s)
```fixing tests for cases where required domains not built
```
 1 from __future__ import division 2 ############################################################################## 3 # 4 # Copyright (c) 2003-2014 by University of Queensland 5 6 # 7 # Primary Business: Queensland, Australia 8 # Licensed under the Open Software License version 3.0 9 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 22 __url__= 23 24 from esys.escript import * 25 from esys.escript.models import DarcyFlow 26 try: 27 from esys.finley import Rectangle 28 HAVE_FINLEY = True 29 except ImportError: 30 HAVE_FINLEY = False 31 from esys.weipa import saveVTK 32 33 if not HAVE_FINLEY: 34 print("Finley module not available") 35 else: 36 # generate domain: 37 mydomain = Rectangle(l0=2.,l1=1.,n0=40, n1=20) 38 # normal flux is given 39 x = mydomain.getX() 40 41 # set location of fixed pressure and flux: 42 p_BC=whereZero(x[1]-1.)*wherePositive(x[0]-1.) 43 u_BC=(whereZero(x[0])+whereZero(x[0]-2.)) * [1.,0.] + \ 44 (whereZero(x[1]) + whereZero(x[1]-1.)*whereNonPositive(x[0]-1.0)) * [0., 1.] 45 46 # define darcy flow solver: 47 mypde = DarcyFlow(domain=mydomain) 48 49 mypde.setValue(g=[0., 2], 50 location_of_fixed_pressure=p_BC, 51 location_of_fixed_flux=u_BC, 52 permeability=100.) 53 54 u,p=mypde.solve(u0=x[1]*[0., -1.], p0=0) 55 56 # write u to an external file 57 saveVTK("u.vtu",flux=u, pressure=p) 58