Data Type: TriangularGrid ()
A data object of type TriangularGrid represents a 2D unstructured finite-element grid composed of triangles. The geometric information is stored in terms of vertices, edges and triangles. Similar to tetrahedral grids triangular grids also contain a 'dictionary' of different material types or regions. In addition to the material names the dictionary may contain colors and other parameters related to material properties.Notice: To put the data reader into the right track of reading 2D triangular grids an entry ContentType "HxTriangularGrid" in the parameter section of an data file is mandatory. Remember that the indices of nodes resp. edges start with 1 (one)!
Triangles can be constructed out of nodes or edges. In the latter case you have to define the list of edges by specifying the two nodes for each edge and then the list of triangles where each triangle is defined through 3 edges.
More information about 's native general-purpose file format can be found here.
A first example. In order to describe the syntax of an data file containing 2D a triangular grid and data defined on that grid we first give a short example.
# AmiraMesh 2D ASCII 2.0 # CreationDate: sometimes define Nodes 9 define Triangles 9 Parameters { ContentType "HxTriangularGrid" } Materials { { Name "Substrat1" Color 0.8 0.1 0.1 Id 5 } { Name "Substrat2" Color 0.1 0.1 0.8 Id 8 } } Nodes { float [2] Coordinates } = @1 Triangles { int[3] Nodes } = @2 Triangles { byte Materials } = @3 Nodes { float v } = @4 Field { float f } = Linear(@4) @1 0. 1. 1. 0.5 0.5 2. 2. 0. 2. 1. 0. 0. 0. 2. 2. 2. 1.5 0.5 @2 0 1 2 1 4 2 1 8 4 1 3 8 3 4 8 0 1 5 1 5 3 0 2 6 2 4 7 @3 5 8 8 8 8 5 8 5 8 @4 0. 1. 2. 3. 4. 5. 6. 7. 8.The first line of an data file should be a special comment including the identifier . Moreover, if the tag ASCII is given in this line all data arrays are stored in plain ascii text. If the tag BINARY is given, the data arrays are stored in IEEE big-endian binary format. Note, that the header section of an data file is always given as ascii text.
The statement define Nodes 9 defines a one-dimensional array of size 9. Later on, this array can be referenced using the name Nodes. The actual kind of data stored per array element will be specified later on.
The optional section Parameters allows the user to define arbitrary additional parameters. Each parameter consists of a key-value pair. Values may be one or multiple integer or floating point numbers or a string. Strings have to be quoted using a pair of "-characters. Here the mandatory parameter ContentType "HxTriangularGrid" gives the information how to read and interpret the file.
The optional section Materials allows the user to define additional material information. This is useful for finite element applications. The material section consists of a comma-separated list of parameters just as in the Parameters section.
The statement Nodes { float[2] Coordinates } = @1 specifies that for each element of the array Nodes defined earlier two floating point numbers (floats) should be stored. These data are given the name Coordinates and a tag in this line and will appear below as a tagged block with the marker @1. Such data markers must always begin with the letter @.
Similar, the following lines define additional data to be stored in the arrays called Nodes and Triangles. The primitive data types must be one of byte, short, int, float, double, or complex. Vectors of primitive data types are allowed, aggregate structs are not, however. The data type complex means two floats (real and imaginary part) for each location the data is defined on.
The statement Field { float f } = Linear(@4) defines a continuous scalar field with the name f. This field will be generated by linear interpolation from the data values Values defined on the nodes of the triangular grid. Another interpolation methods is Constant(@X) where the data is stored for each triangle and thus constantly interpolated within one triangle.
After the marker @1 the coordinate values of the grid are stored. Likewise, the other data arrays are given after their corresponding markers. In case of a BINARY file the line containing the marker is read up to the next new line character. Then the specified number of bytes is read in binary format. It is assumed that sizeof(short) is 2, sizeof(int) is 4, sizeof(float) is 4, sizeof(double) is 8, and sizeof(complex) is 8 (4 + 4).
saveAmiramesh <filename>
Saves the grid as a 2D data file (ascii).numEdges
Returns the number of edges.numPoints
Returns the number of points.numTriangles
Returns the number of triangles.getEdgePoints <edge-number>
Returns the indices of the two end points of an edge.getEdgeTriangles <edge-number>
Returns the indices of the two triangles separated by the given edge.getTriangleEdges <triangle-number>
Returns the indices of the 3 edges of the given triangle.getTrianglePoints <triangle-number>
Returns the indices of the 3 points of the given triangle.getTriangleCenter <triangle-number>
Returns the coordinates of the center of the given triangle.getPoint <vertex-number>
Returns the coordinates of the given point.