From 442c309dca7dfcd9793d619443e90efffd51abd7 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 21 Apr 2022 09:45:28 +0200 Subject: [PATCH] BUG: cut/paste error in searchableExtrudedCircle - use vector::removeCollinear a few places COMP: incorrect initialization order in edgeFaceCirculator COMP: Silence boost bind deprecation warnings (before CGAL-5.2.1) --- .../surface/surfaceBooleanFeatures/CGAL3DKernel.H | 13 +++++++++---- .../surfaceBooleanFeatures/surfaceBooleanFeatures.C | 6 ++++++ .../enrichedPatch/enrichedPatchCutFaces.C | 4 ++-- .../edgeInterpolation/edgeInterpolation.C | 4 ++-- .../directionalWallPointDataI.H | 8 ++++---- src/meshTools/coordinate/rotation/axesRotation.C | 8 +++----- src/meshTools/coordinate/systems/cylindricalCS.C | 5 ++--- .../edgeFaceCirculator/edgeFaceCirculatorI.H | 2 +- .../searchableExtrudedCircle.C | 10 +++++----- .../searchableSurfacesQueries.C | 2 +- .../surfaceIntersection/edgeIntersections.C | 2 +- .../pointToPointPlanarInterpolation.C | 3 ++- 12 files changed, 38 insertions(+), 29 deletions(-) diff --git a/applications/utilities/surface/surfaceBooleanFeatures/CGAL3DKernel.H b/applications/utilities/surface/surfaceBooleanFeatures/CGAL3DKernel.H index b3aa5dc32a..635f52e7d3 100644 --- a/applications/utilities/surface/surfaceBooleanFeatures/CGAL3DKernel.H +++ b/applications/utilities/surface/surfaceBooleanFeatures/CGAL3DKernel.H @@ -32,10 +32,16 @@ Description \*---------------------------------------------------------------------------*/ -#ifndef CGAL3DKernel_H -#define CGAL3DKernel_H +#ifndef Foam_CGAL3DKernel_H +#define Foam_CGAL3DKernel_H -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Silence boost bind deprecation warnings (before CGAL-5.2.1) +#include "CGAL/version.h" +#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000) +#define BOOST_BIND_GLOBAL_PLACEHOLDERS +#endif + +// ------------------------------------------------------------------------- // #ifdef CGAL_INEXACT @@ -51,7 +57,6 @@ Description #endif - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C index 174ae4367a..4dd6511451 100644 --- a/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C +++ b/applications/utilities/surface/surfaceBooleanFeatures/surfaceBooleanFeatures.C @@ -90,6 +90,12 @@ Description #ifndef NO_CGAL +// Silence boost bind deprecation warnings (before CGAL-5.2.1) +#include "CGAL/version.h" +#if defined(CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1050211000) +#define BOOST_BIND_GLOBAL_PLACEHOLDERS +#endif + #include #include #include diff --git a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C index 506c17297b..a993977582 100644 --- a/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C +++ b/src/dynamicMesh/slidingInterface/enrichedPatch/enrichedPatchCutFaces.C @@ -222,7 +222,7 @@ void Foam::enrichedPatch::calcCutFaces() const // Get the vector along the edge and the right vector vector ahead = curPoint - lp[prevPointLabel]; - ahead -= normal*(normal & ahead); + ahead.removeCollinear(normal); ahead.normalise(); const vector right = normalised(normal ^ ahead); @@ -248,7 +248,7 @@ void Foam::enrichedPatch::calcCutFaces() const vector newDir = lp[nextPoints[nextI]] - curPoint; // Pout<< " newDir: " << newDir // << " mag: " << mag(newDir) << flush; - newDir -= normal*(normal & newDir); + newDir.removeCollinear(normal); scalar magNewDir = mag(newDir); // Pout<< " corrected: " << newDir // << " mag: " << mag(newDir) << flush; diff --git a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C index 9e14d5cbb6..0ed885bab5 100644 --- a/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C +++ b/src/finiteArea/interpolation/edgeInterpolation/edgeInterpolation.C @@ -382,7 +382,7 @@ void Foam::edgeInterpolation::makeDeltaCoeffs() const faceCentres[neighbour[edgeI]] - faceCentres[owner[edgeI]]; - unitDelta -= edgeNormal*(edgeNormal & unitDelta); + unitDelta.removeCollinear(edgeNormal); unitDelta.normalise(); @@ -482,7 +482,7 @@ void Foam::edgeInterpolation::makeCorrectionVectors() const faceCentres[neighbour[edgeI]] - faceCentres[owner[edgeI]]; - unitDelta -= edgeNormal*(edgeNormal & unitDelta); + unitDelta.removeCollinear(edgeNormal); unitDelta.normalise(); // Edge normal - area tangent diff --git a/src/meshTools/cellDist/directionalWallPoint/directionalWallPointDataI.H b/src/meshTools/cellDist/directionalWallPoint/directionalWallPointDataI.H index 8b98db3140..c99fba068e 100644 --- a/src/meshTools/cellDist/directionalWallPoint/directionalWallPointDataI.H +++ b/src/meshTools/cellDist/directionalWallPoint/directionalWallPointDataI.H @@ -44,15 +44,15 @@ inline bool directionalWallPointData::update ) { vector d(pt - w2.origin()); - // Knock out component in direction of n - d -= n*(d&n); + d.removeCollinear(n); + scalar dist2 = magSqr(d); if (this->valid(n)) { vector d(pt - this->origin()); - // Knock out component in direction of n - d -= n*(d&n); + d.removeCollinear(n); + scalar currentDistSqr(magSqr(d)); scalar diff = currentDistSqr - dist2; diff --git a/src/meshTools/coordinate/rotation/axesRotation.C b/src/meshTools/coordinate/rotation/axesRotation.C index a2a25ce534..459b0d7b5f 100644 --- a/src/meshTools/coordinate/rotation/axesRotation.C +++ b/src/meshTools/coordinate/rotation/axesRotation.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2021 OpenCFD Ltd. + Copyright (C) 2017-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -88,8 +88,7 @@ Foam::tensor Foam::coordinateRotations::axes::rotation ax2 = findOrthogonal(axis1); } - // Remove colinear component - ax2 -= ((ax1 & ax2) * ax1); + ax2.removeCollinear(ax1); magAxis2 = mag(ax2); @@ -102,8 +101,7 @@ Foam::tensor Foam::coordinateRotations::axes::rotation ax2 = findOrthogonal(axis1); - // Remove colinear component - ax2 -= ((ax1 & ax2) * ax1); + ax2.removeCollinear(ax1); magAxis2 = mag(ax2); diff --git a/src/meshTools/coordinate/systems/cylindricalCS.C b/src/meshTools/coordinate/systems/cylindricalCS.C index 6b75f35a90..11d9584282 100644 --- a/src/meshTools/coordinate/systems/cylindricalCS.C +++ b/src/meshTools/coordinate/systems/cylindricalCS.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -235,8 +235,7 @@ Foam::tensor Foam::coordSystem::cylindrical::R(const point& global) const vector ax2(global - origin_); - // Remove colinear component - ax2 -= ((ax1 & ax2) * ax1); + ax2.removeCollinear(ax1); const scalar magAxis2(mag(ax2)); diff --git a/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H b/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H index e85705d5e5..67ffcafc20 100644 --- a/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H +++ b/src/meshTools/edgeFaceCirculator/edgeFaceCirculatorI.H @@ -118,9 +118,9 @@ Foam::edgeFaceCirculator::edgeFaceCirculator ) : meshPtr_(&mesh), - faceLabel_(faceLabel), ownerSide_(ownerSide), isBoundaryEdge_(isBoundaryEdge), + faceLabel_(faceLabel), index_(index), startFaceLabel_(faceLabel_) {} diff --git a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C index dbe6598fcc..a55d274d42 100644 --- a/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C +++ b/src/meshTools/searchableSurfaces/searchableExtrudedCircle/searchableExtrudedCircle.C @@ -385,7 +385,7 @@ void Foam::searchableExtrudedCircle::findParametricNearest vector radialStart; { radialStart = start-curvePoints[0]; - radialStart -= (radialStart&axialVecs[0])*axialVecs[0]; + radialStart.removeCollinear(axialVecs[0]); radialStart.normalise(); qStart = quaternion(radialStart, 0.0); @@ -396,11 +396,11 @@ void Foam::searchableExtrudedCircle::findParametricNearest quaternion qProjectedEnd; { vector radialEnd(end-curvePoints.last()); - radialEnd -= (radialEnd&axialVecs.last())*axialVecs.last(); + radialEnd.removeCollinear(axialVecs.last()); radialEnd.normalise(); vector projectedEnd = radialEnd; - projectedEnd -= (projectedEnd&axialVecs[0])*axialVecs[0]; + projectedEnd.removeCollinear(axialVecs[0]); projectedEnd.normalise(); qProjectedEnd = quaternion(projectedEnd, 0.0); @@ -413,7 +413,7 @@ void Foam::searchableExtrudedCircle::findParametricNearest quaternion q(slerp(qStart, qProjectedEnd, lambdas[i])); vector radialDir(q.transform(radialStart)); - radialDir -= (radialDir & axialVecs[i]) * axialVecs.last(); + radialDir.removeCollinear(axialVecs[i]); radialDir.normalise(); info[i] = pointIndexHit(true, curvePoints[i]+radius_*radialDir, 0); @@ -462,7 +462,7 @@ void Foam::searchableExtrudedCircle::getNormal // Subtract axial direction const vector axialVec = edges[curvePt.index()].unitVec(points); - normal[i] -= (normal[i] & axialVec) * axialVec; + normal[i].removeCollinear(axialVec); normal[i].normalise(); } } diff --git a/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.C b/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.C index 09953f9491..4b94a017f7 100644 --- a/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.C +++ b/src/meshTools/searchableSurfaces/searchableSurfacesQueries/searchableSurfacesQueries.C @@ -558,7 +558,7 @@ void Foam::searchableSurfacesQueries::findNearest // Calculate vector to move onto intersection line vector d(r.refPoint()-near[i]); - d -= (d&n)*n; + d.removeCollinear(n); // Trim the max distance scalar magD = mag(d); diff --git a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C index 424bb4a2d6..e73c68ba55 100644 --- a/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C +++ b/src/meshTools/triSurface/booleanOps/surfaceIntersection/edgeIntersections.C @@ -326,7 +326,7 @@ bool Foam::edgeIntersections::rotatePerturb scalar magN = mag(n) + VSMALL; n /= magN; - rndVec -= n*(n & rndVec); + rndVec.removeCollinear(n); rndVec.normalise(); // Scale to be moved by tolerance. diff --git a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C index 0dd064bbb3..7b989fa0cc 100644 --- a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C +++ b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C @@ -101,7 +101,8 @@ Foam::pointToPointPlanarInterpolation::calcCoordinateSystem { const point& p2 = points[i]; vector e2(p2 - p0); - e2 -= (e2&e1)*e1; + e2.removeCollinear(e1); + scalar magE2 = mag(e2); if (magE2 > maxDist)