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

Annotation of /trunk/doc/examples/cookbook/example10c_1.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3892 - (hide annotations)
Tue Apr 10 08:57:23 2012 UTC (7 years ago) by jfenwick
File MIME type: text/x-python
File size: 2634 byte(s)
Merged changes across from the attempt2 branch.
This version builds and passes python2 tests.
It also passes most python3 tests.



1 ahallam 3135
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 caltinay 3346 from esys.weipa import saveVTK
37 ahallam 3135 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 jfenwick 3892 print("This example will not run in an MPI world.")
43 ahallam 3135 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 ahallam 3195 gz=length(-grad(sol)*[0,0,1]),\
75     fault=rho)

  ViewVC Help
Powered by ViewVC 1.1.26