Simulating using sensors

Dear FF++ users,

I am solving the 2D wave equation on a square, I am interested to save the values of the solution at each time of the simulation but only in few places on the mesh which simulates sensors locations, there I should save the data of wave equation.

to do this
I first solved the the wave equation in each time of the simulation and at all points of the mesh and saved the solution (at each time and at all points of the mesh) as a finite element function.

Then I define sensors points which are few points of the mesh, and afterwards I defined a radius r=h/2 (h is a step size in space) and I define sensor location as a circle with this radius. i.e.,
suppose (x1,y1) is the sensor point (which is again a point of the mesh) and r=h/2 is the radius. then I define kappa1 as a finite element function as follows
kappa1=(x-x1)^2+(y-y1)^2<r^2;

thus u calculated at the sensor location is defined as
u_at sensor= u*kappa1;

I would like to ask please, is there any other way to simulate and save the data only in few points of the mesh, which will simulate data in sensors?

Thanks in advance,

Mordechai.

You could truncate the mesh around your probes, e.g.

mesh Th = square(100, 100);

fespace Vh(Th, P1);
Vh u = sin(x)*cos(y);

real xc = 0.5, yc = 0.5, r = 0.1;
func kappa = (x-xc)^2+(y-yc)^2 < r^2;

mesh ThProbe = trunc(Th, kappa);
fespace VhProbe(ThProbe, P1);
VhProbe uProbe = u;

plot(u, cmm = "u", fill = true, wait = true);
plot(uProbe, cmm= "truncated u", fill = true, bb= [[0,0], [1,1]], wait = true);

Thank you so much Henkel!

the sample way to get the value at some point

real[int] xx=[1,2,1,2];
real[int] yy=[1,1,2,2];
real [int∏ probe(4);

for(int i=0; i<xx.n;++i)
{
probe[ï]= u(xx[i],yy[i]);
}

Thank you very much Professor Hecht.