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)
This commit is contained in:
Mark Olesen 2022-04-21 09:45:28 +02:00
parent 8e6f2ca5de
commit 442c309dca
12 changed files with 38 additions and 29 deletions

View File

@ -32,10 +32,16 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef CGAL3DKernel_H #ifndef Foam_CGAL3DKernel_H
#define 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 #ifdef CGAL_INEXACT
@ -51,7 +57,6 @@ Description
#endif #endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif

View File

@ -90,6 +90,12 @@ Description
#ifndef NO_CGAL #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 <CGAL/AABB_tree.h> #include <CGAL/AABB_tree.h>
#include <CGAL/AABB_traits.h> #include <CGAL/AABB_traits.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h> #include <CGAL/AABB_face_graph_triangle_primitive.h>

View File

@ -222,7 +222,7 @@ void Foam::enrichedPatch::calcCutFaces() const
// Get the vector along the edge and the right vector // Get the vector along the edge and the right vector
vector ahead = curPoint - lp[prevPointLabel]; vector ahead = curPoint - lp[prevPointLabel];
ahead -= normal*(normal & ahead); ahead.removeCollinear(normal);
ahead.normalise(); ahead.normalise();
const vector right = normalised(normal ^ ahead); const vector right = normalised(normal ^ ahead);
@ -248,7 +248,7 @@ void Foam::enrichedPatch::calcCutFaces() const
vector newDir = lp[nextPoints[nextI]] - curPoint; vector newDir = lp[nextPoints[nextI]] - curPoint;
// Pout<< " newDir: " << newDir // Pout<< " newDir: " << newDir
// << " mag: " << mag(newDir) << flush; // << " mag: " << mag(newDir) << flush;
newDir -= normal*(normal & newDir); newDir.removeCollinear(normal);
scalar magNewDir = mag(newDir); scalar magNewDir = mag(newDir);
// Pout<< " corrected: " << newDir // Pout<< " corrected: " << newDir
// << " mag: " << mag(newDir) << flush; // << " mag: " << mag(newDir) << flush;

View File

@ -382,7 +382,7 @@ void Foam::edgeInterpolation::makeDeltaCoeffs() const
faceCentres[neighbour[edgeI]] faceCentres[neighbour[edgeI]]
- faceCentres[owner[edgeI]]; - faceCentres[owner[edgeI]];
unitDelta -= edgeNormal*(edgeNormal & unitDelta); unitDelta.removeCollinear(edgeNormal);
unitDelta.normalise(); unitDelta.normalise();
@ -482,7 +482,7 @@ void Foam::edgeInterpolation::makeCorrectionVectors() const
faceCentres[neighbour[edgeI]] faceCentres[neighbour[edgeI]]
- faceCentres[owner[edgeI]]; - faceCentres[owner[edgeI]];
unitDelta -= edgeNormal*(edgeNormal & unitDelta); unitDelta.removeCollinear(edgeNormal);
unitDelta.normalise(); unitDelta.normalise();
// Edge normal - area tangent // Edge normal - area tangent

View File

@ -44,15 +44,15 @@ inline bool directionalWallPointData<Type>::update
) )
{ {
vector d(pt - w2.origin()); vector d(pt - w2.origin());
// Knock out component in direction of n d.removeCollinear(n);
d -= n*(d&n);
scalar dist2 = magSqr(d); scalar dist2 = magSqr(d);
if (this->valid(n)) if (this->valid(n))
{ {
vector d(pt - this->origin()); vector d(pt - this->origin());
// Knock out component in direction of n d.removeCollinear(n);
d -= n*(d&n);
scalar currentDistSqr(magSqr(d)); scalar currentDistSqr(magSqr(d));
scalar diff = currentDistSqr - dist2; scalar diff = currentDistSqr - dist2;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd. Copyright (C) 2017-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -88,8 +88,7 @@ Foam::tensor Foam::coordinateRotations::axes::rotation
ax2 = findOrthogonal(axis1); ax2 = findOrthogonal(axis1);
} }
// Remove colinear component ax2.removeCollinear(ax1);
ax2 -= ((ax1 & ax2) * ax1);
magAxis2 = mag(ax2); magAxis2 = mag(ax2);
@ -102,8 +101,7 @@ Foam::tensor Foam::coordinateRotations::axes::rotation
ax2 = findOrthogonal(axis1); ax2 = findOrthogonal(axis1);
// Remove colinear component ax2.removeCollinear(ax1);
ax2 -= ((ax1 & ax2) * ax1);
magAxis2 = mag(ax2); magAxis2 = mag(ax2);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd. Copyright (C) 2018-2022 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -235,8 +235,7 @@ Foam::tensor Foam::coordSystem::cylindrical::R(const point& global) const
vector ax2(global - origin_); vector ax2(global - origin_);
// Remove colinear component ax2.removeCollinear(ax1);
ax2 -= ((ax1 & ax2) * ax1);
const scalar magAxis2(mag(ax2)); const scalar magAxis2(mag(ax2));

View File

@ -118,9 +118,9 @@ Foam::edgeFaceCirculator::edgeFaceCirculator
) )
: :
meshPtr_(&mesh), meshPtr_(&mesh),
faceLabel_(faceLabel),
ownerSide_(ownerSide), ownerSide_(ownerSide),
isBoundaryEdge_(isBoundaryEdge), isBoundaryEdge_(isBoundaryEdge),
faceLabel_(faceLabel),
index_(index), index_(index),
startFaceLabel_(faceLabel_) startFaceLabel_(faceLabel_)
{} {}

