/[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 3892 - (show annotations)
Tue Apr 10 08:57:23 2012 UTC (6 years, 9 months ago) by jfenwick
File MIME type: text/x-python
File size: 3638 byte(s)
Merged changes across from the attempt2 branch.
This version builds and passes python2 tests.
It also passes most python3 tests.



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 # example10m.py
29 # Create a simple 2D mesh, which is optimised for cells close to the
30 # source. Larger elements are used to decrease computational requirements
31 # and to properly fullfil the boundary conditions.
32 #
33 #######################################################EXTERNAL MODULES
34 from esys.pycad import * #domain constructor
35 from esys.pycad.extras import layer_cake
36 from esys.pycad.gmsh import Design #Finite Element meshing package
37 from esys.finley import MakeDomain #Converter for escript
38 from esys.escript import mkDir, getMPISizeWorld
39 import os
40 import subprocess as sp
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","example10m")
49 mkDir(save_path)
50
51 ################################################BIG DOMAIN
52 #ESTABLISHING PARAMETERS
53 width=10000. #width of model
54 depth=10000. #depth of model
55 bele_size=500. #big element size
56 #DOMAIN CONSTRUCTION
57 p0=Point(0.0, 0.0)
58 p1=Point(width, 0.0)
59 p2=Point(width, depth)
60 p3=Point(0.0, depth)
61 # Join corners in anti-clockwise manner.
62 l01=Line(p0, p1)
63 l12=Line(p1, p2)
64 l23=Line(p2, p3)
65 l30=Line(p3, p0)
66
67 cbig=CurveLoop(l01,l12,l23,l30)
68
69 ################################################SMALL DOMAIN
70 #ESTABLISHING PARAMETERS
71 xwidth=1000.0 #x width of model
72 zdepth=1000.0 #y width of model
73 sele_size=10. #small element size
74 #TRANSFORM
75 xshift=width/2-xwidth/2
76 zshift=depth/2-zdepth/2
77 #DOMAIN CONSTRUCTION
78 p4=Point(xshift, zshift)
79 p5=Point(xwidth+xshift, zshift)
80 p6=Point(xwidth+xshift, zdepth+zshift)
81 p7=Point(xshift, zdepth+zshift)
82 # Join corners in anti-clockwise manner.
83 l45=Line(p4, p5)
84 l56=Line(p5, p6)
85 l67=Line(p6, p7)
86 l74=Line(p7, p4)
87
88 csmall=CurveLoop(l45,l56,l67,l74)
89
90 ssmall=PlaneSurface(csmall)
91 sbig=PlaneSurface(cbig,holes=[csmall])
92
93 #############################################EXPORTING MESH FOR ESCRIPT
94 # Design the geometry for the big mesh.
95 d1=Design(dim=2, element_size=bele_size, order=1)
96 d1.addItems(sbig)
97 d1.addItems(PropertySet(l01,l12,l23,l30))
98 d1.setScriptFileName(os.path.join(save_path,"example10m_big.geo"))
99 MakeDomain(d1)
100
101 # Design the geometry for the small mesh.
102 d2=Design(dim=2, element_size=sele_size, order=1)
103 d2.addItems(ssmall)
104 d2.setScriptFileName(os.path.join(save_path,"example10m_small.geo"))
105 MakeDomain(d2)
106
107 # Join the two meshes using Gmsh and then apply a 2D meshing algorithm.
108 # The small mesh must come before the big mesh in the merging call!!@!!@!
109 sp.call("gmsh -2 "+
110 os.path.join(save_path,"example10m_small.geo")+" "+
111 os.path.join(save_path,"example10m_big.geo")+" -o "+
112 os.path.join(save_path,"example10m.msh"),shell=True)

  ViewVC Help
Powered by ViewVC 1.1.26