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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2589 - (hide annotations)
Wed Aug 5 23:06:35 2009 UTC (9 years, 11 months ago) by ahallam
Original Path: trunk/doc/cookbook/heatrefraction_mesher001.py
File MIME type: text/x-python
File size: 2877 byte(s)


1 ahallam 2588
2     ########################################################
3     #
4     # Copyright (c) 2003-2009 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) 2003-2009 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     from esys.pycad import *
27     from esys.pycad.gmsh import Design
28     from esys.finley import MakeDomain
29     import numpy as np
30     #import numpy as n
31     from math import *
32    
33 ahallam 2589 # routine to find consecutive coordinates of a loop in pycad
34 ahallam 2588 def loopcoords(loop):
35 ahallam 2589 # return all construction points of input
36 ahallam 2588 temp = loop.getConstructionPoints()
37 ahallam 2589 #create a numpy array for xyz components or construction points
38 ahallam 2588 coords = np.zeros([len(temp),3],float)
39 ahallam 2589 #place construction points in array
40 ahallam 2588 for i in range(0,len(temp)):
41     coords[i,:]=temp[i].getCoordinates()
42 ahallam 2589 #return a numpy array
43 ahallam 2588 return coords
44    
45     # Overall Domain
46     p0=Point(0.0, 0.0, 0.0)
47     p1=Point(0.0, -6000.0, 0.0)
48     p2=Point(5000.0, -6000.0, 0.0)
49     p3=Point(5000.0, 0.0, 0.0)
50    
51     l01=Line(p0, p1)
52     l12=Line(p1, p2)
53     l23=Line(p2, p3)
54     l30=Line(p3, p0)
55    
56     c=CurveLoop(l01, l12, l23, l30)
57    
58     # Material Boundary
59    
60     x=[ Point(i*100.0,-2500+1500.*cos(pi*i*100.0/2500.0+pi)) for i in range(0,51) ]
61     mysp = Spline(*tuple(x))
62     x1=Spline.getStartPoint(mysp)
63     x2=Spline.getEndPoint(mysp)
64    
65     # TOP BLOCK
66     tbl1=Line(p0,x1)
67     tbl2=mysp
68     tbl3=Line(x2,p3)
69     tblockloop = CurveLoop(tbl1,tbl2,tbl3,l30)
70     tblock = PlaneSurface(tblockloop)
71    
72     tpg = loopcoords(tblockloop)
73     np.savetxt("toppg",tpg,delimiter=" ")
74    
75     # BOTTOM BLOCK
76     bbl1=Line(x1,p1)
77     bbl3=Line(p2,x2)
78     bbl4=-mysp
79     bblockloop = CurveLoop(bbl1,l12,bbl3,bbl4)
80     bblock = PlaneSurface(bblockloop)
81    
82     #clockwise check
83     bblockloop2=CurveLoop(mysp,Line(x2,p2),Line(p2,p1),Line(p1,x1))
84     bpg = loopcoords(bblockloop2)
85     np.savetxt("botpg",bpg,delimiter=" ")
86    
87     # Create a Design which can make the mesh
88     d=Design(dim=2, element_size=200)
89     # Add the trapezoid with cutout
90     d.addItems(PropertySet("top",tblock),PropertySet("bottom",bblock),PropertySet("linebottom",l12))
91     # Create the geometry, mesh and Escript domain
92     d.setScriptFileName("heatrefraction_mesh001.geo")
93    
94     d.setMeshFileName("heatrefraction_mesh001.msh")
95     domain=MakeDomain(d, integrationOrder=-1, reducedIntegrationOrder=-1, optimizeLabeling=True)
96     # Create a file that can be read back in to python with mesh=ReadMesh(fileName)
97     domain.write("heatrefraction_mesh001.fly")
98    
99    

  ViewVC Help
Powered by ViewVC 1.1.26