mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: for-range, forAllIters() ... in meshTools/
- reduced clutter when iterating over containers
This commit is contained in:
committed by
Andrew Heather
parent
24861f5158
commit
2833521576
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2013-2016 OpenFOAM Foundation
|
| Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||||
@ -80,27 +80,22 @@ Foam::cyclicACMIGAMGInterface::cyclicACMIGAMGInterface
|
|||||||
|
|
||||||
Map<label> masterToCoarseFace(localRestrictAddressing.size());
|
Map<label> masterToCoarseFace(localRestrictAddressing.size());
|
||||||
|
|
||||||
forAll(localRestrictAddressing, ffi)
|
for (const label curMaster : localRestrictAddressing)
|
||||||
{
|
{
|
||||||
label curMaster = localRestrictAddressing[ffi];
|
const auto iter = masterToCoarseFace.cfind(curMaster);
|
||||||
|
|
||||||
Map<label>::const_iterator fnd = masterToCoarseFace.find
|
if (iter.found())
|
||||||
(
|
|
||||||
curMaster
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fnd == masterToCoarseFace.end())
|
|
||||||
{
|
{
|
||||||
// New coarse face
|
// Already have coarse face
|
||||||
label coarseI = dynFaceCells.size();
|
dynFaceRestrictAddressing.append(iter.val());
|
||||||
dynFaceRestrictAddressing.append(coarseI);
|
|
||||||
dynFaceCells.append(curMaster);
|
|
||||||
masterToCoarseFace.insert(curMaster, coarseI);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Already have coarse face
|
// New coarse face
|
||||||
dynFaceRestrictAddressing.append(fnd());
|
const label coarseI = dynFaceCells.size();
|
||||||
|
dynFaceRestrictAddressing.append(coarseI);
|
||||||
|
dynFaceCells.append(curMaster);
|
||||||
|
masterToCoarseFace.insert(curMaster, coarseI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,26 +122,21 @@ Foam::cyclicACMIGAMGInterface::cyclicACMIGAMGInterface
|
|||||||
|
|
||||||
Map<label> masterToCoarseFace(neighbourRestrictAddressing.size());
|
Map<label> masterToCoarseFace(neighbourRestrictAddressing.size());
|
||||||
|
|
||||||
forAll(neighbourRestrictAddressing, ffi)
|
for (const label curMaster : neighbourRestrictAddressing)
|
||||||
{
|
{
|
||||||
label curMaster = neighbourRestrictAddressing[ffi];
|
const auto iter = masterToCoarseFace.cfind(curMaster);
|
||||||
|
|
||||||
Map<label>::const_iterator fnd = masterToCoarseFace.find
|
if (iter.found())
|
||||||
(
|
|
||||||
curMaster
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fnd == masterToCoarseFace.end())
|
|
||||||
{
|
{
|
||||||
// New coarse face
|
// Already have coarse face
|
||||||
label coarseI = masterToCoarseFace.size();
|
dynNbrFaceRestrictAddressing.append(iter.val());
|
||||||
dynNbrFaceRestrictAddressing.append(coarseI);
|
|
||||||
masterToCoarseFace.insert(curMaster, coarseI);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Already have coarse face
|
// New coarse face
|
||||||
dynNbrFaceRestrictAddressing.append(fnd());
|
const label coarseI = masterToCoarseFace.size();
|
||||||
|
dynNbrFaceRestrictAddressing.append(coarseI);
|
||||||
|
masterToCoarseFace.insert(curMaster, coarseI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -80,27 +80,22 @@ Foam::cyclicAMIGAMGInterface::cyclicAMIGAMGInterface
|
|||||||
|
|
||||||
Map<label> masterToCoarseFace(localRestrictAddressing.size());
|
Map<label> masterToCoarseFace(localRestrictAddressing.size());
|
||||||
|
|
||||||
forAll(localRestrictAddressing, ffi)
|
for (const label curMaster : localRestrictAddressing)
|
||||||
{
|
{
|
||||||
label curMaster = localRestrictAddressing[ffi];
|
const auto iter = masterToCoarseFace.cfind(curMaster);
|
||||||
|
|
||||||
Map<label>::const_iterator fnd = masterToCoarseFace.find
|
if (iter.found())
|
||||||
(
|
|
||||||
curMaster
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fnd == masterToCoarseFace.end())
|
|
||||||
{
|
{
|
||||||
// New coarse face
|
// Already have coarse face
|
||||||
label coarseI = dynFaceCells.size();
|
dynFaceRestrictAddressing.append(iter.val());
|
||||||
dynFaceRestrictAddressing.append(coarseI);
|
|
||||||
dynFaceCells.append(curMaster);
|
|
||||||
masterToCoarseFace.insert(curMaster, coarseI);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Already have coarse face
|
// New coarse face
|
||||||
dynFaceRestrictAddressing.append(fnd());
|
const label coarseI = dynFaceCells.size();
|
||||||
|
dynFaceRestrictAddressing.append(coarseI);
|
||||||
|
dynFaceCells.append(curMaster);
|
||||||
|
masterToCoarseFace.insert(curMaster, coarseI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,26 +122,21 @@ Foam::cyclicAMIGAMGInterface::cyclicAMIGAMGInterface
|
|||||||
|
|
||||||
Map<label> masterToCoarseFace(neighbourRestrictAddressing.size());
|
Map<label> masterToCoarseFace(neighbourRestrictAddressing.size());
|
||||||
|
|
||||||
forAll(neighbourRestrictAddressing, ffi)
|
for (const label curMaster : neighbourRestrictAddressing)
|
||||||
{
|
{
|
||||||
label curMaster = neighbourRestrictAddressing[ffi];
|
const auto iter = masterToCoarseFace.cfind(curMaster);
|
||||||
|
|
||||||
Map<label>::const_iterator fnd = masterToCoarseFace.find
|
if (iter.found())
|
||||||
(
|
|
||||||
curMaster
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fnd == masterToCoarseFace.end())
|
|
||||||
{
|
{
|
||||||
// New coarse face
|
// Already have coarse face
|
||||||
label coarseI = masterToCoarseFace.size();
|
dynNbrFaceRestrictAddressing.append(iter.val());
|
||||||
dynNbrFaceRestrictAddressing.append(coarseI);
|
|
||||||
masterToCoarseFace.insert(curMaster, coarseI);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Already have coarse face
|
// New coarse face
|
||||||
dynNbrFaceRestrictAddressing.append(fnd());
|
const label coarseI = masterToCoarseFace.size();
|
||||||
|
dynNbrFaceRestrictAddressing.append(coarseI);
|
||||||
|
masterToCoarseFace.insert(curMaster, coarseI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -144,7 +144,7 @@ namespace Foam
|
|||||||
// );
|
// );
|
||||||
//
|
//
|
||||||
// // Add the UniformValueField under the Function1 name
|
// // Add the UniformValueField under the Function1 name
|
||||||
// forAllConstIter(typename F1Type, F1Table, iter)
|
// forAllConstIters(F1Table, iter)
|
||||||
// {
|
// {
|
||||||
// //bool ok =
|
// //bool ok =
|
||||||
// PF1Table.insert(iter.key(), cstrIter());
|
// PF1Table.insert(iter.key(), cstrIter());
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -47,12 +47,6 @@ Foam::patchPatchDist::patchPatchDist
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
Foam::patchPatchDist::~patchPatchDist()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::patchPatchDist::correct()
|
void Foam::patchPatchDist::correct()
|
||||||
@ -120,8 +114,8 @@ void Foam::patchPatchDist::correct()
|
|||||||
{
|
{
|
||||||
const edge& e = patch_.edges()[edgeI];
|
const edge& e = patch_.edges()[edgeI];
|
||||||
const edge meshE = edge(mp[e[0]], mp[e[1]]);
|
const edge meshE = edge(mp[e[0]], mp[e[1]]);
|
||||||
EdgeMap<label>::const_iterator edgeFnd = nbrEdges.find(meshE);
|
|
||||||
if (edgeFnd != nbrEdges.end())
|
if (nbrEdges.found(meshE))
|
||||||
{
|
{
|
||||||
initialEdges.append(edgeI);
|
initialEdges.append(edgeI);
|
||||||
initialEdgesInfo.append
|
initialEdgesInfo.append
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2013 OpenFOAM Foundation
|
| Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
@ -57,10 +57,6 @@ class patchPatchDist
|
|||||||
:
|
:
|
||||||
public scalarField
|
public scalarField
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// Private Member Data
|
// Private Member Data
|
||||||
|
|
||||||
//- Patch to operate on
|
//- Patch to operate on
|
||||||
@ -85,7 +81,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~patchPatchDist();
|
virtual ~patchPatchDist() = default;
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2013-2016 OpenFOAM Foundation
|
| Copyright (C) 2013-2016 OpenFOAM Foundation
|
||||||
@ -36,7 +36,7 @@ License
|
|||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
defineTypeNameAndDebug(meshStructure, 0);
|
defineTypeNameAndDebug(meshStructure, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ void Foam::meshStructure::correct
|
|||||||
label pointi = f[fp];
|
label pointi = f[fp];
|
||||||
label nextPointi = f.nextLabel(fp);
|
label nextPointi = f.nextLabel(fp);
|
||||||
|
|
||||||
EdgeMap<label>::const_iterator fnd = pointsToEdge.find
|
const auto fnd = pointsToEdge.cfind
|
||||||
(
|
(
|
||||||
edge
|
edge
|
||||||
(
|
(
|
||||||
@ -335,9 +335,10 @@ void Foam::meshStructure::correct
|
|||||||
pointData[nextPointi].data()
|
pointData[nextPointi].data()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (fnd != pointsToEdge.end())
|
|
||||||
|
if (fnd.found())
|
||||||
{
|
{
|
||||||
faceToPatchEdgeAddressing_[facei] = fnd();
|
faceToPatchEdgeAddressing_[facei] = fnd.val();
|
||||||
faceToPatchFaceAddressing_[facei] = 0;
|
faceToPatchFaceAddressing_[facei] = 0;
|
||||||
label own = mesh.faceOwner()[facei];
|
label own = mesh.faceOwner()[facei];
|
||||||
faceLayer_[facei] = cellData[own].distance();
|
faceLayer_[facei] = cellData[own].distance();
|
||||||
|
|||||||
@ -276,10 +276,8 @@ void Foam::meshTools::writeOBJ
|
|||||||
{
|
{
|
||||||
writeOBJ(os, bb.points());
|
writeOBJ(os, bb.points());
|
||||||
|
|
||||||
forAll(treeBoundBox::edges, edgei)
|
for (const edge& e : treeBoundBox::edges)
|
||||||
{
|
{
|
||||||
const edge& e = treeBoundBox::edges[edgei];
|
|
||||||
|
|
||||||
os << "l " << (e[0] + 1) << ' ' << (e[1] + 1) << nl;
|
os << "l " << (e[0] + 1) << ' ' << (e[1] + 1) << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -296,10 +294,9 @@ void Foam::meshTools::writeOBJ
|
|||||||
{
|
{
|
||||||
labelHashSet usedFaces(4*cellLabels.size());
|
labelHashSet usedFaces(4*cellLabels.size());
|
||||||
|
|
||||||
forAll(cellLabels, i)
|
for (const label celli : cellLabels)
|
||||||
{
|
{
|
||||||
const cell& cFaces = cells[cellLabels[i]];
|
usedFaces.insert(cells[celli]);
|
||||||
usedFaces.insert(cFaces);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
writeOBJ(os, faces, points, usedFaces.toc());
|
writeOBJ(os, faces, points, usedFaces.toc());
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
| Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
@ -71,23 +71,20 @@ Foam::regionCoupledBaseGAMGInterface::regionCoupledBaseGAMGInterface
|
|||||||
{
|
{
|
||||||
label curMaster = localRestrictAddressing[ffi];
|
label curMaster = localRestrictAddressing[ffi];
|
||||||
|
|
||||||
Map<label>::const_iterator fnd = masterToCoarseFace.find
|
const auto fnd = masterToCoarseFace.cfind(curMaster);
|
||||||
(
|
|
||||||
curMaster
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fnd == masterToCoarseFace.end())
|
if (fnd.found())
|
||||||
{
|
{
|
||||||
// New coarse face
|
// Already have coarse face
|
||||||
label coarseI = dynFaceCells.size();
|
dynFaceRestrictAddressing.append(fnd.val());
|
||||||
dynFaceRestrictAddressing.append(coarseI);
|
|
||||||
dynFaceCells.append(curMaster);
|
|
||||||
masterToCoarseFace.insert(curMaster, coarseI);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Already have coarse face
|
// New coarse face
|
||||||
dynFaceRestrictAddressing.append(fnd());
|
const label coarseI = dynFaceCells.size();
|
||||||
|
dynFaceRestrictAddressing.append(coarseI);
|
||||||
|
dynFaceCells.append(curMaster);
|
||||||
|
masterToCoarseFace.insert(curMaster, coarseI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,22 +150,19 @@ Foam::regionCoupledBaseGAMGInterface::regionCoupledBaseGAMGInterface
|
|||||||
{
|
{
|
||||||
label curMaster = nbrPatchRestrictMap[ffi];
|
label curMaster = nbrPatchRestrictMap[ffi];
|
||||||
|
|
||||||
Map<label>::const_iterator fnd = masterToCoarseFace.find
|
const auto fnd = masterToCoarseFace.cfind(curMaster);
|
||||||
(
|
|
||||||
curMaster
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fnd == masterToCoarseFace.end())
|
if (fnd.found())
|
||||||
{
|
{
|
||||||
// New coarse face
|
// Already have coarse face
|
||||||
label coarseI = masterToCoarseFace.size();
|
dynNbrFaceRestrictAddressing.append(fnd.val());
|
||||||
dynNbrFaceRestrictAddressing.append(coarseI);
|
|
||||||
masterToCoarseFace.insert(curMaster, coarseI);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Already have coarse face
|
// New coarse face
|
||||||
dynNbrFaceRestrictAddressing.append(fnd());
|
const label coarseI = masterToCoarseFace.size();
|
||||||
|
dynNbrFaceRestrictAddressing.append(coarseI);
|
||||||
|
masterToCoarseFace.insert(curMaster, coarseI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -124,9 +124,9 @@ void Foam::localPointRegion::countPointRegions
|
|||||||
// From faces with any duplicated point on it to local face
|
// From faces with any duplicated point on it to local face
|
||||||
meshFaceMap_.resize(meshPointMap_.size());
|
meshFaceMap_.resize(meshPointMap_.size());
|
||||||
|
|
||||||
forAllConstIter(Map<label>, candidateFace, iter)
|
forAllConstIters(candidateFace, iter)
|
||||||
{
|
{
|
||||||
label facei = iter.key();
|
const label facei = iter.key();
|
||||||
|
|
||||||
if (!mesh.isInternalFace(facei))
|
if (!mesh.isInternalFace(facei))
|
||||||
{
|
{
|
||||||
@ -142,14 +142,14 @@ void Foam::localPointRegion::countPointRegions
|
|||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
label pointi = f[fp];
|
const label pointi = f[fp];
|
||||||
|
|
||||||
// Even points which were not candidates for splitting might
|
// Even points which were not candidates for splitting might
|
||||||
// be on multiple baffles that are being split so check.
|
// be on multiple baffles that are being split so check.
|
||||||
|
|
||||||
if (candidatePoint[pointi])
|
if (candidatePoint[pointi])
|
||||||
{
|
{
|
||||||
label region = minRegion[facei][fp];
|
const label region = minRegion[facei][fp];
|
||||||
|
|
||||||
if (minPointRegion[pointi] == -1)
|
if (minPointRegion[pointi] == -1)
|
||||||
{
|
{
|
||||||
@ -158,10 +158,10 @@ void Foam::localPointRegion::countPointRegions
|
|||||||
else if (minPointRegion[pointi] != region)
|
else if (minPointRegion[pointi] != region)
|
||||||
{
|
{
|
||||||
// Multiple regions for this point. Add.
|
// Multiple regions for this point. Add.
|
||||||
Map<label>::iterator iter = meshPointMap_.find(pointi);
|
const auto iter = meshPointMap_.cfind(pointi);
|
||||||
if (iter != meshPointMap_.end())
|
if (iter.found())
|
||||||
{
|
{
|
||||||
labelList& regions = pointRegions[iter()];
|
labelList& regions = pointRegions[iter.val()];
|
||||||
if (!regions.found(region))
|
if (!regions.found(region))
|
||||||
{
|
{
|
||||||
label sz = regions.size();
|
label sz = regions.size();
|
||||||
@ -190,9 +190,9 @@ void Foam::localPointRegion::countPointRegions
|
|||||||
|
|
||||||
// Add internal faces that use any duplicated point. Can only have one
|
// Add internal faces that use any duplicated point. Can only have one
|
||||||
// region!
|
// region!
|
||||||
forAllConstIter(Map<label>, candidateFace, iter)
|
forAllConstIters(candidateFace, iter)
|
||||||
{
|
{
|
||||||
label facei = iter.key();
|
const label facei = iter.key();
|
||||||
|
|
||||||
if (mesh.isInternalFace(facei))
|
if (mesh.isInternalFace(facei))
|
||||||
{
|
{
|
||||||
@ -204,7 +204,7 @@ void Foam::localPointRegion::countPointRegions
|
|||||||
// speeds up rejection.
|
// speeds up rejection.
|
||||||
if (candidatePoint[f[fp]] && meshPointMap_.found(f[fp]))
|
if (candidatePoint[f[fp]] && meshPointMap_.found(f[fp]))
|
||||||
{
|
{
|
||||||
label meshFaceMapI = meshFaceMap_.size();
|
const label meshFaceMapI = meshFaceMap_.size();
|
||||||
meshFaceMap_.insert(facei, meshFaceMapI);
|
meshFaceMap_.insert(facei, meshFaceMapI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ void Foam::localPointRegion::countPointRegions
|
|||||||
|
|
||||||
// Compact minRegion
|
// Compact minRegion
|
||||||
faceRegions_.setSize(meshFaceMap_.size());
|
faceRegions_.setSize(meshFaceMap_.size());
|
||||||
forAllConstIter(Map<label>, meshFaceMap_, iter)
|
forAllConstIters(meshFaceMap_, iter)
|
||||||
{
|
{
|
||||||
faceRegions_[iter()].labelList::transfer(minRegion[iter.key()]);
|
faceRegions_[iter()].labelList::transfer(minRegion[iter.key()]);
|
||||||
|
|
||||||
@ -321,7 +321,7 @@ void Foam::localPointRegion::calcPointRegions
|
|||||||
// only ones using a
|
// only ones using a
|
||||||
// candidate point so the only ones that can be affected)
|
// candidate point so the only ones that can be affected)
|
||||||
faceList minRegion(mesh.nFaces());
|
faceList minRegion(mesh.nFaces());
|
||||||
forAllConstIter(Map<label>, candidateFace, iter)
|
forAllConstIters(candidateFace, iter)
|
||||||
{
|
{
|
||||||
label facei = iter.key();
|
label facei = iter.key();
|
||||||
const face& f = mesh.faces()[facei];
|
const face& f = mesh.faces()[facei];
|
||||||
@ -350,7 +350,7 @@ void Foam::localPointRegion::calcPointRegions
|
|||||||
|
|
||||||
Map<label> minPointValue(128);
|
Map<label> minPointValue(128);
|
||||||
label nChanged = 0;
|
label nChanged = 0;
|
||||||
forAllConstIter(Map<label>, candidateCell, iter)
|
forAllConstIters(candidateCell, iter)
|
||||||
{
|
{
|
||||||
minPointValue.clear();
|
minPointValue.clear();
|
||||||
|
|
||||||
@ -368,8 +368,8 @@ void Foam::localPointRegion::calcPointRegions
|
|||||||
|
|
||||||
forAll(f, fp)
|
forAll(f, fp)
|
||||||
{
|
{
|
||||||
label pointi = f[fp];
|
const label pointi = f[fp];
|
||||||
Map<label>::iterator iter = minPointValue.find(pointi);
|
auto iter = minPointValue.find(pointi);
|
||||||
|
|
||||||
if (iter == minPointValue.end())
|
if (iter == minPointValue.end())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -355,9 +355,9 @@ void Foam::regionToCell::combine(topoSet& set, const bool add) const
|
|||||||
cellSet subSet(mesh_, setName_);
|
cellSet subSet(mesh_, setName_);
|
||||||
|
|
||||||
selectedCell = false;
|
selectedCell = false;
|
||||||
forAllConstIter(cellSet, subSet, iter)
|
for (const label celli : subSet)
|
||||||
{
|
{
|
||||||
selectedCell[iter.key()] = true;
|
selectedCell[celli] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -136,10 +136,8 @@ void Foam::setsToFaceZone::applyToSet
|
|||||||
DynamicList<label> newAddressing(zoneSet.addressing());
|
DynamicList<label> newAddressing(zoneSet.addressing());
|
||||||
DynamicList<bool> newFlipMap(zoneSet.flipMap());
|
DynamicList<bool> newFlipMap(zoneSet.flipMap());
|
||||||
|
|
||||||
forAllConstIter(faceSet, fSet, iter)
|
for (const label facei : fSet)
|
||||||
{
|
{
|
||||||
label facei = iter.key();
|
|
||||||
|
|
||||||
if (!zoneSet.found(facei))
|
if (!zoneSet.found(facei))
|
||||||
{
|
{
|
||||||
bool flipFace = false;
|
bool flipFace = false;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -60,16 +60,13 @@ void Foam::intersectedSurface::writeOBJ
|
|||||||
Ostream& os
|
Ostream& os
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
forAll(points, pointi)
|
for (const point& pt : points)
|
||||||
{
|
{
|
||||||
const point& pt = points[pointi];
|
|
||||||
|
|
||||||
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||||
}
|
}
|
||||||
forAll(edges, edgei)
|
|
||||||
{
|
|
||||||
const edge& e = edges[edgei];
|
|
||||||
|
|
||||||
|
for (const edge& e : edges)
|
||||||
|
{
|
||||||
os << "l " << e.start()+1 << ' ' << e.end()+1 << nl;
|
os << "l " << e.start()+1 << ' ' << e.end()+1 << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,15 +80,13 @@ void Foam::intersectedSurface::writeOBJ
|
|||||||
Ostream& os
|
Ostream& os
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
forAll(points, pointi)
|
for (const point& pt : points)
|
||||||
{
|
{
|
||||||
const point& pt = points[pointi];
|
|
||||||
|
|
||||||
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||||
}
|
}
|
||||||
forAll(faceEdges, i)
|
for (const label edgei : faceEdges)
|
||||||
{
|
{
|
||||||
const edge& e = edges[faceEdges[i]];
|
const edge& e = edges[edgei];
|
||||||
|
|
||||||
os << "l " << e.start()+1 << ' ' << e.end()+1 << nl;
|
os << "l " << e.start()+1 << ' ' << e.end()+1 << nl;
|
||||||
}
|
}
|
||||||
@ -112,13 +107,13 @@ void Foam::intersectedSurface::writeLocalOBJ
|
|||||||
|
|
||||||
label maxVerti = 0;
|
label maxVerti = 0;
|
||||||
|
|
||||||
forAll(faceEdges, i)
|
for (const label edgei : faceEdges)
|
||||||
{
|
{
|
||||||
const edge& e = edges[faceEdges[i]];
|
const edge& e = edges[edgei];
|
||||||
|
|
||||||
forAll(e, i)
|
forAll(e, i)
|
||||||
{
|
{
|
||||||
label pointi = e[i];
|
const label pointi = e[i];
|
||||||
|
|
||||||
if (pointMap[pointi] == -1)
|
if (pointMap[pointi] == -1)
|
||||||
{
|
{
|
||||||
@ -131,9 +126,9 @@ void Foam::intersectedSurface::writeLocalOBJ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(faceEdges, i)
|
for (const label edgei : faceEdges)
|
||||||
{
|
{
|
||||||
const edge& e = edges[faceEdges[i]];
|
const edge& e = edges[edgei];
|
||||||
|
|
||||||
os << "l " << pointMap[e.start()]+1 << ' ' << pointMap[e.end()]+1
|
os << "l " << pointMap[e.start()]+1 << ' ' << pointMap[e.end()]+1
|
||||||
<< nl;
|
<< nl;
|
||||||
@ -148,18 +143,16 @@ void Foam::intersectedSurface::writeOBJ
|
|||||||
Ostream& os
|
Ostream& os
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
forAll(points, pointi)
|
for (const point& pt : points)
|
||||||
{
|
{
|
||||||
const point& pt = points[pointi];
|
|
||||||
|
|
||||||
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
os << 'f';
|
os << 'f';
|
||||||
|
|
||||||
forAll(f, fp)
|
for (const label pointi : f)
|
||||||
{
|
{
|
||||||
os << ' ' << f[fp]+1;
|
os << ' ' << pointi+1;
|
||||||
}
|
}
|
||||||
os << nl;
|
os << nl;
|
||||||
}
|
}
|
||||||
@ -173,10 +166,8 @@ void Foam::intersectedSurface::printVisit
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
Pout<< "Visited:" << nl;
|
Pout<< "Visited:" << nl;
|
||||||
forAll(edgeLabels, i)
|
for (const label edgei : edgeLabels)
|
||||||
{
|
{
|
||||||
label edgei = edgeLabels[i];
|
|
||||||
|
|
||||||
const edge& e = edges[edgei];
|
const edge& e = edges[edgei];
|
||||||
|
|
||||||
label stat = visited[edgei];
|
label stat = visited[edgei];
|
||||||
@ -261,16 +252,7 @@ void Foam::intersectedSurface::incCount
|
|||||||
const label offset
|
const label offset
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Map<label>::iterator iter = visited.find(key);
|
visited(key, 0) += offset;
|
||||||
|
|
||||||
if (iter == visited.end())
|
|
||||||
{
|
|
||||||
visited.insert(key, offset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iter() += offset;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -288,77 +270,50 @@ Foam::intersectedSurface::calcPointEdgeAddressing
|
|||||||
|
|
||||||
Map<DynamicList<label>> facePointEdges(4*fEdges.size());
|
Map<DynamicList<label>> facePointEdges(4*fEdges.size());
|
||||||
|
|
||||||
forAll(fEdges, i)
|
for (const label edgei : fEdges)
|
||||||
{
|
{
|
||||||
label edgei = fEdges[i];
|
|
||||||
|
|
||||||
const edge& e = edges[edgei];
|
const edge& e = edges[edgei];
|
||||||
|
|
||||||
// Add e.start to point-edges
|
// Add e.start to point-edges
|
||||||
Map<DynamicList<label>>::iterator iter =
|
facePointEdges(e.start()).append(edgei);
|
||||||
facePointEdges.find(e.start());
|
|
||||||
|
|
||||||
if (iter == facePointEdges.end())
|
|
||||||
{
|
|
||||||
DynamicList<label> oneEdge;
|
|
||||||
oneEdge.append(edgei);
|
|
||||||
facePointEdges.insert(e.start(), oneEdge);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iter().append(edgei);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add e.end to point-edges
|
// Add e.end to point-edges
|
||||||
Map<DynamicList<label>>::iterator iter2 =
|
facePointEdges(e.end()).append(edgei);
|
||||||
facePointEdges.find(e.end());
|
|
||||||
|
|
||||||
if (iter2 == facePointEdges.end())
|
|
||||||
{
|
|
||||||
DynamicList<label> oneEdge;
|
|
||||||
oneEdge.append(edgei);
|
|
||||||
facePointEdges.insert(e.end(), oneEdge);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iter2().append(edgei);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shrink it
|
// Shrink it
|
||||||
forAllIter(Map<DynamicList<label>>, facePointEdges, iter)
|
forAllIters(facePointEdges, iter)
|
||||||
{
|
{
|
||||||
iter().shrink();
|
iter.val().shrink();
|
||||||
|
|
||||||
// Check on dangling points.
|
// Check on dangling points.
|
||||||
if (iter().empty())
|
if (iter.val().empty())
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Point:" << iter.key() << " used by too few edges:"
|
<< "Point:" << iter.key() << " used by too few edges:"
|
||||||
<< iter() << abort(FatalError);
|
<< iter.val() << abort(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug & 2)
|
if (debug & 2)
|
||||||
{
|
{
|
||||||
// Print facePointEdges
|
// Print facePointEdges
|
||||||
Pout<< "calcPointEdgeAddressing: face consisting of edges:" << endl;
|
Pout<< "calcPointEdgeAddressing: face consisting of edges:" << nl;
|
||||||
forAll(fEdges, i)
|
for (const label edgei : fEdges)
|
||||||
{
|
{
|
||||||
label edgei = fEdges[i];
|
|
||||||
const edge& e = edges[edgei];
|
const edge& e = edges[edgei];
|
||||||
Pout<< " " << edgei << ' ' << e
|
Pout<< " " << edgei << ' ' << e
|
||||||
<< points[e.start()]
|
<< points[e.start()]
|
||||||
<< points[e.end()] << endl;
|
<< points[e.end()] << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pout<< " Constructed point-edge adressing:" << endl;
|
Pout<< " Constructed point-edge adressing:" << nl;
|
||||||
forAllConstIter(Map<DynamicList<label>>, facePointEdges, iter)
|
forAllConstIters(facePointEdges, iter)
|
||||||
{
|
{
|
||||||
Pout<< " vertex " << iter.key() << " is connected to edges "
|
Pout<< " vertex " << iter.key() << " is connected to edges "
|
||||||
<< iter() << endl;
|
<< iter.val() << nl;
|
||||||
}
|
}
|
||||||
Pout<<endl;
|
Pout<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return facePointEdges;
|
return facePointEdges;
|
||||||
@ -469,10 +424,8 @@ Foam::label Foam::intersectedSurface::nextEdge
|
|||||||
scalar maxAngle = -GREAT;
|
scalar maxAngle = -GREAT;
|
||||||
label maxEdgei = -1;
|
label maxEdgei = -1;
|
||||||
|
|
||||||
forAll(connectedEdges, conni)
|
for (const label edgei : connectedEdges)
|
||||||
{
|
{
|
||||||
label edgei = connectedEdges[conni];
|
|
||||||
|
|
||||||
if (edgei != prevEdgei)
|
if (edgei != prevEdgei)
|
||||||
{
|
{
|
||||||
label stat = visited[edgei];
|
label stat = visited[edgei];
|
||||||
@ -638,14 +591,13 @@ void Foam::intersectedSurface::findNearestVisited
|
|||||||
minVerti = -1;
|
minVerti = -1;
|
||||||
minDist = GREAT;
|
minDist = GREAT;
|
||||||
|
|
||||||
forAllConstIter(Map<label>, pointVisited, iter)
|
forAllConstIters(pointVisited, iter)
|
||||||
{
|
{
|
||||||
label pointi = iter.key();
|
const label pointi = iter.key();
|
||||||
|
const label nVisits = iter.val();
|
||||||
|
|
||||||
if (pointi != excludePointi)
|
if (pointi != excludePointi)
|
||||||
{
|
{
|
||||||
label nVisits = iter();
|
|
||||||
|
|
||||||
if (nVisits == 2*facePointEdges[pointi].size())
|
if (nVisits == 2*facePointEdges[pointi].size())
|
||||||
{
|
{
|
||||||
// Fully visited (i.e. both sides of all edges)
|
// Fully visited (i.e. both sides of all edges)
|
||||||
@ -689,11 +641,12 @@ Foam::faceList Foam::intersectedSurface::resplitFace
|
|||||||
// can compare number to facePointEdges.
|
// can compare number to facePointEdges.
|
||||||
Map<label> pointVisited(2*facePointEdges.size());
|
Map<label> pointVisited(2*facePointEdges.size());
|
||||||
|
|
||||||
forAllConstIter(Map<label>, visited, iter)
|
forAllConstIters(visited, iter)
|
||||||
{
|
{
|
||||||
label edgei = iter.key();
|
const label edgei = iter.key();
|
||||||
|
const label stat = iter.val();
|
||||||
|
|
||||||
const edge& e = eSurf.edges()[edgei];
|
const edge& e = eSurf.edges()[edgei];
|
||||||
label stat = iter();
|
|
||||||
|
|
||||||
if (stat == STARTTOEND || stat == ENDTOSTART)
|
if (stat == STARTTOEND || stat == ENDTOSTART)
|
||||||
{
|
{
|
||||||
@ -715,13 +668,13 @@ Foam::faceList Foam::intersectedSurface::resplitFace
|
|||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
forAllConstIter(Map<label>, pointVisited, iter)
|
forAllConstIters(pointVisited, iter)
|
||||||
{
|
{
|
||||||
label pointi = iter.key();
|
const label pointi = iter.key();
|
||||||
|
const label nVisits = iter.val();
|
||||||
|
|
||||||
label nVisits = iter();
|
Pout<< "point:" << pointi
|
||||||
|
<< " nVisited:" << nVisits
|
||||||
Pout<< "point:" << pointi << " nVisited:" << nVisits
|
|
||||||
<< " pointEdges:" << facePointEdges[pointi].size() << endl;
|
<< " pointEdges:" << facePointEdges[pointi].size() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -736,13 +689,13 @@ Foam::faceList Foam::intersectedSurface::resplitFace
|
|||||||
{
|
{
|
||||||
scalar minDist = GREAT;
|
scalar minDist = GREAT;
|
||||||
|
|
||||||
forAllConstIter(Map<DynamicList<label>>, facePointEdges, iter)
|
forAllConstIters(facePointEdges, iter)
|
||||||
{
|
{
|
||||||
label pointi = iter.key();
|
const label pointi = iter.key();
|
||||||
|
|
||||||
label nVisits = pointVisited[pointi];
|
const DynamicList<label>& pEdges = iter.val();
|
||||||
|
|
||||||
const DynamicList<label>& pEdges = iter();
|
const label nVisits = pointVisited[pointi];
|
||||||
|
|
||||||
if (nVisits < 2*pEdges.size())
|
if (nVisits < 2*pEdges.size())
|
||||||
{
|
{
|
||||||
@ -779,15 +732,15 @@ Foam::faceList Foam::intersectedSurface::resplitFace
|
|||||||
{
|
{
|
||||||
scalar minDist = GREAT;
|
scalar minDist = GREAT;
|
||||||
|
|
||||||
forAllConstIter(Map<DynamicList<label>>, facePointEdges, iter)
|
forAllConstIters(facePointEdges, iter)
|
||||||
{
|
{
|
||||||
label pointi = iter.key();
|
const label pointi = iter.key();
|
||||||
|
|
||||||
|
const DynamicList<label>& pEdges = iter.val();
|
||||||
|
|
||||||
if (pointi != unvisitedVert0)
|
if (pointi != unvisitedVert0)
|
||||||
{
|
{
|
||||||
label nVisits = pointVisited[pointi];
|
const label nVisits = pointVisited[pointi];
|
||||||
|
|
||||||
const DynamicList<label>& pEdges = iter();
|
|
||||||
|
|
||||||
if (nVisits < 2*pEdges.size())
|
if (nVisits < 2*pEdges.size())
|
||||||
{
|
{
|
||||||
@ -1032,9 +985,9 @@ Foam::faceList Foam::intersectedSurface::splitFace
|
|||||||
|
|
||||||
if ((n & surf.faceNormals()[facei]) < 0)
|
if ((n & surf.faceNormals()[facei]) < 0)
|
||||||
{
|
{
|
||||||
forAll(faces, i)
|
for (face& f : faces)
|
||||||
{
|
{
|
||||||
reverse(faces[i]);
|
reverse(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1224,7 +1177,7 @@ Foam::intersectedSurface::intersectedSurface
|
|||||||
|
|
||||||
// Edge already connected to surfStart for sure. See if also
|
// Edge already connected to surfStart for sure. See if also
|
||||||
// connects to surfEnd
|
// connects to surfEnd
|
||||||
if (surfE.start() == surfEndi || surfE.end() == surfEndi)
|
if (surfE.found(surfEndi))
|
||||||
{
|
{
|
||||||
surfEdgei = pEdges[i];
|
surfEdgei = pEdges[i];
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -41,9 +41,8 @@ namespace Foam
|
|||||||
// Write points in obj format
|
// Write points in obj format
|
||||||
static void writeObjPoints(const UList<point>& pts, Ostream& os)
|
static void writeObjPoints(const UList<point>& pts, Ostream& os)
|
||||||
{
|
{
|
||||||
forAll(pts, i)
|
for (const point& pt : pts)
|
||||||
{
|
{
|
||||||
const point& pt = pts[i];
|
|
||||||
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,14 +176,9 @@ Foam::edgeList Foam::surfaceIntersection::filterEdges
|
|||||||
{
|
{
|
||||||
const edge& e = edges[edgeI];
|
const edge& e = edges[edgeI];
|
||||||
|
|
||||||
if
|
if ((e.start() != e.end()) && uniqueEdges.insert(e))
|
||||||
(
|
|
||||||
(e.start() != e.end())
|
|
||||||
&& (uniqueEdges.find(e) == uniqueEdges.end())
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// Edge is -non degenerate and -not yet seen.
|
// Edge is non-degenerate and not yet seen.
|
||||||
uniqueEdges.insert(e);
|
|
||||||
|
|
||||||
map[edgeI] = newEdgeI;
|
map[edgeI] = newEdgeI;
|
||||||
|
|
||||||
@ -218,10 +212,9 @@ Foam::labelList Foam::surfaceIntersection::filterLabels
|
|||||||
{
|
{
|
||||||
label elem = elems[elemI];
|
label elem = elems[elemI];
|
||||||
|
|
||||||
if (uniqueElems.find(elem) == uniqueElems.end())
|
if (uniqueElems.insert(elem))
|
||||||
{
|
{
|
||||||
// First time elem is seen
|
// First time elem is seen
|
||||||
uniqueElems.insert(elem);
|
|
||||||
|
|
||||||
map[elemI] = newElemI;
|
map[elemI] = newElemI;
|
||||||
|
|
||||||
@ -291,10 +284,8 @@ Foam::label Foam::surfaceIntersection::classify
|
|||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -803,11 +803,11 @@ Foam::surfaceFeatures::surfaceFeatures
|
|||||||
|
|
||||||
forAll(allEdgeStat, eI)
|
forAll(allEdgeStat, eI)
|
||||||
{
|
{
|
||||||
EdgeMap<label>::const_iterator iter = dynFeatEdges.find(surfEdges[eI]);
|
const auto iter = dynFeatEdges.cfind(surfEdges[eI]);
|
||||||
|
|
||||||
if (iter != dynFeatEdges.end())
|
if (iter.found())
|
||||||
{
|
{
|
||||||
allEdgeStat[eI] = edgeStat[iter()];
|
allEdgeStat[eI] = edgeStat[iter.val()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1215,10 +1215,8 @@ void Foam::surfaceFeatures::writeObj(const fileName& prefix) const
|
|||||||
OFstream pointStr(prefix + "_points.obj");
|
OFstream pointStr(prefix + "_points.obj");
|
||||||
Pout<< "Writing feature points to " << pointStr.name() << endl;
|
Pout<< "Writing feature points to " << pointStr.name() << endl;
|
||||||
|
|
||||||
forAll(featurePoints_, i)
|
for (const label pointi : featurePoints_)
|
||||||
{
|
{
|
||||||
label pointi = featurePoints_[i];
|
|
||||||
|
|
||||||
meshTools::writeOBJ(pointStr, surf_.localPoints()[pointi]);
|
meshTools::writeOBJ(pointStr, surf_.localPoints()[pointi]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1265,7 +1263,7 @@ Foam::Map<Foam::label> Foam::surfaceFeatures::nearestSamples
|
|||||||
|
|
||||||
forAll(pointLabels, i)
|
forAll(pointLabels, i)
|
||||||
{
|
{
|
||||||
label surfPointi = pointLabels[i];
|
const label surfPointi = pointLabels[i];
|
||||||
|
|
||||||
const point& surfPt = surfPoints[surfPointi];
|
const point& surfPt = surfPoints[surfPointi];
|
||||||
|
|
||||||
@ -1304,10 +1302,10 @@ Foam::Map<Foam::label> Foam::surfaceFeatures::nearestSamples
|
|||||||
OFstream objStream("nearestSamples.obj");
|
OFstream objStream("nearestSamples.obj");
|
||||||
|
|
||||||
label vertI = 0;
|
label vertI = 0;
|
||||||
forAllConstIter(Map<label>, nearest, iter)
|
forAllConstIters(nearest, iter)
|
||||||
{
|
{
|
||||||
meshTools::writeOBJ(objStream, samples[iter.key()]); vertI++;
|
meshTools::writeOBJ(objStream, samples[iter.key()]); vertI++;
|
||||||
meshTools::writeOBJ(objStream, surfPoints[iter()]); vertI++;
|
meshTools::writeOBJ(objStream, surfPoints[iter.val()]); vertI++;
|
||||||
objStream<< "l " << vertI-1 << ' ' << vertI << endl;
|
objStream<< "l " << vertI-1 << ' ' << vertI << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1428,13 +1426,13 @@ Foam::Map<Foam::label> Foam::surfaceFeatures::nearestSamples
|
|||||||
OFstream objStream("nearestEdges.obj");
|
OFstream objStream("nearestEdges.obj");
|
||||||
|
|
||||||
label vertI = 0;
|
label vertI = 0;
|
||||||
forAllConstIter(Map<label>, nearest, iter)
|
forAllConstIters(nearest, iter)
|
||||||
{
|
{
|
||||||
const label sampleI = iter.key();
|
const label sampleI = iter.key();
|
||||||
|
|
||||||
meshTools::writeOBJ(objStream, samples[sampleI]); vertI++;
|
const edge& e = surfEdges[iter.val()];
|
||||||
|
|
||||||
const edge& e = surfEdges[iter()];
|
meshTools::writeOBJ(objStream, samples[sampleI]); vertI++;
|
||||||
|
|
||||||
point nearPt =
|
point nearPt =
|
||||||
e.line(surfPoints).nearestDist(samples[sampleI]).rawPoint();
|
e.line(surfPoints).nearestDist(samples[sampleI]).rawPoint();
|
||||||
@ -1582,7 +1580,7 @@ Foam::Map<Foam::pointIndexHit> Foam::surfaceFeatures::nearestEdges
|
|||||||
OFstream objStream("nearestEdges.obj");
|
OFstream objStream("nearestEdges.obj");
|
||||||
|
|
||||||
label vertI = 0;
|
label vertI = 0;
|
||||||
forAllConstIter(Map<pointIndexHit>, nearest, iter)
|
forAllConstIters(nearest, iter)
|
||||||
{
|
{
|
||||||
const label sampleEdgeI = iter.key();
|
const label sampleEdgeI = iter.key();
|
||||||
|
|
||||||
@ -1592,7 +1590,7 @@ Foam::Map<Foam::pointIndexHit> Foam::surfaceFeatures::nearestEdges
|
|||||||
meshTools::writeOBJ(objStream, sampleEdge.centre(samplePoints));
|
meshTools::writeOBJ(objStream, sampleEdge.centre(samplePoints));
|
||||||
vertI++;
|
vertI++;
|
||||||
|
|
||||||
meshTools::writeOBJ(objStream, iter().rawPoint());
|
meshTools::writeOBJ(objStream, iter.val().rawPoint());
|
||||||
vertI++;
|
vertI++;
|
||||||
|
|
||||||
objStream<< "l " << vertI-1 << ' ' << vertI << endl;
|
objStream<< "l " << vertI-1 << ' ' << vertI << endl;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -70,10 +70,8 @@ void Foam::triSurfaceTools::calcRefineStatus
|
|||||||
|
|
||||||
const labelList& myNeighbours = surf.faceFaces()[facei];
|
const labelList& myNeighbours = surf.faceFaces()[facei];
|
||||||
|
|
||||||
forAll(myNeighbours, myNeighbourI)
|
for (const label neighbourFacei : myNeighbours)
|
||||||
{
|
{
|
||||||
label neighbourFacei = myNeighbours[myNeighbourI];
|
|
||||||
|
|
||||||
if (refine[neighbourFacei] == GREEN)
|
if (refine[neighbourFacei] == GREEN)
|
||||||
{
|
{
|
||||||
// Change to red refinement and propagate
|
// Change to red refinement and propagate
|
||||||
@ -165,13 +163,11 @@ Foam::triSurface Foam::triSurfaceTools::doRefine
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Storage for new points. (start after old points)
|
// Storage for new points. (start after old points)
|
||||||
DynamicList<point> newPoints(surf.nPoints());
|
|
||||||
forAll(surf.localPoints(), pointi)
|
|
||||||
{
|
|
||||||
newPoints.append(surf.localPoints()[pointi]);
|
|
||||||
}
|
|
||||||
label newVertI = surf.nPoints();
|
label newVertI = surf.nPoints();
|
||||||
|
|
||||||
|
DynamicList<point> newPoints(newVertI);
|
||||||
|
newPoints.append(surf.localPoints());
|
||||||
|
|
||||||
// Storage for new faces
|
// Storage for new faces
|
||||||
DynamicList<labelledTri> newFaces(surf.size());
|
DynamicList<labelledTri> newFaces(surf.size());
|
||||||
|
|
||||||
@ -186,24 +182,15 @@ Foam::triSurface Foam::triSurfaceTools::doRefine
|
|||||||
// Create new vertices on all edges to be refined.
|
// Create new vertices on all edges to be refined.
|
||||||
const labelList& fEdges = surf.faceEdges()[facei];
|
const labelList& fEdges = surf.faceEdges()[facei];
|
||||||
|
|
||||||
forAll(fEdges, i)
|
for (const label edgei : fEdges)
|
||||||
{
|
{
|
||||||
label edgeI = fEdges[i];
|
if (edgeMid[edgei] == -1)
|
||||||
|
|
||||||
if (edgeMid[edgeI] == -1)
|
|
||||||
{
|
{
|
||||||
const edge& e = surf.edges()[edgeI];
|
const edge& e = surf.edges()[edgei];
|
||||||
|
|
||||||
// Create new point on mid of edge
|
// Create new point on mid of edge
|
||||||
newPoints.append
|
newPoints.append(e.centre(surf.localPoints()));
|
||||||
(
|
edgeMid[edgei] = newVertI++;
|
||||||
0.5
|
|
||||||
* (
|
|
||||||
surf.localPoints()[e.start()]
|
|
||||||
+ surf.localPoints()[e.end()]
|
|
||||||
)
|
|
||||||
);
|
|
||||||
edgeMid[edgeI] = newVertI++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,11 +247,9 @@ Foam::triSurface Foam::triSurfaceTools::doRefine
|
|||||||
|
|
||||||
|
|
||||||
// Create triangles for GREEN refinement.
|
// Create triangles for GREEN refinement.
|
||||||
forAll(fEdges, i)
|
for (const label edgei : fEdges)
|
||||||
{
|
{
|
||||||
const label edgeI = fEdges[i];
|
label otherFacei = otherFace(surf, facei, edgei);
|
||||||
|
|
||||||
label otherFacei = otherFace(surf, facei, edgeI);
|
|
||||||
|
|
||||||
if ((otherFacei != -1) && (refineStatus[otherFacei] == GREEN))
|
if ((otherFacei != -1) && (refineStatus[otherFacei] == GREEN))
|
||||||
{
|
{
|
||||||
@ -272,8 +257,8 @@ Foam::triSurface Foam::triSurfaceTools::doRefine
|
|||||||
(
|
(
|
||||||
surf,
|
surf,
|
||||||
otherFacei,
|
otherFacei,
|
||||||
edgeI,
|
edgei,
|
||||||
edgeMid[edgeI],
|
edgeMid[edgei],
|
||||||
newFaces
|
newFaces
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -335,26 +320,18 @@ void Foam::triSurfaceTools::protectNeighbours
|
|||||||
labelList& faceStatus
|
labelList& faceStatus
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// const labelList& myFaces = surf.pointFaces()[vertI];
|
// for (const label facei : surf.pointFaces()[vertI])
|
||||||
// forAll(myFaces, i)
|
|
||||||
// {
|
// {
|
||||||
// label facei = myFaces[i];
|
|
||||||
//
|
|
||||||
// if ((faceStatus[facei] == ANYEDGE) || (faceStatus[facei] >= 0))
|
// if ((faceStatus[facei] == ANYEDGE) || (faceStatus[facei] >= 0))
|
||||||
// {
|
// {
|
||||||
// faceStatus[facei] = NOEDGE;
|
// faceStatus[facei] = NOEDGE;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
const labelList& myEdges = surf.pointEdges()[vertI];
|
for (const label edgei : surf.pointEdges()[vertI])
|
||||||
forAll(myEdges, i)
|
|
||||||
{
|
{
|
||||||
const labelList& myFaces = surf.edgeFaces()[myEdges[i]];
|
for (const label facei : surf.edgeFaces()[edgei])
|
||||||
|
|
||||||
forAll(myFaces, myFacei)
|
|
||||||
{
|
{
|
||||||
label facei = myFaces[myFacei];
|
|
||||||
|
|
||||||
if ((faceStatus[facei] == ANYEDGE) || (faceStatus[facei] >= 0))
|
if ((faceStatus[facei] == ANYEDGE) || (faceStatus[facei] >= 0))
|
||||||
{
|
{
|
||||||
faceStatus[facei] = NOEDGE;
|
faceStatus[facei] = NOEDGE;
|
||||||
@ -376,8 +353,8 @@ Foam::labelHashSet Foam::triSurfaceTools::getCollapsedFaces
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
const edge& e = surf.edges()[edgeI];
|
const edge& e = surf.edges()[edgeI];
|
||||||
label v1 = e.start();
|
const label v1 = e.start();
|
||||||
label v2 = e.end();
|
const label v2 = e.end();
|
||||||
|
|
||||||
// Faces using edge will certainly get collapsed.
|
// Faces using edge will certainly get collapsed.
|
||||||
const labelList& myFaces = surf.edgeFaces()[edgeI];
|
const labelList& myFaces = surf.edgeFaces()[edgeI];
|
||||||
@ -391,10 +368,8 @@ Foam::labelHashSet Foam::triSurfaceTools::getCollapsedFaces
|
|||||||
// collapses
|
// collapses
|
||||||
const labelList& v1Faces = surf.pointFaces()[v1];
|
const labelList& v1Faces = surf.pointFaces()[v1];
|
||||||
|
|
||||||
forAll(v1Faces, v1Facei)
|
for (const label face1I : v1Faces)
|
||||||
{
|
{
|
||||||
label face1I = v1Faces[v1Facei];
|
|
||||||
|
|
||||||
label otherEdgeI = oppositeEdge(surf, face1I, v1);
|
label otherEdgeI = oppositeEdge(surf, face1I, v1);
|
||||||
|
|
||||||
// Step across edge to other face
|
// Step across edge to other face
|
||||||
@ -425,18 +400,13 @@ Foam::label Foam::triSurfaceTools::vertexUsesFace
|
|||||||
const label vertI
|
const label vertI
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const labelList& myFaces = surf.pointFaces()[vertI];
|
for (const label face1I : surf.pointFaces()[vertI])
|
||||||
|
|
||||||
forAll(myFaces, myFacei)
|
|
||||||
{
|
{
|
||||||
label face1I = myFaces[myFacei];
|
|
||||||
|
|
||||||
if (faceUsed.found(face1I))
|
if (faceUsed.found(face1I))
|
||||||
{
|
{
|
||||||
return face1I;
|
return face1I;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,8 +422,8 @@ void Foam::triSurfaceTools::getMergedEdges
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
const edge& e = surf.edges()[edgeI];
|
const edge& e = surf.edges()[edgeI];
|
||||||
label v1 = e.start();
|
const label v1 = e.start();
|
||||||
label v2 = e.end();
|
const label v2 = e.end();
|
||||||
|
|
||||||
const labelList& v1Faces = surf.pointFaces()[v1];
|
const labelList& v1Faces = surf.pointFaces()[v1];
|
||||||
const labelList& v2Faces = surf.pointFaces()[v2];
|
const labelList& v2Faces = surf.pointFaces()[v2];
|
||||||
@ -461,19 +431,17 @@ void Foam::triSurfaceTools::getMergedEdges
|
|||||||
// Mark all (non collapsed) faces using v2
|
// Mark all (non collapsed) faces using v2
|
||||||
labelHashSet v2FacesHash(v2Faces.size());
|
labelHashSet v2FacesHash(v2Faces.size());
|
||||||
|
|
||||||
forAll(v2Faces, v2Facei)
|
for (const label facei : v2Faces)
|
||||||
{
|
{
|
||||||
if (!collapsedFaces.found(v2Faces[v2Facei]))
|
if (!collapsedFaces.found(facei))
|
||||||
{
|
{
|
||||||
v2FacesHash.insert(v2Faces[v2Facei]);
|
v2FacesHash.insert(facei);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
forAll(v1Faces, v1Facei)
|
for (const label face1I: v1Faces)
|
||||||
{
|
{
|
||||||
label face1I = v1Faces[v1Facei];
|
|
||||||
|
|
||||||
if (collapsedFaces.found(face1I))
|
if (collapsedFaces.found(face1I))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -616,7 +584,6 @@ Foam::scalar Foam::triSurfaceTools::edgeCosAngle
|
|||||||
<< v1 << " of collapsed edge" << abort(FatalError);
|
<< v1 << " of collapsed edge" << abort(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cosAngle;
|
return cosAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,21 +602,15 @@ Foam::scalar Foam::triSurfaceTools::collapseMinCosAngle
|
|||||||
|
|
||||||
scalar minCos = 1;
|
scalar minCos = 1;
|
||||||
|
|
||||||
forAll(v1Faces, v1Facei)
|
for (const label facei : v1Faces)
|
||||||
{
|
{
|
||||||
label facei = v1Faces[v1Facei];
|
|
||||||
|
|
||||||
if (collapsedFaces.found(facei))
|
if (collapsedFaces.found(facei))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const labelList& myEdges = surf.faceEdges()[facei];
|
for (const label edgeI : surf.faceEdges()[facei])
|
||||||
|
|
||||||
forAll(myEdges, myEdgeI)
|
|
||||||
{
|
{
|
||||||
label edgeI = myEdges[myEdgeI];
|
|
||||||
|
|
||||||
minCos =
|
minCos =
|
||||||
min
|
min
|
||||||
(
|
(
|
||||||
@ -688,10 +649,8 @@ bool Foam::triSurfaceTools::collapseCreatesFold
|
|||||||
{
|
{
|
||||||
const labelList& v1Faces = surf.pointFaces()[v1];
|
const labelList& v1Faces = surf.pointFaces()[v1];
|
||||||
|
|
||||||
forAll(v1Faces, v1Facei)
|
for (const label facei : v1Faces)
|
||||||
{
|
{
|
||||||
label facei = v1Faces[v1Facei];
|
|
||||||
|
|
||||||
if (collapsedFaces.found(facei))
|
if (collapsedFaces.found(facei))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@ -699,10 +658,8 @@ bool Foam::triSurfaceTools::collapseCreatesFold
|
|||||||
|
|
||||||
const labelList& myEdges = surf.faceEdges()[facei];
|
const labelList& myEdges = surf.faceEdges()[facei];
|
||||||
|
|
||||||
forAll(myEdges, myEdgeI)
|
for (const label edgeI : myEdges)
|
||||||
{
|
{
|
||||||
label edgeI = myEdges[myEdgeI];
|
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
edgeCosAngle
|
edgeCosAngle
|
||||||
@ -750,10 +707,8 @@ bool Foam::triSurfaceTools::collapseCreatesFold
|
|||||||
//
|
//
|
||||||
// labelList collapsed = collapsedFaces.toc();
|
// labelList collapsed = collapsedFaces.toc();
|
||||||
//
|
//
|
||||||
// forAll(collapsed, collapseI)
|
// for (const label facei : collapsed)
|
||||||
// {
|
// {
|
||||||
// const label facei = collapsed[collapseI];
|
|
||||||
//
|
|
||||||
// const labelList& myEdges = surf.faceEdges()[facei];
|
// const labelList& myEdges = surf.faceEdges()[facei];
|
||||||
//
|
//
|
||||||
// Pout<< "collapsing facei:" << facei << " uses edges:" << myEdges
|
// Pout<< "collapsing facei:" << facei << " uses edges:" << myEdges
|
||||||
@ -1022,7 +977,6 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cut;
|
return cut;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1173,10 +1127,8 @@ Foam::surfaceLocation Foam::triSurfaceTools::visitFaces
|
|||||||
|
|
||||||
scalar minDistSqr = Foam::sqr(GREAT);
|
scalar minDistSqr = Foam::sqr(GREAT);
|
||||||
|
|
||||||
forAll(eFaces, i)
|
for (const label triI : eFaces)
|
||||||
{
|
{
|
||||||
label triI = eFaces[i];
|
|
||||||
|
|
||||||
// Make sure we don't revisit previous face
|
// Make sure we don't revisit previous face
|
||||||
if (triI != start.triangle())
|
if (triI != start.triangle())
|
||||||
{
|
{
|
||||||
@ -1253,10 +1205,8 @@ void Foam::triSurfaceTools::writeOBJ
|
|||||||
{
|
{
|
||||||
OFstream outFile(fName);
|
OFstream outFile(fName);
|
||||||
|
|
||||||
forAll(pts, pointi)
|
for (const point& pt : pts)
|
||||||
{
|
{
|
||||||
const point& pt = pts[pointi];
|
|
||||||
|
|
||||||
outFile<< "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
|
outFile<< "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
|
||||||
}
|
}
|
||||||
Pout<< "Written " << pts.size() << " vertices to file " << fName << endl;
|
Pout<< "Written " << pts.size() << " vertices to file " << fName << endl;
|
||||||
@ -1319,15 +1269,13 @@ void Foam::triSurfaceTools::getVertexTriangles
|
|||||||
edgeTris.setSize(startFaces.size() + endFaces.size() - myFaces.size());
|
edgeTris.setSize(startFaces.size() + endFaces.size() - myFaces.size());
|
||||||
|
|
||||||
label nTris = 0;
|
label nTris = 0;
|
||||||
forAll(startFaces, startFacei)
|
for (const label facei : startFaces)
|
||||||
{
|
{
|
||||||
edgeTris[nTris++] = startFaces[startFacei];
|
edgeTris[nTris++] = facei;
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(endFaces, endFacei)
|
for (const label facei : endFaces)
|
||||||
{
|
{
|
||||||
label facei = endFaces[endFacei];
|
|
||||||
|
|
||||||
if ((facei != face1I) && (facei != face2I))
|
if ((facei != face1I) && (facei != face2I))
|
||||||
{
|
{
|
||||||
edgeTris[nTris++] = facei;
|
edgeTris[nTris++] = facei;
|
||||||
@ -1344,30 +1292,24 @@ Foam::labelList Foam::triSurfaceTools::getVertexVertices
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
const edgeList& edges = surf.edges();
|
const edgeList& edges = surf.edges();
|
||||||
|
const label v1 = e.start();
|
||||||
label v1 = e.start();
|
const label v2 = e.end();
|
||||||
label v2 = e.end();
|
|
||||||
|
|
||||||
// Get all vertices connected to v1 or v2 through an edge
|
// Get all vertices connected to v1 or v2 through an edge
|
||||||
labelHashSet vertexNeighbours;
|
labelHashSet vertexNeighbours;
|
||||||
|
|
||||||
const labelList& v1Edges = surf.pointEdges()[v1];
|
const labelList& v1Edges = surf.pointEdges()[v1];
|
||||||
|
|
||||||
forAll(v1Edges, v1EdgeI)
|
for (const label edgei : v1Edges)
|
||||||
{
|
{
|
||||||
const edge& e = edges[v1Edges[v1EdgeI]];
|
vertexNeighbours.insert(edges[edgei].otherVertex(v1));
|
||||||
vertexNeighbours.insert(e.otherVertex(v1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const labelList& v2Edges = surf.pointEdges()[v2];
|
const labelList& v2Edges = surf.pointEdges()[v2];
|
||||||
|
|
||||||
forAll(v2Edges, v2EdgeI)
|
for (const label edgei : v2Edges)
|
||||||
{
|
{
|
||||||
const edge& e = edges[v2Edges[v2EdgeI]];
|
vertexNeighbours.insert(edges[edgei].otherVertex(v2));
|
||||||
|
|
||||||
label vertI = e.otherVertex(v2);
|
|
||||||
|
|
||||||
vertexNeighbours.insert(vertI);
|
|
||||||
}
|
}
|
||||||
return vertexNeighbours.toc();
|
return vertexNeighbours.toc();
|
||||||
}
|
}
|
||||||
@ -1387,9 +1329,7 @@ Foam::label Foam::triSurfaceTools::otherFace
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else if (facei == myFaces[0])
|
||||||
{
|
|
||||||
if (facei == myFaces[0])
|
|
||||||
{
|
{
|
||||||
return myFaces[1];
|
return myFaces[1];
|
||||||
}
|
}
|
||||||
@ -1397,7 +1337,6 @@ Foam::label Foam::triSurfaceTools::otherFace
|
|||||||
{
|
{
|
||||||
return myFaces[0];
|
return myFaces[0];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1460,7 +1399,8 @@ void Foam::triSurfaceTools::otherVertices
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Vertex " << vertI << " not in face " << f << abort(FatalError);
|
<< "Vertex " << vertI << " not in face " << f << nl
|
||||||
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1475,20 +1415,19 @@ Foam::label Foam::triSurfaceTools::oppositeEdge
|
|||||||
{
|
{
|
||||||
const labelList& myEdges = surf.faceEdges()[facei];
|
const labelList& myEdges = surf.faceEdges()[facei];
|
||||||
|
|
||||||
forAll(myEdges, myEdgeI)
|
for (const label edgei : myEdges)
|
||||||
{
|
{
|
||||||
label edgeI = myEdges[myEdgeI];
|
const edge& e = surf.edges()[edgei];
|
||||||
|
|
||||||
const edge& e = surf.edges()[edgeI];
|
if (!e.found(vertI))
|
||||||
|
|
||||||
if ((e.start() != vertI) && (e.end() != vertI))
|
|
||||||
{
|
{
|
||||||
return edgeI;
|
return edgei;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Cannot find vertex " << vertI << " in edges of face " << facei
|
<< "Cannot find vertex " << vertI << " in edges of face " << facei
|
||||||
|
<< nl
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@ -1506,13 +1445,11 @@ Foam::label Foam::triSurfaceTools::oppositeVertex
|
|||||||
const triSurface::FaceType& f = surf.localFaces()[facei];
|
const triSurface::FaceType& f = surf.localFaces()[facei];
|
||||||
const edge& e = surf.edges()[edgeI];
|
const edge& e = surf.edges()[edgeI];
|
||||||
|
|
||||||
forAll(f, fp)
|
for (const label pointi : f)
|
||||||
{
|
{
|
||||||
label vertI = f[fp];
|
if (!e.found(pointi))
|
||||||
|
|
||||||
if (vertI != e.start() && vertI != e.end())
|
|
||||||
{
|
{
|
||||||
return vertI;
|
return pointi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1534,14 +1471,13 @@ Foam::label Foam::triSurfaceTools::getEdge
|
|||||||
{
|
{
|
||||||
const labelList& v1Edges = surf.pointEdges()[v1];
|
const labelList& v1Edges = surf.pointEdges()[v1];
|
||||||
|
|
||||||
forAll(v1Edges, v1EdgeI)
|
for (const label edgei : v1Edges)
|
||||||
{
|
{
|
||||||
label edgeI = v1Edges[v1EdgeI];
|
const edge& e = surf.edges()[edgei];
|
||||||
const edge& e = surf.edges()[edgeI];
|
|
||||||
|
|
||||||
if ((e.start() == v2) || (e.end() == v2))
|
if (e.found(v2))
|
||||||
{
|
{
|
||||||
return edgeI;
|
return edgei;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -1567,10 +1503,8 @@ Foam::label Foam::triSurfaceTools::getTriangle
|
|||||||
|
|
||||||
const labelList& eFaces = surf.edgeFaces()[e0I];
|
const labelList& eFaces = surf.edgeFaces()[e0I];
|
||||||
|
|
||||||
forAll(eFaces, eFacei)
|
for (const label facei : eFaces)
|
||||||
{
|
{
|
||||||
label facei = eFaces[eFacei];
|
|
||||||
|
|
||||||
const labelList& myEdges = surf.faceEdges()[facei];
|
const labelList& myEdges = surf.faceEdges()[facei];
|
||||||
|
|
||||||
if
|
if
|
||||||
@ -1607,13 +1541,7 @@ Foam::triSurface Foam::triSurfaceTools::collapseEdges
|
|||||||
forAll(edgeMids, edgeI)
|
forAll(edgeMids, edgeI)
|
||||||
{
|
{
|
||||||
const edge& e = surf.edges()[edgeI];
|
const edge& e = surf.edges()[edgeI];
|
||||||
|
edgeMids[edgeI] = e.centre(surf.localPoints());
|
||||||
edgeMids[edgeI] =
|
|
||||||
0.5
|
|
||||||
* (
|
|
||||||
surf.localPoints()[e.start()]
|
|
||||||
+ surf.localPoints()[e.end()]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1674,20 +1602,18 @@ Foam::triSurface Foam::triSurfaceTools::collapseEdges
|
|||||||
|
|
||||||
// Do actual 'collapsing' of edges
|
// Do actual 'collapsing' of edges
|
||||||
|
|
||||||
forAll(collapseEdgeLabels, collapseEdgeI)
|
for (const label edgei : collapseEdgeLabels)
|
||||||
{
|
{
|
||||||
const label edgeI = collapseEdgeLabels[collapseEdgeI];
|
if (edgei < 0 || edgei >= surf.nEdges())
|
||||||
|
|
||||||
if ((edgeI < 0) || (edgeI >= surf.nEdges()))
|
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Edge label outside valid range." << endl
|
<< "Edge label outside valid range." << endl
|
||||||
<< "edge label:" << edgeI << endl
|
<< "edge label:" << edgei << endl
|
||||||
<< "total number of edges:" << surf.nEdges() << endl
|
<< "total number of edges:" << surf.nEdges() << endl
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const labelList& neighbours = edgeFaces[edgeI];
|
const labelList& neighbours = edgeFaces[edgei];
|
||||||
|
|
||||||
if (neighbours.size() == 2)
|
if (neighbours.size() == 2)
|
||||||
{
|
{
|
||||||
@ -1697,11 +1623,11 @@ Foam::triSurface Foam::triSurfaceTools::collapseEdges
|
|||||||
// Check faceStatus to make sure this one can be collapsed
|
// Check faceStatus to make sure this one can be collapsed
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
((stat0 == ANYEDGE) || (stat0 == edgeI))
|
((stat0 == ANYEDGE) || (stat0 == edgei))
|
||||||
&& ((stat1 == ANYEDGE) || (stat1 == edgeI))
|
&& ((stat1 == ANYEDGE) || (stat1 == edgei))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const edge& e = edges[edgeI];
|
const edge& e = edges[edgei];
|
||||||
|
|
||||||
// Set up mapping to 'collapse' points of edge
|
// Set up mapping to 'collapse' points of edge
|
||||||
if
|
if
|
||||||
@ -1712,7 +1638,7 @@ Foam::triSurface Foam::triSurfaceTools::collapseEdges
|
|||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "points already mapped. Double collapse." << endl
|
<< "points already mapped. Double collapse." << endl
|
||||||
<< "edgeI:" << edgeI
|
<< "edgei:" << edgei
|
||||||
<< " start:" << e.start()
|
<< " start:" << e.start()
|
||||||
<< " end:" << e.end()
|
<< " end:" << e.end()
|
||||||
<< " pointMap[start]:" << pointMap[e.start()]
|
<< " pointMap[start]:" << pointMap[e.start()]
|
||||||
@ -1725,7 +1651,7 @@ Foam::triSurface Foam::triSurfaceTools::collapseEdges
|
|||||||
pointMap[e.end()] = minVert;
|
pointMap[e.end()] = minVert;
|
||||||
|
|
||||||
// Move shared vertex to mid of edge
|
// Move shared vertex to mid of edge
|
||||||
newPoints[minVert] = edgeMids[edgeI];
|
newPoints[minVert] = edgeMids[edgei];
|
||||||
|
|
||||||
// Protect neighbouring faces
|
// Protect neighbouring faces
|
||||||
protectNeighbours(surf, e.start(), faceStatus);
|
protectNeighbours(surf, e.start(), faceStatus);
|
||||||
@ -1733,13 +1659,13 @@ Foam::triSurface Foam::triSurfaceTools::collapseEdges
|
|||||||
protectNeighbours
|
protectNeighbours
|
||||||
(
|
(
|
||||||
surf,
|
surf,
|
||||||
oppositeVertex(surf, neighbours[0], edgeI),
|
oppositeVertex(surf, neighbours[0], edgei),
|
||||||
faceStatus
|
faceStatus
|
||||||
);
|
);
|
||||||
protectNeighbours
|
protectNeighbours
|
||||||
(
|
(
|
||||||
surf,
|
surf,
|
||||||
oppositeVertex(surf, neighbours[1], edgeI),
|
oppositeVertex(surf, neighbours[1], edgei),
|
||||||
faceStatus
|
faceStatus
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1748,7 +1674,7 @@ Foam::triSurface Foam::triSurfaceTools::collapseEdges
|
|||||||
getCollapsedFaces
|
getCollapsedFaces
|
||||||
(
|
(
|
||||||
surf,
|
surf,
|
||||||
edgeI
|
edgei
|
||||||
).toc();
|
).toc();
|
||||||
|
|
||||||
forAll(collapseFaces, collapseI)
|
forAll(collapseFaces, collapseI)
|
||||||
@ -1848,17 +1774,15 @@ Foam::triSurface Foam::triSurfaceTools::greenRefine
|
|||||||
|
|
||||||
|
|
||||||
// Refine edges
|
// Refine edges
|
||||||
forAll(refineEdges, refineEdgeI)
|
for (const label edgei : refineEdges)
|
||||||
{
|
{
|
||||||
label edgeI = refineEdges[refineEdgeI];
|
const labelList& myFaces = surf.edgeFaces()[edgei];
|
||||||
|
|
||||||
const labelList& myFaces = surf.edgeFaces()[edgeI];
|
|
||||||
|
|
||||||
bool neighbourIsRefined= false;
|
bool neighbourIsRefined= false;
|
||||||
|
|
||||||
forAll(myFaces, myFacei)
|
for (const label facei : myFaces)
|
||||||
{
|
{
|
||||||
if (refineStatus[myFaces[myFacei]] != NONE)
|
if (refineStatus[facei] != NONE)
|
||||||
{
|
{
|
||||||
neighbourIsRefined = true;
|
neighbourIsRefined = true;
|
||||||
}
|
}
|
||||||
@ -1868,35 +1792,28 @@ Foam::triSurface Foam::triSurfaceTools::greenRefine
|
|||||||
if (!neighbourIsRefined)
|
if (!neighbourIsRefined)
|
||||||
{
|
{
|
||||||
// Refine edge
|
// Refine edge
|
||||||
const edge& e = surf.edges()[edgeI];
|
const edge& e = surf.edges()[edgei];
|
||||||
|
|
||||||
point mid =
|
newPoints[newPointi] = e.centre(surf.localPoints());
|
||||||
0.5
|
|
||||||
* (
|
|
||||||
surf.localPoints()[e.start()]
|
|
||||||
+ surf.localPoints()[e.end()]
|
|
||||||
);
|
|
||||||
|
|
||||||
newPoints[newPointi] = mid;
|
|
||||||
|
|
||||||
// Refine faces using edge
|
// Refine faces using edge
|
||||||
forAll(myFaces, myFacei)
|
for (const label facei : myFaces)
|
||||||
{
|
{
|
||||||
// Add faces to newFaces
|
// Add faces to newFaces
|
||||||
greenRefine
|
greenRefine
|
||||||
(
|
(
|
||||||
surf,
|
surf,
|
||||||
myFaces[myFacei],
|
facei,
|
||||||
edgeI,
|
edgei,
|
||||||
newPointi,
|
newPointi,
|
||||||
newFaces
|
newFaces
|
||||||
);
|
);
|
||||||
|
|
||||||
// Mark as refined
|
// Mark as refined
|
||||||
refineStatus[myFaces[myFacei]] = GREEN;
|
refineStatus[facei] = GREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
newPointi++;
|
++newPointi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1928,26 +1845,23 @@ Foam::label Foam::triSurfaceTools::minEdge
|
|||||||
const labelList& edgeIndices
|
const labelList& edgeIndices
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
scalar minLength = GREAT;
|
scalar minLen = GREAT;
|
||||||
label minIndex = -1;
|
label minEdge = -1;
|
||||||
forAll(edgeIndices, i)
|
|
||||||
{
|
|
||||||
const edge& e = surf.edges()[edgeIndices[i]];
|
|
||||||
|
|
||||||
scalar length =
|
for (const label edgei : edgeIndices)
|
||||||
mag
|
|
||||||
(
|
|
||||||
surf.localPoints()[e.end()]
|
|
||||||
- surf.localPoints()[e.start()]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (length < minLength)
|
|
||||||
{
|
{
|
||||||
minLength = length;
|
const edge& e = surf.edges()[edgei];
|
||||||
minIndex = i;
|
|
||||||
|
const scalar length = e.mag(surf.localPoints());
|
||||||
|
|
||||||
|
if (length < minLen)
|
||||||
|
{
|
||||||
|
minLen = length;
|
||||||
|
minEdge = edgei;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return edgeIndices[minIndex];
|
|
||||||
|
return minEdge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1958,26 +1872,23 @@ Foam::label Foam::triSurfaceTools::maxEdge
|
|||||||
const labelList& edgeIndices
|
const labelList& edgeIndices
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
scalar maxLength = -GREAT;
|
scalar maxLen = -GREAT;
|
||||||
label maxIndex = -1;
|
label maxEdge = -1;
|
||||||
forAll(edgeIndices, i)
|
|
||||||
{
|
|
||||||
const edge& e = surf.edges()[edgeIndices[i]];
|
|
||||||
|
|
||||||
scalar length =
|
for (const label edgei : edgeIndices)
|
||||||
mag
|
|
||||||
(
|
|
||||||
surf.localPoints()[e.end()]
|
|
||||||
- surf.localPoints()[e.start()]
|
|
||||||
);
|
|
||||||
|
|
||||||
if (length > maxLength)
|
|
||||||
{
|
{
|
||||||
maxLength = length;
|
const edge& e = surf.edges()[edgei];
|
||||||
maxIndex = i;
|
|
||||||
|
const scalar length = e.mag(surf.localPoints());
|
||||||
|
|
||||||
|
if (length > maxLen)
|
||||||
|
{
|
||||||
|
maxLen = length;
|
||||||
|
maxEdge = edgei;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return edgeIndices[maxIndex];
|
|
||||||
|
return maxEdge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2368,9 +2279,8 @@ Foam::triSurface Foam::triSurfaceTools::triangulate
|
|||||||
|
|
||||||
label newPatchi = 0;
|
label newPatchi = 0;
|
||||||
|
|
||||||
forAllConstIter(labelHashSet, includePatches, iter)
|
for (const label patchi : includePatches)
|
||||||
{
|
{
|
||||||
const label patchi = iter.key();
|
|
||||||
const polyPatch& patch = bMesh[patchi];
|
const polyPatch& patch = bMesh[patchi];
|
||||||
const pointField& points = patch.points();
|
const pointField& points = patch.points();
|
||||||
|
|
||||||
@ -2425,15 +2335,14 @@ Foam::triSurface Foam::triSurfaceTools::triangulate
|
|||||||
|
|
||||||
newPatchi = 0;
|
newPatchi = 0;
|
||||||
|
|
||||||
forAllConstIter(labelHashSet, includePatches, iter)
|
for (const label patchi : includePatches)
|
||||||
{
|
{
|
||||||
const label patchi = iter.key();
|
|
||||||
const polyPatch& patch = bMesh[patchi];
|
const polyPatch& patch = bMesh[patchi];
|
||||||
|
|
||||||
surface.patches()[newPatchi].name() = patch.name();
|
surface.patches()[newPatchi].name() = patch.name();
|
||||||
surface.patches()[newPatchi].geometricType() = patch.type();
|
surface.patches()[newPatchi].geometricType() = patch.type();
|
||||||
|
|
||||||
newPatchi++;
|
++newPatchi;
|
||||||
}
|
}
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
@ -2544,10 +2453,10 @@ Foam::triSurface Foam::triSurfaceTools::delaunay2D(const List<vector2D>& pts)
|
|||||||
// pts.begin() if double precision.
|
// pts.begin() if double precision.
|
||||||
List<doubleScalar> geompackVertices(2*pts.size());
|
List<doubleScalar> geompackVertices(2*pts.size());
|
||||||
label doubleI = 0;
|
label doubleI = 0;
|
||||||
forAll(pts, i)
|
for (const vector2D& pt : pts)
|
||||||
{
|
{
|
||||||
geompackVertices[doubleI++] = pts[i][0];
|
geompackVertices[doubleI++] = pt[0];
|
||||||
geompackVertices[doubleI++] = pts[i][1];
|
geompackVertices[doubleI++] = pt[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Storage for triangles
|
// Storage for triangles
|
||||||
@ -2656,10 +2565,8 @@ void Foam::triSurfaceTools::calcInterpolationWeights
|
|||||||
|
|
||||||
scalar minDistance = GREAT;
|
scalar minDistance = GREAT;
|
||||||
|
|
||||||
forAll(s, facei)
|
for (const labelledTri& f : s)
|
||||||
{
|
{
|
||||||
const labelledTri& f = s[facei];
|
|
||||||
|
|
||||||
triPointRef tri(f.tri(points));
|
triPointRef tri(f.tri(points));
|
||||||
|
|
||||||
label nearType, nearLabel;
|
label nearType, nearLabel;
|
||||||
@ -2774,9 +2681,9 @@ bool Foam::triSurfaceTools::validTri
|
|||||||
const FaceType& f = surf[facei];
|
const FaceType& f = surf[facei];
|
||||||
|
|
||||||
// Simple check on indices ok.
|
// Simple check on indices ok.
|
||||||
forAll(f, fp)
|
for (const label pointi : f)
|
||||||
{
|
{
|
||||||
if (f[fp] < 0 || f[fp] >= surf.points().size())
|
if (pointi < 0 || pointi >= surf.points().size())
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
@ -2807,10 +2714,8 @@ bool Foam::triSurfaceTools::validTri
|
|||||||
|
|
||||||
// Check if faceNeighbours use same points as this face.
|
// Check if faceNeighbours use same points as this face.
|
||||||
// Note: discards normal information - sides of baffle are merged.
|
// Note: discards normal information - sides of baffle are merged.
|
||||||
forAll(fFaces, i)
|
for (const label nbrFacei : fFaces)
|
||||||
{
|
{
|
||||||
label nbrFacei = fFaces[i];
|
|
||||||
|
|
||||||
if (nbrFacei <= facei)
|
if (nbrFacei <= facei)
|
||||||
{
|
{
|
||||||
// lower numbered faces already checked
|
// lower numbered faces already checked
|
||||||
@ -2867,9 +2772,9 @@ bool Foam::triSurfaceTools::validTri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simple check on indices ok.
|
// Simple check on indices ok.
|
||||||
forAll(f, fp)
|
for (const label pointi : f)
|
||||||
{
|
{
|
||||||
if (f[fp] < 0 || f[fp] >= surf.points().size())
|
if (pointi < 0 || pointi >= surf.points().size())
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
@ -2900,10 +2805,8 @@ bool Foam::triSurfaceTools::validTri
|
|||||||
|
|
||||||
// Check if faceNeighbours use same points as this face.
|
// Check if faceNeighbours use same points as this face.
|
||||||
// Note: discards normal information - sides of baffle are merged.
|
// Note: discards normal information - sides of baffle are merged.
|
||||||
forAll(fFaces, i)
|
for (const label nbrFacei : fFaces)
|
||||||
{
|
{
|
||||||
label nbrFacei = fFaces[i];
|
|
||||||
|
|
||||||
if (nbrFacei <= facei)
|
if (nbrFacei <= facei)
|
||||||
{
|
{
|
||||||
// lower numbered faces already checked
|
// lower numbered faces already checked
|
||||||
@ -3058,7 +2961,6 @@ Foam::surfaceLocation Foam::triSurfaceTools::trackToEdge
|
|||||||
}
|
}
|
||||||
snapToEnd(s, end, nearest);
|
snapToEnd(s, end, nearest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nearest;
|
return nearest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd |
|
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
@ -59,14 +59,13 @@ void Foam::twoDPointCorrector::calcAddressing() const
|
|||||||
// Try and find a wedge patch
|
// Try and find a wedge patch
|
||||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||||
|
|
||||||
forAll(patches, patchi)
|
for (const polyPatch& p : patches)
|
||||||
{
|
{
|
||||||
if (isA<wedgePolyPatch>(patches[patchi]))
|
if (isA<wedgePolyPatch>(p))
|
||||||
{
|
{
|
||||||
isWedge_ = true;
|
isWedge_ = true;
|
||||||
|
|
||||||
const wedgePolyPatch& wp =
|
const wedgePolyPatch& wp = refCast<const wedgePolyPatch>(p);
|
||||||
refCast<const wedgePolyPatch>(patches[patchi]);
|
|
||||||
|
|
||||||
pn = wp.centreNormal();
|
pn = wp.centreNormal();
|
||||||
|
|
||||||
@ -75,7 +74,7 @@ void Foam::twoDPointCorrector::calcAddressing() const
|
|||||||
|
|
||||||
if (polyMesh::debug)
|
if (polyMesh::debug)
|
||||||
{
|
{
|
||||||
Pout<< "Found normal from wedge patch " << patchi;
|
Pout<< "Found normal from wedge patch " << p.index() << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -85,15 +84,15 @@ void Foam::twoDPointCorrector::calcAddressing() const
|
|||||||
// Try to find an empty patch with faces
|
// Try to find an empty patch with faces
|
||||||
if (!isWedge_)
|
if (!isWedge_)
|
||||||
{
|
{
|
||||||
forAll(patches, patchi)
|
for (const polyPatch& p : patches)
|
||||||
{
|
{
|
||||||
if (isA<emptyPolyPatch>(patches[patchi]) && patches[patchi].size())
|
if (isA<emptyPolyPatch>(p) && p.size())
|
||||||
{
|
{
|
||||||
pn = patches[patchi].faceAreas()[0];
|
pn = p.faceAreas()[0];
|
||||||
|
|
||||||
if (polyMesh::debug)
|
if (polyMesh::debug)
|
||||||
{
|
{
|
||||||
Pout<< "Found normal from empty patch " << patchi;
|
Pout<< "Found normal from empty patch " << p.index() << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -115,7 +114,7 @@ void Foam::twoDPointCorrector::calcAddressing() const
|
|||||||
|
|
||||||
if (polyMesh::debug)
|
if (polyMesh::debug)
|
||||||
{
|
{
|
||||||
Pout<< " twoDPointCorrector normal: " << pn << endl;
|
Pout<< " twoDPointCorrector normal: " << pn << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Select edges to be included in check.
|
// Select edges to be included in check.
|
||||||
@ -132,7 +131,7 @@ void Foam::twoDPointCorrector::calcAddressing() const
|
|||||||
{
|
{
|
||||||
const edge& e = meshEdges[edgeI];
|
const edge& e = meshEdges[edgeI];
|
||||||
|
|
||||||
vector edgeVector = e.vec(meshPoints)/(e.mag(meshPoints) + VSMALL);
|
vector edgeVector = e.unitVec(meshPoints);
|
||||||
|
|
||||||
if (mag(edgeVector & pn) > edgeOrthogonalityTol)
|
if (mag(edgeVector & pn) > edgeOrthogonalityTol)
|
||||||
{
|
{
|
||||||
@ -235,15 +234,13 @@ Foam::direction Foam::twoDPointCorrector::normalDir() const
|
|||||||
{
|
{
|
||||||
return vector::Z;
|
return vector::Z;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Plane normal not aligned with the coordinate system" << nl
|
<< "Plane normal not aligned with the coordinate system" << nl
|
||||||
<< " pn = " << pn
|
<< " pn = " << pn
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
|
|
||||||
return vector::Z;
|
return vector::Z;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -284,11 +281,11 @@ void Foam::twoDPointCorrector::correctPoints(pointField& p) const
|
|||||||
const labelList& neIndices = normalEdgeIndices();
|
const labelList& neIndices = normalEdgeIndices();
|
||||||
const vector& pn = planeNormal();
|
const vector& pn = planeNormal();
|
||||||
|
|
||||||
forAll(neIndices, edgeI)
|
for (const label edgei : neIndices)
|
||||||
{
|
{
|
||||||
point& pStart = p[meshEdges[neIndices[edgeI]].start()];
|
point& pStart = p[meshEdges[edgei].start()];
|
||||||
|
|
||||||
point& pEnd = p[meshEdges[neIndices[edgeI]].end()];
|
point& pEnd = p[meshEdges[edgei].end()];
|
||||||
|
|
||||||
// calculate average point position
|
// calculate average point position
|
||||||
point A = 0.5*(pStart + pEnd);
|
point A = 0.5*(pStart + pEnd);
|
||||||
@ -328,9 +325,9 @@ void Foam::twoDPointCorrector::correctDisplacement
|
|||||||
const labelList& neIndices = normalEdgeIndices();
|
const labelList& neIndices = normalEdgeIndices();
|
||||||
const vector& pn = planeNormal();
|
const vector& pn = planeNormal();
|
||||||
|
|
||||||
forAll(neIndices, edgeI)
|
for (const label edgei : neIndices)
|
||||||
{
|
{
|
||||||
const edge& e = meshEdges[neIndices[edgeI]];
|
const edge& e = meshEdges[edgei];
|
||||||
|
|
||||||
label startPointi = e.start();
|
label startPointi = e.start();
|
||||||
point pStart = p[startPointi] + disp[startPointi];
|
point pStart = p[startPointi] + disp[startPointi];
|
||||||
|
|||||||
Reference in New Issue
Block a user