mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: vector mag(), magSqr() methods - complementary to dist(), distSqr()
ENH: use direct access to pointHit as point(), use dist(), distSqr() - if the pointHit has already been checked for hit(), can/should simply use point() noexcept access subsequently to avoid redundant checks. Using vector distSqr() methods provides a minor optimization (no itermediate temporary), but can also make for clearer code. ENH: copy construct pointIndexHit with different index - symmetric with constructing from a pointHit with an index STYLE: prefer pointHit point() instead of rawPoint()
This commit is contained in:
committed by
Andrew Heather
parent
5ec435aca3
commit
27c2cdc040
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -145,21 +145,16 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
|
||||
// the location written to the header.
|
||||
|
||||
//const point& facePt = mesh.faceCentres()[faceI];
|
||||
const point& facePt = info.hitPoint();
|
||||
const point& facePt = info.point();
|
||||
|
||||
mappedPatchBase::nearInfo sampleInfo;
|
||||
|
||||
sampleInfo.first() = pointIndexHit
|
||||
(
|
||||
true,
|
||||
facePt,
|
||||
facei
|
||||
);
|
||||
sampleInfo.first() = pointIndexHit(true, facePt, facei);
|
||||
|
||||
sampleInfo.second().first() = magSqr(facePt - sample);
|
||||
sampleInfo.second().first() = facePt.distSqr(sample);
|
||||
sampleInfo.second().second() = Pstream::myProcNo();
|
||||
|
||||
nearest[probei]= sampleInfo;
|
||||
nearest[probei] = sampleInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -174,7 +169,7 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
|
||||
forAll(nearest, samplei)
|
||||
{
|
||||
oldPoints_[samplei] = operator[](samplei);
|
||||
operator[](samplei) = nearest[samplei].first().rawPoint();
|
||||
operator[](samplei) = nearest[samplei].first().point();
|
||||
}
|
||||
|
||||
if (debug)
|
||||
@ -188,7 +183,7 @@ void Foam::patchProbes::findElements(const fvMesh& mesh)
|
||||
Info<< " " << samplei << " coord:"<< operator[](samplei)
|
||||
<< " found on processor:" << proci
|
||||
<< " in local face:" << locali
|
||||
<< " with location:" << nearest[samplei].first().rawPoint()
|
||||
<< " with location:" << nearest[samplei].first().point()
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -255,7 +255,7 @@ void Foam::faceOnlySet::calcSamples
|
||||
& normOffset;
|
||||
|
||||
// Pout<< "Finding next boundary : "
|
||||
// << "bPoint:" << bHits[bHitI].hitPoint()
|
||||
// << "bPoint:" << bHits[bHitI].point()
|
||||
// << " tracking:" << singleParticle.position()
|
||||
// << " dist:" << dist
|
||||
// << endl;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -144,11 +144,8 @@ void Foam::patchCloudSet::calcSamples
|
||||
// Set nearest to mesh face label
|
||||
nearInfo.setIndex(patchFaces[nearInfo.index()]);
|
||||
|
||||
nearest[sampleI].second().first() = magSqr
|
||||
(
|
||||
nearInfo.hitPoint()
|
||||
- sample
|
||||
);
|
||||
nearest[sampleI].second().first() =
|
||||
nearInfo.point().distSqr(sample);
|
||||
nearest[sampleI].second().second() = Pstream::myProcNo();
|
||||
}
|
||||
}
|
||||
@ -177,7 +174,7 @@ void Foam::patchCloudSet::calcSamples
|
||||
{
|
||||
meshTools::writeOBJ(str, sampleCoords_[i]);
|
||||
++vertI;
|
||||
meshTools::writeOBJ(str, nearest[i].first().hitPoint());
|
||||
meshTools::writeOBJ(str, nearest[i].first().point());
|
||||
++vertI;
|
||||
str << "l " << vertI-1 << ' ' << vertI << nl;
|
||||
}
|
||||
@ -196,7 +193,7 @@ void Foam::patchCloudSet::calcSamples
|
||||
{
|
||||
label facei = nearInfo.index();
|
||||
|
||||
samplingPts.append(nearInfo.hitPoint());
|
||||
samplingPts.append(nearInfo.point());
|
||||
samplingCells.append(mesh().faceOwner()[facei]);
|
||||
samplingFaces.append(facei);
|
||||
samplingSegments.append(0);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2012-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -273,12 +273,12 @@ void Foam::patchSeedSet::calcSamples
|
||||
const point& cc = mesh().cellCentres()[celli];
|
||||
samplingPts.append
|
||||
(
|
||||
info.hitPoint() + 1e-1*(cc-info.hitPoint())
|
||||
info.point() + 1e-1*(cc-info.point())
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
samplingPts.append(info.rawPoint());
|
||||
samplingPts.append(info.point());
|
||||
}
|
||||
samplingCells.append(celli);
|
||||
samplingFaces.append(facei);
|
||||
|
||||
@ -194,16 +194,7 @@ Foam::label Foam::sampledSet::findNearFace
|
||||
|
||||
pointHit inter = f.nearestPoint(sample, mesh().points());
|
||||
|
||||
scalar dist;
|
||||
|
||||
if (inter.hit())
|
||||
{
|
||||
dist = mag(inter.hitPoint() - sample);
|
||||
}
|
||||
else
|
||||
{
|
||||
dist = mag(inter.missPoint() - sample);
|
||||
}
|
||||
scalar dist = inter.point().dist(sample);
|
||||
|
||||
if (dist < smallDist)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
Copyright (C) 2021-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -330,7 +330,7 @@ void Foam::uniformSet::calcSamples
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "Finding next boundary : "
|
||||
<< "bPoint:" << bHits[bHitI].hitPoint()
|
||||
<< "bPoint:" << bHits[bHitI].point()
|
||||
<< " tracking:" << singleParticle.position()
|
||||
<< " dist:" << dist
|
||||
<< endl;
|
||||
|
||||
@ -170,7 +170,7 @@ bool Foam::sampledMeshedSurface::update(const meshSearch& meshSearcher)
|
||||
|
||||
if (info.hit())
|
||||
{
|
||||
near.first() = magSqr(info.hitPoint()-pt);
|
||||
near.first() = info.point().distSqr(pt);
|
||||
near.second() = globalCells.toGlobal(info.index());
|
||||
}
|
||||
}
|
||||
@ -213,7 +213,7 @@ bool Foam::sampledMeshedSurface::update(const meshSearch& meshSearcher)
|
||||
|
||||
if (info.hit())
|
||||
{
|
||||
near.first() = magSqr(info.hitPoint()-pt);
|
||||
near.first() = info.point().distSqr(pt);
|
||||
near.second() =
|
||||
globalCells.toGlobal
|
||||
(
|
||||
@ -346,7 +346,7 @@ bool Foam::sampledMeshedSurface::update(const meshSearch& meshSearcher)
|
||||
if (info.distance() < minDistSqr)
|
||||
{
|
||||
minDistSqr = info.distance();
|
||||
samplePoints_[pointi] = info.rawPoint();
|
||||
samplePoints_[pointi] = info.point();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -385,7 +385,7 @@ bool Foam::sampledMeshedSurface::update(const meshSearch& meshSearcher)
|
||||
(
|
||||
pt,
|
||||
mesh().points()
|
||||
).rawPoint();
|
||||
).point();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -368,7 +368,7 @@ void Foam::isoSurfaceCell::calcSnappedCc
|
||||
if (info.hit())
|
||||
{
|
||||
snappedCc[celli] = snappedPoints.size();
|
||||
snappedPoints.append(info.hitPoint());
|
||||
snappedPoints.append(info.point());
|
||||
|
||||
//Pout<< "cell:" << celli
|
||||
// << " at " << mesh_.cellCentres()[celli]
|
||||
|
||||
Reference in New Issue
Block a user