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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3773 by caltinay, Fri Dec 9 04:48:08 2011 UTC revision 3774 by jfenwick, Wed Jan 18 06:29:34 2012 UTC
# Line 33  for a mesh generator. Line 33  for a mesh generator.
33    
34  __author__="Lutz Gross, l.gross@uq.edu.au"  __author__="Lutz Gross, l.gross@uq.edu.au"
35    
36  from primitives import Primitive, ReversePrimitive, PropertySet, Point, Manifold1D, Manifold2D, Manifold3D  from .primitives import Primitive, ReversePrimitive, PropertySet, Point, Manifold1D, Manifold2D, Manifold3D
37  from xml.dom import minidom  from xml.dom import minidom
38  import tempfile, os  import tempfile, os
39    
# Line 56  class TagMap(object): Line 56  class TagMap(object):
56        to a name.        to a name.
57        """        """
58        self.__mapping={}        self.__mapping={}
59        for tag, name in mapping.items():        for tag, name in list(mapping.items()):
60            if not isinstance(tag, int):            if not isinstance(tag, int):
61                raise TypeError("tag needs to be an int")                raise TypeError("tag needs to be an int")
62            if not isinstance(name, str):            if not isinstance(name, str):
# Line 70  class TagMap(object): Line 70  class TagMap(object):
70        the mapping will be overwritten. Otherwise a new mapping <tag> -> <name>        the mapping will be overwritten. Otherwise a new mapping <tag> -> <name>
71        is set. Notice that a single name can be assigned to different tags.        is set. Notice that a single name can be assigned to different tags.
72        """        """
73        for name, tag in kwargs.items():        for name, tag in list(kwargs.items()):
74            if not isinstance(tag, int):            if not isinstance(tag, int):
75               raise TypeError("tag needs to be an int")               raise TypeError("tag needs to be an int")
76            self.__mapping[tag]=name            self.__mapping[tag]=name
# Line 81  class TagMap(object): Line 81  class TagMap(object):
81          a list of all tags is returned.          a list of all tags is returned.
82          """          """
83          if name == None:          if name == None:
84             out=self.__mapping.keys()             out=list(self.__mapping.keys())
85          else:          else:
86             out=[]             out=[]
87             for tag, arg in self.__mapping.items():             for tag, arg in list(self.__mapping.items()):
88               if arg == name: out.append(tag)               if arg == name: out.append(tag)
89          return out          return out
90    
# Line 120  class TagMap(object): Line 120  class TagMap(object):
120          """          """
121          out={}          out={}
122          for tag in self.__mapping:          for tag in self.__mapping:
123             if kwargs.has_key(self.__mapping[tag]):             if self.__mapping[tag] in kwargs:
124                out[tag]=kwargs[self.__mapping[tag]]                out[tag]=kwargs[self.__mapping[tag]]
125             else:             else:
126                out[tag]=default                out[tag]=default
# Line 133  class TagMap(object): Line 133  class TagMap(object):
133          which map onto name with unspecified values.          which map onto name with unspecified values.
134          """          """
135          d=self.map(default=default,**kwargs)          d=self.map(default=default,**kwargs)
136          for t,v in d.items():          for t,v in list(d.items()):
137               data.setTaggedValue(t,v)               data.setTaggedValue(t,v)
138    
139      def passToDomain(self,domain):      def passToDomain(self,domain):
140          """          """
141          Passes the tag map to the `esys.escript.Domain` ``domain``.          Passes the tag map to the `esys.escript.Domain` ``domain``.
142          """          """
143          for tag, name in self.__mapping.items():          for tag, name in list(self.__mapping.items()):
144            print "Tag",name, "is mapped to id ", tag            print("Tag",name, "is mapped to id ", tag)
145            domain.setTagMap(name,tag)            domain.setTagMap(name,tag)
146    
147      def toDOM(self,dom):      def toDOM(self,dom):
# Line 150  class TagMap(object): Line 150  class TagMap(object):
150           """           """
151           tm=dom.createElement("TagMap")           tm=dom.createElement("TagMap")
152           dom.appendChild(tm)           dom.appendChild(tm)
153           for tag,name in self.getMapping().items():           for tag,name in list(self.getMapping().items()):
154               item_dom=dom.createElement("map")               item_dom=dom.createElement("map")
155               tag_dom=dom.createElement("tag")               tag_dom=dom.createElement("tag")
156               name_dom=dom.createElement("name")               name_dom=dom.createElement("name")
# Line 393  class Design(object): Line 393  class Design(object):
393    
394         """         """
395         if not format in [ self.GMSH, self.IDEAS, self.VRML, self.STL, self.NASTRAN, self.MEDIT, self.CGNS, self.PLOT3D, self.DIFFPACK] :         if not format in [ self.GMSH, self.IDEAS, self.VRML, self.STL, self.NASTRAN, self.MEDIT, self.CGNS, self.PLOT3D, self.DIFFPACK] :
396             raise ValueError,"unknown file format %s."%format             raise ValueError("unknown file format %s."%format)
397         self.__fileformat=format         self.__fileformat=format
398                        
399      def getFileFormat(self):      def getFileFormat(self):

Legend:
Removed from v.3773  
changed lines
  Added in v.3774

  ViewVC Help
Powered by ViewVC 1.1.26