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

  ViewVC Help
Powered by ViewVC 1.1.26