# Calculate on variable depth scalar field

**URL:** <https://community.freefem.org/t/calculate-on-variable-depth-scalar-field/1077>\
**Category:** General Discussion\
**Created:** [July 2, 2021, 2:11pm UTC](https://community.freefem.org/t/calculate-on-variable-depth-scalar-field/1077 "2021-07-02T14:11:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antonin\_a](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Antonin\_a](https://community.freefem.org/u/Antonin_a)\
**Post date:** [July 2, 2021, 2:11pm UTC](https://community.freefem.org/t/calculate-on-variable-depth-scalar-field/1077/1 "2021-07-02T14:11:51Z")

</div>

Hello everyone,

In order to solver a simple mildslope equation (in 2D), I’d like to make calculation over a bathymetry (variable depth). I have a grid with the coordinates x, y, z .

My problem is in the mildslope equation, I will have to use a function h(x,y) = z (the bathymetry) over all the domain. But I can’t find a way to define thise function. Do you have any idea ?

What I did tried for now :

I made a mesh Th on Freefem, and obtained Th.x and Th.y. I then made a nearest neighbour (with python) between Th.x,Th.y and x,y,z to make correspond the “z” of my grid to my mesh.  
I thought I could then re-use my new grid on Freefem to solve my problem but did not succeed.

Thanks for reading,

Best,

---

<div class="post-metadata">

**Author:** ![Antonin\_a](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Antonin\_a](https://community.freefem.org/u/Antonin_a)\
**Post date:** [July 14, 2021, 1:28pm UTC](https://community.freefem.org/t/calculate-on-variable-depth-scalar-field/1077/2 "2021-07-14T13:28:46Z")

</div>

Hello again,

As I did not succeed to solve my problem, I come back here.

To make it simplier, let’s say I would like to solve a Helmholtz equation in 2D :

```auto
\Delta f(x,y) = -k^2 f(x,y)

```

where k is a function of z, the depth.

(k is obtained via the dispersion relation, with variable depth).

My problem is that I don’t know how to take this third dimension into account while solving this problem using FreeFem.  
Could any of you help me ?

Thank you,

Regards
