/[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 6651 - (show annotations)
Wed Feb 7 02:12:08 2018 UTC (2 years, 3 months ago) by jfenwick
File MIME type: text/x-python
File size: 4195 byte(s)
Make everyone sad by touching all the files

Copyright dates update

1 ##############################################################################
2 #
3 # Copyright (c) 2009-2018 by The University of Queensland
4 # http://www.uq.edu.au
5 #
6 # Primary Business: Queensland, Australia
7 # Licensed under the Apache License, version 2.0
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 # Development 2012-2013 by School of Earth Sciences
12 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
13 #
14 ##############################################################################
15 from __future__ import division, print_function
16
17 __copyright__="""Copyright (c) 2009-2018 by The University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Apache License, version 2.0
21 http://www.apache.org/licenses/LICENSE-2.0"""
22 __url__="https://launchpad.net/escript-finley"
23
24 """
25 Author: Antony Hallam antony.hallam@uqconnect.edu.au
26 """
27
28
29 ############################################################FILE HEADER
30 # example10m.py
31 # Create a simple 2D mesh, which is optimised for cells close to the
32 # source. Larger elements are used to decrease computational requirements
33 # and to properly fullfil the boundary conditions.
34 #
35 #######################################################EXTERNAL MODULES
36 from esys.escript import mkDir, getMPISizeWorld, hasFeature
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
48 ########################################################MPI WORLD CHECK
49 if getMPISizeWorld() > 1 or (hasFeature('mpi') and hasFeature('gmsh_mpi')):
50 print("This example will not run in an MPI world!")
51 elif HAVE_FINLEY:
52 import os
53 import subprocess as sp
54 # make sure path exists
55 save_path = os.path.join("data","example10m")
56 mkDir(save_path)
57
58 ################################################BIG DOMAIN
59 #ESTABLISHING PARAMETERS
60 width=10000. #width of model
61 depth=10000. #depth of model
62 bele_size=500. #big element size
63 #DOMAIN CONSTRUCTION
64 p0=Point(0.0, 0.0)
65 p1=Point(width, 0.0)
66 p2=Point(width, depth)
67 p3=Point(0.0, 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
74 cbig=CurveLoop(l01,l12,l23,l30)
75
76 ################################################SMALL DOMAIN
77 #ESTABLISHING PARAMETERS
78 xwidth=1000.0 #x width of model
79 zdepth=1000.0 #y width of model
80 sele_size=10. #small element size
81 #TRANSFORM
82 xshift=width/2-xwidth/2
83 zshift=depth/2-zdepth/2
84 #DOMAIN CONSTRUCTION
85 p4=Point(xshift, zshift)
86 p5=Point(xwidth+xshift, zshift)
87 p6=Point(xwidth+xshift, zdepth+zshift)
88 p7=Point(xshift, zdepth+zshift)
89 # Join corners in anti-clockwise manner.
90 l45=Line(p4, p5)
91 l56=Line(p5, p6)
92 l67=Line(p6, p7)
93 l74=Line(p7, p4)
94
95 csmall=CurveLoop(l45,l56,l67,l74)
96
97 ssmall=PlaneSurface(csmall)
98 sbig=PlaneSurface(cbig,holes=[csmall])
99
100 #############################################EXPORTING MESH FOR ESCRIPT
101 # Design the geometry for the big mesh.
102 d1=Design(dim=2, element_size=bele_size, order=1)
103 d1.addItems(sbig)
104 d1.addItems(PropertySet(l01,l12,l23,l30))
105 d1.setScriptFileName(os.path.join(save_path,"example10m_big.geo"))
106 MakeDomain(d1)
107
108 # Design the geometry for the small mesh.
109 d2=Design(dim=2, element_size=sele_size, order=1)
110 d2.addItems(ssmall)
111 d2.setScriptFileName(os.path.join(save_path,"example10m_small.geo"))
112 MakeDomain(d2)
113
114 # Join the two meshes using Gmsh and then apply a 2D meshing algorithm.
115 # The small mesh must come before the big mesh in the merging call!!@!!@!
116 sp.call("gmsh -2 "+
117 os.path.join(save_path,"example10m_small.geo")+" "+
118 os.path.join(save_path,"example10m_big.geo")+" -o "+
119 os.path.join(save_path,"example10m.msh"),shell=True)
120

  ViewVC Help
Powered by ViewVC 1.1.26