diff --git a/include/viennals/lsCalculateVisibilities.hpp b/include/viennals/lsCalculateVisibilities.hpp index 8d6bfe09..a1d685b3 100644 --- a/include/viennals/lsCalculateVisibilities.hpp +++ b/include/viennals/lsCalculateVisibilities.hpp @@ -88,8 +88,12 @@ template class CalculateVisibilities { } } - levelSet->getPointData().insertNextScalarData(visibilities, - visibilitiesLabel); + auto &pointData = levelSet->getPointData(); + // delete if already exists + if (int i = pointData.getScalarDataIndex(visibilitiesLabel); i != -1) { + pointData.eraseScalarData(i); + } + pointData.insertNextScalarData(visibilities, visibilitiesLabel); assert(id == numDefinedPoints); }