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

Contents of /trunk/doc/examples/cookbook/example04a.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: 3539 byte(s)
Make everyone sad by touching all the files

Copyright dates update

1 from __future__ import division, print_function
2 ##############################################################################
3 #
4 # Copyright (c) 2009-2018 by The University of Queensland
5 # http://www.uq.edu.au
6 #
7 # Primary Business: Queensland, Australia
8 # Licensed under the Apache License, version 2.0
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
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 # example04a.py
31 # Create either a 2D mesh for a rectangle model using pycad meshing
32 # tools.
33 #
34 #######################################################EXTERNAL MODULES
35 from esys.pycad import * #domain constructor
36 from esys.pycad.gmsh import Design #Finite Element meshing package
37 from esys.escript import mkDir, getMPISizeWorld
38 from esys.escript.unitsSI import *
39 import os,sys
40 try:
41 # This imports the rectangle domain function
42 from esys.finley import MakeDomain#Converter for escript
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:
50 import sys
51 print("This example will not run in an MPI world.")
52 sys.exit(0)
53
54 if HAVE_FINLEY:
55 # make sure path exists
56 save_path= os.path.join("data","example04")
57 mkDir(save_path)
58
59 ################################################ESTABLISHING PARAMETERS
60 #Model Parameters
61 width=5000.0*m #width of model
62 depth=-6000.0*m #depth of model
63
64 ####################################################DOMAIN CONSTRUCTION
65 # Domain Corners
66 p0=Point(0.0, 0.0, 0.0)
67 p1=Point(0.0, depth, 0.0)
68 p2=Point(width, depth, 0.0)
69 p3=Point(width, 0.0, 0.0)
70 # Join corners in anti-clockwise manner.
71 l01=Line(p0, p1)
72 l12=Line(p1, p2)
73 l23=Line(p2, p3)
74 l30=Line(p3, p0)
75 # Join line segments to create domain boundary.
76 c=CurveLoop(l01, l12, l23, l30)
77 # surface
78 rec = PlaneSurface(c)
79
80 #############################################EXPORTING MESH FOR ESCRIPT
81 # Create a Design which can make the mesh
82 d=Design(dim=2, element_size=200*m)
83 # Add the subdomains and flux boundaries.
84 d.addItems(rec, PropertySet("linebottom",l12) )
85 d.addItems(l23, l30, l01) # just in case we need them.
86
87 # this is the name of gmsh input file generated by pycad
88 #
89 # >> gmsh example04.geo
90 #
91 # to show the mesh.
92 #
93 d.setScriptFileName(os.path.join(save_path,"example04.geo"))
94
95 # this is the name of mesh file generated gmsh. Use
96 #
97 # >> gmsh example04.msh
98 #
99 # to show the mesh.
100 #
101 d.setMeshFileName(os.path.join(save_path,"example04.msh"))
102 #
103 # make the domain:
104 #
105 domain=MakeDomain(d)
106 # Create a file that can be read back in to python with
107 # mesh=ReadMesh(fileName)
108 domain.write(os.path.join(save_path,"example04.fly"))
109
110

  ViewVC Help
Powered by ViewVC 1.1.26