/[escript]/trunk/doc/examples/usersguide/darcy.py
ViewVC logotype

Diff of /trunk/doc/examples/usersguide/darcy.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5287 by jfenwick, Wed Apr 9 05:41:57 2014 UTC revision 5288 by sshaw, Tue Dec 2 23:18:40 2014 UTC
# Line 23  __url__="https://launchpad.net/escript-f Line 23  __url__="https://launchpad.net/escript-f
23    
24  from esys.escript import *  from esys.escript import *
25  from esys.escript.models import DarcyFlow  from esys.escript.models import DarcyFlow
26  from esys.finley import Rectangle  try:
27        from esys.finley import Rectangle
28        HAVE_FINLEY = True
29    except ImportError:
30        HAVE_FINLEY = False
31  from esys.weipa import saveVTK  from esys.weipa import saveVTK
 # generate domain:  
 mydomain = Rectangle(l0=2.,l1=1.,n0=40, n1=20)  
 # normal flux is given  
 x = mydomain.getX()  
   
 # set location of fixed pressure and flux:  
 p_BC=whereZero(x[1]-1.)*wherePositive(x[0]-1.)  
 u_BC=(whereZero(x[0])+whereZero(x[0]-2.)) * [1.,0.] + \  
      (whereZero(x[1]) + whereZero(x[1]-1.)*whereNonPositive(x[0]-1.0)) * [0., 1.]  
   
 # define darcy flow solver:  
 mypde = DarcyFlow(domain=mydomain)  
   
 mypde.setValue(g=[0., 2],  
                location_of_fixed_pressure=p_BC,  
                location_of_fixed_flux=u_BC,  
                permeability=100.)  
32    
33  u,p=mypde.solve(u0=x[1]*[0., -1.], p0=0)  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  # write u to an external file      u,p=mypde.solve(u0=x[1]*[0., -1.], p0=0)
55  saveVTK("u.vtu",flux=u, pressure=p)  
56        # write u to an external file
57        saveVTK("u.vtu",flux=u, pressure=p)
58    

Legend:
Removed from v.5287  
changed lines
  Added in v.5288

  ViewVC Help
Powered by ViewVC 1.1.26