Is there any way to efficiently extract global element id of elements?
Getting hex number associated with an element is straightforward, but getting the global element id of a group of elements is not trivial. Adding them to group will only add them as hex numbers instead of global element id. So now, in order to get global element id of elements, I’d add to select each element one at a time and list its information.
Global element id of elements are useful because they relate to actual FEM analysis.
You could use the extended parsing expression "in face in surface in volume " to specify which hexes you include. For example, run this journal file:
reset
bri x 1
mesh vol 1
block 1 hex in face in surface in volume 1
graphics clip on direction 1 0 -2
draw block 1
You should see only the hexes around the boundary of the cube. When adding hexes to Block 1, using the expression “hex in face in surface in volume 1” will only add the hexes that have a face in the surfaces of volume 1.
In the previous example where we got the global element ids, you could get the list of hexes on the border using:
hex_id_list = cubit.parse_cubit_list(‘hex’, ‘in face in surface in volume 1’)
Thanks for the tip; it worked. Is there an option to instead of exporting/showing onto the Trelis command window, the result (element ID) exported to a external text file?
I would use Python to export the ID list to a file, something like this:
hex_id_list = cubit.parse_cubit_list(‘hex’, ‘in face in surface in volume 1’)
f = open(‘exportHexIDList.txt’, ‘w’)
f.write(repr(hex_id_list))
f.close()
Or formatted somehow:
hex_id_list = cubit.parse_cubit_list(‘hex’, ‘in face in surface in volume 1’)
f = open(‘exportHexIDList.txt’, ‘w’)
for hex_id in hex_id_list:
f.write(“Hex ID: {0}\n”.format(hex_id))
f.close()
This file can be run from the Journal Editor. ExportHexIDList.py (402 Bytes)
So I tried using that script but I get the following errors like the text I want to open and write on Permission is denied. See below:
Traceback (most recent call last):
File “”, line 2, in
IOError: [Errno 13] Permission denied: ‘exportHexIDList.txt’
Trelis>
Traceback (most recent call last):
File “”, line 3, in
NameError: name ‘f’ is not defined
Trelis>
Traceback (most recent call last):
File “”, line 4, in
NameError: name ‘f’ is not defined