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

Annotation of /trunk/doc/examples/cookbook/example04a.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3892 - (hide annotations)
Tue Apr 10 08:57:23 2012 UTC (7 years ago) by jfenwick
File MIME type: text/x-python
File size: 2982 byte(s)
Merged changes across from the attempt2 branch.
This version builds and passes python2 tests.
It also passes most python3 tests.



1 gross 2948
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 gross 2951 # example04a.py
29 gross 2948 # Create either a 2D mesh for a rectangle model using pycad meshing
30     # tools.
31     #
32     #######################################################EXTERNAL MODULES
33     from esys.pycad import * #domain constructor
34     from esys.pycad.gmsh import Design #Finite Element meshing package
35     from esys.finley import MakeDomain #Converter for escript
36 gross 2953 from esys.escript import mkDir, getMPISizeWorld
37 gross 2948 from esys.escript.unitsSI import *
38     import os
39     ########################################################MPI WORLD CHECK
40     if getMPISizeWorld() > 1:
41     import sys
42 jfenwick 3892 print("This example will not run in an MPI world.")
43 gross 2948 sys.exit(0)
44    
45     # make sure path exists
46 gross 2953 save_path= os.path.join("data","example04")
47 gross 2948 mkDir(save_path)
48    
49     ################################################ESTABLISHING PARAMETERS
50     #Model Parameters
51     width=5000.0*m #width of model
52     depth=-6000.0*m #depth of model
53    
54     ####################################################DOMAIN CONSTRUCTION
55     # Domain Corners
56     p0=Point(0.0, 0.0, 0.0)
57     p1=Point(0.0, depth, 0.0)
58     p2=Point(width, depth, 0.0)
59     p3=Point(width, 0.0, 0.0)
60     # Join corners in anti-clockwise manner.
61     l01=Line(p0, p1)
62     l12=Line(p1, p2)
63     l23=Line(p2, p3)
64     l30=Line(p3, p0)
65     # Join line segments to create domain boundary.
66     c=CurveLoop(l01, l12, l23, l30)
67     # surface
68     rec = PlaneSurface(c)
69    
70     #############################################EXPORTING MESH FOR ESCRIPT
71     # Create a Design which can make the mesh
72     d=Design(dim=2, element_size=200*m)
73     # Add the subdomains and flux boundaries.
74 gross 3644 d.addItems(rec, PropertySet("linebottom",l12) )
75     d.addItems(l23, l30, l01) # just in case we need them.
76 gross 2948
77     # this is the name of gmsh input file generated by pycad
78     #
79 gross 2951 # >> gmsh example04.geo
80 gross 2948 #
81     # to show the mesh.
82     #
83 gross 2951 d.setScriptFileName(os.path.join(save_path,"example04.geo"))
84 gross 2948
85     # this is the name of mesh file generated gmsh. Use
86     #
87 gross 2951 # >> gmsh example04.msh
88 gross 2948 #
89     # to show the mesh.
90     #
91 gross 2951 d.setMeshFileName(os.path.join(save_path,"example04.msh"))
92 gross 2948 #
93 jfenwick 3259 # make the domain:
94 gross 2948 #
95     domain=MakeDomain(d)
96     # Create a file that can be read back in to python with
97     # mesh=ReadMesh(fileName)
98 gross 2951 domain.write(os.path.join(save_path,"example04.fly"))
99 gross 2948
100    

  ViewVC Help
Powered by ViewVC 1.1.26