Merge branch 'feature-PtrList' into 'develop'

PtrListOps and adjustments for sync

See merge request Development/openfoam!422
This commit is contained in:
Andrew Heather
2021-02-09 19:04:04 +00:00
31 changed files with 779 additions and 1195 deletions

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -82,25 +83,15 @@ void Foam::conformalVoronoiMesh::selectSeparatedCoupledFaces
boolList& selected boolList& selected
) const ) const
{ {
const polyBoundaryMesh& patches = mesh.boundaryMesh(); for (const polyPatch& pp : mesh.boundaryMesh())
forAll(patches, patchi)
{ {
// Check all coupled. Avoid using .coupled() so we also pick up AMI. // Check all coupled. Avoid using .coupled() so we also pick up AMI.
if (isA<coupledPolyPatch>(patches[patchi]))
{
const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>
(
patches[patchi]
);
if (cpp.separated() || !cpp.parallel()) const auto* cpp = isA<coupledPolyPatch>(patches[patchi]);
if (cpp && (cpp->separated() || !cpp->parallel())
{ {
forAll(cpp, i) SubList<bool>(selected, pp.size(), pp.start()) = true;
{
selected[cpp.start()+i] = true;
}
}
} }
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -205,18 +205,14 @@ void filterPatches(polyMesh& mesh, const wordHashSet& addedPatchNames)
// Dump for all patches the current match // Dump for all patches the current match
void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh) void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
{ {
const polyBoundaryMesh& patches = mesh.boundaryMesh(); for (const polyPatch& pp : mesh.boundaryMesh())
{
const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(pp);
forAll(patches, patchi) if (cpp && cpp->owner())
{ {
if const auto& cycPatch = *cpp;
( const auto& nbrPatch = cycPatch.neighbPatch();
isA<cyclicPolyPatch>(patches[patchi])
&& refCast<const cyclicPolyPatch>(patches[patchi]).owner()
)
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patches[patchi]);
// Dump patches // Dump patches
{ {
@ -231,7 +227,6 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
); );
} }
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
{ {
OFstream str(prefix+nbrPatch.name()+".obj"); OFstream str(prefix+nbrPatch.name()+".obj");
Pout<< "Dumping " << nbrPatch.name() Pout<< "Dumping " << nbrPatch.name()
@ -325,22 +320,16 @@ void syncPoints
if (Pstream::parRun()) if (Pstream::parRun())
{ {
// Send const labelList& procPatches = mesh.globalData().processorPatches();
forAll(patches, patchi) // Send
for (const label patchi : procPatches)
{ {
const polyPatch& pp = patches[patchi]; const polyPatch& pp = patches[patchi];
const auto& procPatch = refCast<const processorPolyPatch>(pp);
if if (pp.nPoints() && procPatch.owner())
(
isA<processorPolyPatch>(pp)
&& pp.nPoints() > 0
&& refCast<const processorPolyPatch>(pp).owner()
)
{ {
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(pp);
// Get data per patchPoint in neighbouring point numbers. // Get data per patchPoint in neighbouring point numbers.
pointField patchInfo(procPatch.nPoints(), nullValue); pointField patchInfo(procPatch.nPoints(), nullValue);
@ -368,20 +357,13 @@ void syncPoints
// Receive and set. // Receive and set.
forAll(patches, patchi) for (const label patchi : procPatches)
{ {
const polyPatch& pp = patches[patchi]; const polyPatch& pp = patches[patchi];
const auto& procPatch = refCast<const processorPolyPatch>(pp);
if if (pp.nPoints() && !procPatch.owner())
(
isA<processorPolyPatch>(pp)
&& pp.nPoints() > 0
&& !refCast<const processorPolyPatch>(pp).owner()
)
{ {
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(pp);
pointField nbrPatchInfo(procPatch.nPoints()); pointField nbrPatchInfo(procPatch.nPoints());
{ {
// We do not know the number of points on the other side // We do not know the number of points on the other side
@ -419,22 +401,19 @@ void syncPoints
} }
// Do the cyclics. // Do the cyclics.
forAll(patches, patchi) for (const polyPatch& pp : patches)
{ {
const polyPatch& pp = patches[patchi]; const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(pp);
if if (cpp && cpp->owner())
(
isA<cyclicPolyPatch>(pp)
&& refCast<const cyclicPolyPatch>(pp).owner()
)
{ {
const cyclicPolyPatch& cycPatch = // Owner does all.
refCast<const cyclicPolyPatch>(pp);
const auto& cycPatch = *cpp;
const auto& nbrPatch = cycPatch.neighbPatch();
const edgeList& coupledPoints = cycPatch.coupledPoints(); const edgeList& coupledPoints = cycPatch.coupledPoints();
const labelList& meshPts = cycPatch.meshPoints(); const labelList& meshPts = cycPatch.meshPoints();
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const labelList& nbrMeshPts = nbrPatch.meshPoints(); const labelList& nbrMeshPts = nbrPatch.meshPoints();
pointField half0Values(coupledPoints.size()); pointField half0Values(coupledPoints.size());

View File

@ -117,25 +117,24 @@ void writeWeights(const polyMesh& mesh)
for (const polyPatch& pp : mesh.boundaryMesh()) for (const polyPatch& pp : mesh.boundaryMesh())
{ {
if (isA<cyclicAMIPolyPatch>(pp)) const auto* cpp = isA<cyclicAMIPolyPatch>(pp);
{
const cyclicAMIPolyPatch& cpp =
refCast<const cyclicAMIPolyPatch>(pp);
if (cpp.owner()) if (cpp && cpp->owner())
{ {
const auto& cycPatch = *cpp;
const auto& nbrPatch = cycPatch.neighbPatch();
const AMIPatchToPatchInterpolation& ami = cycPatch.AMI();
Info<< "Calculating AMI weights between owner patch: " Info<< "Calculating AMI weights between owner patch: "
<< cpp.name() << " and neighbour patch: " << cycPatch.name() << " and neighbour patch: "
<< cpp.neighbPatch().name() << endl; << nbrPatch.name() << endl;
const AMIPatchToPatchInterpolation& ami =
cpp.AMI();
writeWeights writeWeights
( (
mesh, mesh,
ami.tgtWeightsSum(), ami.tgtWeightsSum(),
cpp.neighbPatch(), nbrPatch,
outputDir, outputDir,
"patch" + Foam::name(pp.index()) + "-tgt", "patch" + Foam::name(pp.index()) + "-tgt",
mesh.time() mesh.time()
@ -144,14 +143,13 @@ void writeWeights(const polyMesh& mesh)
( (
mesh, mesh,
ami.srcWeightsSum(), ami.srcWeightsSum(),
cpp, cycPatch,
outputDir, outputDir,
"patch" + Foam::name(pp.index()) + "-src", "patch" + Foam::name(pp.index()) + "-src",
mesh.time() mesh.time()
); );
} }
} }
}
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2014-2016 OpenFOAM Foundation Copyright (C) 2014-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -44,22 +45,18 @@ void Foam::domainDecomposition::processInterCyclics
// Processor boundaries from split cyclics // Processor boundaries from split cyclics
forAll(patches, patchi) forAll(patches, patchi)
{ {
if (isA<cyclicPolyPatch>(patches[patchi])) const auto& pp = patches[patchi];
{ const auto* cpp = isA<cyclicPolyPatch>(pp);
const cyclicPolyPatch& pp = refCast<const cyclicPolyPatch>
(
patches[patchi]
);
if (pp.owner() != owner) if (cpp && cpp->owner() == owner)
{ {
continue; // cyclic: check opposite side on this processor
} const auto& cycPatch = *cpp;
const auto& nbrPatch = cycPatch.neighbPatch();
// cyclic: check opposite side on this processor // cyclic: check opposite side on this processor
const labelUList& patchFaceCells = pp.faceCells(); const labelUList& patchFaceCells = pp.faceCells();
const labelUList& nbrPatchFaceCells = const labelUList& nbrPatchFaceCells = nbrPatch.faceCells();
pp.neighbPatch().faceCells();
// Store old sizes. Used to detect which inter-proc patches // Store old sizes. Used to detect which inter-proc patches
// have been added to. // have been added to.

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -136,8 +136,59 @@ struct greater
}; };
//- List of values generated by applying the access operation
//- to each list item.
//
// For example,
// \code
// PtrListOps::get(mesh.boundaryMesh(), nameOp<polyPatch>());
// \endcode
template<class ReturnType, class T, class AccessOp>
List<ReturnType> get
(
const UPtrList<T>& list,
const AccessOp& aop
);
//- List of names generated by calling \c name() for each list item
//- and filtered for matches
//
// For example,
// \code
// wordRes matches(...);
// PtrListOps::names(mesh.boundaryMesh(), matches);
//
// PtrListOps::names(mesh.boundaryMesh(), predicates::always());
// \endcode
template<class T, class UnaryMatchPredicate>
List<word> names
(
const UPtrList<T>& list,
const UnaryMatchPredicate& matcher
);
//- Find first list item with 'name()' that matches, -1 on failure
template<class T, class UnaryMatchPredicate>
label firstMatching
(
const UPtrList<T>& list,
const UnaryMatchPredicate& matcher
);
//- Extract list indices for all items with 'name()' that matches
template<class T, class UnaryMatchPredicate>
labelList findMatching
(
const UPtrList<T>& list,
const UnaryMatchPredicate& matcher
);
} // End namespace ListOps } // End namespace ListOps
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam } // End namespace Foam

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -103,4 +103,118 @@ void Foam::shuffle(UPtrList<T>& list)
} }
// Templated implementation for types(), names(), etc - file-scope
template<class ReturnType, class T, class AccessOp>
Foam::List<ReturnType> Foam::PtrListOps::get
(
const UPtrList<T>& list,
const AccessOp& aop
)
{
const label len = list.size();
List<ReturnType> output(len);
label count = 0;
for (label i = 0; i < len; ++i)
{
const T* ptr = list.get(i);
if (bool(ptr))
{
output[count++] = aop(*ptr);
}
}
output.resize(count);
return output;
}
template<class T, class UnaryMatchPredicate>
Foam::List<Foam::word> Foam::PtrListOps::names
(
const UPtrList<T>& list,
const UnaryMatchPredicate& matcher
)
{
// Possible: const auto aop = nameOp<T>();
const label len = list.size();
List<word> output(len);
label count = 0;
for (label i = 0; i < len; ++i)
{
const T* ptr = list.get(i);
if (bool(ptr))
{
if (matcher(ptr->name()))
{
output[count++] = (ptr->name());
}
}
}
output.resize(count);
return output;
}
template<class T, class UnaryMatchPredicate>
Foam::label Foam::PtrListOps::firstMatching
(
const UPtrList<T>& list,
const UnaryMatchPredicate& matcher
)
{
const label len = list.size();
for (label i = 0; i < len; ++i)
{
const T* ptr = list.get(i);
if (bool(ptr) && matcher(ptr->name()))
{
return i;
}
}
return -1;
}
template<class T, class UnaryMatchPredicate>
Foam::labelList Foam::PtrListOps::findMatching
(
const UPtrList<T>& list,
const UnaryMatchPredicate& matcher
)
{
const label len = list.size();
labelList output(len);
label count = 0;
for (label i = 0; i < len; ++i)
{
const T* ptr = list.get(i);
if (bool(ptr) && matcher(ptr->name()))
{
output[count++] = i;
}
}
output.resize(count);
return output;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -34,6 +34,7 @@ License
#include "lduSchedule.H" #include "lduSchedule.H"
#include "globalMeshData.H" #include "globalMeshData.H"
#include "stringListOps.H" #include "stringListOps.H"
#include "PtrListOps.H"
#include "edgeHashes.H" #include "edgeHashes.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -43,81 +44,6 @@ namespace Foam
defineTypeNameAndDebug(polyBoundaryMesh, 0); defineTypeNameAndDebug(polyBoundaryMesh, 0);
} }
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
// Templated implementation for types(), names(), etc - file-scope
template<class ListType, class GetOp>
static ListType getMethodImpl
(
const polyPatchList& list,
const GetOp& getop
)
{
const label len = list.size();
ListType output(len);
for (label i = 0; i < len; ++i)
{
output[i] = getop(list[i]);
}
return output;
}
// Templated implementation for indices() - file-scope
template<class UnaryMatchPredicate>
static labelList indicesImpl
(
const polyPatchList& list,
const UnaryMatchPredicate& matcher
)
{
const label len = list.size();
labelList output(len);
label count = 0;
for (label i = 0; i < len; ++i)
{
if (matcher(list[i].name()))
{
output[count++] = i;
}
}
output.resize(count);
return output;
}
// Templated implementation for findIndex() - file-scope
template<class UnaryMatchPredicate>
label findIndexImpl
(
const polyPatchList& list,
const UnaryMatchPredicate& matcher
)
{
const label len = list.size();
for (label i = 0; i < len; ++i)
{
if (matcher(list[i].name()))
{
return i;
}
}
return -1;
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -592,20 +518,20 @@ Foam::label Foam::polyBoundaryMesh::nNonProcessor() const
Foam::wordList Foam::polyBoundaryMesh::names() const Foam::wordList Foam::polyBoundaryMesh::names() const
{ {
return getMethodImpl<wordList>(*this, getNameOp<polyPatch>()); return PtrListOps::get<word>(*this, nameOp<polyPatch>());
} }
Foam::wordList Foam::polyBoundaryMesh::types() const Foam::wordList Foam::polyBoundaryMesh::types() const
{ {
return getMethodImpl<wordList>(*this, getTypeOp<polyPatch>()); return PtrListOps::get<word>(*this, typeOp<polyPatch>());
} }
Foam::wordList Foam::polyBoundaryMesh::physicalTypes() const Foam::wordList Foam::polyBoundaryMesh::physicalTypes() const
{ {
return return
getMethodImpl<wordList> PtrListOps::get<word>
( (
*this, *this,
[](const polyPatch& p) { return p.physicalType(); } [](const polyPatch& p) { return p.physicalType(); }
@ -616,7 +542,7 @@ Foam::wordList Foam::polyBoundaryMesh::physicalTypes() const
Foam::labelList Foam::polyBoundaryMesh::patchStarts() const Foam::labelList Foam::polyBoundaryMesh::patchStarts() const
{ {
return return
getMethodImpl<labelList> PtrListOps::get<label>
( (
*this, *this,
[](const polyPatch& p) { return p.start(); } [](const polyPatch& p) { return p.start(); }
@ -627,7 +553,7 @@ Foam::labelList Foam::polyBoundaryMesh::patchStarts() const
Foam::labelList Foam::polyBoundaryMesh::patchSizes() const Foam::labelList Foam::polyBoundaryMesh::patchSizes() const
{ {
return return
getMethodImpl<labelList> PtrListOps::get<label>
( (
*this, *this,
[](const polyPatch& p) { return p.size(); } [](const polyPatch& p) { return p.size(); }
@ -681,8 +607,7 @@ Foam::labelList Foam::polyBoundaryMesh::indices
if (key.isPattern()) if (key.isPattern())
{ {
const regExp matcher(key); const regExp matcher(key);
patchIndices = PtrListOps::findMatching(*this, matcher);
patchIndices = indicesImpl(*this, matcher);
// Only examine patch groups if requested and when they exist. // Only examine patch groups if requested and when they exist.
if (useGroups && !groupPatchIDs().empty()) if (useGroups && !groupPatchIDs().empty())
@ -713,8 +638,7 @@ Foam::labelList Foam::polyBoundaryMesh::indices
// Special version of above for reduced memory footprint // Special version of above for reduced memory footprint
const word& matcher = key; const word& matcher = key;
const label patchId = PtrListOps::firstMatching(*this, matcher);
const label patchId = findIndexImpl(*this, matcher);
if (patchId >= 0) if (patchId >= 0)
{ {
@ -750,14 +674,14 @@ Foam::label Foam::polyBoundaryMesh::findIndex(const keyType& key) const
else if (key.isPattern()) else if (key.isPattern())
{ {
// Find as regex // Find as regex
regExp matcher(key); const regExp matcher(key);
return findIndexImpl(*this, matcher); return PtrListOps::firstMatching(*this, matcher);
} }
else else
{ {
// Find as literal string // Find as literal string
const word& matcher = key; const word& matcher = key;
return findIndexImpl(*this, matcher); return PtrListOps::firstMatching(*this, matcher);
} }
} }
@ -773,7 +697,7 @@ Foam::label Foam::polyBoundaryMesh::findPatchID
return -1; return -1;
} }
const label patchId = findIndexImpl(*this, patchName); const label patchId = PtrListOps::firstMatching(*this, patchName);
if (patchId >= 0) if (patchId >= 0)
{ {
@ -782,15 +706,18 @@ Foam::label Foam::polyBoundaryMesh::findPatchID
if (!allowNotFound) if (!allowNotFound)
{ {
string regionStr;
if (mesh_.name() != polyMesh::defaultRegion)
{
regionStr = "in region '" + mesh_.name() + "' ";
}
FatalErrorInFunction FatalErrorInFunction
<< "Patch '" << patchName << "' not found. " << "Patch '" << patchName << "' not found. "
<< "Available patch names " << regionStr << "include: " << names() << "Available patch names";
if (polyMesh::defaultRegion != mesh_.name())
{
FatalError
<< " in region '" << mesh_.name() << "'";
}
FatalError
<< " include: " << names() << endl
<< exit(FatalError); << exit(FatalError);
} }
@ -799,7 +726,7 @@ Foam::label Foam::polyBoundaryMesh::findPatchID
{ {
Pout<< "label polyBoundaryMesh::findPatchID(const word&) const" Pout<< "label polyBoundaryMesh::findPatchID(const word&) const"
<< "Patch named " << patchName << " not found. " << "Patch named " << patchName << " not found. "
<< "List of available patch names: " << names() << endl; << "Available patch names: " << names() << endl;
} }
// Not found, return -1 // Not found, return -1

View File

@ -130,13 +130,13 @@ void Foam::syncTools::syncPointMap
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking); PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
// Send // Send
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.nPoints() > 0) const auto* ppp = isA<processorPolyPatch>(pp);
if (ppp && pp.nPoints())
{ {
const processorPolyPatch& procPatch = const auto& procPatch = *ppp;
refCast<const processorPolyPatch>(pp);
// Get data per patchPoint in neighbouring point numbers. // Get data per patchPoint in neighbouring point numbers.
@ -165,13 +165,13 @@ void Foam::syncTools::syncPointMap
pBufs.finishedSends(); pBufs.finishedSends();
// Receive and combine. // Receive and combine.
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.nPoints() > 0) const auto* ppp = isA<processorPolyPatch>(pp);
if (ppp && pp.nPoints())
{ {
const processorPolyPatch& procPatch = const auto& procPatch = *ppp;
refCast<const processorPolyPatch>(pp);
UIPstream fromNbr(procPatch.neighbProcNo(), pBufs); UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
Map<T> nbrPatchInfo(fromNbr); Map<T> nbrPatchInfo(fromNbr);
@ -199,16 +199,15 @@ void Foam::syncTools::syncPointMap
// Do the cyclics. // Do the cyclics.
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<cyclicPolyPatch>(pp)) const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(pp);
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(pp);
if (cycPatch.owner()) if (cpp && cpp->owner())
{ {
// Owner does all. // Owner does all.
const cyclicPolyPatch& cycPatch = *cpp;
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch(); const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const edgeList& coupledPoints = cycPatch.coupledPoints(); const edgeList& coupledPoints = cycPatch.coupledPoints();
const labelList& meshPtsA = cycPatch.meshPoints(); const labelList& meshPtsA = cycPatch.meshPoints();
const labelList& meshPtsB = nbrPatch.meshPoints(); const labelList& meshPtsB = nbrPatch.meshPoints();
@ -272,7 +271,6 @@ void Foam::syncTools::syncPointMap
} }
} }
} }
}
// Synchronize multiple shared points. // Synchronize multiple shared points.
if (pd.nGlobalPoints() > 0) if (pd.nGlobalPoints() > 0)
@ -386,14 +384,13 @@ void Foam::syncTools::syncEdgeMap
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking); PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
// Send // Send
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.nEdges() > 0) const auto* ppp = isA<processorPolyPatch>(pp);
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(pp);
if (ppp && pp.nEdges())
{
const auto& procPatch = *ppp;
// Get data per patch edge in neighbouring edge. // Get data per patch edge in neighbouring edge.
@ -424,13 +421,13 @@ void Foam::syncTools::syncEdgeMap
pBufs.finishedSends(); pBufs.finishedSends();
// Receive and combine. // Receive and combine.
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.nEdges() > 0) const auto* ppp = isA<processorPolyPatch>(pp);
if (ppp && pp.nEdges())
{ {
const processorPolyPatch& procPatch = const auto& procPatch = *ppp;
refCast<const processorPolyPatch>(pp);
EdgeMap<T> nbrPatchInfo; EdgeMap<T> nbrPatchInfo;
{ {
@ -468,19 +465,20 @@ void Foam::syncTools::syncEdgeMap
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<cyclicPolyPatch>(pp)) const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(pp);
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(pp);
if (cycPatch.owner()) if (cpp && cpp->owner())
{ {
// Owner does all. // Owner does all.
const cyclicPolyPatch& cycPatch = *cpp;
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const edgeList& coupledEdges = cycPatch.coupledEdges(); const edgeList& coupledEdges = cycPatch.coupledEdges();
const labelList& meshPtsA = cycPatch.meshPoints(); const labelList& meshPtsA = cycPatch.meshPoints();
const edgeList& edgesA = cycPatch.edges(); const edgeList& edgesA = cycPatch.edges();
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const labelList& meshPtsB = nbrPatch.meshPoints(); const labelList& meshPtsB = nbrPatch.meshPoints();
const edgeList& edgesB = nbrPatch.edges(); const edgeList& edgesB = nbrPatch.edges();
@ -488,9 +486,9 @@ void Foam::syncTools::syncEdgeMap
Map<T> half0Values(edgesA.size() / 20); Map<T> half0Values(edgesA.size() / 20);
Map<T> half1Values(half0Values.size()); Map<T> half1Values(half0Values.size());
forAll(coupledEdges, i) forAll(coupledEdges, edgei)
{ {
const edge& twoEdges = coupledEdges[i]; const edge& twoEdges = coupledEdges[edgei];
{ {
const edge& e0 = edgesA[twoEdges[0]]; const edge& e0 = edgesA[twoEdges[0]];
@ -500,7 +498,7 @@ void Foam::syncTools::syncEdgeMap
if (iter.found()) if (iter.found())
{ {
half0Values.insert(i, *iter); half0Values.insert(edgei, *iter);
} }
} }
{ {
@ -511,7 +509,7 @@ void Foam::syncTools::syncEdgeMap
if (iter.found()) if (iter.found())
{ {
half1Values.insert(i, *iter); half1Values.insert(edgei, *iter);
} }
} }
} }
@ -523,11 +521,11 @@ void Foam::syncTools::syncEdgeMap
// Extract and combine information // Extract and combine information
forAll(coupledEdges, i) forAll(coupledEdges, edgei)
{ {
const edge& twoEdges = coupledEdges[i]; const edge& twoEdges = coupledEdges[edgei];
const auto half1Fnd = half1Values.cfind(i); const auto half1Fnd = half1Values.cfind(edgei);
if (half1Fnd.found()) if (half1Fnd.found())
{ {
@ -543,7 +541,7 @@ void Foam::syncTools::syncEdgeMap
); );
} }
const auto half0Fnd = half0Values.cfind(i); const auto half0Fnd = half0Values.cfind(edgei);
if (half0Fnd.found()) if (half0Fnd.found())
{ {
@ -561,7 +559,6 @@ void Foam::syncTools::syncEdgeMap
} }
} }
} }
}
// Synchronize multiple shared points. // Synchronize multiple shared points.
// Problem is that we don't want to construct shared edges so basically // Problem is that we don't want to construct shared edges so basically
@ -1022,6 +1019,8 @@ void Foam::syncTools::syncBoundaryFaceList
if (parRun) if (parRun)
{ {
// Avoid mesh.globalData() - possible race condition
if if
( (
is_contiguous<T>::value is_contiguous<T>::value
@ -1036,16 +1035,17 @@ void Foam::syncTools::syncBoundaryFaceList
// Set up reads // Set up reads
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.size() > 0) const auto* ppp = isA<processorPolyPatch>(pp);
if (ppp && pp.size())
{ {
const processorPolyPatch& procPatch = const auto& procPatch = *ppp;
refCast<const processorPolyPatch>(pp);
SubList<T> fld SubList<T> fld
( (
receivedValues, receivedValues,
procPatch.size(), pp.size(),
procPatch.offset() pp.start()-boundaryOffset
); );
IPstream::read IPstream::read
@ -1061,16 +1061,17 @@ void Foam::syncTools::syncBoundaryFaceList
// Set up writes // Set up writes
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.size() > 0) const auto* ppp = isA<processorPolyPatch>(pp);
if (ppp && pp.size())
{ {
const processorPolyPatch& procPatch = const auto& procPatch = *ppp;
refCast<const processorPolyPatch>(pp);
const SubList<T> fld const SubList<T> fld
( (
faceValues, faceValues,
procPatch.size(), pp.size(),
procPatch.offset() pp.start()-boundaryOffset
); );
OPstream::write OPstream::write
@ -1089,15 +1090,17 @@ void Foam::syncTools::syncBoundaryFaceList
// Combine with existing data // Combine with existing data
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.size() > 0) const auto* ppp = isA<processorPolyPatch>(pp);
if (ppp && pp.size())
{ {
const processorPolyPatch& procPatch = const auto& procPatch = *ppp;
refCast<const processorPolyPatch>(pp);
SubList<T> recvFld SubList<T> recvFld
( (
receivedValues, receivedValues,
procPatch.size(), pp.size(),
procPatch.offset() pp.start()-boundaryOffset
); );
const List<T>& fakeList = recvFld; const List<T>& fakeList = recvFld;
top(procPatch, const_cast<List<T>&>(fakeList)); top(procPatch, const_cast<List<T>&>(fakeList));
@ -1105,9 +1108,10 @@ void Foam::syncTools::syncBoundaryFaceList
SubList<T> patchValues SubList<T> patchValues
( (
faceValues, faceValues,
procPatch.size(), pp.size(),
procPatch.offset() pp.start()-boundaryOffset
); );
forAll(patchValues, i) forAll(patchValues, i)
{ {
cop(patchValues[i], recvFld[i]); cop(patchValues[i], recvFld[i]);
@ -1120,48 +1124,54 @@ void Foam::syncTools::syncBoundaryFaceList
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking); PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
// Send // Send
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.size() > 0) const auto* ppp = isA<processorPolyPatch>(pp);
if (ppp && pp.size())
{ {
const processorPolyPatch& procPatch = const auto& procPatch = *ppp;
refCast<const processorPolyPatch>(pp);
const label patchStart = procPatch.start()-boundaryOffset; const SubList<T> fld
(
faceValues,
pp.size(),
pp.start()-boundaryOffset
);
// Send slice of values on the patch
UOPstream toNbr(procPatch.neighbProcNo(), pBufs); UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
toNbr << toNbr << fld;;
SubList<T>(faceValues, procPatch.size(), patchStart);
} }
} }
pBufs.finishedSends(); pBufs.finishedSends();
// Receive and combine. // Receive and combine.
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.size() > 0) const auto* ppp = isA<processorPolyPatch>(pp);
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(pp);
List<T> nbrVals(procPatch.size()); if (ppp && pp.size())
{
const auto& procPatch = *ppp;
List<T> recvFld(pp.size());
UIPstream fromNbr(procPatch.neighbProcNo(), pBufs); UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
fromNbr >> nbrVals; fromNbr >> recvFld;
top(procPatch, nbrVals); top(procPatch, recvFld);
label bFacei = procPatch.start()-boundaryOffset; SubList<T> patchValues
(
faceValues,
pp.size(),
pp.start()-boundaryOffset
);
for (const T& nbrVal : nbrVals) forAll(patchValues, i)
{ {
cop(faceValues[bFacei++], nbrVal); cop(patchValues[i], recvFld[i]);
} }
} }
} }
@ -1171,38 +1181,45 @@ void Foam::syncTools::syncBoundaryFaceList
// Do the cyclics. // Do the cyclics.
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<cyclicPolyPatch>(pp)) const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(pp);
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(pp);
if (cycPatch.owner()) if (cpp && cpp->owner())
{ {
// Owner does all. // Owner does all.
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const cyclicPolyPatch& cycPatch = *cpp;
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const label patchSize = cycPatch.size(); const label patchSize = cycPatch.size();
const label ownStart = cycPatch.start()-boundaryOffset;
const label nbrStart = nbrPatch.start()-boundaryOffset; SubList<T> ownPatchValues
(
faceValues,
patchSize,
cycPatch.start()-boundaryOffset
);
SubList<T> nbrPatchValues
(
faceValues,
patchSize,
nbrPatch.start()-boundaryOffset
);
// Transform (copy of) data on both sides // Transform (copy of) data on both sides
List<T> ownVals(SubList<T>(faceValues, patchSize, ownStart)); List<T> ownVals(ownPatchValues);
top(nbrPatch, ownVals); top(nbrPatch, ownVals);
List<T> nbrVals(SubList<T>(faceValues, patchSize, nbrStart)); List<T> nbrVals(nbrPatchValues);
top(cycPatch, nbrVals); top(cycPatch, nbrVals);
label bFacei = ownStart; forAll(ownPatchValues, i)
for (T& nbrVal : nbrVals)
{ {
cop(faceValues[bFacei++], nbrVal); cop(ownPatchValues[i], nbrVals[i]);
} }
bFacei = nbrStart; forAll(nbrPatchValues, i)
for (T& ownVal : ownVals)
{ {
cop(faceValues[bFacei++], ownVal); cop(nbrPatchValues[i], ownVals[i]);
}
} }
} }
} }
@ -1224,17 +1241,14 @@ void Foam::syncTools::syncFaceList
// Offset (global to local) for start of boundaries // Offset (global to local) for start of boundaries
const label boundaryOffset = (isBoundaryOnly ? mesh.nInternalFaces() : 0); const label boundaryOffset = (isBoundaryOnly ? mesh.nInternalFaces() : 0);
if // Check size
( if (faceValues.size() != (mesh.nFaces() - boundaryOffset))
faceValues.size()
!= (isBoundaryOnly ? mesh.nBoundaryFaces() : mesh.nFaces())
)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Number of values " << faceValues.size() << "Number of values " << faceValues.size()
<< " is not equal to the number of " << " is not equal to the number of "
<< (isBoundaryOnly ? "boundary" : "mesh") << " faces " << (isBoundaryOnly ? "boundary" : "mesh") << " faces "
<< (isBoundaryOnly ? mesh.nBoundaryFaces() : mesh.nFaces()) << nl << ((mesh.nFaces() - boundaryOffset)) << nl
<< abort(FatalError); << abort(FatalError);
} }
@ -1250,13 +1264,13 @@ void Foam::syncTools::syncFaceList
// Set up reads // Set up reads
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.size()) const auto* ppp = isA<processorPolyPatch>(pp);
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(pp);
const label patchSize = procPatch.size(); if (ppp && pp.size())
const label patchi = procPatch.index(); {
const auto& procPatch = *ppp;
const label patchi = pp.index();
const label patchSize = pp.size();
recvInfos.set(patchi, new PackedList<Width>(patchSize)); recvInfos.set(patchi, new PackedList<Width>(patchSize));
PackedList<Width>& recvInfo = recvInfos[patchi]; PackedList<Width>& recvInfo = recvInfos[patchi];
@ -1277,18 +1291,18 @@ void Foam::syncTools::syncFaceList
// Set up writes // Set up writes
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.size()) const auto* ppp = isA<processorPolyPatch>(pp);
if (ppp && pp.size())
{ {
const processorPolyPatch& procPatch = const auto& procPatch = *ppp;
refCast<const processorPolyPatch>(pp); const label patchi = pp.index();
const labelRange range const labelRange range
( (
procPatch.start()-boundaryOffset, pp.start()-boundaryOffset,
procPatch.size() pp.size()
); );
const label patchi = procPatch.index();
sendInfos.set sendInfos.set
( (
patchi, patchi,
@ -1312,17 +1326,17 @@ void Foam::syncTools::syncFaceList
// Combine with existing data // Combine with existing data
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<processorPolyPatch>(pp) && pp.size()) const auto* ppp = isA<processorPolyPatch>(pp);
{
const processorPolyPatch& procPatch = if (ppp && pp.size())
refCast<const processorPolyPatch>(pp); {
const label patchi = pp.index();
const label patchSize = pp.size();
const label patchSize = procPatch.size();
const label patchi = procPatch.index();
const PackedList<Width>& recvInfo = recvInfos[patchi]; const PackedList<Width>& recvInfo = recvInfos[patchi];
// Combine (bitwise) // Combine (bitwise)
label bFacei = procPatch.start()-boundaryOffset; label bFacei = pp.start()-boundaryOffset;
for (label i = 0; i < patchSize; ++i) for (label i = 0; i < patchSize; ++i)
{ {
unsigned int recvVal = recvInfo[i]; unsigned int recvVal = recvInfo[i];
@ -1335,82 +1349,20 @@ void Foam::syncTools::syncFaceList
} }
} }
} }
//PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
//
//// Send
//
//for (const polyPatch& pp : patches)
//{
// if (isA<processorPolyPatch>(pp) && pp.size())
// {
// const processorPolyPatch& procPatch =
// refCast<const processorPolyPatch>(pp);
//
// const labelRange range
// (
// procPatch.start()-boundaryOffset,
// procPatch.size()
// );
//
// // Send slice of values on the patch
// UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
// toNbr<< PackedList<Width>(faceValues, range);
// }
//}
//
//pBufs.finishedSends();
//
//
//// Receive and combine.
//
//for (const polyPatch& pp : patches)
//{
// if (isA<processorPolyPatch>(pp) && pp.size())
// {
// const processorPolyPatch& procPatch =
// refCast<const processorPolyPatch>(pp);
//
// const label patchSize = procPatch.size();
//
// // Recv slice of values on the patch
// PackedList<Width> recvInfo(patchSize);
// {
// UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
// fromNbr >> recvInfo;
// }
//
// // Combine (bitwise)
// label bFacei = procPatch.start()-boundaryOffset;
// for (label i = 0; i < patchSize; ++i)
// {
// unsigned int recvVal = recvInfo[i];
// unsigned int faceVal = faceValues[bFacei];
//
// cop(faceVal, recvVal);
// faceValues.set(bFacei, faceVal);
//
// ++bFacei;
// }
// }
//}
} }
// Do the cyclics. // Do the cyclics.
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
if (isA<cyclicPolyPatch>(pp)) const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(pp);
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(pp);
if (cycPatch.owner()) if (cpp && cpp->owner())
{ {
// Owner does all. // Owner does all.
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const cyclicPolyPatch& cycPatch = *cpp;
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const label patchSize = cycPatch.size(); const label patchSize = cycPatch.size();
label face0 = cycPatch.start()-boundaryOffset; label face0 = cycPatch.start()-boundaryOffset;
@ -1432,7 +1384,6 @@ void Foam::syncTools::syncFaceList
} }
} }
} }
}
} }
@ -1458,11 +1409,9 @@ void Foam::syncTools::swapBoundaryCellList
for (const polyPatch& pp : patches) for (const polyPatch& pp : patches)
{ {
label bFacei = pp.start()-mesh.nInternalFaces(); label bFacei = pp.offset();
const labelUList& faceCells = pp.faceCells(); for (const label celli : pp.faceCells())
for (const label celli : faceCells)
{ {
neighbourCellData[bFacei] = cellData[celli]; neighbourCellData[bFacei] = cellData[celli];
++bFacei; ++bFacei;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,6 +30,7 @@ License
#include "entry.H" #include "entry.H"
#include "demandDrivenData.H" #include "demandDrivenData.H"
#include "Pstream.H" #include "Pstream.H"
#include "PtrListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -138,91 +139,6 @@ bool Foam::ZoneMesh<ZoneType, MeshType>::read()
} }
// Templated implementation for names()
template<class ZoneType, class MeshType>
template<class UnaryMatchPredicate>
Foam::wordList Foam::ZoneMesh<ZoneType, MeshType>::namesImpl
(
const PtrList<ZoneType>& list,
const UnaryMatchPredicate& matcher,
const bool doSort
)
{
const label len = list.size();
wordList output(len);
label count = 0;
for (label i = 0; i < len; ++i)
{
const word& itemName = list[i].name();
if (matcher(itemName))
{
output[count++] = itemName;
}
}
output.resize(count);
if (doSort)
{
Foam::sort(output);
}
return output;
}
template<class ZoneType, class MeshType>
template<class UnaryMatchPredicate>
Foam::labelList Foam::ZoneMesh<ZoneType, MeshType>::indicesImpl
(
const PtrList<ZoneType>& list,
const UnaryMatchPredicate& matcher
)
{
const label len = list.size();
labelList output(len);
label count = 0;
for (label i = 0; i < len; ++i)
{
if (matcher(list[i].name()))
{
output[count++] = i;
}
}
output.resize(count);
return output;
}
template<class ZoneType, class MeshType>
template<class UnaryMatchPredicate>
Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findIndexImpl
(
const PtrList<ZoneType>& list,
const UnaryMatchPredicate& matcher
)
{
const label len = list.size();
for (label i = 0; i < len; ++i)
{
if (matcher(list[i].name()))
{
return i;
}
}
return -1;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ZoneType, class MeshType> template<class ZoneType, class MeshType>
@ -323,32 +239,14 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::whichZone
template<class ZoneType, class MeshType> template<class ZoneType, class MeshType>
Foam::wordList Foam::ZoneMesh<ZoneType, MeshType>::types() const Foam::wordList Foam::ZoneMesh<ZoneType, MeshType>::types() const
{ {
const PtrList<ZoneType>& zones = *this; return PtrListOps::get<word>(*this, typeOp<ZoneType>());
wordList list(zones.size());
forAll(zones, zonei)
{
list[zonei] = zones[zonei].type();
}
return list;
} }
template<class ZoneType, class MeshType> template<class ZoneType, class MeshType>
Foam::wordList Foam::ZoneMesh<ZoneType, MeshType>::names() const Foam::wordList Foam::ZoneMesh<ZoneType, MeshType>::names() const
{ {
const PtrList<ZoneType>& zones = *this; return PtrListOps::get<word>(*this, nameOp<ZoneType>());
wordList list(zones.size());
forAll(zones, zonei)
{
list[zonei] = zones[zonei].name();
}
return list;
} }
@ -358,7 +256,7 @@ Foam::wordList Foam::ZoneMesh<ZoneType, MeshType>::names
const wordRe& matcher const wordRe& matcher
) const ) const
{ {
return namesImpl(*this, matcher, false); return PtrListOps::names(*this, matcher);
} }
@ -369,7 +267,7 @@ Foam::wordList Foam::ZoneMesh<ZoneType, MeshType>::names
) )
const const
{ {
return namesImpl(*this, matcher, false); return PtrListOps::names(*this, matcher);
} }
@ -389,7 +287,10 @@ Foam::wordList Foam::ZoneMesh<ZoneType, MeshType>::sortedNames
const wordRe& matcher const wordRe& matcher
) const ) const
{ {
return namesImpl(*this, matcher, true); wordList sorted(this->names(matcher));
Foam::sort(sorted);
return sorted;
} }
@ -400,7 +301,10 @@ Foam::wordList Foam::ZoneMesh<ZoneType, MeshType>::sortedNames
) )
const const
{ {
return namesImpl(*this, matcher, true); wordList sorted(this->names(matcher));
Foam::sort(sorted);
return sorted;
} }
@ -417,14 +321,14 @@ Foam::labelList Foam::ZoneMesh<ZoneType, MeshType>::indices
else if (key.isPattern()) else if (key.isPattern())
{ {
// Match as regex // Match as regex
regExp matcher(key); const regExp matcher(key);
return indicesImpl(*this, matcher); return PtrListOps::findMatching(*this, matcher);
} }
else else
{ {
// Compare as literal string // Compare as literal string
const word& matcher = key; const word& matcher = key;
return indicesImpl(*this, matcher); return PtrListOps::findMatching(*this, matcher);
} }
} }
@ -439,8 +343,7 @@ Foam::labelList Foam::ZoneMesh<ZoneType, MeshType>::indices
{ {
return labelList(); return labelList();
} }
return PtrListOps::findMatching(*this, matcher);
return indicesImpl(*this, matcher);
} }
@ -457,14 +360,14 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findIndex
else if (key.isPattern()) else if (key.isPattern())
{ {
// Find as regex // Find as regex
regExp matcher(key); const regExp matcher(key);
return findIndexImpl(*this, matcher); return PtrListOps::firstMatching(*this, matcher);
} }
else else
{ {
// Find as literal string // Find as literal string
const word& matcher = key; const word& matcher = key;
return findIndexImpl(*this, matcher); return PtrListOps::firstMatching(*this, matcher);
} }
} }
@ -475,7 +378,7 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findIndex
const wordRes& matcher const wordRes& matcher
) const ) const
{ {
return (matcher.empty() ? -1 : findIndexImpl(*this, matcher)); return (matcher.empty() ? -1 : PtrListOps::firstMatching(*this, matcher));
} }
@ -490,7 +393,7 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findZoneID
return -1; return -1;
} }
label zoneId = findIndexImpl(*this, zoneName); label zoneId = PtrListOps::firstMatching(*this, zoneName);
if (zoneId < 0) if (zoneId < 0)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -85,32 +85,6 @@ class ZoneMesh
//- Create zone map //- Create zone map
void calcZoneMap() const; void calcZoneMap() const;
//- Templated implementation for names()
template<class UnaryMatchPredicate>
static wordList namesImpl
(
const PtrList<ZoneType>& list,
const UnaryMatchPredicate& matcher,
const bool doSort
);
//- Templated implementation for indices()
template<class UnaryMatchPredicate>
static labelList indicesImpl
(
const PtrList<ZoneType>& list,
const UnaryMatchPredicate& matcher
);
//- Templated implementation for findIndex()
template<class UnaryMatchPredicate>
static label findIndexImpl
(
const PtrList<ZoneType>& list,
const UnaryMatchPredicate& matcher
);
//- No copy construct //- No copy construct
ZoneMesh(const ZoneMesh&) = delete; ZoneMesh(const ZoneMesh&) = delete;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -271,30 +271,13 @@ struct compareOp
}; };
//- General get operation to extract the 'name' from an object as a word. //- Deprecated(2020-11) use nameOp (word.H)
// The default implementation uses the 'name()' method commonly used within // \deprecated(2020-11) use nameOp
// OpenFOAM. template<class T> struct getNameOp : nameOp<T> {};
template<class T>
struct getNameOp
{
word operator()(const T& x) const WARNRETURN
{
return x.name();
}
};
//- Deprecated(2020-11) use typeOp (word.H)
//- General get operation to extract the 'type' from an object as a word. // \deprecated(2020-11) use typeOp
// The default implementation uses the 'type()' method commonly used within template<class T> struct getTypeOp : typeOp<T> {};
// OpenFOAM.
template<class T>
struct getTypeOp
{
word operator()(const T& x) const WARNRETURN
{
return x.type();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2018 OpenFOAM Foundation Copyright (C) 2011-2018 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -312,13 +312,12 @@ Foam::label Foam::fvMeshDistribute::findNonEmptyPatch() const
forAll(patches, patchi) forAll(patches, patchi)
{ {
const polyPatch& pp = patches[patchi]; const polyPatch& pp = patches[patchi];
const auto* cpp = isA<cyclicACMIPolyPatch>(pp);
if (isA<cyclicACMIPolyPatch>(pp)) if (cpp)
{ {
isCoupledPatch.set(patchi); isCoupledPatch.set(patchi);
const cyclicACMIPolyPatch& cpp = const label dupPatchID = cpp->nonOverlapPatchID();
refCast<const cyclicACMIPolyPatch>(pp);
const label dupPatchID = cpp.nonOverlapPatchID();
if (dupPatchID != -1) if (dupPatchID != -1)
{ {
isCoupledPatch.set(dupPatchID); isCoupledPatch.set(dupPatchID);
@ -510,12 +509,8 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::deleteProcPatches
// or new patchID // or new patchID
labelList newPatchID(mesh_.nBoundaryFaces(), -1); labelList newPatchID(mesh_.nBoundaryFaces(), -1);
label nProcPatches = 0; for (const polyPatch& pp : mesh_.boundaryMesh())
forAll(mesh_.boundaryMesh(), patchi)
{ {
const polyPatch& pp = mesh_.boundaryMesh()[patchi];
if (isA<processorPolyPatch>(pp)) if (isA<processorPolyPatch>(pp))
{ {
if (debug) if (debug)
@ -525,14 +520,12 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::fvMeshDistribute::deleteProcPatches
<< endl; << endl;
} }
label offset = pp.start() - mesh_.nInternalFaces(); SubList<label>
(
forAll(pp, i) newPatchID,
{ pp.size(),
newPatchID[offset+i] = destinationPatch; pp.offset()
} ) = destinationPatch;
nProcPatches++;
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -136,12 +136,13 @@ void Foam::fvMeshSubset::doCoupledPatches
// Send face usage across processor patches // Send face usage across processor patches
for (const polyPatch& pp : oldPatches) for (const polyPatch& pp : oldPatches)
{ {
if (isA<processorPolyPatch>(pp)) const auto* procPatch = isA<processorPolyPatch>(pp);
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(pp);
UOPstream toNeighbour(procPatch.neighbProcNo(), pBufs); if (procPatch)
{
const label nbrProci = procPatch->neighbProcNo();
UOPstream toNeighbour(nbrProci, pBufs);
if (!nCellsUsingFace.empty()) if (!nCellsUsingFace.empty())
{ {
@ -160,12 +161,13 @@ void Foam::fvMeshSubset::doCoupledPatches
// Receive face usage count and check for faces that become uncoupled. // Receive face usage count and check for faces that become uncoupled.
for (const polyPatch& pp : oldPatches) for (const polyPatch& pp : oldPatches)
{ {
if (isA<processorPolyPatch>(pp)) const auto* procPatch = isA<processorPolyPatch>(pp);
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(pp);
UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs); if (procPatch)
{
const label nbrProci = procPatch->neighbProcNo();
UIPstream fromNeighbour(nbrProci, pBufs);
const labelList nbrList(fromNeighbour); const labelList nbrList(fromNeighbour);
@ -199,13 +201,12 @@ void Foam::fvMeshSubset::doCoupledPatches
// Do same for cyclics. // Do same for cyclics.
for (const polyPatch& pp : oldPatches) for (const polyPatch& pp : oldPatches)
{ {
if (isA<cyclicPolyPatch>(pp)) const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(pp);
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(pp);
if (!nCellsUsingFace.empty()) if (cpp && !nCellsUsingFace.empty())
{ {
const auto& cycPatch = *cpp;
forAll(cycPatch, i) forAll(cycPatch, i)
{ {
label thisFacei = cycPatch.start() + i; label thisFacei = cycPatch.start() + i;
@ -223,7 +224,6 @@ void Foam::fvMeshSubset::doCoupledPatches
} }
} }
} }
}
if (syncPar) if (syncPar)
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -30,6 +30,7 @@ License
#include "polyMesh.H" #include "polyMesh.H"
#include "polyTopoChange.H" #include "polyTopoChange.H"
#include "Time.H" #include "Time.H"
#include "PtrListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -135,31 +136,13 @@ Foam::polyTopoChanger::polyTopoChanger(polyMesh& mesh)
Foam::wordList Foam::polyTopoChanger::types() const Foam::wordList Foam::polyTopoChanger::types() const
{ {
const PtrList<polyMeshModifier>& modifiers = *this; return PtrListOps::get<word>(*this, typeOp<polyMeshModifier>());
wordList lst(modifiers.size());
forAll(modifiers, i)
{
lst[i] = modifiers[i].type();
}
return lst;
} }
Foam::wordList Foam::polyTopoChanger::names() const Foam::wordList Foam::polyTopoChanger::names() const
{ {
const PtrList<polyMeshModifier>& modifiers = *this; return PtrListOps::get<word>(*this, typeOp<polyMeshModifier>());
wordList lst(modifiers.size());
forAll(modifiers, i)
{
lst[i] = modifiers[i].name();
}
return lst;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 Wikki Ltd Copyright (C) 2016-2017 Wikki Ltd
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -29,6 +29,7 @@ License
#include "faBoundaryMesh.H" #include "faBoundaryMesh.H"
#include "faMesh.H" #include "faMesh.H"
#include "primitiveMesh.H" #include "primitiveMesh.H"
#include "PtrListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -37,82 +38,6 @@ namespace Foam
defineTypeNameAndDebug(faBoundaryMesh, 0); defineTypeNameAndDebug(faBoundaryMesh, 0);
} }
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
// Templated implementation for types(), names(), etc - file-scope
template<class ListType, class GetOp>
static ListType getMethodImpl
(
const faPatchList& list,
const GetOp& getop
)
{
const label len = list.size();
ListType output(len);
for (label i = 0; i < len; ++i)
{
output[i] = getop(list[i]);
}
return output;
}
// Templated implementation for indices() - file-scope
template<class UnaryMatchPredicate>
static labelList indicesImpl
(
const faPatchList& list,
const UnaryMatchPredicate& matcher
)
{
const label len = list.size();
labelList output(len);
label count = 0;
for (label i = 0; i < len; ++i)
{
if (matcher(list[i].name()))
{
output[count++] = i;
}
}
output.resize(count);
return output;
}
// Templated implementation for findIndex() - file-scope
template<class UnaryMatchPredicate>
label findIndexImpl
(
const faPatchList& list,
const UnaryMatchPredicate& matcher
)
{
const label len = list.size();
for (label i = 0; i < len; ++i)
{
if (matcher(list[i].name()))
{
return i;
}
}
return -1;
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::faBoundaryMesh::faBoundaryMesh Foam::faBoundaryMesh::faBoundaryMesh
@ -220,13 +145,13 @@ Foam::lduInterfacePtrsList Foam::faBoundaryMesh::interfaces() const
Foam::wordList Foam::faBoundaryMesh::names() const Foam::wordList Foam::faBoundaryMesh::names() const
{ {
return getMethodImpl<wordList>(*this, getNameOp<faPatch>()); return PtrListOps::get<word>(*this, nameOp<faPatch>());
} }
Foam::wordList Foam::faBoundaryMesh::types() const Foam::wordList Foam::faBoundaryMesh::types() const
{ {
return getMethodImpl<wordList>(*this, getTypeOp<faPatch>()); return PtrListOps::get<word>(*this, typeOp<faPatch>());
} }
@ -244,8 +169,7 @@ Foam::labelList Foam::faBoundaryMesh::indices
if (key.isPattern()) if (key.isPattern())
{ {
const regExp matcher(key); const regExp matcher(key);
return PtrListOps::findMatching(*this, matcher);
return indicesImpl(*this, matcher);
} }
else else
{ {
@ -253,8 +177,7 @@ Foam::labelList Foam::faBoundaryMesh::indices
// Special version of above for reduced memory footprint // Special version of above for reduced memory footprint
const word& matcher = key; const word& matcher = key;
const label patchId = PtrListOps::firstMatching(*this, matcher);
const label patchId = findIndexImpl(*this, matcher);
if (patchId >= 0) if (patchId >= 0)
{ {
@ -275,14 +198,14 @@ Foam::label Foam::faBoundaryMesh::findIndex(const keyType& key) const
else if (key.isPattern()) else if (key.isPattern())
{ {
// Find as regex // Find as regex
regExp matcher(key); const regExp matcher(key);
return findIndexImpl(*this, matcher); return PtrListOps::firstMatching(*this, matcher);
} }
else else
{ {
// Find as literal string // Find as literal string
const word& matcher = key; const word& matcher = key;
return findIndexImpl(*this, matcher); return PtrListOps::firstMatching(*this, matcher);
} }
} }
@ -294,7 +217,7 @@ Foam::label Foam::faBoundaryMesh::findPatchID(const word& patchName) const
return -1; return -1;
} }
return findIndexImpl(*this, patchName); return PtrListOps::firstMatching(*this, patchName);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -315,21 +315,16 @@ bool Foam::functionObjects::AMIWeights::read(const dictionary& dict)
{ {
if (fvMeshFunctionObject::read(dict) && writeFile::read(dict)) if (fvMeshFunctionObject::read(dict) && writeFile::read(dict))
{ {
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
patchIDs_.clear(); patchIDs_.clear();
labelHashSet ids; labelHashSet ids;
forAll(pbm, patchi)
{
if (isA<cyclicAMIPolyPatch>(pbm[patchi]))
{
const auto& ami =
static_cast<const cyclicAMIPolyPatch&>(pbm[patchi]);
if (ami.owner()) for (const polyPatch& pp : mesh_.boundaryMesh())
{ {
ids.insert(patchi); const auto* amicpp = isA<cyclicAMIPolyPatch>(pp);
}
if (amicpp && amicpp->owner())
{
ids.insert(pp.index());
} }
} }

View File

@ -211,16 +211,11 @@ void Foam::functionObjects::extractEulerianParticles::setBlockedFaces
const polyPatch& pp = mesh_.boundaryMesh()[patchi]; const polyPatch& pp = mesh_.boundaryMesh()[patchi];
const scalarField& alphafp = alphaf.boundaryField()[patchi]; const scalarField& alphafp = alphaf.boundaryField()[patchi];
const auto* cpp = isA<coupledPolyPatch>(pp);
if (isA<coupledPolyPatch>(pp)) if (cpp)
{ {
const coupledPolyPatch& cpp = patchFacei = (cpp->owner() ? pp.whichFace(facei) : -1);
refCast<const coupledPolyPatch>(pp);
if (cpp.owner())
{
patchFacei = cpp.whichFace(facei);
}
} }
else if (!isA<emptyPolyPatch>(pp)) else if (!isA<emptyPolyPatch>(pp))
{ {

View File

@ -193,21 +193,15 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
{ {
facePatchId = mesh_.boundaryMesh().whichPatch(meshFacei); facePatchId = mesh_.boundaryMesh().whichPatch(meshFacei);
const polyPatch& pp = mesh_.boundaryMesh()[facePatchId]; const polyPatch& pp = mesh_.boundaryMesh()[facePatchId];
const auto* cpp = isA<coupledPolyPatch>(pp);
if (isA<coupledPolyPatch>(pp)) if (cpp)
{ {
if (refCast<const coupledPolyPatch>(pp).owner()) faceId = (cpp->owner() ? pp.whichFace(meshFacei) : -1);
{
faceId = pp.whichFace(meshFacei);
}
else
{
faceId = -1;
}
} }
else if (!isA<emptyPolyPatch>(pp)) else if (!isA<emptyPolyPatch>(pp))
{ {
faceId = meshFacei - pp.start(); faceId = pp.whichFace(meshFacei);
} }
else else
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -208,6 +208,7 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZone
forAll(fZone, i) forAll(fZone, i)
{ {
label facei = fZone[i]; label facei = fZone[i];
const bool isFlip = fZone.flipMap()[i];
label faceID = -1; label faceID = -1;
label facePatchID = -1; label facePatchID = -1;
@ -220,20 +221,15 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZone
{ {
facePatchID = mesh_.boundaryMesh().whichPatch(facei); facePatchID = mesh_.boundaryMesh().whichPatch(facei);
const polyPatch& pp = mesh_.boundaryMesh()[facePatchID]; const polyPatch& pp = mesh_.boundaryMesh()[facePatchID];
if (isA<coupledPolyPatch>(pp)) const auto* cpp = isA<coupledPolyPatch>(pp);
if (cpp)
{ {
if (refCast<const coupledPolyPatch>(pp).owner()) faceID = (cpp->owner() ? pp.whichFace(facei) : -1);
{
faceID = pp.whichFace(facei);
}
else
{
faceID = -1;
}
} }
else if (!isA<emptyPolyPatch>(pp)) else if (!isA<emptyPolyPatch>(pp))
{ {
faceID = facei - pp.start(); faceID = pp.whichFace(facei);
} }
else else
{ {
@ -245,15 +241,7 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZone
if (faceID >= 0) if (faceID >= 0)
{ {
// Orientation set by faceZone flip map // Orientation set by faceZone flip map
if (fZone.flipMap()[i]) flips.append(isFlip);
{
flips.append(true);
}
else
{
flips.append(false);
}
faceIDs.append(faceID); faceIDs.append(faceID);
facePatchIDs.append(facePatchID); facePatchIDs.append(facePatchID);
} }
@ -317,20 +305,15 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZoneAndDirection
{ {
facePatchID = mesh_.boundaryMesh().whichPatch(facei); facePatchID = mesh_.boundaryMesh().whichPatch(facei);
const polyPatch& pp = mesh_.boundaryMesh()[facePatchID]; const polyPatch& pp = mesh_.boundaryMesh()[facePatchID];
if (isA<coupledPolyPatch>(pp)) const auto* cpp = isA<coupledPolyPatch>(pp);
if (cpp)
{ {
if (refCast<const coupledPolyPatch>(pp).owner()) faceID = (cpp->owner() ? pp.whichFace(facei) : -1);
{
faceID = pp.whichFace(facei);
}
else
{
faceID = -1;
}
} }
else if (!isA<emptyPolyPatch>(pp)) else if (!isA<emptyPolyPatch>(pp))
{ {
faceID = facei - pp.start(); faceID = pp.whichFace(facei);
} }
else else
{ {

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -82,7 +82,7 @@ void Foam::fv::directionalPressureGradientExplicitSource::initialise()
label count = 0; label count = 0;
forAll(fZone, i) forAll(fZone, i)
{ {
label faceI = fZone[i]; const label faceI = fZone[i];
label faceId = -1; label faceId = -1;
label facePatchId = -1; label facePatchId = -1;
@ -95,20 +95,15 @@ void Foam::fv::directionalPressureGradientExplicitSource::initialise()
{ {
facePatchId = mesh_.boundaryMesh().whichPatch(faceI); facePatchId = mesh_.boundaryMesh().whichPatch(faceI);
const polyPatch& pp = mesh_.boundaryMesh()[facePatchId]; const polyPatch& pp = mesh_.boundaryMesh()[facePatchId];
if (isA<coupledPolyPatch>(pp)) const auto* cpp = isA<coupledPolyPatch>(pp);
if (cpp)
{ {
if (refCast<const coupledPolyPatch>(pp).owner()) faceId = (cpp->owner() ? pp.whichFace(faceI) : -1);
{
faceId = pp.whichFace(faceI);
}
else
{
faceId = -1;
}
} }
else if (!isA<emptyPolyPatch>(pp)) else if (!isA<emptyPolyPatch>(pp))
{ {
faceId = faceI - pp.start(); faceId = pp.whichFace(faceI);
} }
else else
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2015 OpenFOAM Foundation Copyright (C) 2013-2015 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -87,20 +87,15 @@ void Foam::fv::effectivenessHeatExchangerSource::initialise()
{ {
facePatchId = mesh_.boundaryMesh().whichPatch(facei); facePatchId = mesh_.boundaryMesh().whichPatch(facei);
const polyPatch& pp = mesh_.boundaryMesh()[facePatchId]; const polyPatch& pp = mesh_.boundaryMesh()[facePatchId];
if (isA<coupledPolyPatch>(pp)) const auto* cpp = isA<coupledPolyPatch>(pp);
if (cpp)
{ {
if (refCast<const coupledPolyPatch>(pp).owner()) faceId = (cpp->owner() ? pp.whichFace(facei) : -1);
{
faceId = pp.whichFace(facei);
}
else
{
faceId = -1;
}
} }
else if (!isA<emptyPolyPatch>(pp)) else if (!isA<emptyPolyPatch>(pp))
{ {
faceId = facei - pp.start(); faceId = pp.whichFace(facei);
} }
else else
{ {

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017, 2020 OpenFOAM Foundation Copyright (C) 2011-2017, 2020 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -41,18 +41,17 @@ License
template<class ParticleType> template<class ParticleType>
void Foam::Cloud<ParticleType>::checkPatches() const void Foam::Cloud<ParticleType>::checkPatches() const
{ {
const polyBoundaryMesh& pbm = polyMesh_.boundaryMesh();
bool ok = true; bool ok = true;
for (const polyPatch& pp : pbm) for (const polyPatch& pp : polyMesh_.boundaryMesh())
{ {
if (isA<cyclicAMIPolyPatch>(pp)) const auto* camipp = isA<cyclicAMIPolyPatch>(pp);
{
const cyclicAMIPolyPatch& cami =
refCast<const cyclicAMIPolyPatch>(pp);
if (cami.owner()) if (camipp && camipp->owner())
{ {
ok = ok && (cami.AMI().singlePatchProc() != -1); ok = (camipp->AMI().singlePatchProc() != -1);
if (!ok)
{
break;
} }
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -240,17 +240,11 @@ void Foam::meshRefinement::calcCellCellRays
// coupled unset. // coupled unset.
bitSet isMaster(mesh_.nBoundaryFaces(), true); bitSet isMaster(mesh_.nBoundaryFaces(), true);
{ {
const polyBoundaryMesh& patches = mesh_.boundaryMesh(); for (const polyPatch& pp : mesh_.boundaryMesh())
for (const polyPatch& pp : patches)
{ {
if (pp.coupled() && !refCast<const coupledPolyPatch>(pp).owner()) if (pp.coupled() && !refCast<const coupledPolyPatch>(pp).owner())
{ {
const labelRange bSlice isMaster.unset(labelRange(pp.offset(), pp.size()));
(
pp.start()-mesh_.nInternalFaces(),
pp.size()
);
isMaster.unset(bSlice);
} }
} }
} }
@ -2447,25 +2441,14 @@ bool Foam::meshRefinement::getFaceZoneInfo
void Foam::meshRefinement::selectSeparatedCoupledFaces(boolList& selected) const void Foam::meshRefinement::selectSeparatedCoupledFaces(boolList& selected) const
{ {
const polyBoundaryMesh& patches = mesh_.boundaryMesh(); for (const polyPatch& pp : mesh_.boundaryMesh())
forAll(patches, patchi)
{ {
// Check all coupled. Avoid using .coupled() so we also pick up AMI. // Check all coupled. Avoid using .coupled() so we also pick up AMI.
if (isA<coupledPolyPatch>(patches[patchi])) const auto* cpp = isA<coupledPolyPatch>(pp);
{
const coupledPolyPatch& cpp = refCast<const coupledPolyPatch>
(
patches[patchi]
);
if (cpp.separated() || !cpp.parallel()) if (cpp && (cpp->separated() || !cpp->parallel()))
{ {
forAll(cpp, i) SubList<bool>(selected, pp.size(), pp.start()) = true;
{
selected[cpp.start()+i] = true;
}
}
} }
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -649,12 +649,12 @@ void Foam::FaceCellWave<Type, TrackingData>::handleCyclicPatches()
for (const polyPatch& patch : mesh_.boundaryMesh()) for (const polyPatch& patch : mesh_.boundaryMesh())
{ {
if (isA<cyclicPolyPatch>(patch)) const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(patch);
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patch);
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch(); if (cpp)
{
const auto& cycPatch = *cpp;
const auto& nbrPatch = cycPatch.neighbPatch();
// Allocate buffers // Allocate buffers
label nReceiveFaces; label nReceiveFaces;
@ -733,12 +733,12 @@ void Foam::FaceCellWave<Type, TrackingData>::handleAMICyclicPatches()
for (const polyPatch& patch : mesh_.boundaryMesh()) for (const polyPatch& patch : mesh_.boundaryMesh())
{ {
if (isA<cyclicAMIPolyPatch>(patch)) const cyclicAMIPolyPatch* cpp = isA<cyclicAMIPolyPatch>(patch);
{
const cyclicAMIPolyPatch& cycPatch =
refCast<const cyclicAMIPolyPatch>(patch);
const cyclicAMIPolyPatch& nbrPatch = cycPatch.neighbPatch(); if (cpp)
{
const auto& cycPatch = *cpp;
const auto& nbrPatch = cycPatch.neighbPatch();
List<Type> receiveInfo; List<Type> receiveInfo;

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -435,10 +436,12 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
{ {
const polyPatch& patch = mesh_.boundaryMesh()[patchi]; const polyPatch& patch = mesh_.boundaryMesh()[patchi];
if (isA<cyclicPolyPatch>(patch)) const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(patch);
if (cpp)
{ {
const cyclicPolyPatch& cycPatch = const auto& cycPatch = *cpp;
refCast<const cyclicPolyPatch>(patch); const auto& nbrPatch = cycPatch.neighbPatch();
nbrInfo.clear(); nbrInfo.clear();
nbrInfo.reserve(cycPatch.nPoints()); nbrInfo.reserve(cycPatch.nPoints());
@ -449,7 +452,6 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
// Collect nbrPatch points that have changed // Collect nbrPatch points that have changed
{ {
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const edgeList& pairs = cycPatch.coupledPoints(); const edgeList& pairs = cycPatch.coupledPoints();
const labelList& meshPoints = nbrPatch.meshPoints(); const labelList& meshPoints = nbrPatch.meshPoints();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,6 +27,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "coordinateSystems.H" #include "coordinateSystems.H"
#include "predicates.H"
#include "PtrListOps.H"
#include "Time.H" #include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -42,99 +44,8 @@ namespace Foam
static const char* headerTypeCompat = "IOPtrList<coordinateSystem>"; static const char* headerTypeCompat = "IOPtrList<coordinateSystem>";
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
// Templated implementation for names() - file-scope
template<class UnaryMatchPredicate>
static wordList namesImpl
(
const PtrList<coordinateSystem>& list,
const UnaryMatchPredicate& matcher,
const bool doSort
)
{
const label len = list.size();
wordList output(len);
label count = 0;
for (label i = 0; i < len; ++i)
{
const word& itemName = list[i].name();
if (matcher(itemName))
{
output[count++] = itemName;
}
}
output.resize(count);
if (doSort)
{
Foam::sort(output);
}
return output;
}
// Templated implementation for indices() - file-scope
template<class UnaryMatchPredicate>
static labelList indicesImpl
(
const PtrList<coordinateSystem>& list,
const UnaryMatchPredicate& matcher
)
{
const label len = list.size();
labelList output(len);
label count = 0;
for (label i = 0; i < len; ++i)
{
if (matcher(list[i].name()))
{
output[count++] = i;
}
}
output.resize(count);
return output;
}
// Templated implementation for findIndex() - file-scope
template<class UnaryMatchPredicate>
label findIndexImpl
(
const PtrList<coordinateSystem>& list,
const UnaryMatchPredicate& matcher
)
{
const label len = list.size();
for (label i = 0; i < len; ++i)
{
if (matcher(list[i].name()))
{
return i;
}
}
return -1;
}
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::coordinateSystems::readFromStream(const bool valid) void Foam::coordinateSystems::readFromStream(const bool valid)
{ {
Istream& is = readStream(word::null, valid); Istream& is = readStream(word::null, valid);
@ -277,14 +188,14 @@ Foam::labelList Foam::coordinateSystems::indices(const keyType& key) const
else if (key.isPattern()) else if (key.isPattern())
{ {
// Match as regex // Match as regex
regExp matcher(key); const regExp matcher(key);
return indicesImpl(*this, matcher); return PtrListOps::findMatching(*this, matcher);
} }
else else
{ {
// Compare as literal string // Compare as literal string
const word& matcher = key; const word& matcher = key;
return indicesImpl(*this, matcher); return PtrListOps::findMatching(*this, matcher);
} }
} }
@ -295,7 +206,7 @@ Foam::labelList Foam::coordinateSystems::indices(const wordRes& matcher) const
{ {
return labelList(); return labelList();
} }
return indicesImpl(*this, matcher); return PtrListOps::findMatching(*this, matcher);
} }
@ -305,18 +216,17 @@ Foam::label Foam::coordinateSystems::findIndex(const keyType& key) const
{ {
return -1; return -1;
} }
else if (key.isPattern())
if (key.isPattern())
{ {
// Find as regex // Find as regex
regExp matcher(key); const regExp matcher(key);
return findIndexImpl(*this, matcher); return PtrListOps::firstMatching(*this, matcher);
} }
else else
{ {
// Find as literal string // Find as literal string
const word& matcher = key; const word& matcher = key;
return findIndexImpl(*this, matcher); return PtrListOps::firstMatching(*this, matcher);
} }
} }
@ -327,7 +237,7 @@ Foam::label Foam::coordinateSystems::findIndex(const wordRes& matcher) const
{ {
return -1; return -1;
} }
return findIndexImpl(*this, matcher); return PtrListOps::firstMatching(*this, matcher);
} }
@ -384,17 +294,7 @@ Foam::coordinateSystems::lookup(const word& name) const
Foam::wordList Foam::coordinateSystems::names() const Foam::wordList Foam::coordinateSystems::names() const
{ {
const PtrList<coordinateSystem>& list = *this; return PtrListOps::names(*this, predicates::always{});
wordList result(list.size());
forAll(list, i)
{
result[i] = list[i].name();
}
return result;
// return ListOps::create<word>(list, nameOp<coordinateSystem>());
} }
@ -407,27 +307,27 @@ Foam::wordList Foam::coordinateSystems::names(const keyType& key) const
else if (key.isPattern()) else if (key.isPattern())
{ {
// Find as regex // Find as regex
regExp matcher(key); const regExp matcher(key);
return namesImpl(*this, matcher, false); return PtrListOps::names(*this, matcher);
} }
else else
{ {
// Find as literal string // Find as literal string
const word& matcher = key; const word& matcher = key;
return namesImpl(*this, matcher, false); return PtrListOps::names(*this, matcher);
} }
} }
Foam::wordList Foam::coordinateSystems::names(const wordRe& matcher) const Foam::wordList Foam::coordinateSystems::names(const wordRe& matcher) const
{ {
return namesImpl(*this, matcher, false); return PtrListOps::names(*this, matcher);
} }
Foam::wordList Foam::coordinateSystems::names(const wordRes& matcher) const Foam::wordList Foam::coordinateSystems::names(const wordRes& matcher) const
{ {
return namesImpl(*this, matcher, false); return PtrListOps::names(*this, matcher);
} }

View File

@ -232,7 +232,7 @@ void Foam::regionSplit::fillSeedMask
{ {
const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(pp); const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(pp);
if (bool(cpp) && cpp->owner()) if (cpp && cpp->owner())
{ {
// Transfer from neighbourPatch to here or vice versa. // Transfer from neighbourPatch to here or vice versa.
const auto& cycPatch = *cpp; const auto& cycPatch = *cpp;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd. Copyright (C) 2020-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -111,22 +111,15 @@ Foam::labelList Foam::SloanRenumber::renumber
const pointField& points const pointField& points
) const ) const
{ {
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
// Construct graph : faceOwner + connections across cyclics. // Construct graph : faceOwner + connections across cyclics.
// Determine neighbour cell // Determine neighbour cell
labelList nbr(mesh.nBoundaryFaces(), -1); labelList nbr(mesh.nBoundaryFaces(), -1);
forAll(pbm, patchi) for (const polyPatch& pp : mesh.boundaryMesh())
{ {
if (pbm[patchi].coupled() && !isA<processorPolyPatch>(pbm[patchi])) if (pp.coupled() && !isA<processorPolyPatch>(pp))
{ {
SubList<label> SubList<label>(nbr, pp.size(), pp.offset()) = pp.faceCells();
(
nbr,
pbm[patchi].size(),
pbm[patchi].start()-mesh.nInternalFaces()
) = pbm[patchi].faceCells();
} }
} }
syncTools::swapBoundaryFaceList(mesh, nbr); syncTools::swapBoundaryFaceList(mesh, nbr);
@ -140,28 +133,29 @@ Foam::labelList Foam::SloanRenumber::renumber
add_edge(mesh.faceOwner()[facei], mesh.faceNeighbour()[facei], G); add_edge(mesh.faceOwner()[facei], mesh.faceNeighbour()[facei], G);
} }
// Add cyclics // Add cyclics
forAll(pbm, patchi) for (const polyPatch& pp : mesh.boundaryMesh())
{ {
if if
( (
pbm[patchi].coupled() pp.coupled()
&& !isA<processorPolyPatch>(pbm[patchi]) && !isA<processorPolyPatch>(pp)
&& refCast<const coupledPolyPatch>(pbm[patchi]).owner() && refCast<const coupledPolyPatch>(pp).owner()
) )
{ {
const labelUList& faceCells = pbm[patchi].faceCells(); label bFacei = pp.offset();
forAll(faceCells, i)
{
label bFacei = pbm[patchi].start()+i-mesh.nInternalFaces();
label nbrCelli = nbr[bFacei];
if (faceCells[i] < nbrCelli) for (const label ownCelli : pp.faceCells())
{ {
add_edge(faceCells[i], nbrCelli, G); const label nbrCelli = nbr[bFacei];
++bFacei;
if (ownCelli < nbrCelli)
{
add_edge(ownCelli, nbrCelli, G);
} }
else else
{ {
add_edge(nbrCelli, faceCells[i], G); add_edge(nbrCelli, ownCelli, G);
} }
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -405,17 +405,11 @@ void Foam::meshToMesh::distributeCells
forAll(tgtMesh.boundaryMesh(), patchi) forAll(tgtMesh.boundaryMesh(), patchi)
{ {
const polyPatch& pp = tgtMesh.boundaryMesh()[patchi]; const polyPatch& pp = tgtMesh.boundaryMesh()[patchi];
const auto* procPatch = isA<processorPolyPatch>(pp);
label nbrProci = -1; // Store info for faces on processor patches
const label nbrProci =
// store info for faces on processor patches (procPatch ? procPatch->neighbProcNo() : -1);
if (isA<processorPolyPatch>(pp))
{
const processorPolyPatch& ppp =
dynamic_cast<const processorPolyPatch&>(pp);
nbrProci = ppp.neighbProcNo();
}
forAll(pp, i) forAll(pp, i)
{ {

View File

@ -196,7 +196,7 @@ bool Foam::sampledFaceZone::update()
} }
else else
{ {
faceId = meshFacei - pp.start(); faceId = pp.whichFace(meshFacei);
} }
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -79,7 +79,7 @@ struct storeOp
static inline bool collocatedPatch(const polyPatch& pp) static inline bool collocatedPatch(const polyPatch& pp)
{ {
const auto* cpp = isA<coupledPolyPatch>(pp); const auto* cpp = isA<coupledPolyPatch>(pp);
return bool(cpp) && cpp->parallel() && !cpp->separated(); return cpp && cpp->parallel() && !cpp->separated();
} }
@ -158,21 +158,18 @@ void Foam::isoSurfacePoint::syncUnseparatedPoints
if (Pstream::parRun()) if (Pstream::parRun())
{ {
// Send const labelList& procPatches = mesh_.globalData().processorPatches();
for (const polyPatch& p : patches)
{
if
(
isA<processorPolyPatch>(p)
&& p.nPoints() > 0
&& collocatedPatch(p)
)
{
const processorPolyPatch& pp =
refCast<const processorPolyPatch>(p);
const labelList& meshPts = pp.meshPoints(); // Send
const labelList& nbrPts = pp.neighbPoints(); for (const label patchi : procPatches)
{
const polyPatch& pp = patches[patchi];
const auto& procPatch = refCast<const processorPolyPatch>(pp);
if (pp.nPoints() && collocatedPatch(pp))
{
const labelList& meshPts = procPatch.meshPoints();
const labelList& nbrPts = procPatch.neighbPoints();
pointField patchInfo(meshPts.size()); pointField patchInfo(meshPts.size());
@ -185,38 +182,33 @@ void Foam::isoSurfacePoint::syncUnseparatedPoints
OPstream toNbr OPstream toNbr
( (
Pstream::commsTypes::blocking, Pstream::commsTypes::blocking,
pp.neighbProcNo() procPatch.neighbProcNo()
); );
toNbr << patchInfo; toNbr << patchInfo;
} }
} }
// Receive and combine. // Receive and combine.
for (const polyPatch& p : patches) for (const label patchi : procPatches)
{ {
if const polyPatch& pp = patches[patchi];
( const auto& procPatch = refCast<const processorPolyPatch>(pp);
isA<processorPolyPatch>(p)
&& p.nPoints() > 0
&& collocatedPatch(p)
)
{
const processorPolyPatch& pp =
refCast<const processorPolyPatch>(p);
pointField nbrPatchInfo(pp.nPoints()); if (pp.nPoints() && collocatedPatch(pp))
{
pointField nbrPatchInfo(procPatch.nPoints());
{ {
// We do not know the number of points on the other side // We do not know the number of points on the other side
// so cannot use Pstream::read. // so cannot use Pstream::read.
IPstream fromNbr IPstream fromNbr
( (
Pstream::commsTypes::blocking, Pstream::commsTypes::blocking,
pp.neighbProcNo() procPatch.neighbProcNo()
); );
fromNbr >> nbrPatchInfo; fromNbr >> nbrPatchInfo;
} }
const labelList& meshPts = pp.meshPoints(); const labelList& meshPts = procPatch.meshPoints();
forAll(meshPts, pointi) forAll(meshPts, pointi)
{ {
@ -232,20 +224,19 @@ void Foam::isoSurfacePoint::syncUnseparatedPoints
} }
// Do the cyclics. // Do the cyclics.
for (const polyPatch& p : patches) for (const polyPatch& pp : patches)
{ {
if (isA<cyclicPolyPatch>(p)) const cyclicPolyPatch* cpp = isA<cyclicPolyPatch>(pp);
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(p);
if (cycPatch.owner() && collocatedPatch(cycPatch)) if (cpp && cpp->owner() && collocatedPatch(*cpp))
{ {
// Owner does all. // Owner does all.
const auto& cycPatch = *cpp;
const auto& nbrPatch = cycPatch.neighbPatch();
const edgeList& coupledPoints = cycPatch.coupledPoints(); const edgeList& coupledPoints = cycPatch.coupledPoints();
const labelList& meshPts = cycPatch.meshPoints(); const labelList& meshPts = cycPatch.meshPoints();
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const labelList& nbrMeshPoints = nbrPatch.meshPoints(); const labelList& nbrMeshPoints = nbrPatch.meshPoints();
pointField half0Values(coupledPoints.size()); pointField half0Values(coupledPoints.size());
@ -269,7 +260,6 @@ void Foam::isoSurfacePoint::syncUnseparatedPoints
} }
} }
} }
}
// Synchronize multiple shared points. // Synchronize multiple shared points.
const globalMeshData& pd = mesh_.globalData(); const globalMeshData& pd = mesh_.globalData();