Skip to content
Snippets Groups Projects

Handle unused boundary nodes correctly

Merged Ansgar Burchardt requested to merge bugfix/issue-55-uggrid-boundary-segments into master
1 file
+ 6
2
Compare changes
  • Side-by-side
  • Inline
  • f8570134
    For "unused" boundary nodes the special value `-1` is used.  Mapping
    this through `isBoundaryNode[-1]` would result in an out-of-bounds
    memory access and invalid values in the `vertices_c_style` array.
    
    Closes: #55
@@ -322,8 +322,12 @@ createGrid()
// Copy the vertices into a C-style array
// We copy four vertices here even if the segment is a triangle -- it doesn't matter
int vertices_c_style[dimworld*2-2];
for (int j=0; j<dimworld*2-2; j++)
vertices_c_style[j] = isBoundaryNode[boundarySegmentVertices_[i][j]];
for (int j=0; j<dimworld*2-2; j++) {
// For parameterized boundary segments, -1 is used as a sentinel value
// for unused vertices and must be preserved.
const auto idx = boundarySegmentVertices_[i][j];
vertices_c_style[j] = idx == -1 ? -1 : isBoundaryNode[idx];
}
if (grid_->boundarySegments_[i]) {
Loading