Solving Null Pointer Error in 3DEC FISH

Hi everyone,
I have created a simple function to monitor damage in a UCS test in 3DEC.
The function runs for several numerical steps but after that I get an abrupt error:
“Unable to convert parameter type from Null Pointer to SubcontactThing Pointer.”
This means that the isubc is ‘null’ in the subcontact list. However, it was not in the cycle before because I could see the damage percentage.

Do you know what would be the possible reason and how can I correct it?

block group ‘Cohesion=Rock’
[subc_list = block.subcontact.list(block.subcontact.isgroup(::block.subcontact.list,‘Rock’))]
[num_subcontacts = list.size(subc_list)]
def get_damage
bonded_subcontacts = 0
loop foreach isubc subc_list
current_state = block.subcontact.state(isubc)
if current_state <1
bonded_subcontacts +=1
endif
endloop
damaged_percentage = 100 - 100*(bonded_subcontacts/num_subcontacts)
end
fish history get_damage
fish history damaged_percentage

Thanks

If you are running in large strain, it is possible for subcontacts to disappear. It is also possible for new subcontacts to form. So probably you want to recreate the list each time the function is called. i.e.

def get_damage
  bonded_subcontacts = 0
  subc_list = block.subcontact.list(block.subcontact.isgroup(::block.subcontact.list,‘Rock’))
  loop foreach isubc subc_list
  ...
1 Like

Many thanks, that is helpful.