Extracting Global Element ID (instead of Hex number)

General topics about Trelis/Cubit, such as localization, GUI, etc.

Extracting Global Element ID (instead of Hex number)

Postby xlao » Sat Dec 01, 2018 10:25 pm

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.

Thanks.
xlao
 
Posts: 15
Joined: Wed Jan 11, 2017 3:06 pm

Re: Extracting Global Element ID (instead of Hex number)

Postby csimsoft Moderator » Tue Dec 04, 2018 2:38 pm

You can use the get_global_element_id functions for this. Open your Journal Editor and click the Python button on the toolbar. Paste the following:

cubit.cmd('reset')
cubit.cmd('bri x 1')
cubit.cmd('vol 1 int 2')
cubit.cmd('mesh vol 1')
cubit.cmd('block 1 vol all')

Add this code to use the get_global_element_id function. I used a variable 'element_type' to specify hex elements.

element_type = 'hex'
element_id_list = cubit.parse_cubit_list(element_type, 'all')
for element_id in element_id_list:
global_element_id = cubit.get_global_element_id(element_type, element_id)
print "Element ID: {0}, Global ID: {1}".format(element_id, global_element_id)

(The indentation doesn't work right in the forum post. You will need to indent the two lines after the for statement.)

Or, you can use the get_hex_global_element_id function:

hex_id_list = cubit.parse_cubit_list('hex', 'all')
for hex_id in hex_id_list:
global_hex_id = cubit.get_hex_global_element_id(hex_id)
print "Hex ID: {0}, Global ID: {1}".format(hex_id, global_hex_id)

(The indentation doesn't work right in the forum post. You will need to indent the two lines after the for statement.)

Other functions can be found under Mesh Element Queries here:

https://csimsoft.com/help/appendix/pyth ... erface.htm
csimsoft
csimsoft Moderator
 
Posts: 285
Joined: Tue Feb 14, 2012 5:59 pm
Location: American Fork, UT


Return to General Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron

Search / Mark

User Control Panel

Login

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 83 on Tue Nov 13, 2018 11:44 am

Users browsing this forum: No registered users and 1 guest