mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: optional saving of illegal edges in patch surfaceType() check
- reduce some intermediate storage in looping STYLE: explicit iterator dereference in syncTools
This commit is contained in:
@ -32,8 +32,8 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef dummyTransform_H
|
||||
#define dummyTransform_H
|
||||
#ifndef Foam_dummyTransform_H
|
||||
#define Foam_dummyTransform_H
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -42,8 +42,8 @@ SourceFiles
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef syncTools_H
|
||||
#define syncTools_H
|
||||
#ifndef Foam_syncTools_H
|
||||
#define Foam_syncTools_H
|
||||
|
||||
#include "Pstream.H"
|
||||
#include "edgeHashes.H"
|
||||
@ -170,7 +170,7 @@ public:
|
||||
UList<T>& faceValues,
|
||||
const CombineOp& cop,
|
||||
const TransformOp& top,
|
||||
const bool parRun = Pstream::parRun()
|
||||
const bool parRun = UPstream::parRun()
|
||||
);
|
||||
|
||||
|
||||
@ -609,7 +609,7 @@ public:
|
||||
const bool isBoundaryOnly,
|
||||
PackedList<Width>& faceValues,
|
||||
const CombineOp& cop,
|
||||
const bool parRun = Pstream::parRun()
|
||||
const bool parRun = UPstream::parRun()
|
||||
);
|
||||
|
||||
//- Synchronize mesh face values from PackedList/bitSet
|
||||
@ -619,7 +619,7 @@ public:
|
||||
const polyMesh& mesh,
|
||||
PackedList<Width>& faceValues,
|
||||
const CombineOp& cop,
|
||||
const bool parRun = Pstream::parRun()
|
||||
const bool parRun = UPstream::parRun()
|
||||
);
|
||||
|
||||
//- Synchronize boundary face values from PackedList/bitSet
|
||||
@ -629,7 +629,7 @@ public:
|
||||
const polyMesh& mesh,
|
||||
PackedList<Width>& faceValues,
|
||||
const CombineOp& cop,
|
||||
const bool parRun = Pstream::parRun()
|
||||
const bool parRun = UPstream::parRun()
|
||||
);
|
||||
|
||||
//- Swap coupled face values. Uses eqOp
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2015-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2015-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -48,7 +48,7 @@ void Foam::syncTools::combine
|
||||
|
||||
if (iter.good())
|
||||
{
|
||||
cop(*iter, val);
|
||||
cop(iter.val(), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -70,7 +70,7 @@ void Foam::syncTools::combine
|
||||
|
||||
if (iter.good())
|
||||
{
|
||||
cop(*iter, val);
|
||||
cop(iter.val(), val);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -118,17 +118,17 @@ void Foam::syncTools::syncPointMap
|
||||
sharedPointValues,
|
||||
cop,
|
||||
sharedPtAddr[i], // index
|
||||
*fnd // value
|
||||
fnd.val() // value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (Pstream::parRun())
|
||||
if (UPstream::parRun())
|
||||
{
|
||||
DynamicList<label> neighbProcs;
|
||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
||||
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
|
||||
|
||||
// Send
|
||||
for (const polyPatch& pp : patches)
|
||||
@ -140,7 +140,7 @@ void Foam::syncTools::syncPointMap
|
||||
const auto& procPatch = *ppp;
|
||||
const label nbrProci = procPatch.neighbProcNo();
|
||||
|
||||
neighbProcs.append(nbrProci);
|
||||
neighbProcs.push_back(nbrProci);
|
||||
|
||||
// Get data per patchPoint in neighbouring point numbers.
|
||||
|
||||
@ -157,7 +157,7 @@ void Foam::syncTools::syncPointMap
|
||||
|
||||
if (iter.good())
|
||||
{
|
||||
patchInfo.insert(nbrPts[i], *iter);
|
||||
patchInfo.insert(nbrPts[i], iter.val());
|
||||
}
|
||||
}
|
||||
|
||||
@ -300,14 +300,14 @@ void Foam::syncTools::syncPointMap
|
||||
|
||||
// Reduce on master.
|
||||
|
||||
if (Pstream::parRun())
|
||||
if (UPstream::parRun())
|
||||
{
|
||||
if (Pstream::master())
|
||||
if (UPstream::master())
|
||||
{
|
||||
// Receive the edges using shared points from other procs
|
||||
for (const int proci : Pstream::subProcs())
|
||||
for (const int proci : UPstream::subProcs())
|
||||
{
|
||||
IPstream fromProc(Pstream::commsTypes::scheduled, proci);
|
||||
IPstream fromProc(UPstream::commsTypes::scheduled, proci);
|
||||
Map<T> nbrValues(fromProc);
|
||||
|
||||
// Merge neighbouring values with my values
|
||||
@ -328,8 +328,8 @@ void Foam::syncTools::syncPointMap
|
||||
// Send to master
|
||||
OPstream toMaster
|
||||
(
|
||||
Pstream::commsTypes::scheduled,
|
||||
Pstream::masterNo()
|
||||
UPstream::commsTypes::scheduled,
|
||||
UPstream::masterNo()
|
||||
);
|
||||
toMaster << sharedPointValues;
|
||||
}
|
||||
@ -355,7 +355,7 @@ void Foam::syncTools::syncPointMap
|
||||
|
||||
if (sharedFnd.good())
|
||||
{
|
||||
pointValues.set(*iter, *sharedFnd);
|
||||
pointValues.set(iter.val(), sharedFnd.val());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -381,10 +381,10 @@ void Foam::syncTools::syncEdgeMap
|
||||
// Swap proc patch info
|
||||
// ~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if (Pstream::parRun())
|
||||
if (UPstream::parRun())
|
||||
{
|
||||
DynamicList<label> neighbProcs;
|
||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
||||
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
|
||||
|
||||
// Send
|
||||
for (const polyPatch& pp : patches)
|
||||
@ -396,7 +396,7 @@ void Foam::syncTools::syncEdgeMap
|
||||
const auto& procPatch = *ppp;
|
||||
const label nbrProci = procPatch.neighbProcNo();
|
||||
|
||||
neighbProcs.append(nbrProci);
|
||||
neighbProcs.push_back(nbrProci);
|
||||
|
||||
// Get data per patch edge in neighbouring edge.
|
||||
|
||||
@ -408,14 +408,14 @@ void Foam::syncTools::syncEdgeMap
|
||||
|
||||
for (const edge& e : edges)
|
||||
{
|
||||
const edge meshEdge(meshPts[e[0]], meshPts[e[1]]);
|
||||
const edge meshEdge(meshPts, e);
|
||||
|
||||
const auto iter = edgeValues.cfind(meshEdge);
|
||||
|
||||
if (iter.good())
|
||||
{
|
||||
const edge nbrEdge(nbrPts[e[0]], nbrPts[e[1]]);
|
||||
patchInfo.insert(nbrEdge, *iter);
|
||||
const edge nbrEdge(nbrPts, e);
|
||||
patchInfo.insert(nbrEdge, iter.val());
|
||||
}
|
||||
}
|
||||
|
||||
@ -515,7 +515,7 @@ void Foam::syncTools::syncEdgeMap
|
||||
|
||||
if (iter.good())
|
||||
{
|
||||
half0Values.insert(edgei, *iter);
|
||||
half0Values.insert(edgei, iter.val());
|
||||
}
|
||||
}
|
||||
{
|
||||
@ -526,7 +526,7 @@ void Foam::syncTools::syncEdgeMap
|
||||
|
||||
if (iter.good())
|
||||
{
|
||||
half1Values.insert(edgei, *iter);
|
||||
half1Values.insert(edgei, iter.val());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -653,14 +653,14 @@ void Foam::syncTools::syncEdgeMap
|
||||
// shared edge).
|
||||
// Reduce this on the master.
|
||||
|
||||
if (Pstream::parRun())
|
||||
if (UPstream::parRun())
|
||||
{
|
||||
if (Pstream::master())
|
||||
if (UPstream::master())
|
||||
{
|
||||
// Receive the edges using shared points from other procs
|
||||
for (const int proci : Pstream::subProcs())
|
||||
for (const int proci : UPstream::subProcs())
|
||||
{
|
||||
IPstream fromProc(Pstream::commsTypes::scheduled, proci);
|
||||
IPstream fromProc(UPstream::commsTypes::scheduled, proci);
|
||||
EdgeMap<T> nbrValues(fromProc);
|
||||
|
||||
// Merge neighbouring values with my values
|
||||
@ -682,8 +682,8 @@ void Foam::syncTools::syncEdgeMap
|
||||
{
|
||||
OPstream toMaster
|
||||
(
|
||||
Pstream::commsTypes::scheduled,
|
||||
Pstream::masterNo()
|
||||
UPstream::commsTypes::scheduled,
|
||||
UPstream::masterNo()
|
||||
);
|
||||
toMaster << sharedEdgeValues;
|
||||
}
|
||||
@ -772,7 +772,7 @@ void Foam::syncTools::syncPointList
|
||||
|
||||
if (iter.good())
|
||||
{
|
||||
cppFld[*iter] = pointValues[i];
|
||||
cppFld[iter.val()] = pointValues[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -793,7 +793,7 @@ void Foam::syncTools::syncPointList
|
||||
|
||||
if (iter.good())
|
||||
{
|
||||
pointValues[i] = cppFld[*iter];
|
||||
pointValues[i] = cppFld[iter.val()];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1028,7 +1028,7 @@ void Foam::syncTools::syncBoundaryFaceList
|
||||
if
|
||||
(
|
||||
is_contiguous<T>::value
|
||||
&& Pstream::defaultCommsType == Pstream::commsTypes::nonBlocking
|
||||
&& UPstream::defaultCommsType == UPstream::commsTypes::nonBlocking
|
||||
)
|
||||
{
|
||||
const label startRequest = UPstream::nRequests();
|
||||
@ -1054,7 +1054,7 @@ void Foam::syncTools::syncBoundaryFaceList
|
||||
|
||||
UIPstream::read
|
||||
(
|
||||
Pstream::commsTypes::nonBlocking,
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
procPatch.neighbProcNo(),
|
||||
fld.data_bytes(),
|
||||
fld.size_bytes()
|
||||
@ -1080,7 +1080,7 @@ void Foam::syncTools::syncBoundaryFaceList
|
||||
|
||||
UOPstream::write
|
||||
(
|
||||
Pstream::commsTypes::nonBlocking,
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
procPatch.neighbProcNo(),
|
||||
fld.cdata_bytes(),
|
||||
fld.size_bytes()
|
||||
@ -1126,7 +1126,7 @@ void Foam::syncTools::syncBoundaryFaceList
|
||||
else
|
||||
{
|
||||
DynamicList<label> neighbProcs;
|
||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
||||
PstreamBuffers pBufs(UPstream::commsTypes::nonBlocking);
|
||||
|
||||
// Send
|
||||
for (const polyPatch& pp : patches)
|
||||
@ -1138,7 +1138,7 @@ void Foam::syncTools::syncBoundaryFaceList
|
||||
const auto& procPatch = *ppp;
|
||||
const label nbrProci = procPatch.neighbProcNo();
|
||||
|
||||
neighbProcs.append(nbrProci);
|
||||
neighbProcs.push_back(nbrProci);
|
||||
|
||||
const SubList<T> fld
|
||||
(
|
||||
@ -1289,7 +1289,7 @@ void Foam::syncTools::syncFaceList
|
||||
|
||||
UIPstream::read
|
||||
(
|
||||
Pstream::commsTypes::nonBlocking,
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
procPatch.neighbProcNo(),
|
||||
recvInfo.data_bytes(),
|
||||
recvInfo.size_bytes()
|
||||
@ -1324,7 +1324,7 @@ void Foam::syncTools::syncFaceList
|
||||
|
||||
UOPstream::write
|
||||
(
|
||||
Pstream::commsTypes::nonBlocking,
|
||||
UPstream::commsTypes::nonBlocking,
|
||||
procPatch.neighbProcNo(),
|
||||
sendInfo.cdata_bytes(),
|
||||
sendInfo.size_bytes()
|
||||
@ -1333,7 +1333,7 @@ void Foam::syncTools::syncFaceList
|
||||
}
|
||||
|
||||
// Wait for all comms to finish
|
||||
Pstream::waitRequests(startRequest);
|
||||
UPstream::waitRequests(startRequest);
|
||||
|
||||
// Combine with existing data
|
||||
for (const polyPatch& pp : patches)
|
||||
|
||||
@ -92,7 +92,7 @@ void Foam::PatchTools::gatherAndMerge
|
||||
|
||||
labelList boundaryPoints;
|
||||
|
||||
if (Pstream::parRun())
|
||||
if (UPstream::parRun())
|
||||
{
|
||||
const globalIndex localPointAddr
|
||||
(
|
||||
@ -117,7 +117,7 @@ void Foam::PatchTools::gatherAndMerge
|
||||
}
|
||||
|
||||
|
||||
if (Pstream::parRun() && Pstream::master())
|
||||
if (UPstream::parRun() && UPstream::master())
|
||||
{
|
||||
labelList pointToUnique;
|
||||
|
||||
@ -206,7 +206,7 @@ void Foam::PatchTools::gatherAndMerge
|
||||
{
|
||||
typedef typename FaceList::value_type FaceType;
|
||||
|
||||
if (Pstream::parRun())
|
||||
if (UPstream::parRun())
|
||||
{
|
||||
// Renumber the points/faces into unique points
|
||||
globalPointsPtr = mesh.globalData().mergePoints
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -111,6 +111,7 @@ public:
|
||||
// Public Data Types
|
||||
|
||||
//- Enumeration defining the surface type. Used in check routines.
|
||||
// Ordered from 'good' to 'bad'
|
||||
enum surfaceTopo
|
||||
{
|
||||
MANIFOLD,
|
||||
@ -242,10 +243,10 @@ private:
|
||||
void visitPointRegion
|
||||
(
|
||||
const label pointi,
|
||||
const labelList& pFaces,
|
||||
const labelUList& pFaces,
|
||||
const label startFacei,
|
||||
const label startEdgeI,
|
||||
boolList& pFacesHad
|
||||
const label startEdgei,
|
||||
UList<bool>& pFacesVisited
|
||||
) const;
|
||||
|
||||
|
||||
@ -525,12 +526,14 @@ public:
|
||||
|
||||
// Check
|
||||
|
||||
//- Calculate surface type formed by patch.
|
||||
// Types:
|
||||
//- Calculate surface type formed by patch,
|
||||
//- optionally recording the indices of illegal edges.
|
||||
//
|
||||
// Return types:
|
||||
// - all edges have two neighbours (manifold)
|
||||
// - some edges have more than two neighbours (illegal)
|
||||
// - other (open)
|
||||
surfaceTopo surfaceType() const;
|
||||
surfaceTopo surfaceType(labelHashSet* badEdgesPtr = nullptr) const;
|
||||
|
||||
//- Check surface formed by patch for manifoldness (see above).
|
||||
// Return true if any incorrect edges are found.
|
||||
@ -538,7 +541,7 @@ public:
|
||||
bool checkTopology
|
||||
(
|
||||
const bool report = false,
|
||||
labelHashSet* setPtr = nullptr
|
||||
labelHashSet* pointSetPtr = nullptr
|
||||
) const;
|
||||
|
||||
//- Checks primitivePatch for faces sharing point but not edge.
|
||||
@ -550,7 +553,7 @@ public:
|
||||
bool checkPointManifold
|
||||
(
|
||||
const bool report = false,
|
||||
labelHashSet* setPtr = nullptr
|
||||
labelHashSet* pointSetPtr = nullptr
|
||||
) const;
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -31,7 +31,7 @@ Description
|
||||
|
||||
#include "PrimitivePatch.H"
|
||||
#include "Map.H"
|
||||
#include "ListOps.H"
|
||||
#include "DynamicList.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -40,60 +40,54 @@ void
|
||||
Foam::PrimitivePatch<FaceList, PointField>::visitPointRegion
|
||||
(
|
||||
const label pointi,
|
||||
const labelList& pFaces,
|
||||
const labelUList& pFaces,
|
||||
const label startFacei,
|
||||
const label startEdgeI,
|
||||
boolList& pFacesHad
|
||||
const label startEdgei,
|
||||
UList<bool>& pFacesVisited
|
||||
) const
|
||||
{
|
||||
label index = pFaces.find(startFacei);
|
||||
const label index = pFaces.find(startFacei);
|
||||
|
||||
if (!pFacesHad[index])
|
||||
if (index >= 0 && !pFacesVisited[index])
|
||||
{
|
||||
// Mark face as been visited.
|
||||
pFacesHad[index] = true;
|
||||
// Mark face as visited
|
||||
pFacesVisited[index] = true;
|
||||
|
||||
// Step to next edge on face which is still using pointi
|
||||
const labelList& fEdges = faceEdges()[startFacei];
|
||||
label nextEdgei = -1;
|
||||
|
||||
label nextEdgeI = -1;
|
||||
|
||||
forAll(fEdges, i)
|
||||
for (const label faceEdgei : faceEdges()[startFacei])
|
||||
{
|
||||
label edgeI = fEdges[i];
|
||||
const edge& e = edges()[faceEdgei];
|
||||
|
||||
const edge& e = edges()[edgeI];
|
||||
|
||||
if (edgeI != startEdgeI && (e[0] == pointi || e[1] == pointi))
|
||||
if (faceEdgei != startEdgei && e.contains(pointi))
|
||||
{
|
||||
nextEdgeI = edgeI;
|
||||
|
||||
nextEdgei = faceEdgei;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nextEdgeI == -1)
|
||||
if (nextEdgei == -1)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Problem: cannot find edge out of " << fEdges
|
||||
<< "Problem: cannot find edge out of "
|
||||
<< faceEdges()[startFacei]
|
||||
<< "on face " << startFacei << " that uses point " << pointi
|
||||
<< " and is not edge " << startEdgeI << abort(FatalError);
|
||||
<< " and is not edge " << startEdgei << abort(FatalError);
|
||||
}
|
||||
|
||||
// Walk to next face(s) across edge.
|
||||
const labelList& eFaces = edgeFaces()[nextEdgeI];
|
||||
|
||||
forAll(eFaces, i)
|
||||
for (const label edgeFacei : edgeFaces()[nextEdgei])
|
||||
{
|
||||
if (eFaces[i] != startFacei)
|
||||
if (edgeFacei != startFacei)
|
||||
{
|
||||
visitPointRegion
|
||||
(
|
||||
pointi,
|
||||
pFaces,
|
||||
eFaces[i],
|
||||
nextEdgeI,
|
||||
pFacesHad
|
||||
edgeFacei,
|
||||
nextEdgei,
|
||||
pFacesVisited
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -105,33 +99,56 @@ Foam::PrimitivePatch<FaceList, PointField>::visitPointRegion
|
||||
|
||||
template<class FaceList, class PointField>
|
||||
typename Foam::PrimitivePatch<FaceList, PointField>::surfaceTopo
|
||||
Foam::PrimitivePatch<FaceList, PointField>::surfaceType() const
|
||||
Foam::PrimitivePatch<FaceList, PointField>::surfaceType
|
||||
(
|
||||
labelHashSet* badEdgesPtr
|
||||
) const
|
||||
{
|
||||
DebugInFunction << "Calculating patch topology" << nl;
|
||||
if (badEdgesPtr)
|
||||
{
|
||||
badEdgesPtr->clear();
|
||||
}
|
||||
|
||||
bool foundError = false;
|
||||
|
||||
surfaceTopo pType = surfaceTopo::MANIFOLD;
|
||||
|
||||
const labelListList& edgeFcs = edgeFaces();
|
||||
|
||||
surfaceTopo pType = MANIFOLD;
|
||||
|
||||
forAll(edgeFcs, edgeI)
|
||||
forAll(edgeFcs, edgei)
|
||||
{
|
||||
label nNbrs = edgeFcs[edgeI].size();
|
||||
const label nNbrs = edgeFcs[edgei].size();
|
||||
|
||||
if (nNbrs < 1 || nNbrs > 2)
|
||||
{
|
||||
pType = ILLEGAL;
|
||||
// Surface is illegal
|
||||
foundError = true;
|
||||
|
||||
// Can exit now. Surface is illegal.
|
||||
return pType;
|
||||
if (badEdgesPtr)
|
||||
{
|
||||
// Record and continue
|
||||
if (nNbrs > 2)
|
||||
{
|
||||
badEdgesPtr->insert(edgei);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Early exit when not recording bad edges
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (nNbrs == 1)
|
||||
{
|
||||
// Surface might be open or illegal so keep looping.
|
||||
pType = OPEN;
|
||||
pType = surfaceTopo::OPEN;
|
||||
}
|
||||
}
|
||||
|
||||
DebugInFunction << "Calculated patch topology" << nl;
|
||||
if (foundError)
|
||||
{
|
||||
return surfaceTopo::ILLEGAL;
|
||||
}
|
||||
|
||||
return pType;
|
||||
}
|
||||
@ -142,45 +159,40 @@ bool
|
||||
Foam::PrimitivePatch<FaceList, PointField>::checkTopology
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
labelHashSet* pointSetPtr
|
||||
) const
|
||||
{
|
||||
DebugInFunction << "Checking patch topology" << nl;
|
||||
|
||||
// Check edgeFaces
|
||||
|
||||
bool foundError = false;
|
||||
|
||||
const labelListList& edgeFcs = edgeFaces();
|
||||
|
||||
bool illegalTopo = false;
|
||||
|
||||
forAll(edgeFcs, edgeI)
|
||||
forAll(edgeFcs, edgei)
|
||||
{
|
||||
label nNbrs = edgeFcs[edgeI].size();
|
||||
const label nNbrs = edgeFcs[edgei].size();
|
||||
|
||||
if (nNbrs < 1 || nNbrs > 2)
|
||||
{
|
||||
illegalTopo = true;
|
||||
foundError = true;
|
||||
|
||||
if (report)
|
||||
{
|
||||
Info<< "Edge " << edgeI << " with vertices:" << edges()[edgeI]
|
||||
<< " has " << nNbrs << " face neighbours"
|
||||
<< endl;
|
||||
Info<< "Edge " << edgei << " with vertices:" << edges()[edgei]
|
||||
<< " has " << nNbrs << " face neighbours" << endl;
|
||||
}
|
||||
|
||||
if (setPtr)
|
||||
if (pointSetPtr)
|
||||
{
|
||||
const edge& e = edges()[edgeI];
|
||||
const edge& e = edges()[edgei];
|
||||
|
||||
setPtr->insert(meshPoints()[e.start()]);
|
||||
setPtr->insert(meshPoints()[e.end()]);
|
||||
pointSetPtr->insert(meshPoints()[e.first()]);
|
||||
pointSetPtr->insert(meshPoints()[e.second()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DebugInFunction << "Checked patch topology" << nl;
|
||||
|
||||
return illegalTopo;
|
||||
return foundError;
|
||||
}
|
||||
|
||||
|
||||
@ -189,7 +201,7 @@ bool
|
||||
Foam::PrimitivePatch<FaceList, PointField>::checkPointManifold
|
||||
(
|
||||
const bool report,
|
||||
labelHashSet* setPtr
|
||||
labelHashSet* pointSetPtr
|
||||
) const
|
||||
{
|
||||
const labelListList& pf = pointFaces();
|
||||
@ -199,47 +211,48 @@ Foam::PrimitivePatch<FaceList, PointField>::checkPointManifold
|
||||
|
||||
bool foundError = false;
|
||||
|
||||
// Visited faces (as indices into pFaces)
|
||||
DynamicList<bool> pFacesVisited;
|
||||
|
||||
forAll(pf, pointi)
|
||||
{
|
||||
const labelList& pFaces = pf[pointi];
|
||||
|
||||
// Visited faces (as indices into pFaces)
|
||||
boolList pFacesHad(pFaces.size(), false);
|
||||
pFacesVisited.resize_nocopy(pFaces.size());
|
||||
pFacesVisited = false;
|
||||
|
||||
// Starting edge
|
||||
const labelList& pEdges = pe[pointi];
|
||||
label startEdgeI = pEdges[0];
|
||||
const label startEdgei = pEdges[0];
|
||||
|
||||
const labelList& eFaces = ef[startEdgeI];
|
||||
const labelList& eFaces = ef[startEdgei];
|
||||
|
||||
forAll(eFaces, i)
|
||||
for (const label edgeFacei : eFaces)
|
||||
{
|
||||
// Visit all faces using pointi, starting from eFaces[i] and
|
||||
// startEdgeI. Mark off all faces visited in pFacesHad.
|
||||
// startEdgei. Mark off all faces visited in pFacesVisited.
|
||||
this->visitPointRegion
|
||||
(
|
||||
pointi,
|
||||
pFaces,
|
||||
eFaces[i], // starting face for walk
|
||||
startEdgeI, // starting edge for walk
|
||||
pFacesHad
|
||||
edgeFacei, // starting face for walk
|
||||
startEdgei, // starting edge for walk
|
||||
pFacesVisited
|
||||
);
|
||||
}
|
||||
|
||||
// After this all faces using pointi should have been visited and
|
||||
// marked off in pFacesHad.
|
||||
// marked off in pFacesVisited.
|
||||
|
||||
label unset = pFacesHad.find(false);
|
||||
|
||||
if (unset != -1)
|
||||
if (pFacesVisited.contains(false))
|
||||
{
|
||||
foundError = true;
|
||||
|
||||
label meshPointi = mp[pointi];
|
||||
const label meshPointi = mp[pointi];
|
||||
|
||||
if (setPtr)
|
||||
if (pointSetPtr)
|
||||
{
|
||||
setPtr->insert(meshPointi);
|
||||
pointSetPtr->insert(meshPointi);
|
||||
}
|
||||
|
||||
if (report)
|
||||
@ -251,18 +264,18 @@ Foam::PrimitivePatch<FaceList, PointField>::checkPointManifold
|
||||
<< " is multiply connected at this point" << nl
|
||||
<< "Connected (patch) faces:" << nl;
|
||||
|
||||
forAll(pFacesHad, i)
|
||||
forAll(pFacesVisited, i)
|
||||
{
|
||||
if (pFacesHad[i])
|
||||
if (pFacesVisited[i])
|
||||
{
|
||||
Info<< " " << pFaces[i] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< nl << "Unconnected (patch) faces:" << nl;
|
||||
forAll(pFacesHad, i)
|
||||
forAll(pFacesVisited, i)
|
||||
{
|
||||
if (!pFacesHad[i])
|
||||
if (!pFacesVisited[i])
|
||||
{
|
||||
Info<< " " << pFaces[i] << endl;
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -50,7 +50,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcEdgeLoops() const
|
||||
|
||||
const edgeList& patchEdges = edges();
|
||||
const label nIntEdges = nInternalEdges();
|
||||
const label nBdryEdges = patchEdges.size() - nIntEdges;
|
||||
const label nBdryEdges = (patchEdges.size() - nIntEdges);
|
||||
|
||||
// Size return list plenty big
|
||||
edgeLoopsPtr_.reset(new labelListList(nBdryEdges));
|
||||
@ -68,74 +68,61 @@ Foam::PrimitivePatch<FaceList, PointField>::calcEdgeLoops() const
|
||||
// Walk point-edge-point and assign loop number
|
||||
//
|
||||
|
||||
// Loop per (boundary) edge.
|
||||
labelList loopNumber(nBdryEdges, -1);
|
||||
|
||||
// Current loop number.
|
||||
label loopI = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Find edge not yet given a loop number.
|
||||
label currentEdgeI = -1;
|
||||
|
||||
for (label edgeI = nIntEdges; edgeI < patchEdges.size(); edgeI++)
|
||||
{
|
||||
if (loopNumber[edgeI-nIntEdges] == -1)
|
||||
{
|
||||
currentEdgeI = edgeI;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentEdgeI == -1)
|
||||
{
|
||||
// Did not find edge not yet assigned a loop number so done all.
|
||||
break;
|
||||
}
|
||||
|
||||
// Temporary storage for vertices of current loop
|
||||
DynamicList<label> loop(nBdryEdges);
|
||||
|
||||
// In a loop? - per boundary edge
|
||||
boolList unvisited(nBdryEdges, true);
|
||||
|
||||
// Current loop number
|
||||
label numLoops = 0;
|
||||
|
||||
// Walk all boundary edges not yet in a loop
|
||||
for
|
||||
(
|
||||
label bndEdgei = -1;
|
||||
(bndEdgei = unvisited.find(true)) >= 0;
|
||||
/*nil*/
|
||||
)
|
||||
{
|
||||
label currentEdgei = (bndEdgei + nIntEdges);
|
||||
|
||||
// Walk from first all the way round, assigning loops
|
||||
label currentVertI = patchEdges[currentEdgeI].start();
|
||||
label currentVerti = patchEdges[currentEdgei].first();
|
||||
|
||||
loop.clear();
|
||||
|
||||
do
|
||||
{
|
||||
loop.append(currentVertI);
|
||||
loop.push_back(currentVerti);
|
||||
|
||||
loopNumber[currentEdgeI - nIntEdges] = loopI;
|
||||
unvisited[currentEdgei - nIntEdges] = false;
|
||||
|
||||
// Step to next vertex
|
||||
currentVertI = patchEdges[currentEdgeI].otherVertex(currentVertI);
|
||||
currentVerti = patchEdges[currentEdgei].otherVertex(currentVerti);
|
||||
|
||||
// Step to next (unmarked, boundary) edge.
|
||||
const labelList& curEdges = patchPointEdges[currentVertI];
|
||||
currentEdgei = -1;
|
||||
|
||||
currentEdgeI = -1;
|
||||
|
||||
forAll(curEdges, pI)
|
||||
for (const label edgei : patchPointEdges[currentVerti])
|
||||
{
|
||||
label edgeI = curEdges[pI];
|
||||
|
||||
if (edgeI >= nIntEdges && (loopNumber[edgeI - nIntEdges] == -1))
|
||||
if (edgei >= nIntEdges && unvisited[edgei - nIntEdges])
|
||||
{
|
||||
// Unassigned boundary edge.
|
||||
currentEdgeI = edgeI;
|
||||
|
||||
// Unvisited boundary edge
|
||||
currentEdgei = edgei;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (currentEdgeI != -1);
|
||||
while (currentEdgei != -1);
|
||||
|
||||
// Done all for current loop. Transfer to edgeLoops.
|
||||
edgeLoops[loopI].transfer(loop);
|
||||
// Done all for current loop - copy to edgeLoops
|
||||
edgeLoops[numLoops] = loop;
|
||||
|
||||
loopI++;
|
||||
++numLoops;
|
||||
}
|
||||
|
||||
edgeLoops.setSize(loopI);
|
||||
edgeLoops.resize(numLoops);
|
||||
|
||||
DebugInFunction << "Calculated boundary edge loops" << nl;
|
||||
}
|
||||
|
||||
@ -90,7 +90,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcMeshData() const
|
||||
{
|
||||
if (markedPoints.insert(pointi, meshPoints.size()))
|
||||
{
|
||||
meshPoints.append(pointi);
|
||||
meshPoints.push_back(pointi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcPointFaces() const
|
||||
{
|
||||
for (const label pointi : locFcs[facei])
|
||||
{
|
||||
pointFcs[pointi].append(facei);
|
||||
pointFcs[pointi].push_back(facei);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user