# Dist2Walls: wall distance computation

## Version: 2.5 (20/09/2017)

## Author: Onera

### Preamble

Dist2Walls gathers efficient algorithms for computing the distance fields
for arrays (as defined in Converter documentation) or
for CGNS/python tree (pyTrees).

This module is part of Cassiopee, a free open-source
pre- and post-processor for CFD simulations.

When using the Converter array interface,
a (or b) denotes an array, and A (or B) denotes a list of arrays.
Then, Dist2Walls module must be imported:
import Dist2Walls as DTW

When using the pyTree interface, import the module:
import Dist2Walls.PyTree as DTW

In that case, a is a zone node and A is a list of zone nodes or a pyTree.

### Module functions

**DTW.distance2Walls **: computes the distance field from a set of bodies.

compute the distance field located at nodes or centers of zone a (or zones in A), provided a list
of surfaces defining the bodies to which the distance is computed.

Two algorithms are available:

- type='ortho' means a distance computed by an orthogonal projection to the surface faces defined by bodies.

- type='mininterf' returns the minimum distance of the point to the vertices of bodies.

If loc='nodes', returns a distance computed at nodes of a (A), else if loc='centers, distance is computed at cell centers
of a (A).

Parameter 'signed'=1 enables to compute a signed distance (negative inside bodies).

When using signed distances, each body in bodies list must be a closed and watertight surface.

In array version, cellnbodies provides the 'cellN' field for any vertex in bodies. Default value is 1.

The algorithm 'ortho' does not take into account a body face if cellN=0 for all the vertices of that face.

The algorithm 'mininterf' does not compute the distance to a vertex of cellN=0.

b = DTW.distance2Walls(a, bodies, cellnbodies=[], type='ortho', loc='centers', signed=0, dim=3) *.or.*
B = DTW.distance2Walls(A, bodies, cellnbodies=[], type='ortho', loc='centers', signed=0, dim=3)

In the pyTree version, 'cellN' variable must be stored in bodies directly.

If loc='nodes', the distance field is stored as a 'TurbulentDistance' field located at nodes, and
if loc='centers', it is stored in nodes located at centers:

b = DTW.distance2Walls(a, bodies, type='ortho', loc='centers', signed=0, dim=3) *.or.*
B = DTW.distance2Walls(A, bodies, type='ortho', loc='centers', signed=0, dim=3)

*Example of use: * distance to walls (array),
distance to walls (pyTree),
dump TurbulentDistance node to a file (pyTree).

Return to main userguide