77 |
subregions with share the same material properties or to mark portions of the boundary. |
subregions with share the same material properties or to mark portions of the boundary. |
78 |
For efficiency, the \Design class object assigns a integer to each of its property sets, |
For efficiency, the \Design class object assigns a integer to each of its property sets, |
79 |
a so-called tag \index{tag}. The appropriate tag is attached to the elements at generation time. |
a so-called tag \index{tag}. The appropriate tag is attached to the elements at generation time. |
80 |
The \TagMap generated by the \Design allows mapping the a name onto the corresponding tag. |
|
|
In order to avoid ambiguity it is recommended to have unique names of property sets within a \Design. |
|
|
|
|
81 |
|
|
82 |
\begin{classdesc}{PropertySet}{name,*items} |
\begin{classdesc}{PropertySet}{name,*items} |
83 |
defines a group geometrical objects which can be accessed through a \var{name} |
defines a group geometrical objects which can be accessed through a \var{name} |
119 |
returns the tag used for this property set |
returns the tag used for this property set |
120 |
\end{methoddesc} |
\end{methoddesc} |
121 |
|
|
|
\subsection{Accessing \PropertySet Names} |
|
|
During mesh generation the \PropertySet objects are not identified by their name but an integer tag (mainly to provide |
|
|
a quicker indexing mechanism). The \TagMap which is generated by a \Design class object at mesh generation time |
|
|
provides an mechanism to map the property set names onto tags and vice versa. |
|
|
The following example illustrates the mechanis: In this case, the \TagMap \var{tm} |
|
|
maps the names \var{x}, \var{a} onto the tags \var{5} and \var{4} and the tag \var{4}, respectively: |
|
|
\begin{python} |
|
|
tm=TagMap({5 : "x" }) |
|
|
tm.setMap(a=1,x=4) |
|
|
print tm.getTags("a"), tm.getTags("x") |
|
|
\end{python} |
|
|
Th output is |
|
|
\begin{python} |
|
|
[ 1 ], [ 5, 4 ] |
|
|
\end{python} |
|
|
|
|
|
\begin{python} |
|
|
d=Design() |
|
|
d.add(PropertySet(name="a")) |
|
|
print d.getTagMap().getTags("a") |
|
|
\end{python} |
|
|
|
|
|
\begin{python} |
|
|
d=Design() |
|
|
d.add(PropertySet(name="a")) |
|
|
domain=esys.finley. |
|
|
print d.getTagMap().getTags("a") |
|
|
\end{python} |
|
|
|
|
|
\begin{classdesc}{TagMap}{\optional{map = \{\} }} |
|
|
defines a mapping between names (str) and tags (int). |
|
|
The dictionary \var{map} sets an initial mapping from tag to name. |
|
|
\end{classdesc} |
|
|
|
|
|
\begin{methoddesc}[TagMap]{setMap}{**kwargs} |
|
|
adds a map from names to tags using keyword arguments. For instance |
|
|
\var{top=1234} assigns the tag \var{123} to name \var{top}. The tag has to be integer. |
|
|
If a tag has been assigned to a name before the mapping will be overwritten. |
|
|
Notice that a single name can be assigned to different tags. |
|
|
\end{methoddesc} |
|
|
|
|
|
\begin{methoddesc}[TagMap]{getTags}{\optional{name=None}} |
|
|
returns a list of the tags assigned to \var{name}. If \var{name} is not present |
|
|
a list of tags is returned. |
|
|
\end{methoddesc} |
|
|
|
|
|
\begin{methoddesc}[TagMap]{getName}{\optional{tag=None}} |
|
|
returns a the name assigned to \var{name}. If \var{tag} is not present |
|
|
a list of all names is returned. |
|
|
\end{methoddesc} |
|
|
|
|
|
|
|
|
\begin{methoddesc}[TagMap]{getMapping}{} |
|
|
returns a dictionary where the tags define the keys and the values the corresponding names. |
|
|
\end{methoddesc} |
|
|
|
|
|
\begin{methoddesc}[TagMap]{map}{\optional{default=0}, \optional{**kwargs}} |
|
|
returns a dictionary where the keys are the tags and the values are the corresponding values assigned |
|
|
to the tag via the keyword arguments \var{**kwargs}. The value of \var{default} is used for tags |
|
|
which map onto name with unspecified values. |
|
|
|
|
|
The following example demonstrate the usage: |
|
|
\begin{python} |
|
|
tm=TagMap(x=5) |
|
|
tm.setMap(a=1,x=4,z=10) |
|
|
print tm.map(default = "unknown", x="john", a="peter") |
|
|
\end{python} |
|
|
The output is |
|
|
\begin{python} |
|
|
{ 5 : "john", 4: "john", 1 : "peter", 10 : "unknown" } |
|
|
\end{python} |
|
|
\end{methoddesc} |
|
|
|
|
|
\begin{methoddesc}[TagMap]{insert}{data,\optional{default=0, \optional{**kwargs}}} |
|
|
inserts the values assigned to name via the keyword arguments \var{**kwargs} |
|
|
into the \Data object \var{Data}. The value \var{default} is used for names with no given value. |
|
|
\end{methoddesc} |
|
|
|
|
|
\begin{methoddesc}[TagMap]{writeXML}{\optional{iostream=None}} |
|
|
writes an XML serialization into the \var{iostream} or if not present returns the XML representation |
|
|
as a string. |
|
|
\end{methoddesc} |
|
|
|
|
|
\begin{methoddesc}[TagMap]{fillFromXML}{iostream} |
|
|
uses XML data \var{iostream} defining an iostream or string. This method is the |
|
|
inverse method of \var{writeXML}. |
|
|
|
|
|
The following example demonstrates the usage: |
|
|
\begin{python} |
|
|
tm=TagMap(x=5) |
|
|
tm.setMap(a=1,x=4,z=10) |
|
|
tm.writeXML(open("tag_map.xml", "w")) |
|
|
tm2=TagMap() |
|
|
tm2.fillFromXML(open("tag_map.xml", "r")) |
|
|
\end{python} |
|
|
\end{methoddesc} |
|
|
|
|
|
|
|
|
|
|
122 |
\section{Interface to \gmshextern} |
\section{Interface to \gmshextern} |
123 |
\declaremodule{extension}{esys.pycad.gmsh} |
\declaremodule{extension}{esys.pycad.gmsh} |
124 |
\modulesynopsis{Python geometry description and meshing interface} |
\modulesynopsis{Python geometry description and meshing interface} |