Skip to content

Second order issue with KNOWN and TRIAL values #2

@wd15

Description

@wd15

This seems to be an issue with both LSMLIB and Scikit-fmm. The following test fails with LSMLIB, but passes (by luck) in Scikit-fmm.

>>> from skfmm import distance
>>> phi = distance([[-1, -1, -1, -1],
                 [ 1,  1, -1, -1],
                 [ 1,  1, -1, -1],
                 [ 1,  1, -1, -1]], order=2)
>>> print distance(phi, order=2)
[[-0.5        -0.58578644 -1.08578644 -1.85136395]
 [ 0.5         0.29289322 -0.58578644 -1.54389939]
 [ 1.30473785  0.5        -0.5        -1.5       ]
 [ 1.49547948  0.5        -0.5        -1.5       ]]

One gets a different answer with LSMLIB

 >>> from pylsmlib import distance
 >>> phi = distance([[-1, -1, -1, -1],
 ...           [ 1,  1, -1, -1],
 ...           [ 1,  1, -1, -1],
 ...           [ 1,  1, -1, -1]], order=2)
 >>> print distance(phi, order=2)
[[-0.5        -0.58578644 -1.08578644 -1.85170563]
 [ 0.5         0.29289322 -0.58578644 -1.54468054]
 [ 1.30473785  0.5        -0.5        -1.5       ]
 [ 1.49547948  0.5        -0.5        -1.5       ]]

The issue is that newly created KNOWN values only update their closest neighbour's values. For second order schemes newly created KNOWN values need to update all values in the stencil. That is cells that are two steps away with a KNOWN value between.

Toy Problem

Take three cells lieing in a larger 2D array of cells. Say that 0.5 is the smallest value in the TRIAL cells

| TRIAL 0.5 | TRIAL 0.5 | TRIAL 0.51 |

One of the two values becomes updated to KNOWN, but that now information happens to lower the value of the left side cell.

| TRIAL 0.405 | KNOWN 0.5 | TRIAL 0.505 |

The left cell then becomes KNOWN

| KNOWN 0.405 | KNOWN 0.5 | TRIAL 0.505 |

TRIAL 0.51 is not reupdated when the left cell becomes KNOWN although the value is required for second order accuracy.

| KNOWN 0.405 | KNOWN 0.5 | KNOWN 0.505|

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions