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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (9 years, 1 month ago) by jfenwick
File MIME type: text/x-python
File size: 5091 byte(s)
Merging dudley and scons updates from branches

1
2 ########################################################
3 #
4 # Copyright (c) 2009-2010 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-2010 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
27 ############################################################FILE HEADER
28 # example09m.py
29 # Create a simple 3D model for use in example09. This is the low res
30 # mesh for illustration purposes only.
31 #
32 #######################################################EXTERNAL MODULES
33 from esys.pycad import * #domain constructor
34 from esys.pycad.gmsh import Design #Finite Element meshing package
35 from esys.finley import MakeDomain #Converter for escript
36 from esys.escript import mkDir, getMPISizeWorld
37 import os
38 ########################################################MPI WORLD CHECK
39 if getMPISizeWorld() > 1:
40 import sys
41 print "This example will not run in an MPI world."
42 sys.exit(0)
43
44 # make sure path exists
45 save_path= os.path.join("data","example09")
46 mkDir(save_path)
47
48 ################################################ESTABLISHING PARAMETERS
49 #Model Parameters
50 xwidth=2000.0 #x width of model
51 ywidth=2000.0 #y width of model
52 depth=500.0 #depth of model
53 intf=depth/2. #Depth of the interface.
54
55 ####################################################DOMAIN CONSTRUCTION
56 # Domain Corners
57 p0=Point(0.0, 0.0, 0.0)
58 p1=Point(xwidth, 0.0, 0.0)
59 p2=Point(xwidth, ywidth, 0.0)
60 p3=Point(0.0, ywidth, 0.0)
61 p4=Point(0.0, ywidth, depth)
62 p5=Point(0.0, 0.0, depth)
63 p6=Point(xwidth, 0.0, depth)
64 p7=Point(xwidth, ywidth, depth)
65 # Join corners in anti-clockwise manner.
66 l01=Line(p0, p1)
67 l12=Line(p1, p2)
68 l23=Line(p2, p3)
69 l30=Line(p3, p0)
70 l56=Line(p5, p6)
71 l67=Line(p6, p7)
72 l74=Line(p7, p4)
73 l45=Line(p4, p5)
74
75 # Join line segments to create domain boundaries and then surfaces
76 ctop=CurveLoop(l01, l12, l23, l30); stop=PlaneSurface(ctop)
77 cbot=CurveLoop(-l67, -l56, -l45, -l74); sbot=PlaneSurface(cbot)
78
79 # for each side
80 ip0=Point(0.0, 0.0, intf)
81 ip1=Point(xwidth, 0.0, intf)
82 ip2=Point(xwidth, ywidth, intf)
83 ip3=Point(0.0, ywidth, intf)
84
85 linte_ar=[]; #lines for vertical edges
86 linhe_ar=[]; #lines for horizontal edges
87 linte_ar.append(Line(p0,ip0))
88 linte_ar.append(Line(ip0,p5))
89 linte_ar.append(Line(p1,ip1))
90 linte_ar.append(Line(ip1,p6))
91 linte_ar.append(Line(p2,ip2))
92 linte_ar.append(Line(ip2,p7))
93 linte_ar.append(Line(p3,ip3))
94 linte_ar.append(Line(ip3,p4))
95
96 linhe_ar.append(Line(ip0,ip1))
97 linhe_ar.append(Line(ip1,ip2))
98 linhe_ar.append(Line(ip2,ip3))
99 linhe_ar.append(Line(ip3,ip0))
100
101 cintfa_ar=[]; cintfb_ar=[] #curveloops for above and below interface on sides
102 cintfa_ar.append(CurveLoop(linte_ar[0],linhe_ar[0],-linte_ar[2],-l01))
103 cintfa_ar.append(CurveLoop(linte_ar[2],linhe_ar[1],-linte_ar[4],-l12))
104 cintfa_ar.append(CurveLoop(linte_ar[4],linhe_ar[2],-linte_ar[6],-l23))
105 cintfa_ar.append(CurveLoop(linte_ar[6],linhe_ar[3],-linte_ar[0],-l30))
106
107 cintfb_ar.append(CurveLoop(linte_ar[1],l56,-linte_ar[3],-linhe_ar[0]))
108 cintfb_ar.append(CurveLoop(linte_ar[3],l67,-linte_ar[5],-linhe_ar[1]))
109 cintfb_ar.append(CurveLoop(linte_ar[5],l74,-linte_ar[7],-linhe_ar[2]))
110 cintfb_ar.append(CurveLoop(linte_ar[7],l45,-linte_ar[1],-linhe_ar[3]))
111
112 sintfa_ar=[PlaneSurface(cintfa_ar[i]) for i in range(0,4)]
113 sintfb_ar=[PlaneSurface(cintfb_ar[i]) for i in range(0,4)]
114
115 sintf=PlaneSurface(CurveLoop(*tuple(linhe_ar)))
116
117 vintfa=Volume(SurfaceLoop(stop,-sintf,*tuple(sintfa_ar)))
118 vintfb=Volume(SurfaceLoop(sbot,sintf,*tuple(sintfb_ar)))
119
120 # Create the volume.
121 #sloop=SurfaceLoop(stop,sbot,*tuple(sintfa_ar+sintfb_ar))
122 #model=Volume(sloop)
123
124
125 #############################################EXPORTING MESH FOR ESCRIPT
126 # Create a Design which can make the mesh
127 d=Design(dim=3, element_size=200.0)
128
129 d.addItems(PropertySet('vintfa',vintfa))
130 d.addItems(PropertySet('vintfb',vintfb))
131 d.addItems(sintf)
132
133 d.setScriptFileName(os.path.join(save_path,"example09n.geo"))
134 d.setMeshFileName(os.path.join(save_path,"example09n.msh"))
135 #
136 #
137 #
138 domain=MakeDomain(d)
139 # Create a file that can be read back in to python with
140 # mesh=ReadMesh(fileName)
141 domain.write(os.path.join(save_path,"example09n.fly"))
142
143 from esys.pycad import layer_cake
144 intfaces=[10,30,50,55,80,100,200,250,400,500]
145
146 cmplx_domain=layer_cake.LayerCake(xwidth,ywidth,intfaces,200.0)
147 cmplx_domain.setScriptFileName(os.path.join(save_path,"example09lc.geo"))
148 cmplx_domain.setMeshFileName(os.path.join(save_path,"example09lc.msh"))
149 dcmplx=MakeDomain(cmplx_domain)
150 dcmplx.write(os.path.join(save_path,"example09lc.fly"))
151
152
153
154

  ViewVC Help
Powered by ViewVC 1.1.26