/[escript]/trunk/doc/examples/cookbook/example06.py
ViewVC logotype

Diff of /trunk/doc/examples/cookbook/example06.py

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

revision 2977 by ahallam, Tue Mar 9 00:33:28 2010 UTC revision 4853 by jfenwick, Wed Apr 9 05:41:57 2014 UTC
# Line 1  Line 1 
1    from __future__ import division
2  ########################################################  from __future__ import print_function
3    ##############################################################################
4  #  #
5  # Copyright (c) 2009-2010 by University of Queensland  # Copyright (c) 2009-2014 by University of Queensland
6  # Earth Systems Science Computational Center (ESSCC)  # http://www.uq.edu.au
 # http://www.uq.edu.au/esscc  
7  #  #
8  # Primary Business: Queensland, Australia  # Primary Business: Queensland, Australia
9  # Licensed under the Open Software License version 3.0  # Licensed under the Open Software License version 3.0
10  # http://www.opensource.org/licenses/osl-3.0.php  # http://www.opensource.org/licenses/osl-3.0.php
11  #  #
12  ########################################################  # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
13    # Development 2012-2013 by School of Earth Sciences
14    # Development from 2014 by Centre for Geoscience Computing (GeoComp)
15    #
16    ##############################################################################
17    
18  __copyright__="""Copyright (c) 2009-2010 by University of Queensland  __copyright__="""Copyright (c) 2009-2014 by University of Queensland
19  Earth Systems Science Computational Center (ESSCC)  http://www.uq.edu.au
 http://www.uq.edu.au/esscc  
20  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
21  __license__="""Licensed under the Open Software License version 3.0  __license__="""Licensed under the Open Software License version 3.0
22  http://www.opensource.org/licenses/osl-3.0.php"""  http://www.opensource.org/licenses/osl-3.0.php"""
# Line 43  import os, sys Line 46  import os, sys
46    
47  ########################################################MPI WORLD CHECK  ########################################################MPI WORLD CHECK
48  if getMPISizeWorld() > 1:  if getMPISizeWorld() > 1:
49      import sys          import sys
50      print "This example will not run in an MPI world."          print("This example will not run in an MPI world.")
51      sys.exit(0)          sys.exit(0)
52  #################################################ESTABLISHING VARIABLES  #################################################ESTABLISHING VARIABLES
53  # where to put output files  # where to put output files
54  save_path= os.path.join("data","example06")  save_path= os.path.join("data","example06")
# Line 72  p4=Point(0.0,    -2400.0, 0.0) Line 75  p4=Point(0.0,    -2400.0, 0.0)
75  p5=Point(2000.0, -2400.0, 0.0)  p5=Point(2000.0, -2400.0, 0.0)
76  p6=Point(3000.0, -6000.0, 0.0)  p6=Point(3000.0, -6000.0, 0.0)
77  p7=Point(5000.0, -2400.0, 0.0)  p7=Point(5000.0, -2400.0, 0.0)
78        
79  # Create TOP BLOCK  # Create TOP BLOCK
80  tbl1=Line(p0,p4)  tbl1=Line(p0,p4)
81  tbl2=Line(p4,p5)  tbl2=Line(p4,p5)
# Line 111  d.setScriptFileName(os.path.join(save_pa Line 114  d.setScriptFileName(os.path.join(save_pa
114    
115  d.setMeshFileName(os.path.join(save_path,"example06.msh"))  d.setMeshFileName(os.path.join(save_path,"example06.msh"))
116  domain=MakeDomain(d)  domain=MakeDomain(d)
117  print "Domain has been generated ..."  print("Domain has been generated ...")
118    
119  # set up kappa (thermal conductivity across domain) using tags  # set up kappa (thermal conductivity across domain) using tags
120  kappa=Scalar(0,Function(domain))  kappa=Scalar(0,Function(domain))
# Line 128  mypde.setValue(q=whereZero(x[1]-sup(x[1] Line 131  mypde.setValue(q=whereZero(x[1]-sup(x[1]
131  qS=Scalar(0,FunctionOnBoundary(domain))  qS=Scalar(0,FunctionOnBoundary(domain))
132  qS.setTaggedValue("linebottom",qin)  qS.setTaggedValue("linebottom",qin)
133  mypde.setValue(y=qS)  mypde.setValue(y=qS)
134  print "PDE has been generated ..."  print("PDE has been generated ...")
135  ###########################################################GET SOLUTION  ###########################################################GET SOLUTION
136  T=mypde.getSolution()  T=mypde.getSolution()
137  print "PDE has been solved ..."  print("PDE has been solved ...")
138  ###############################################################PLOTTING  ###############################################################PLOTTING
139  # show temperature:  # show temperature:
140  xi, yi, zi = toRegGrid(T, nx=50, ny=50)  xi, yi, zi = toRegGrid(T, nx=50, ny=50)
# Line 153  pl.xlabel("Horizontal Displacement (m)") Line 156  pl.xlabel("Horizontal Displacement (m)")
156  pl.ylabel("Depth (m)")  pl.ylabel("Depth (m)")
157  pl.legend()  pl.legend()
158  pl.savefig(os.path.join(save_path,"flux.png"))  pl.savefig(os.path.join(save_path,"flux.png"))
159  print "Flux has been plotted  ..."  print("Flux has been plotted  ...")

Legend:
Removed from v.2977  
changed lines
  Added in v.4853

  ViewVC Help
Powered by ViewVC 1.1.26