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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4576 - (show annotations)
Mon Dec 9 23:35:30 2013 UTC (5 years, 10 months ago) by sshaw
File MIME type: text/x-python
File size: 3721 byte(s)
python3ified things, replaced mixed whitespace and xrange calls
1
2 ##############################################################################
3 #
4 # Copyright (c) 2009-2013 by University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Open Software License version 3.0
9 # http://www.opensource.org/licenses/osl-3.0.php
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development since 2012 by School of Earth Sciences
13 #
14 ##############################################################################
15
16 __copyright__="""Copyright (c) 2009-2013 by University of Queensland
17 http://www.uq.edu.au
18 Primary Business: Queensland, Australia"""
19 __license__="""Licensed under the Open Software License version 3.0
20 http://www.opensource.org/licenses/osl-3.0.php"""
21 __url__="https://launchpad.net/escript-finley"
22
23 """
24 Author: Antony Hallam antony.hallam@uqconnect.edu.au
25 """
26
27
28 ############################################################FILE HEADER
29 # example10m.py
30 # Create a simple 2D mesh, which is optimised for cells close to the
31 # source. Larger elements are used to decrease computational requirements
32 # and to properly fullfil the boundary conditions.
33 #
34 #######################################################EXTERNAL MODULES
35 from esys.pycad import * #domain constructor
36 from esys.pycad.extras import layer_cake
37 from esys.pycad.gmsh import Design #Finite Element meshing package
38 from esys.finley import MakeDomain #Converter for escript
39 from esys.escript import mkDir, getMPISizeWorld
40 import os
41 import subprocess as sp
42 ########################################################MPI WORLD CHECK
43 if getMPISizeWorld() > 1:
44 import sys
45 print("This example will not run in an MPI world.")
46 sys.exit(0)
47
48 # make sure path exists
49 save_path= os.path.join("data","example10m")
50 mkDir(save_path)
51
52 ################################################BIG DOMAIN
53 #ESTABLISHING PARAMETERS
54 width=10000. #width of model
55 depth=10000. #depth of model
56 bele_size=500. #big element size
57 #DOMAIN CONSTRUCTION
58 p0=Point(0.0, 0.0)
59 p1=Point(width, 0.0)
60 p2=Point(width, depth)
61 p3=Point(0.0, depth)
62 # Join corners in anti-clockwise manner.
63 l01=Line(p0, p1)
64 l12=Line(p1, p2)
65 l23=Line(p2, p3)
66 l30=Line(p3, p0)
67
68 cbig=CurveLoop(l01,l12,l23,l30)
69
70 ################################################SMALL DOMAIN
71 #ESTABLISHING PARAMETERS
72 xwidth=1000.0 #x width of model
73 zdepth=1000.0 #y width of model
74 sele_size=10. #small element size
75 #TRANSFORM
76 xshift=width/2-xwidth/2
77 zshift=depth/2-zdepth/2
78 #DOMAIN CONSTRUCTION
79 p4=Point(xshift, zshift)
80 p5=Point(xwidth+xshift, zshift)
81 p6=Point(xwidth+xshift, zdepth+zshift)
82 p7=Point(xshift, zdepth+zshift)
83 # Join corners in anti-clockwise manner.
84 l45=Line(p4, p5)
85 l56=Line(p5, p6)
86 l67=Line(p6, p7)
87 l74=Line(p7, p4)
88
89 csmall=CurveLoop(l45,l56,l67,l74)
90
91 ssmall=PlaneSurface(csmall)
92 sbig=PlaneSurface(cbig,holes=[csmall])
93
94 #############################################EXPORTING MESH FOR ESCRIPT
95 # Design the geometry for the big mesh.
96 d1=Design(dim=2, element_size=bele_size, order=1)
97 d1.addItems(sbig)
98 d1.addItems(PropertySet(l01,l12,l23,l30))
99 d1.setScriptFileName(os.path.join(save_path,"example10m_big.geo"))
100 MakeDomain(d1)
101
102 # Design the geometry for the small mesh.
103 d2=Design(dim=2, element_size=sele_size, order=1)
104 d2.addItems(ssmall)
105 d2.setScriptFileName(os.path.join(save_path,"example10m_small.geo"))
106 MakeDomain(d2)
107
108 # Join the two meshes using Gmsh and then apply a 2D meshing algorithm.
109 # The small mesh must come before the big mesh in the merging call!!@!!@!
110 sp.call("gmsh -2 "+
111 os.path.join(save_path,"example10m_small.geo")+" "+
112 os.path.join(save_path,"example10m_big.geo")+" -o "+
113 os.path.join(save_path,"example10m.msh"),shell=True)

  ViewVC Help
Powered by ViewVC 1.1.26