Groups are a way of defining a list of entities such as nodes and elements. IMAT supplies an imat_group object, which contains lists of entities. Entities are stored as ID/TYPE pairs. Multiple entity types can be stored in a single group. Entity IDs must be unique within a given entity type, but do not need to be unique across entity types, even within the same group.
Groups are marginally useful on their own, but become much more useful when used in conjunction with imat_fem objects. The primary purpose of groups in this context is defining subsets of the FEM.
The IMAT_GROUP class is a fairly simple class, with three public properties (id, name, and data), and a special property, (type). The .id property contains the group ID. This is generally not used by IMAT, but is there for complete round-tripping through Universal files. The .name property is a string up to 80 characters that contains the group name. The .data property contains the entities in the group. This property is an Nx2 matrix, where the first column contains the entity IDs and the second column contains the entity types. The combination of entity ID and type must be unique within a group. The type property is a special dependent property that returns enumerations for the supported entity types. We will show how to use this later in this section.
For a complete definition of the various classes and descriptions of their contents, please refer to the Group Data Format Reference. Below is an example of the IMAT_GROUP object and its contents. This class operates very much like MATLAB structures.
>> g=readunv('../data/groups.unv',2477);
Read 4 imat_group objects
>> g
g =
4x1 IMAT_GROUP - Groups
GROUP(1): 1 - EVERYTHING
ID Name Type
-------- ----------------- ----
1 coordinate system 1
1 node 7
2 node 7
3 node 7
4 node 7
1 element 8
-------- ----------------- ----
1 coordinate system
4 nodes
1 element
GROUP(2): 2 - TWO NODES
ID Name Type
-------- ----------------- ----
3 node 7
4 node 7
-------- ----------------- ----
2 nodes
GROUP(3): 3 - ONE ELEMENT
ID Name Type
-------- ----------------- ----
1 element 8
-------- ----------------- ----
1 element
GROUP(4): 4 - ONE CS ONE ELEM TWO NODES
ID Name Type
-------- ----------------- ----
1 coordinate system 1
2 node 7
3 node 7
1 element 8
-------- ----------------- ----
1 coordinate system
2 nodes
1 element
>> g2 = g(1)
g2 =
IMAT_GROUP - Groups
GROUP(1): 1 - EVERYTHING
ID Name Type
-------- ----------------- ----
1 coordinate system 1
1 node 7
2 node 7
3 node 7
4 node 7
1 element 8
-------- ----------------- ----
1 coordinate system
4 nodes
1 element
>> g.type
ans =
gUnknown: 0
gCSys: 1
gNode: 7
gElement: 8
gTraceline: 27
>>
In the example above, note that the group object can contain an array of groups. Each index into the group variable g contains a different group. Access to these groups follows the familiar MATLAB parenthesis "()" notation.
IMAT provides several methods to operate on groups. The methods are primarily boolean methods for combining groups, and are shown in the code snippet below. You can find a complete list of IMAT_GROUP methods here.
>> g(2) & g(3) % Boolean AND will produce an empty group
ans =
GROUP(2): 2 - TWO NODES
--- Empty ---
>> g(2) | g(3) % Boolean OR merges without sorting
ans =
GROUP(2): 2 - TWO NODES
ID Name Type
-------- ----------------- ----
3 node 7
4 node 7
1 element 8
-------- ----------------- ----
2 nodes
1 element
>> union(g(2),g(3)) % Union merges and sorts
ans =
GROUP(2): 2 - TWO NODES
ID Name Type
-------- ----------------- ----
1 element 8
3 node 7
4 node 7
-------- ----------------- ----
2 nodes
1 element
>> g(2).extract(g.type.gNode) % Extract the node IDs
ans =
3
4
>>
Group objects can be arrays of groups. Group properties can be accessed using the "dot" (structure) notation. Please see the following code snippet for examples of IMAT_GROUP subscripting.
>> g2 = g(3) % Subscript notation accesses individual groups in the group object
g2 =
GROUP(1): 3 - ONE ELEMENT
ID Name Type
-------- ----------------- ----
1 element 8
-------- ----------------- ----
1 element
>> g2.id = 1234 % "dot" notation accesses individual properties
g2 =
GROUP(1): 1234 - ONE ELEMENT
ID Name Type
-------- ----------------- ----
1 element 8
-------- ----------------- ----
1 element
>> g2.name = 'new name'
g2 =
GROUP(1): 1234 - newname
ID Name Type
-------- ----------------- ----
1 element 8
-------- ----------------- ----
1 element
>> g.id % "dot" notation also works on arrays of groups
ans =
[1]
[2]
[3]
[4]
>>
Within an individual group, you can partition a group to entities of a specific type using {} notation.
>> g=imat_group([1 8; 10 7; 11 7; 2 8])
g =
IMAT_GROUP - Groups
GROUP(1): 0 -
ID Name Type
-------- ----------------- ----
1 element 8
10 node 7
11 node 7
2 element 8
-------- ----------------- ----
2 nodes
2 elements
>> g{g.type.gNode} % Extract just the nodes. Equivalent to using imat_group/keep
ans =
IMAT_GROUP - Groups
GROUP(1): 0 -
ID Name Type
-------- ----------------- ----
10 node 7
11 node 7
-------- ----------------- ----
2 nodes
>>
Group objects have several properties defined to allow you to access the specific entity IDs (nodes, elements, etc.) directly. You can retrieve and set the entity IDs. If you set the specific entity type, entities of the same type in the group will be removed and replaced with the new entity IDs.
>> g=imat_group([1 8; 10 7; 11 7; 2 8])
g =
IMAT_GROUP - Groups
GROUP(1): 0 -
ID Name Type
-------- ----------------- ----
1 element 8
10 node 7
11 node 7
2 element 8
-------- ----------------- ----
2 nodes
2 elements
>> g.node
ans =
10
11
>> g.element
ans =
1
2
>> g.element=12345
g =
IMAT_GROUP - Groups
GROUP(1): 0 -
ID Name Type
-------- ----------------- ----
10 node 7
11 node 7
12345 element 8
-------- ----------------- ----
2 nodes
1 element
>>