# Simulating using sensors

**URL:** <https://community.freefem.org/t/simulating-using-sensors/688>\
**Category:** General Discussion\
**Created:** [December 14, 2020, 2:17am UTC](https://community.freefem.org/t/simulating-using-sensors/688 "2020-12-14T02:17:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mordechaiy](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@mordechaiy](https://community.freefem.org/u/mordechaiy)\
**Post date:** [December 14, 2020, 2:17am UTC](https://community.freefem.org/t/simulating-using-sensors/688/1 "2020-12-14T02:17:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![henkel](https://avatars.discourse-cdn.com/v4/letter/h/b77776/32.png) [@henkel](https://community.freefem.org/u/henkel)\
**Post date:** [December 14, 2020, 11:06am UTC](https://community.freefem.org/t/simulating-using-sensors/688/2 "2020-12-14T11:06:47Z")

</div>

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);
```

---

<div class="post-metadata">

**Author:** ![mordechaiy](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@mordechaiy](https://community.freefem.org/u/mordechaiy)\
**Post date:** [December 14, 2020, 2:05pm UTC](https://community.freefem.org/t/simulating-using-sensors/688/3 "2020-12-14T14:05:07Z")

</div>

Thank you so much Henkel!

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [December 14, 2020, 8:01pm UTC](https://community.freefem.org/t/simulating-using-sensors/688/4 "2020-12-14T20:01:25Z")

</div>

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]);  
}

---

<div class="post-metadata">

**Author:** ![mordechaiy](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@mordechaiy](https://community.freefem.org/u/mordechaiy)\
**Post date:** [December 22, 2020, 10:39pm UTC](https://community.freefem.org/t/simulating-using-sensors/688/5 "2020-12-22T22:39:48Z")

</div>

Thank you very much Professor Hecht.

---

<div class="post-metadata">

**Author:** ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)\
**Post date:** [January 11, 2021, 9:14pm UTC](https://community.freefem.org/t/simulating-using-sensors/688/6 "2021-01-11T21:14:29Z")

</div>

Closed on January 11, 2021, 9:14pm UTC


