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