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

  ViewVC Help
Powered by ViewVC 1.1.26