How to get stress field of a subdomain created by MeshView?

You should try to reduce your problem to the smallest possible problem, with as few variables as possible, that reproduces your error. See for instance: How to define a Function in a submesh based on function values present in an adjoining submesh? - #4 by dokken which reduces the original example: How to define a Function in a submesh based on function values present in an adjoining submesh? - #3 by Sabarish_Gopi from over 100 lines of code to 48.

The key to get help is to identify what particular function causes the issue, remove all code that should be called after this error, and then remove one and one variable, and check that your code still produces the error.