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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2948 - (show annotations)
Thu Feb 25 04:54:30 2010 UTC (9 years, 5 months ago) by gross
File MIME type: text/x-python
File size: 2907 byte(s)
a new almost completed version of the cookbook
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 # simple_mesher001.py
29 # 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 from esys.escript import mkDir
37 from esys.escript.unitsSI import *
38 import os
39 ########################################################MPI WORLD CHECK
40 if getMPISizeWorld() > 1:
41 import sys
42 print "This example will not run in an MPI world."
43 sys.exit(0)
44
45 # make sure path exists
46 save_path= os.path.join("data","simpleheat")
47 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 d.addItems(rec, PropertySet("linebottom",l12))
75
76 # this is the name of gmsh input file generated by pycad
77 #
78 # >> gmsh simple.geo
79 #
80 # to show the mesh.
81 #
82 d.setScriptFileName(os.path.join(save_path,"simple.geo"))
83
84 # this is the name of mesh file generated gmsh. Use
85 #
86 # >> gmsh simple.msh
87 #
88 # to show the mesh.
89 #
90 d.setMeshFileName(os.path.join(save_path,"simple.msh"))
91 #
92 # make the finley domain:
93 #
94 domain=MakeDomain(d)
95 # Create a file that can be read back in to python with
96 # mesh=ReadMesh(fileName)
97 domain.write(os.path.join(save_path,"simple.fly"))
98
99

  ViewVC Help
Powered by ViewVC 1.1.26