# Distance function (Topology Optimization)

**URL:** <https://community.freefem.org/t/distance-function-topology-optimization/4184>\
**Category:** General Discussion\
**Created:** [January 12, 2026, 3:22pm UTC](https://community.freefem.org/t/distance-function-topology-optimization/4184 "2026-01-12T15:22:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![HMasson](https://avatars.discourse-cdn.com/v4/letter/h/b9bd4f/32.png) [@HMasson](https://community.freefem.org/u/HMasson)\
**Post date:** [January 12, 2026, 3:22pm UTC](https://community.freefem.org/t/distance-function-topology-optimization/4184/1 "2026-01-12T15:22:30Z")

</div>

Hello,

I’m using the **distance** function (from : load “distance”) to compute the distance field to the contour of a shape defined via a surface.

Now my shape is defined via a P0 density field.

I would like to compute the sensitivity of the distance field relative to my density field. What reference or algorithm is used to compute the distance field ?

Thank you in advance for your answer.

HMasson
