Generated mesh missing region

For the generated mesh. Block 2 is not generated:

Using ExodusII API version 8.03 and DB version 8.03 to export "cubit01.e".
Writing Exodus file: |=>                                                                                                                                   |  2%WARNING: The Exodus output format cannot output elements of type UNKNOWN_ELEMENT_TYPE
         Skipping block 2
Writing Exodus file: |=========================>                                                                                                           | 20%WARNING: The model contains 52 nodes (and their attached elements)
         that will not be written to the genesis file.
         This may indicate a problem in element block assignments.
Writing Exodus file: |====================================================================================================================================>|100%
                                                                                                                                                                

build3.py (5.0 KB)

What’s happening is that when you do the remove overlap commands, these operate on the volumes (bodies) and a new surface is created on the volume that you’re removing overlap from. As you previously set the block to be on the surface of said volume, you’re losing your block assignment. The error you’re getting is that you’re thus trying to export a block with zero elements.

One way around this is to assign the volumes / sheet bodies to groups and do your remove overlaps, then create the blocks out of the surfaces in each volume within each group.

Here are two short scripts that demonstrate this behavior:

Doesn’t work

reset
create surface rectangle width 1 zplane 
create surface rectangle width .5 zplane 

block 1 surface 1
block 2 surface 2
remove overlap volume 1 2 modify volume 1
mesh surf all
# No elements in block 1

Correct way

reset
create surface rectangle width 1 zplane 
create surface rectangle width .5 zplane 

create group "green_volume"
create group "yellow_volume"
green_volume add volume 1
yellow_volume add volume 2
remove overlap volume 1 2 modify volume 1
block 1 add surface in volume in green_volume
block 2 add surface in volume in yellow_volume
mesh surf all

Thanks for your response. Since the volume id is not changing, I now wait until after the merge and iterate over the surfaces.

for name, body in block_volumes.items():
    for s in body.surfaces():
        cubit.cmd('block %d add surface %d' %(body.id(), s.id()))
    cubit.cmd('block %d name "%s"' % (body.id(), name))