View File

@ -385,7 +385,7 @@ void Foam::searchableExtrudedCircle::findParametricNearest
vector radialStart; vector radialStart;
{ {
radialStart = start-curvePoints[0]; radialStart = start-curvePoints[0];
radialStart -= (radialStart&axialVecs[0])*axialVecs[0]; radialStart.removeCollinear(axialVecs[0]);
radialStart.normalise(); radialStart.normalise();
qStart = quaternion(radialStart, 0.0); qStart = quaternion(radialStart, 0.0);
@ -396,11 +396,11 @@ void Foam::searchableExtrudedCircle::findParametricNearest
quaternion qProjectedEnd; quaternion qProjectedEnd;
{ {
vector radialEnd(end-curvePoints.last()); vector radialEnd(end-curvePoints.last());
radialEnd -= (radialEnd&axialVecs.last())*axialVecs.last(); radialEnd.removeCollinear(axialVecs.last());
radialEnd.normalise(); radialEnd.normalise();
vector projectedEnd = radialEnd; vector projectedEnd = radialEnd;
projectedEnd -= (projectedEnd&axialVecs[0])*axialVecs[0]; projectedEnd.removeCollinear(axialVecs[0]);
projectedEnd.normalise(); projectedEnd.normalise();
qProjectedEnd = quaternion(projectedEnd, 0.0); qProjectedEnd = quaternion(projectedEnd, 0.0);
@ -413,7 +413,7 @@ void Foam::searchableExtrudedCircle::findParametricNearest
quaternion q(slerp(qStart, qProjectedEnd, lambdas[i])); quaternion q(slerp(qStart, qProjectedEnd, lambdas[i]));
vector radialDir(q.transform(radialStart)); vector radialDir(q.transform(radialStart));
radialDir -= (radialDir & axialVecs[i]) * axialVecs.last(); radialDir.removeCollinear(axialVecs[i]);
radialDir.normalise(); radialDir.normalise();
info[i] = pointIndexHit(true, curvePoints[i]+radius_*radialDir, 0); info[i] = pointIndexHit(true, curvePoints[i]+radius_*radialDir, 0);
@ -462,7 +462,7 @@ void Foam::searchableExtrudedCircle::getNormal
// Subtract axial direction // Subtract axial direction
const vector axialVec = edges[curvePt.index()].unitVec(points); const vector axialVec = edges[curvePt.index()].unitVec(points);
normal[i] -= (normal[i] & axialVec) * axialVec; normal[i].removeCollinear(axialVec);
normal[i].normalise(); normal[i].normalise();
} }
} }

View File

@ -558,7 +558,7 @@ void Foam::searchableSurfacesQueries::findNearest
// Calculate vector to move onto intersection line // Calculate vector to move onto intersection line
vector d(r.refPoint()-near[i]); vector d(r.refPoint()-near[i]);
d -= (d&n)*n; d.removeCollinear(n);
// Trim the max distance // Trim the max distance
scalar magD = mag(d); scalar magD = mag(d);

View File

@ -326,7 +326,7 @@ bool Foam::edgeIntersections::rotatePerturb
scalar magN = mag(n) + VSMALL; scalar magN = mag(n) + VSMALL;
n /= magN; n /= magN;
rndVec -= n*(n & rndVec); rndVec.removeCollinear(n);
rndVec.normalise(); rndVec.normalise();
// Scale to be moved by tolerance. // Scale to be moved by tolerance.

View File

@ -101,7 +101,8 @@ Foam::pointToPointPlanarInterpolation::calcCoordinateSystem
{ {
const point& p2 = points[i]; const point& p2 = points[i];
vector e2(p2 - p0); vector e2(p2 - p0);
e2 -= (e2&e1)*e1; e2.removeCollinear(e1);
scalar magE2 = mag(e2); scalar magE2 = mag(e2);
if (magE2 > maxDist) if (magE2 > maxDist)