/[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 3058 - (show annotations)
Tue Jul 6 02:13:14 2010 UTC (10 years, 4 months ago) by ahallam
File MIME type: text/x-python
File size: 4944 byte(s)


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

  ViewVC Help
Powered by ViewVC 1.1.26