How to use notaregion (identify if a point is within the domain)

Hi everyone,

I’m trying to identify if a point is in a working domain or not, so I write the following simple code:

mesh Th;
Th = square(10,10,[0.+1.*x,0.+1.*y],region=1);
cout << "point (0.5,0.5) has a region number: " << Th(0.5,0.5).region << endl;
cout << "point (-100,-100) has a region number: " << Th(-100,-100).region << endl;

However, both of Th(0.5,0.5).region and Th(-100,-100).region return me a constant 1. I assume Th(-100,-100).region in the last line will give me a integer constant notaregion, which is a large negative value. So what is wrong with my interpretation above? Thanks!

You can do this

mesh Th;
Th = square(10,10,[0.+1.*x,0.+1.*y]);
fespace V0h(Th,P0);
V0h Inside=1;
real xx=0.5; real yy=0.5;
if(!Inside(xx,yy)) cout << “outside” << endl;
else cout << “inside” << endl;

1 Like

This is a smart solution! I tried and it worked well for my problem. Thank you @julienG !