/[escript]/trunk/pycad/py_src/design.py
ViewVC logotype

Contents of /trunk/pycad/py_src/design.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 932 - (show annotations)
Fri Jan 19 09:27:15 2007 UTC (13 years, 1 month ago) by gross
File MIME type: text/x-python
File size: 4260 byte(s)
Design added. The loops tests are switched off to allow faults.
1 # $Id:$
2
3 """
4 template for the Design which defines a regions and features
5 for a mesh generator.
6
7 @var __author__: name of author
8 @var __copyright__: copyrights
9 @var __license__: licence agreement
10 @var __url__: url entry point on documentation
11 @var __version__: version
12 @var __date__: date of the version
13 """
14
15
16 __author__="Lutz Gross, l.gross@uq.edu.au"
17 __copyright__=""" Copyright (c) 2007 by ACcESS MNRF
18 http://www.access.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Open Software License version 3.0
21 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="http://www.iservo.edu.au/esys/escript"
23 __version__="$Revision:$"
24 __date__="$Date:$"
25
26
27 from primitives import Primitive, ReversePrimitive
28
29 class Design(object):
30 """
31 template for a design which defines the input for a mesh generator
32 """
33 def __init__(self,dim=3,element_size=1.,order=1,keep_files=False):
34 """
35 initializes a design
36
37 @param dim: patial dimension
38 @element_size: global element size
39 @order: element order
40 @keep_files: flag to keep work files.
41 """
42 self.clearItems()
43 self.setElementSize(element_size)
44 self.setDim(dim)
45 self.setElementOrder(order)
46 if keep_files:
47 self.setKeepFilesOn()
48 else:
49 self.setKeepFilesOff()
50 def setDim(self,dim=3):
51 """
52 sets the spatial dimension
53 """
54 if not dim in [1,2,3]:
55 raise ValueError("only dimension 1, 2, 3 are supported.")
56 self.__dim=dim
57 def getDim(self,dim=3):
58 """
59 returns the spatial dimension
60 """
61 return self.__dim
62 def setElementOrder(self,order=1):
63 """
64 sets the element order
65 """
66 if not order in [1,2]:
67 raise ValueError("only element orser 1 or 2 is supported.")
68 self.__order=order
69 def getElementOrder(self,order=1):
70 """
71 returns the element order
72 """
73 return self.__order
74 def setElementSize(self,element_size=0.1):
75 """
76 set the global element size.
77 """
78 if element_size<=0.:
79 raise ValueError("element size needs to be non--negative.")
80 self.__element_size=element_size
81 def getElementSize(self,element_size=1.):
82 """
83 returns the global element size.
84 """
85 return self.__element_size
86 def setKeepFilesOn(self):
87 """
88 work files are kept at the end of the generation
89 """
90 self.__keep_files=True
91 def setKeepFilesOff(self):
92 """
93 work files are deleted at the end of the generation
94 """
95 self.__keep_files=False
96 def keepFiles(self):
97 """
98 returns True if work files are kept
99 """
100 return self.__keep_files
101 def addItems(self,*items):
102 """
103 adds items to the design
104 """
105 for i in range(len(items)):
106 if not isinstance(items[i],(Primitive, ReversePrimitive)):
107 raise TypeError("%s-th argument is not a Primitive object"%i)
108 for i in items:
109 self.__items.append(i)
110 def getItems(self):
111 """
112 returns a list of the items used in the design
113 """
114 return self.__items
115 def clearItems(self):
116 """
117 resets the items in design
118 """
119 self.__items=[]
120 def getAllPrimitives(self):
121 """
122 returns a list of all primitives used to create the design.
123 each primitve appears once. The primitives are ordered by their
124 order of generation
125 """
126 prims=set()
127 for i in self.getItems(): prims|=set(i.getPrimitives())
128 prims=list(prims)
129 prims.sort()
130 return prims
131
132 def setOptions(self,**kwargs):
133 """
134 sets options of the mesh generator
135
136 @note: this method is typically overwritten by a particular Design implementation
137 """
138 pass
139 def getMeshHandler(self):
140 """
141 returns a handle to a mesh meshing the design
142
143 @note: this method has to be overwritten by a particular Design implementation
144 """
145 raise NotImplementedError()
146

  ViewVC Help
Powered by ViewVC 1.1.26