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: 18
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: 292
Joined: Tue Feb 14, 2012 5:59 pm
Location: American Fork, UT

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

Postby xlao » Sun Mar 10, 2019 8:23 pm

I tried the reply and it work. But now I'm trying to get the global id for a selected list or group of hex?

I want to:
1. Create a list of hex id (here I was hoping I can choose whichever hex I want to put into this list); for example, all the hex at the boundary etc.
2. Use this list and then the post python script to loop through this hex_id_list and print out the corresponding Global_Element_ID.

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

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

Postby csimsoft Moderator » Mon Mar 11, 2019 1:10 pm

You could use the extended parsing expression "in face in surface in volume <range>" 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')
csimsoft
csimsoft Moderator
 
Posts: 292
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 3 guests

cron

Search / Mark

User Control Panel

Login

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests (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 3 guests