mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: align faceZone handling (functionObjects, sampling)
- pattern as per surfaceFieldValue::setFaceZoneFaces()
1. define faceId, facePatchId assuming an internal face
2. if actually a boundary face:
- get facePatchId
- ignore if emptyPolyPatch or coupledPolyPatch (neighbour side)
- get patch relative faceId
This currently seems to be the least amount of code clutter.
ENH: recover some memory my shrinking lists in fluxSummary
BUG: potentially trailing rubbish in the heatExchangerModel lists
- the final resize to length actually used was missing.
Does not affect any released versions
This commit is contained in:
@ -168,9 +168,9 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
|
||||
}
|
||||
#endif
|
||||
|
||||
faceId_.resize(numFaces);
|
||||
facePatchId_.resize(numFaces);
|
||||
faceFlip_.resize(numFaces);
|
||||
faceId_.resize_nocopy(numFaces);
|
||||
facePatchId_.resize_nocopy(numFaces);
|
||||
faceFlip_.resize_nocopy(numFaces);
|
||||
|
||||
numFaces = 0;
|
||||
|
||||
@ -192,21 +192,20 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::setFaceZoneFaces()
|
||||
{
|
||||
facePatchId = mesh_.boundaryMesh().whichPatch(meshFacei);
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[facePatchId];
|
||||
|
||||
if (isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
continue; // Ignore empty patch
|
||||
}
|
||||
|
||||
const auto* cpp = isA<coupledPolyPatch>(pp);
|
||||
|
||||
if (cpp)
|
||||
if (cpp && !cpp->owner())
|
||||
{
|
||||
faceId = (cpp->owner() ? pp.whichFace(meshFacei) : -1);
|
||||
}
|
||||
else if (!isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
faceId = pp.whichFace(meshFacei);
|
||||
}
|
||||
else
|
||||
{
|
||||
faceId = -1;
|
||||
facePatchId = -1;
|
||||
continue; // Ignore neighbour side
|
||||
}
|
||||
|
||||
faceId = pp.whichFace(meshFacei);
|
||||
}
|
||||
|
||||
if (faceId >= 0)
|
||||
|
||||
@ -201,56 +201,62 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZone
|
||||
names.append(faceZoneName);
|
||||
directions.append(Zero); // dummy value
|
||||
|
||||
DynamicList<label> faceIDs(fZone.size());
|
||||
DynamicList<label> facePatchIDs(fZone.size());
|
||||
DynamicList<bool> flips(fZone.size());
|
||||
labelList faceIds(fZone.size());
|
||||
labelList facePatchIds(fZone.size());
|
||||
boolList faceFlips(fZone.size());
|
||||
|
||||
// Total number of faces selected
|
||||
label numFaces = 0;
|
||||
|
||||
forAll(fZone, i)
|
||||
{
|
||||
label facei = fZone[i];
|
||||
const label meshFacei = fZone[i];
|
||||
const bool isFlip = fZone.flipMap()[i];
|
||||
|
||||
label faceID = -1;
|
||||
label facePatchID = -1;
|
||||
if (mesh_.isInternalFace(facei))
|
||||
// Internal faces
|
||||
label faceId = meshFacei;
|
||||
label facePatchId = -1;
|
||||
|
||||
// Boundary faces
|
||||
if (!mesh_.isInternalFace(meshFacei))
|
||||
{
|
||||
faceID = facei;
|
||||
facePatchID = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
facePatchID = mesh_.boundaryMesh().whichPatch(facei);
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[facePatchID];
|
||||
facePatchId = mesh_.boundaryMesh().whichPatch(meshFacei);
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[facePatchId];
|
||||
|
||||
if (isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
continue; // Ignore empty patch
|
||||
}
|
||||
|
||||
const auto* cpp = isA<coupledPolyPatch>(pp);
|
||||
|
||||
if (cpp)
|
||||
if (cpp && !cpp->owner())
|
||||
{
|
||||
faceID = (cpp->owner() ? pp.whichFace(facei) : -1);
|
||||
}
|
||||
else if (!isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
faceID = pp.whichFace(facei);
|
||||
}
|
||||
else
|
||||
{
|
||||
faceID = -1;
|
||||
facePatchID = -1;
|
||||
continue; // Ignore neighbour side
|
||||
}
|
||||
|
||||
faceId = pp.whichFace(meshFacei);
|
||||
}
|
||||
|
||||
if (faceID >= 0)
|
||||
if (faceId >= 0)
|
||||
{
|
||||
// Orientation set by faceZone flip map
|
||||
flips.append(isFlip);
|
||||
faceIDs.append(faceID);
|
||||
facePatchIDs.append(facePatchID);
|
||||
faceIds[numFaces] = faceId;
|
||||
facePatchIds[numFaces] = facePatchId;
|
||||
faceFlips[numFaces] = isFlip;
|
||||
|
||||
++numFaces;
|
||||
}
|
||||
}
|
||||
|
||||
// could reduce some copying here
|
||||
faceID.append(faceIDs);
|
||||
facePatchID.append(facePatchIDs);
|
||||
faceFlip.append(flips);
|
||||
// Shrink to size used
|
||||
faceIds.resize(numFaces);
|
||||
facePatchIds.resize(numFaces);
|
||||
faceFlips.resize(numFaces);
|
||||
|
||||
faceID.append(std::move(faceIds));
|
||||
facePatchID.append(std::move(facePatchIds));
|
||||
faceFlip.append(std::move(faceFlips));
|
||||
}
|
||||
|
||||
|
||||
@ -281,78 +287,84 @@ void Foam::functionObjects::fluxSummary::initialiseFaceZoneAndDirection
|
||||
names.append(faceZoneName);
|
||||
directions.append(refDir);
|
||||
|
||||
DynamicList<label> faceIDs(fZone.size());
|
||||
DynamicList<label> facePatchIDs(fZone.size());
|
||||
DynamicList<bool> flips(fZone.size());
|
||||
labelList faceIds(fZone.size());
|
||||
labelList facePatchIds(fZone.size());
|
||||
boolList faceFlips(fZone.size());
|
||||
|
||||
const surfaceVectorField& Sf = mesh_.Sf();
|
||||
const surfaceScalarField& magSf = mesh_.magSf();
|
||||
|
||||
vector n(Zero);
|
||||
|
||||
// Total number of faces selected
|
||||
label numFaces = 0;
|
||||
|
||||
forAll(fZone, i)
|
||||
{
|
||||
label facei = fZone[i];
|
||||
const label meshFacei = fZone[i];
|
||||
|
||||
label faceID = -1;
|
||||
label facePatchID = -1;
|
||||
if (mesh_.isInternalFace(facei))
|
||||
// Internal faces
|
||||
label faceId = meshFacei;
|
||||
label facePatchId = -1;
|
||||
|
||||
// Boundary faces
|
||||
if (!mesh_.isInternalFace(meshFacei))
|
||||
{
|
||||
faceID = facei;
|
||||
facePatchID = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
facePatchID = mesh_.boundaryMesh().whichPatch(facei);
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[facePatchID];
|
||||
facePatchId = mesh_.boundaryMesh().whichPatch(meshFacei);
|
||||
const polyPatch& pp = mesh_.boundaryMesh()[facePatchId];
|
||||
|
||||
if (isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
continue; // Ignore empty patch
|
||||
}
|
||||
|
||||
const auto* cpp = isA<coupledPolyPatch>(pp);
|
||||
|
||||
if (cpp)
|
||||
if (cpp && !cpp->owner())
|
||||
{
|
||||
faceID = (cpp->owner() ? pp.whichFace(facei) : -1);
|
||||
}
|
||||
else if (!isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
faceID = pp.whichFace(facei);
|
||||
}
|
||||
else
|
||||
{
|
||||
faceID = -1;
|
||||
facePatchID = -1;
|
||||
continue; // Ignore neighbour side
|
||||
}
|
||||
|
||||
faceId = pp.whichFace(meshFacei);
|
||||
}
|
||||
|
||||
if (faceID >= 0)
|
||||
if (faceId >= 0)
|
||||
{
|
||||
// orientation set by comparison with reference direction
|
||||
if (facePatchID != -1)
|
||||
// Orientation set by comparison with reference direction
|
||||
if (facePatchId != -1)
|
||||
{
|
||||
n = Sf.boundaryField()[facePatchID][faceID]
|
||||
/(magSf.boundaryField()[facePatchID][faceID] + ROOTVSMALL);
|
||||
n = Sf.boundaryField()[facePatchId][faceId]
|
||||
/(magSf.boundaryField()[facePatchId][faceId] + ROOTVSMALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
n = Sf[faceID]/(magSf[faceID] + ROOTVSMALL);
|
||||
n = Sf[faceId]/(magSf[faceId] + ROOTVSMALL);
|
||||
}
|
||||
|
||||
if ((n & refDir) > tolerance_)
|
||||
{
|
||||
flips.append(false);
|
||||
faceFlips[numFaces] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
flips.append(true);
|
||||
faceFlips[numFaces] = true;
|
||||
}
|
||||
|
||||
faceIDs.append(faceID);
|
||||
facePatchIDs.append(facePatchID);
|
||||
faceIds[numFaces] = faceId;
|
||||
facePatchIds[numFaces] = facePatchId;
|
||||
|
||||
++numFaces;
|
||||
}
|
||||
}
|
||||
|
||||
// could reduce copying here
|
||||
faceID.append(faceIDs);
|
||||
facePatchID.append(facePatchIDs);
|
||||
faceFlip.append(flips);
|
||||
// Shrink to size used
|
||||
faceIds.resize(numFaces);
|
||||
facePatchIds.resize(numFaces);
|
||||
faceFlips.resize(numFaces);
|
||||
|
||||
faceID.append(std::move(faceIds));
|
||||
facePatchID.append(std::move(facePatchIds));
|
||||
faceFlip.append(std::move(faceFlips));
|
||||
}
|
||||
|
||||
|
||||
@ -498,7 +510,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
|
||||
<< "Starting walk to split patch into faceZones"
|
||||
<< endl;
|
||||
|
||||
globalIndex globalFaces(patch.size());
|
||||
const globalIndex globalFaces(patch.size());
|
||||
|
||||
label oldFaceID = 0;
|
||||
label regioni = 0;
|
||||
|
||||
@ -70,7 +70,7 @@ setFaceZoneFaces(const dictionary& dict)
|
||||
|
||||
label numFaces = fZone.size();
|
||||
|
||||
if (!returnReduce(bool(numFaces), orOp<bool>()))
|
||||
if (!returnReduceOr(numFaces))
|
||||
{
|
||||
FatalIOErrorInFunction(dict)
|
||||
<< "referenceFaceZone: " << faceZoneName
|
||||
@ -78,49 +78,55 @@ setFaceZoneFaces(const dictionary& dict)
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
faceId_.resize(numFaces);
|
||||
facePatchId_.resize(numFaces);
|
||||
faceId_.resize_nocopy(numFaces);
|
||||
facePatchId_.resize_nocopy(numFaces);
|
||||
|
||||
numFaces = 0;
|
||||
|
||||
forAll(fZone, i)
|
||||
// TDB: handle multiple zones
|
||||
{
|
||||
const label meshFacei = fZone[i];
|
||||
|
||||
// Internal faces
|
||||
label faceId = meshFacei;
|
||||
label facePatchId = -1;
|
||||
|
||||
// Boundary faces
|
||||
if (!mesh.isInternalFace(meshFacei))
|
||||
forAll(fZone, i)
|
||||
{
|
||||
facePatchId = mesh.boundaryMesh().whichPatch(meshFacei);
|
||||
const polyPatch& pp = mesh.boundaryMesh()[facePatchId];
|
||||
const auto* cpp = isA<coupledPolyPatch>(pp);
|
||||
const label meshFacei = fZone[i];
|
||||
|
||||
if (cpp)
|
||||
{
|
||||
faceId = (cpp->owner() ? pp.whichFace(meshFacei) : -1);
|
||||
}
|
||||
else if (!isA<emptyPolyPatch>(pp))
|
||||
// Internal faces
|
||||
label faceId = meshFacei;
|
||||
label facePatchId = -1;
|
||||
|
||||
// Boundary faces
|
||||
if (!mesh.isInternalFace(meshFacei))
|
||||
{
|
||||
facePatchId = mesh.boundaryMesh().whichPatch(meshFacei);
|
||||
const polyPatch& pp = mesh.boundaryMesh()[facePatchId];
|
||||
|
||||
if (isA<emptyPolyPatch>(pp))
|
||||
{
|
||||
continue; // Ignore empty patch
|
||||
}
|
||||
|
||||
const auto* cpp = isA<coupledPolyPatch>(pp);
|
||||
|
||||
if (cpp && !cpp->owner())
|
||||
{
|
||||
continue; // Ignore neighbour side
|
||||
}
|
||||
|
||||
faceId = pp.whichFace(meshFacei);
|
||||
}
|
||||
else
|
||||
|
||||
if (faceId >= 0)
|
||||
{
|
||||
faceId = -1;
|
||||
facePatchId = -1;
|
||||
faceId_[numFaces] = faceId;
|
||||
facePatchId_[numFaces] = facePatchId;
|
||||
|
||||
++numFaces;
|
||||
}
|
||||
}
|
||||
|
||||
if (faceId >= 0)
|
||||
{
|
||||
faceId_[numFaces] = faceId;
|
||||
facePatchId_[numFaces] = facePatchId;
|
||||
|
||||
++numFaces;
|
||||
}
|
||||
}
|
||||
|
||||
// Shrink to size used
|
||||
faceId_.resize(numFaces);
|
||||
facePatchId_.resize(numFaces);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user