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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5707 - (show annotations)
Mon Jun 29 03:59:06 2015 UTC (3 years, 6 months ago) by sshaw
File MIME type: text/x-python
File size: 3101 byte(s)
adding copyright headers to files without copyright info, moved header to top of file in some cases where it wasn't
1 ##############################################################################
2 #
3 # Copyright (c) 2009-2015 by The University of Queensland
4 # http://www.uq.edu.au
5 #
6 # Primary Business: Queensland, Australia
7 # Licensed under the Open Software License version 3.0
8 # http://www.opensource.org/licenses/osl-3.0.php
9 #
10 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 # Development 2012-2013 by School of Earth Sciences
12 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
13 #
14 ##############################################################################
15 from __future__ import division, print_function
16
17 __copyright__="""Copyright (c) 2009-2015 by The 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 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="https://launchpad.net/escript-finley"
23
24 """
25 Author: Antony Hallam antony.hallam@uqconnect.edu.au
26 """
27
28 ############################################################FILE HEADER
29 # example10a.py
30 # Model of gravitational Potential.
31
32 #######################################################EXTERNAL MODULES
33 # To solve the problem it is necessary to import the modules we require.
34 from esys.escript import * # This imports everything from the escript library
35 from esys.escript.unitsSI import *
36 from esys.escript.linearPDEs import LinearPDE # This defines LinearPDE as LinearPDE
37 from esys.weipa import saveVTK
38 import os, sys #This package is necessary to handle saving our data.
39
40 try:
41 # This imports the rectangle domain function
42 from esys.finley import ReadMesh
43 HAVE_FINLEY = True
44 except ImportError:
45 print("Finley module not available")
46 HAVE_FINLEY = False
47 ########################################################MPI WORLD CHECK
48 if getMPISizeWorld() > 1:
49 print("This example will not run in an MPI world.")
50 sys.exit(0)
51
52 if HAVE_FINLEY:
53 #################################################ESTABLISHING VARIABLES
54 G=6.67300*10E-11
55
56 ################################################ESTABLISHING PARAMETERS
57 #the folder to put our outputs in, leave blank "" for script path
58 save_path= os.path.join("data","example10")
59 #ensure the dir exists
60 mkDir(save_path)
61
62 ####################################################DOMAIN CONSTRUCTION
63 domain=ReadMesh(os.path.join(save_path,'fault.fly')) # create the domain
64 x=Solution(domain).getX()
65 rho=Scalar(0,Function(domain))
66 rho.setTaggedValue("xx",500.)
67 rho.setTaggedValue("limestone",0.0)
68 rho.setTaggedValue("fault",1200.)
69
70 kro=kronecker(domain)
71
72 q=whereZero(x[2])#-sup(x[2]))
73 ###############################################ESCRIPT PDE CONSTRUCTION
74
75 mypde=LinearPDE(domain)
76 mypde.setValue(A=kro,Y=4.*3.1415*G*rho,q=q,r=0)
77 sol=mypde.getSolution()
78 saveVTK(os.path.join(save_path,"ex10c.vtu"),\
79 grav_pot=sol,\
80 g_field=-grad(sol),\
81 g_fieldz=-grad(sol)*[0,0,1],\
82 gz=length(-grad(sol)*[0,0,1]),\
83 fault=rho)

  ViewVC Help
Powered by ViewVC 1.1.26