Skip to content

Commit 2396840

Browse files
authored
Weight generation for integrated bilinear generalized barycentric schemes for meshes with holes (#114)
* Added conditional in generalized barycentric coordinates weight function. * Integrated bilinear and generalized barycentric schemes for meshes with holes. * The integrated schemes intbilin and intbilingb now normalize rows by default when the source mesh has holes.
1 parent 03192f6 commit 2396840

File tree

3 files changed

+1123
-508
lines changed

3 files changed

+1123
-508
lines changed

src/FiniteVolumeTools.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,44 @@ void GeneralizedBarycentricCoordinates(
16731673

16741674
}
16751675

1676+
//Use nearest neighbor weighting if there are too many edges. This is necessary to avoid numerical instability.
1677+
1678+
if( iEdges > 30 ){
1679+
1680+
int iNodeMin = 0;
1681+
1682+
Node nodeZero = nodesFaceI[0];
1683+
1684+
Node nodeDiffZeroQ = nodeZero - nodeQ;
1685+
1686+
double dMinDist = nodeDiffZeroQ.Magnitude();
1687+
1688+
for (int i = 0; i < iEdges; i++){
1689+
1690+
Node nodeI = nodesFaceI[i];
1691+
1692+
Node nodeDiff = nodeI - nodeQ;
1693+
1694+
double dMagNodeDiff = nodeDiff.Magnitude();
1695+
1696+
if ( dMagNodeDiff < dMinDist){
1697+
1698+
dMinDist = dMagNodeDiff;
1699+
1700+
iNodeMin = i;
1701+
1702+
}
1703+
1704+
}
1705+
1706+
std::fill(vecWeights.begin(), vecWeights.end(), 0);
1707+
1708+
vecWeights[iNodeMin] = 1;
1709+
1710+
return;
1711+
1712+
}
1713+
16761714

16771715
//Subtriangles with the sample point as a vertex (q,m,m+1) where q is the sample point
16781716
std::vector<double> vecTriangleSubAreas(iEdges);

0 commit comments

Comments
 (0)