Dear all,
I would like to solve the following task with your kind support.
I use Coreform Cubit as pre-processor, the mesh will be transfered into a seperate software for calculation purposes.
To wite out the mesh I use the following (or similar) code (only one group is shown as an example):
outucdfile = "D:\test.dat"
outfile = open(outucdfile,"w")
cubit.cmd("group 'temp_hexes' add hex all")
group_id = cubit.get_id_from_name("temp_hexes")
hex_list = cubit.get_group_hexes(group_id)
outfile.write(str(len(hex_list))+"\n")
for hex_num in hex_list:
outfile.write(str(hex_num)+"\n")
hex_nodes = cubit.get_connectivity("Hex", hex_num)
i = 0
while i < 8:
coord = cubit.get_nodal_coordinates(hex_nodes[i])
outfile.write(str(coord) + "\n")
i += 1
Defined group in Coreform Cubit
group_hexes = cubit.get_group_hexes(2)
q = len(cubit.get_group_hexes(2))
outfile.write(str(q)+"\n")
k = 0
while k < q:
group_hexes_2 = group_hexes[k]
outfile.write(str(group_hexes_2) + "\n")
k += 1
Definition of material properties:
To define a material for volumes/hex which are part of a group I define blocks and name the blocks according to the materials (like Steel). As an example: The block “steel” containes then several group IDs.
Two tasks I would like to solve:
- Write out the group name, not only the ID
- Write out the material property of a group which is defined in a Block
It could look like in the output file:
Group name: Example
Group material: steel
…
Many thanks
BR Stefan
Hi @Stefan_R,
you can query the name and ids of the groups with cubit.group_names_ids()
After that you only need to search for your group id in the vector to get the group name.
Could look like this
group_id = 2
names_ids = cubit.group_names_ids()
for pair in names_ids:
if pair[1] == group_id:
print("Group Name:" + pair[0])
For the Material you can first get the material id form a block and then query the material name.
block_id = 1
material_id = cubit.get_block_material(block_id)
print("Group Material:" + cubit.get_material_name(material_id))
Hi @Norbert_Hofbauer ,
many thanks for the supprt - works perfectly fine.
Hi @Norbert_Hofbauer ,
one question in addition came up:
- Materials can be defined in coreform
- Blocks can be defined and materials can be assigned to blocks
- A block can contain groups.
How can I read which groups are contained in a block?
Many thanks!
BR Stefan
Hi @Stefan_R,
normally you should be able to get a group list with
cubit.get_block_children()
But unfortunately it currently throws me an error when i try this with the python api. I already informed the devs about this issue. Using the C++ version with the SDK would work
If you are using the python api for your process, it would be better to store the block group assignment in a global variable for later access. I currently don’t have a workaround for the missing function.
Hi @Norbert_Hofbauer,
happy new year!
Many thanks - please keep me updated if you receive an answer from devs.
At the moment I have solved the problem with a workaround, if possible I want to get rid of it with the help of “block.children()”
Thanks
BR Stefan
Hi @Norbert_Hofbauer, do you know if this issue have been fixed by devs in the newest Coreform Cubit version? Thanks! BR Stefan
Unfortunately not. The issue still persists in Cubit 2024.3 and the latest dev builds.