IV.2.2.4 Adding Groups to a DataBase
In the examples of section IV.2.2.2, one initialized a DataBase and examined its Groups and the
content of the Groups. In this example, one shows how the Groups can be manipulated, and the
DataBase modified during the execution of the program.
The groups contained in session file “groups.ses” are not sufficient to suit our post-processing
requirements. Indeed, it would be very practical if for each panel, a distinction between the skins and
honeycomb could be made. We decide that it shall be done by adding new Groups to the DataBase.
This problem can be solved in four steps:
-
1.
- Initialization of a DataBase.
-
2.
- Creation of Groups by association to materials.
-
3.
- Creation of Groups by intersections and insertion in the DataBase.
-
4.
- Printing of the Groups contained in the DataBase (for checking the result of the
operation).
Steps 1 and 4 above correspond to the operation of the example presented in section IV.2.2.2. Therefore,
one does not present those parts of the program here. One only gives explanation on steps 2 and
3.
The creation of “material Groups” is done by calling the DataBase
“getElementsAssociatedToMaterialId” method. Three Groups are created, corresponding to honeycomb 50
, honeycomb
72 and
Aluminum 2024 T3 respectively. Practically this is programmed as follows:
# Groups created by Materials :
tmpGroup_Honey_50 = db.getElementsAssociatedToMaterialId(5)
tmpGroup_Honey_50 += db.getElementsAssociatedToMaterialId(4)
tmpGroup_Honey_50.Name="Honey_50"
tmpGroup_Honey_72 = db.getElementsAssociatedToMaterialId(6)
tmpGroup_Honey_72.Name="Honey_72"
tmpGroup_Al_2024 = db.getElementsAssociatedToMaterialId(3)
tmpGroup_Al_2024.Name="Al_2024"
tmpGroup_CFRP = db.getElementsAssociatedToMaterials(10000)
tmpGroup_CFRP.Name="CFRP"
matGroups = Array.new()
matGroups << tmpGroup_Honey_50
matGroups << tmpGroup_Honey_72
matGroups << tmpGroup_Al_2024
matGroups << tmpGroup_CFRP
db.addGroupCopy(tmpGroup_Honey_50)
db.addGroupCopy(tmpGroup_Honey_72)
db.addGroupCopy(tmpGroup_Al_2024)
db.addGroupCopy(tmpGroup_CFRP)
One can make a few remarks about the previous ruby lines:
- The integer identifiers of the various materials are described in section IV.1.2.
- For the honeycomb 50 ,
the Group is created in two steps because two corresponding materials have been defined:
one MAT8 and one MAT9. The MAT8 corresponds to the -Z panel which is modeled with
surface elements. There is no corresponding duplication for Aluminum 2024 material
which is isotropic (MAT1).
- After being created, the material Groups are stored in an Array called “matGroups”. This
storage simplifies the creation of the Groups by intersection at step 3.
- The three Groups are stored in the DataBase. This operation has no peculiar utility in this
example and could be cancelled.
After the creation of material Groups, one creates the other Groups by intersection (step 3). This is done
as follows:
# Groups created by intersection :
panelGroupNames = Array.new()
panelGroupNames << "pan_MX"
panelGroupNames << "pan_MY"
panelGroupNames << "pan_MZ"
panelGroupNames << "pan_PX"
panelGroupNames << "pan_PY"
panelGroupNames << "pan_PZ"
panelGroupNames << "pan_SUP"
for panelGroupName in panelGroupNames
panelGroup = db.getGroupCopy(panelGroupName)
for matGrp in matGroups
newGrp = panelGroup * matGrp
newGrp.Name=panelGroupName+"_"+matGrp.Name
if newGrp.getEntitiesByType("Element").size > 0
db.addGroupCopy(newGrp)
end
end
end
Here again, a few commentaries can be done:
- “panelGroupNames”, an Array containing the names of the Groups corresponding to the
different sandwich panels is constructed explicitly.
- A “for” loop is nested into another “for” loop. The external one is the loop on the panel
Group names, and the internal one is the loop on the material Groups.
- In the external loop, one asks to the DataBase a copy of The Group with the appropriate
name.
- In the internal loop, on performs the intersection operations. Each Group is stored in
variable newGroup. It is named with a String obtained by concatenation of the names of
intersected Groups. Then it is inserted in the DataBase only if it contains entities.
The example is given in file “RUBY/EX03/makeMatGroups.rb”.