Block Assignment Segfault/Crash

Hi I’ve got a mesh that only exists as a mesh, it was generated via an image based meshing technique. Using Coreform Cubit on Fedora Core 33.

I know that the following tet id’s correspond to the blocks that I want, 1 to 1084211 block 1, 1084212 to 13971250 block 2 and 13971251 to 19289205 block 3. Firstly, when I run the command

block 1 add tet 1 to 1084211

Something happens, but the elements never get assigned to the blocks. So I did

draw tet 1 to 1084211

Which works, and shows me a bunch of tets, I then to an x-ray select on those elements and then when selected, add them to the block, however I get a CTD. When launched from the terminal I just get segfault, and running via gdb gets me a > 40k line backtrace.

Further, If i save the file (Cubit), I get a 7kb file for something with more than 10k elements, so something is v weird.

Any and all help appreciated :slight_smile: Ive started uploading the exodus file for your pleasure

I know the problem, but its still a bug i think in Trelis, all the elements already belong in a block, and so adding them fails. When I do this for a few, we get a repeated error message like

Block 1 Tet 1525370 Tet 299 Tet 1287732 T
WARNING: Some elements not added because they are already in other blocks.
To allow duplicate block elements use command: 'set duplicate block elements on'

Im guessing some buffer somewhere gets overloaded when this is done for 2e6 elements.

If it is crashing, it is a bug in our code. We should at least give an error and not crash. Dealing with individual elements like this can use a lot of memory. Cubit was not optimized for this case. How is your memory usage when you crash?

Fine, my machine has 128 Gb of RAM, doesnt touch the sides :slight_smile:

I’ve further noticed, it only works if you import mesh geometry, the lite version its non-functional.

Sorry, further distraction, is there a capability currently to select triangle faces by normal? What I would like to do is select the yellow and pink triangles that lie along the the interior curved surface of that shown in the image below. I have a mesh library that I use, where what I would do is select a triangle element, then query the connectivity and find ouf the adjacent triangles, and keep walking this tree of connectivity, only adding those whose normal was within some tolerance of the last. Does Trelis/Cubit have that level of API?

We don’t expose a triangle normal function. You could calculate this pretty easily in python. You need to know that the connectivity is defined by the right hand rule so that you can correctly take the cross product. I also have numpy installed in my version of cubit’s python.

import numpy as np
cubit.cmd("compress")  # only needed if the ids aren't already 1 based and sequential
for tri_id in range(1, cubit.tri_count):
   conn = cubit.get_connectivity("tri", tri_id)
   coords1 = np.array(cubit.get_nodal_coordinates(conn[0]))
   coords2 = np.array(cubit.get_nodal_coordinates(conn[1]))
   normal = np.cross(coords3 - coords1, coords2 - coords1)

You may want to normalize and do other calculations, but this would be the skeleton code.

To get the adjacent triangles I would create a group.

cubit.cmd(f"group ‘tmp_tris’ equals tri in edge in tri {tri_id} except {tri_id}")
group_id = cubit.get_id_from_name(“tmp_tris”)
adjacent_tris = cubit.get_group_tris(group_id)

I suspect you would want to create a set of visited triangles to make sure that you are not visiting the same triangle multiple times.

Are you running OK as long as you don’t have the duplicate block error issue?

Yeah, once I cleared that block, everything is fine.

But…just to be clear, there is definitively a bug though.