The first partial solution for this problem seems to be found in this useful post:
Identifying subdomains from level set function on fenicsx
From what I understand we can use a “conditional” to identfy the subdomains.
The other suggestion of meshing the boundary seems not possible, since we do not know the the analytic solution.
To reduce the error we can do 2 things:
- increase the number of elements
- (recommended in the post) increase order of elements
Therefor we have to rewite the tutorial to account for higher order elements load a certain example and use the conditional to identify the subdomains