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

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

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

revision 5287 by jfenwick, Wed Apr 9 05:41:57 2014 UTC revision 5288 by sshaw, Tue Dec 2 23:18:40 2014 UTC
# Line 35  Author: Antony Hallam antony.hallam@uqco Line 35  Author: Antony Hallam antony.hallam@uqco
35  from esys.escript import * # This imports everything from the escript library  from esys.escript import * # This imports everything from the escript library
36  from esys.escript.unitsSI import *  from esys.escript.unitsSI import *
37  from esys.escript.linearPDEs import LinearPDE # This defines LinearPDE as LinearPDE  from esys.escript.linearPDEs import LinearPDE # This defines LinearPDE as LinearPDE
 from esys.finley import ReadMesh  
38  from esys.weipa import saveVTK  from esys.weipa import saveVTK
39  import os, sys #This package is necessary to handle saving our data.  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  ########################################################MPI WORLD CHECK
49  if getMPISizeWorld() > 1:  if getMPISizeWorld() > 1:
     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    
53  #################################################ESTABLISHING VARIABLES  if HAVE_FINLEY:
54  G=6.67300*10E-11      #################################################ESTABLISHING VARIABLES
55        G=6.67300*10E-11
56  ################################################ESTABLISHING PARAMETERS  
57  #the folder to put our outputs in, leave blank "" for script path      ################################################ESTABLISHING PARAMETERS
58  save_path= os.path.join("data","example10")      #the folder to put our outputs in, leave blank "" for script path
59  #ensure the dir exists      save_path= os.path.join("data","example10")
60  mkDir(save_path)      #ensure the dir exists
61        mkDir(save_path)
62  ####################################################DOMAIN CONSTRUCTION  
63  domain=ReadMesh(os.path.join(save_path,'fault.fly')) # create the domain      ####################################################DOMAIN CONSTRUCTION
64  x=Solution(domain).getX()      domain=ReadMesh(os.path.join(save_path,'fault.fly')) # create the domain
65  rho=Scalar(0,Function(domain))      x=Solution(domain).getX()
66  rho.setTaggedValue("xx",500.)      rho=Scalar(0,Function(domain))
67  rho.setTaggedValue("limestone",0.0)      rho.setTaggedValue("xx",500.)
68  rho.setTaggedValue("fault",1200.)      rho.setTaggedValue("limestone",0.0)
69        rho.setTaggedValue("fault",1200.)
70  kro=kronecker(domain)  
71        kro=kronecker(domain)
72  q=whereZero(x[2])#-sup(x[2]))  
73  ###############################################ESCRIPT PDE CONSTRUCTION      q=whereZero(x[2])#-sup(x[2]))
74        ###############################################ESCRIPT PDE CONSTRUCTION
75  mypde=LinearPDE(domain)  
76  mypde.setValue(A=kro,Y=4.*3.1415*G*rho,q=q,r=0)      mypde=LinearPDE(domain)
77  sol=mypde.getSolution()      mypde.setValue(A=kro,Y=4.*3.1415*G*rho,q=q,r=0)
78  saveVTK(os.path.join(save_path,"ex10c.vtu"),\      sol=mypde.getSolution()
79          grav_pot=sol,\      saveVTK(os.path.join(save_path,"ex10c.vtu"),\
80          g_field=-grad(sol),\              grav_pot=sol,\
81          g_fieldz=-grad(sol)*[0,0,1],\              g_field=-grad(sol),\
82          gz=length(-grad(sol)*[0,0,1]),\              g_fieldz=-grad(sol)*[0,0,1],\
83          fault=rho)              gz=length(-grad(sol)*[0,0,1]),\
84                fault=rho)

Legend:
Removed from v.5287  
changed lines
  Added in v.5288

  ViewVC Help
Powered by ViewVC 1.1.26