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

Contents of /trunk/doc/examples/cookbook/example10c.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3346 - (show annotations)
Fri Nov 12 01:19:02 2010 UTC (9 years, 1 month ago) by caltinay
File MIME type: text/x-python
File size: 2633 byte(s)
Replaced usage of esys.escript.util.saveVTK by weipa.saveVTK in all python
scripts.

1
2 ########################################################
3 #
4 # Copyright (c) 2009 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2009 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 """
23 Author: Antony Hallam antony.hallam@uqconnect.edu.au
24 """
25
26 ############################################################FILE HEADER
27 # example10a.py
28 # Model of gravitational Potential.
29
30 #######################################################EXTERNAL MODULES
31 # To solve the problem it is necessary to import the modules we require.
32 from esys.escript import * # This imports everything from the escript library
33 from esys.escript.unitsSI import *
34 from esys.escript.linearPDEs import LinearPDE # This defines LinearPDE as LinearPDE
35 from esys.finley import ReadMesh
36 from esys.weipa import saveVTK
37 import os, sys #This package is necessary to handle saving our data.
38
39 ########################################################MPI WORLD CHECK
40 if getMPISizeWorld() > 1:
41 import sys
42 print "This example will not run in an MPI world."
43 sys.exit(0)
44
45 #################################################ESTABLISHING VARIABLES
46 G=6.67300*10E-11
47
48 ################################################ESTABLISHING PARAMETERS
49 #the folder to put our outputs in, leave blank "" for script path
50 save_path= os.path.join("data","example10")
51 #ensure the dir exists
52 mkDir(save_path)
53
54 ####################################################DOMAIN CONSTRUCTION
55 domain=ReadMesh(os.path.join(save_path,'fault.fly')) # create the domain
56 x=Solution(domain).getX()
57 rho=Scalar(0,Function(domain))
58 rho.setTaggedValue("xx",500.)
59 rho.setTaggedValue("limestone",0.0)
60 rho.setTaggedValue("fault",1200.)
61
62 kro=kronecker(domain)
63
64 q=whereZero(x[2])#-sup(x[2]))
65 ###############################################ESCRIPT PDE CONSTRUCTION
66
67 mypde=LinearPDE(domain)
68 mypde.setValue(A=kro,Y=4.*3.1415*G*rho,q=q,r=0)
69 sol=mypde.getSolution()
70 saveVTK(os.path.join(save_path,"ex10c.vtu"),\
71 grav_pot=sol,\
72 g_field=-grad(sol),\
73 g_fieldz=-grad(sol)*[0,0,1],\
74 gz=length(-grad(sol)*[0,0,1]),\
75 fault=rho)

  ViewVC Help
Powered by ViewVC 1.1.26