WIP: faMesh edge connections

This commit is contained in:
Mark Olesen 2023-05-08 17:08:12 +02:00
parent 763bf4674d
commit a07272a52d
3 changed files with 53 additions and 21 deletions

View File

@ -97,6 +97,8 @@ static labelList selectPatchFaces
<< exit(FatalError); << exit(FatalError);
} }
Pout<< "patchIDs: " << flatOutput(patchIDs) << endl;
label nFaceLabels = 0; label nFaceLabels = 0;
for (const label patchi : patchIDs) for (const label patchi : patchIDs)
{ {

View File

@ -407,6 +407,10 @@ Foam::faPatchList Foam::faMesh::createPatchList
: word::null : word::null
) )
<< nl; << nl;
Pout<< "local/finite-area = " << a.is_localProc() << "/" << a.is_finiteArea()
<< " <=> " << b.is_localProc() << "/" << b.is_finiteArea() << endl;
} }
} }
} }

View File

@ -120,6 +120,9 @@ Foam::faMesh::getBoundaryEdgeConnections() const
labelHashSet badEdges(2*nBoundaryEdges); labelHashSet badEdges(2*nBoundaryEdges);
labelHashSet danglingEdges(2*nBoundaryEdges); labelHashSet danglingEdges(2*nBoundaryEdges);
// Heavy handed
labelHashSet facesUsed(faceLabels_);
{ {
// Local collection structure for accounting of patch pairs. // Local collection structure for accounting of patch pairs.
// Based on 'edge' which has some hash-like insertion properties // Based on 'edge' which has some hash-like insertion properties
@ -143,6 +146,22 @@ Foam::faMesh::getBoundaryEdgeConnections() const
<< "Determining required boundary edge connections, " << "Determining required boundary edge connections, "
<< "resolving locally attached boundary edges." << endl; << "resolving locally attached boundary edges." << endl;
// Pass 1:
// - setup lookup (edge -> bnd index)
// - add owner patch for each boundary edge
labelList nEdgeFaces(nBoundaryEdges, Zero);
for (label bndEdgei = 0; bndEdgei < nBoundaryEdges; ++bndEdgei)
{
const label patchEdgei = (bndEdgei + nInternalEdges);
// The attached patch face. Should only be one!
const labelList& edgeFaces = patch().edgeFaces()[patchEdgei];
nEdgeFaces[bndEdgei] = edgeFaces.size();
}
Pout<< "nEdgeFaces : "; nEdgeFaces.writeList(Pout) << endl;
// Pass 1: // Pass 1:
// - setup lookup (edge -> bnd index) // - setup lookup (edge -> bnd index)
// - add owner patch for each boundary edge // - add owner patch for each boundary edge
@ -250,6 +269,24 @@ Foam::faMesh::getBoundaryEdgeConnections() const
{ {
// Has a matching owner boundary edge // Has a matching owner boundary edge
// The attached patch face. Should only be one!
const labelList& edgeFaces = pp.edgeFaces()[patchEdgei];
if (edgeFaces.size() != 1)
{
badEdges.insert(badEdges.size());
continue;
}
const label patchFacei = edgeFaces[0];
const label meshFacei = patchFacei + pp.start();
if (facesUsed.contains(meshFacei))
{
Pout<< "patch=" << patchi << " face " << meshFacei << endl;
continue;
}
auto& pairing = patchPairings[bndEdgei]; auto& pairing = patchPairings[bndEdgei];
// Add neighbour (patchId, patchEdgei, meshFacei) // Add neighbour (patchId, patchEdgei, meshFacei)
@ -257,23 +294,11 @@ Foam::faMesh::getBoundaryEdgeConnections() const
// which does not insert the same value twice // which does not insert the same value twice
if (pairing.insert(patchi)) if (pairing.insert(patchi))
{ {
// The attached patch face. Should only be one!
const labelList& edgeFaces = pp.edgeFaces()[patchEdgei];
if (edgeFaces.size() != 1)
{
pairing.erase(patchi);
badEdges.insert(badEdges.size());
continue;
}
const label patchFacei = edgeFaces[0];
const label meshFacei = patchFacei + pp.start();
// The neighbour information // The neighbour information
pairing.patchEdgei_ = patchEdgei; pairing.patchEdgei_ = patchEdgei;
pairing.meshFacei_ = meshFacei; pairing.meshFacei_ = meshFacei;
--nMissing; --nMissing;
if (!nMissing) break; // Early exit if (!nMissing) break; // Early exit
} }
@ -451,7 +476,7 @@ Foam::faMesh::getBoundaryEdgeConnections() const
if (bndEdgei != -1) if (bndEdgei != -1)
{ {
// A boundary finiteEdge edge (known from this side) // A boundary finiteArea edge (known from this side)
auto& gathered = gatheredConnections[cppEdgei]; auto& gathered = gatheredConnections[cppEdgei];
gathered.setCapacity_nocopy(2); gathered.setCapacity_nocopy(2);
@ -565,7 +590,7 @@ Foam::faMesh::getBoundaryEdgeConnections() const
if (bndEdgei != -1) if (bndEdgei != -1)
{ {
// A boundary finiteEdge edge (known from this side) // A boundary finiteArea edge (known from this side)
auto& connection = bndEdgeConnections[bndEdgei]; auto& connection = bndEdgeConnections[bndEdgei];
if (gathered.size() == 1) if (gathered.size() == 1)
@ -678,8 +703,7 @@ Foam::faMesh::getBoundaryEdgeConnections() const
<< nl << "Dangling edges detected" << endl; << nl << "Dangling edges detected" << endl;
// Print out edges as point pairs // Print out edges as point pairs
// These are globally synchronised - so only output on master constexpr label maxOutput = 5;
constexpr label maxOutput = 10;
label nOutput = 0; label nOutput = 0;
@ -689,17 +713,17 @@ Foam::faMesh::getBoundaryEdgeConnections() const
const auto& gathered = gatheredConnections[cppEdgei]; const auto& gathered = gatheredConnections[cppEdgei];
Info<< "connection: "; Pout<< "connection: ";
gathered.writeList(Info) << nl; gathered.writeList(Pout) << nl;
Info<<" edge : " Pout<<" edge : "
<< cpp.points()[e.first()] << ' ' << cpp.points()[e.first()] << ' '
<< cpp.points()[e.second()] << nl; << cpp.points()[e.second()] << nl;
++nOutput; ++nOutput;
if (maxOutput > 0 && nOutput >= maxOutput) if (maxOutput > 0 && nOutput >= maxOutput)
{ {
Info<< " ... suppressing further output" << nl; Pout<< " ... suppressing further output" << nl;
break; break;
} }
} }
@ -825,6 +849,8 @@ Foam::faMesh::getBoundaryEdgeConnections() const
// Globally consistent ordering // Globally consistent ordering
patchTuple::sort(bndEdgeConnections); patchTuple::sort(bndEdgeConnections);
Pout<< "connections " << flatOutput(bndEdgeConnections) << endl;
DebugInFunction DebugInFunction
<< "Return sorted list of boundary connections" << endl; << "Return sorted list of boundary connections" << endl;