mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve memory allocations for explicit connections (issue #805)
STYLE: change access methods names in mesh wave algorithms - nUnvisitedCells(), nUnvisitedFaces() etc instead of getUnsetCells(), getUnsetFaces() - simplify some coding with range-for
This commit is contained in:
@ -259,9 +259,9 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict)
|
|||||||
);
|
);
|
||||||
wallDistCalc.iterate(nMedialAxisIter);
|
wallDistCalc.iterate(nMedialAxisIter);
|
||||||
|
|
||||||
label nUnvisit = returnReduce
|
const label nUnvisit = returnReduce
|
||||||
(
|
(
|
||||||
wallDistCalc.getUnsetPoints(),
|
wallDistCalc.nUnvisitedPoints(),
|
||||||
sumOp<label>()
|
sumOp<label>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -122,11 +122,11 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateCell
|
|||||||
// - changedCell_, changedCells_
|
// - changedCell_, changedCells_
|
||||||
// - statistics: nEvals_, nUnvisitedCells_
|
// - statistics: nEvals_, nUnvisitedCells_
|
||||||
|
|
||||||
nEvals_++;
|
++nEvals_;
|
||||||
|
|
||||||
bool wasValid = cellInfo.valid(td_);
|
const bool wasValid = cellInfo.valid(td_);
|
||||||
|
|
||||||
bool propagate =
|
const bool propagate =
|
||||||
cellInfo.updateCell
|
cellInfo.updateCell
|
||||||
(
|
(
|
||||||
mesh_,
|
mesh_,
|
||||||
@ -139,9 +139,8 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateCell
|
|||||||
|
|
||||||
if (propagate)
|
if (propagate)
|
||||||
{
|
{
|
||||||
if (!changedCell_[celli])
|
if (changedCell_.set(celli))
|
||||||
{
|
{
|
||||||
changedCell_.set(celli);
|
|
||||||
changedCells_.append(celli);
|
changedCells_.append(celli);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,11 +170,11 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateFace
|
|||||||
// - changedFace_, changedFaces_,
|
// - changedFace_, changedFaces_,
|
||||||
// - statistics: nEvals_, nUnvisitedFaces_
|
// - statistics: nEvals_, nUnvisitedFaces_
|
||||||
|
|
||||||
nEvals_++;
|
++nEvals_;
|
||||||
|
|
||||||
bool wasValid = faceInfo.valid(td_);
|
const bool wasValid = faceInfo.valid(td_);
|
||||||
|
|
||||||
bool propagate =
|
const bool propagate =
|
||||||
faceInfo.updateFace
|
faceInfo.updateFace
|
||||||
(
|
(
|
||||||
mesh_,
|
mesh_,
|
||||||
@ -218,11 +217,11 @@ bool Foam::FaceCellWave<Type, TrackingData>::updateFace
|
|||||||
// - changedFace_, changedFaces_,
|
// - changedFace_, changedFaces_,
|
||||||
// - statistics: nEvals_, nUnvisitedFaces_
|
// - statistics: nEvals_, nUnvisitedFaces_
|
||||||
|
|
||||||
nEvals_++;
|
++nEvals_;
|
||||||
|
|
||||||
bool wasValid = faceInfo.valid(td_);
|
const bool wasValid = faceInfo.valid(td_);
|
||||||
|
|
||||||
bool propagate =
|
const bool propagate =
|
||||||
faceInfo.updateFace
|
faceInfo.updateFace
|
||||||
(
|
(
|
||||||
mesh_,
|
mesh_,
|
||||||
@ -262,8 +261,8 @@ void Foam::FaceCellWave<Type, TrackingData>::checkCyclic
|
|||||||
|
|
||||||
forAll(patch, patchFacei)
|
forAll(patch, patchFacei)
|
||||||
{
|
{
|
||||||
label i1 = patch.start() + patchFacei;
|
const label i1 = patch.start() + patchFacei;
|
||||||
label i2 = nbrPatch.start() + patchFacei;
|
const label i2 = nbrPatch.start() + patchFacei;
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -299,9 +298,9 @@ template<class Type, class TrackingData>
|
|||||||
template<class PatchType>
|
template<class PatchType>
|
||||||
bool Foam::FaceCellWave<Type, TrackingData>::hasPatch() const
|
bool Foam::FaceCellWave<Type, TrackingData>::hasPatch() const
|
||||||
{
|
{
|
||||||
forAll(mesh_.boundaryMesh(), patchi)
|
for (const polyPatch& p : mesh_.boundaryMesh())
|
||||||
{
|
{
|
||||||
if (isA<PatchType>(mesh_.boundaryMesh()[patchi]))
|
if (isA<PatchType>(p))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -313,15 +312,39 @@ bool Foam::FaceCellWave<Type, TrackingData>::hasPatch() const
|
|||||||
template<class Type, class TrackingData>
|
template<class Type, class TrackingData>
|
||||||
void Foam::FaceCellWave<Type, TrackingData>::setFaceInfo
|
void Foam::FaceCellWave<Type, TrackingData>::setFaceInfo
|
||||||
(
|
(
|
||||||
const labelList& changedFaces,
|
const label facei,
|
||||||
|
const Type& faceInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const bool wasValid = allFaceInfo_[facei].valid(td_);
|
||||||
|
|
||||||
|
// Copy info for facei
|
||||||
|
allFaceInfo_[facei] = faceInfo;
|
||||||
|
|
||||||
|
// Maintain count of unset faces
|
||||||
|
if (!wasValid && allFaceInfo_[facei].valid(td_))
|
||||||
|
{
|
||||||
|
--nUnvisitedFaces_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark facei as visited and changed (both on list and on face itself)
|
||||||
|
changedFace_.set(facei);
|
||||||
|
changedFaces_.append(facei);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, class TrackingData>
|
||||||
|
void Foam::FaceCellWave<Type, TrackingData>::setFaceInfo
|
||||||
|
(
|
||||||
|
const labelUList& changedFaces,
|
||||||
const List<Type>& changedFacesInfo
|
const List<Type>& changedFacesInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
forAll(changedFaces, changedFacei)
|
forAll(changedFaces, changedFacei)
|
||||||
{
|
{
|
||||||
label facei = changedFaces[changedFacei];
|
const label facei = changedFaces[changedFacei];
|
||||||
|
|
||||||
bool wasValid = allFaceInfo_[facei].valid(td_);
|
const bool wasValid = allFaceInfo_[facei].valid(td_);
|
||||||
|
|
||||||
// Copy info for facei
|
// Copy info for facei
|
||||||
allFaceInfo_[facei] = changedFacesInfo[changedFacei];
|
allFaceInfo_[facei] = changedFacesInfo[changedFacei];
|
||||||
@ -333,7 +356,6 @@ void Foam::FaceCellWave<Type, TrackingData>::setFaceInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mark facei as changed, both on list and on face itself.
|
// Mark facei as changed, both on list and on face itself.
|
||||||
|
|
||||||
changedFace_.set(facei);
|
changedFace_.set(facei);
|
||||||
changedFaces_.append(facei);
|
changedFaces_.append(facei);
|
||||||
}
|
}
|
||||||
@ -345,29 +367,29 @@ void Foam::FaceCellWave<Type, TrackingData>::mergeFaceInfo
|
|||||||
(
|
(
|
||||||
const polyPatch& patch,
|
const polyPatch& patch,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const labelList& changedFaces,
|
const labelUList& changedFaces,
|
||||||
const List<Type>& changedFacesInfo
|
const List<Type>& changedFacesInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Merge face information into member data
|
// Merge face information into member data
|
||||||
|
|
||||||
for (label changedFacei = 0; changedFacei < nFaces; changedFacei++)
|
for (label changedFacei = 0; changedFacei < nFaces; ++changedFacei)
|
||||||
{
|
{
|
||||||
const Type& neighbourWallInfo = changedFacesInfo[changedFacei];
|
const Type& newInfo = changedFacesInfo[changedFacei];
|
||||||
label patchFacei = changedFaces[changedFacei];
|
const label patchFacei = changedFaces[changedFacei];
|
||||||
|
|
||||||
label meshFacei = patch.start() + patchFacei;
|
const label meshFacei = patch.start() + patchFacei;
|
||||||
|
|
||||||
Type& currentWallInfo = allFaceInfo_[meshFacei];
|
Type& currInfo = allFaceInfo_[meshFacei];
|
||||||
|
|
||||||
if (!currentWallInfo.equal(neighbourWallInfo, td_))
|
if (!currInfo.equal(newInfo, td_))
|
||||||
{
|
{
|
||||||
updateFace
|
updateFace
|
||||||
(
|
(
|
||||||
meshFacei,
|
meshFacei,
|
||||||
neighbourWallInfo,
|
newInfo,
|
||||||
propagationTol_,
|
propagationTol_,
|
||||||
currentWallInfo
|
currInfo
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -387,22 +409,22 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::getChangedPatchFaces
|
|||||||
// Construct compact patchFace change arrays for a (slice of a) single
|
// Construct compact patchFace change arrays for a (slice of a) single
|
||||||
// patch. changedPatchFaces in local patch numbering.
|
// patch. changedPatchFaces in local patch numbering.
|
||||||
// Return length of arrays.
|
// Return length of arrays.
|
||||||
label nChangedPatchFaces = 0;
|
label nChanged = 0;
|
||||||
|
|
||||||
for (label i = 0; i < nFaces; i++)
|
for (label i = 0; i < nFaces; ++i)
|
||||||
{
|
{
|
||||||
label patchFacei = i + startFacei;
|
const label patchFacei = i + startFacei;
|
||||||
|
const label meshFacei = patch.start() + patchFacei;
|
||||||
label meshFacei = patch.start() + patchFacei;
|
|
||||||
|
|
||||||
if (changedFace_.test(meshFacei))
|
if (changedFace_.test(meshFacei))
|
||||||
{
|
{
|
||||||
changedPatchFaces[nChangedPatchFaces] = patchFacei;
|
changedPatchFaces[nChanged] = patchFacei;
|
||||||
changedPatchFacesInfo[nChangedPatchFaces] = allFaceInfo_[meshFacei];
|
changedPatchFacesInfo[nChanged] = allFaceInfo_[meshFacei];
|
||||||
nChangedPatchFaces++;
|
++nChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nChangedPatchFaces;
|
|
||||||
|
return nChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -411,7 +433,7 @@ void Foam::FaceCellWave<Type, TrackingData>::leaveDomain
|
|||||||
(
|
(
|
||||||
const polyPatch& patch,
|
const polyPatch& patch,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const labelList& faceLabels,
|
const labelUList& faceLabels,
|
||||||
List<Type>& faceInfo
|
List<Type>& faceInfo
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
@ -419,11 +441,11 @@ void Foam::FaceCellWave<Type, TrackingData>::leaveDomain
|
|||||||
|
|
||||||
const vectorField& fc = mesh_.faceCentres();
|
const vectorField& fc = mesh_.faceCentres();
|
||||||
|
|
||||||
for (label i = 0; i < nFaces; i++)
|
for (label i = 0; i < nFaces; ++i)
|
||||||
{
|
{
|
||||||
label patchFacei = faceLabels[i];
|
const label patchFacei = faceLabels[i];
|
||||||
|
const label meshFacei = patch.start() + patchFacei;
|
||||||
|
|
||||||
label meshFacei = patch.start() + patchFacei;
|
|
||||||
faceInfo[i].leaveDomain(mesh_, patch, patchFacei, fc[meshFacei], td_);
|
faceInfo[i].leaveDomain(mesh_, patch, patchFacei, fc[meshFacei], td_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -434,7 +456,7 @@ void Foam::FaceCellWave<Type, TrackingData>::enterDomain
|
|||||||
(
|
(
|
||||||
const polyPatch& patch,
|
const polyPatch& patch,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const labelList& faceLabels,
|
const labelUList& faceLabels,
|
||||||
List<Type>& faceInfo
|
List<Type>& faceInfo
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
@ -442,11 +464,11 @@ void Foam::FaceCellWave<Type, TrackingData>::enterDomain
|
|||||||
|
|
||||||
const vectorField& fc = mesh_.faceCentres();
|
const vectorField& fc = mesh_.faceCentres();
|
||||||
|
|
||||||
for (label i = 0; i < nFaces; i++)
|
for (label i = 0; i < nFaces; ++i)
|
||||||
{
|
{
|
||||||
label patchFacei = faceLabels[i];
|
const label patchFacei = faceLabels[i];
|
||||||
|
const label meshFacei = patch.start() + patchFacei;
|
||||||
|
|
||||||
label meshFacei = patch.start() + patchFacei;
|
|
||||||
faceInfo[i].enterDomain(mesh_, patch, patchFacei, fc[meshFacei], td_);
|
faceInfo[i].enterDomain(mesh_, patch, patchFacei, fc[meshFacei], td_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -466,14 +488,14 @@ void Foam::FaceCellWave<Type, TrackingData>::transform
|
|||||||
{
|
{
|
||||||
const tensor& T = rotTensor[0];
|
const tensor& T = rotTensor[0];
|
||||||
|
|
||||||
for (label facei = 0; facei < nFaces; facei++)
|
for (label facei = 0; facei < nFaces; ++facei)
|
||||||
{
|
{
|
||||||
faceInfo[facei].transform(mesh_, T, td_);
|
faceInfo[facei].transform(mesh_, T, td_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (label facei = 0; facei < nFaces; facei++)
|
for (label facei = 0; facei < nFaces; ++facei)
|
||||||
{
|
{
|
||||||
faceInfo[facei].transform(mesh_, rotTensor[facei], td_);
|
faceInfo[facei].transform(mesh_, rotTensor[facei], td_);
|
||||||
}
|
}
|
||||||
@ -490,10 +512,10 @@ void Foam::FaceCellWave<Type, TrackingData>::offset
|
|||||||
labelList& faces
|
labelList& faces
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Offset mesh face. Used for transferring from one cyclic half to the
|
// Offset mesh face.
|
||||||
// other.
|
// Used for transferring from one cyclic half to the other.
|
||||||
|
|
||||||
for (label facei = 0; facei < nFaces; facei++)
|
for (label facei = 0; facei < nFaces; ++facei)
|
||||||
{
|
{
|
||||||
faces[facei] += cycOffset;
|
faces[facei] += cycOffset;
|
||||||
}
|
}
|
||||||
@ -514,10 +536,8 @@ void Foam::FaceCellWave<Type, TrackingData>::handleProcPatches()
|
|||||||
|
|
||||||
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
|
||||||
|
|
||||||
forAll(procPatches, i)
|
for (const label patchi : procPatches)
|
||||||
{
|
{
|
||||||
label patchi = procPatches[i];
|
|
||||||
|
|
||||||
const processorPolyPatch& procPatch =
|
const processorPolyPatch& procPatch =
|
||||||
refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
|
refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
|
||||||
|
|
||||||
@ -564,10 +584,8 @@ void Foam::FaceCellWave<Type, TrackingData>::handleProcPatches()
|
|||||||
|
|
||||||
// Receive all
|
// Receive all
|
||||||
|
|
||||||
forAll(procPatches, i)
|
for (const label patchi : procPatches)
|
||||||
{
|
{
|
||||||
label patchi = procPatches[i];
|
|
||||||
|
|
||||||
const processorPolyPatch& procPatch =
|
const processorPolyPatch& procPatch =
|
||||||
refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
|
refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchi]);
|
||||||
|
|
||||||
@ -625,14 +643,14 @@ void Foam::FaceCellWave<Type, TrackingData>::handleCyclicPatches()
|
|||||||
{
|
{
|
||||||
// Transfer information across cyclic halves.
|
// Transfer information across cyclic halves.
|
||||||
|
|
||||||
forAll(mesh_.boundaryMesh(), patchi)
|
for (const polyPatch& patch : mesh_.boundaryMesh())
|
||||||
{
|
{
|
||||||
const polyPatch& patch = mesh_.boundaryMesh()[patchi];
|
|
||||||
|
|
||||||
if (isA<cyclicPolyPatch>(patch))
|
if (isA<cyclicPolyPatch>(patch))
|
||||||
{
|
{
|
||||||
const cyclicPolyPatch& nbrPatch =
|
const cyclicPolyPatch& cycPatch =
|
||||||
refCast<const cyclicPolyPatch>(patch).neighbPatch();
|
refCast<const cyclicPolyPatch>(patch);
|
||||||
|
|
||||||
|
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
|
||||||
|
|
||||||
// Allocate buffers
|
// Allocate buffers
|
||||||
label nReceiveFaces;
|
label nReceiveFaces;
|
||||||
@ -658,12 +676,9 @@ void Foam::FaceCellWave<Type, TrackingData>::handleCyclicPatches()
|
|||||||
receiveFacesInfo
|
receiveFacesInfo
|
||||||
);
|
);
|
||||||
|
|
||||||
const cyclicPolyPatch& cycPatch =
|
|
||||||
refCast<const cyclicPolyPatch>(patch);
|
|
||||||
|
|
||||||
if (!cycPatch.parallel())
|
if (!cycPatch.parallel())
|
||||||
{
|
{
|
||||||
// received data from other half
|
// Received data from other half
|
||||||
transform
|
transform
|
||||||
(
|
(
|
||||||
cycPatch.forwardT(),
|
cycPatch.forwardT(),
|
||||||
@ -674,7 +689,8 @@ void Foam::FaceCellWave<Type, TrackingData>::handleCyclicPatches()
|
|||||||
|
|
||||||
if (debug & 2)
|
if (debug & 2)
|
||||||
{
|
{
|
||||||
Pout<< " Cyclic patch " << patchi << ' ' << cycPatch.name()
|
Pout<< " Cyclic patch "
|
||||||
|
<< cycPatch.index() << ' ' << cycPatch.name()
|
||||||
<< " Changed : " << nReceiveFaces
|
<< " Changed : " << nReceiveFaces
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
@ -711,21 +727,18 @@ void Foam::FaceCellWave<Type, TrackingData>::handleAMICyclicPatches()
|
|||||||
{
|
{
|
||||||
// Transfer information across cyclicAMI halves.
|
// Transfer information across cyclicAMI halves.
|
||||||
|
|
||||||
forAll(mesh_.boundaryMesh(), patchi)
|
for (const polyPatch& patch : mesh_.boundaryMesh())
|
||||||
{
|
{
|
||||||
const polyPatch& patch = mesh_.boundaryMesh()[patchi];
|
|
||||||
|
|
||||||
if (isA<cyclicAMIPolyPatch>(patch))
|
if (isA<cyclicAMIPolyPatch>(patch))
|
||||||
{
|
{
|
||||||
const cyclicAMIPolyPatch& cycPatch =
|
const cyclicAMIPolyPatch& cycPatch =
|
||||||
refCast<const cyclicAMIPolyPatch>(patch);
|
refCast<const cyclicAMIPolyPatch>(patch);
|
||||||
|
|
||||||
|
const cyclicAMIPolyPatch& nbrPatch = cycPatch.neighbPatch();
|
||||||
|
|
||||||
List<Type> receiveInfo;
|
List<Type> receiveInfo;
|
||||||
|
|
||||||
{
|
{
|
||||||
const cyclicAMIPolyPatch& nbrPatch =
|
|
||||||
refCast<const cyclicAMIPolyPatch>(patch).neighbPatch();
|
|
||||||
|
|
||||||
// Get nbrPatch data (so not just changed faces)
|
// Get nbrPatch data (so not just changed faces)
|
||||||
typename List<Type>::subList sendInfo
|
typename List<Type>::subList sendInfo
|
||||||
(
|
(
|
||||||
@ -787,22 +800,20 @@ void Foam::FaceCellWave<Type, TrackingData>::handleAMICyclicPatches()
|
|||||||
// Merge into global storage
|
// Merge into global storage
|
||||||
forAll(receiveInfo, i)
|
forAll(receiveInfo, i)
|
||||||
{
|
{
|
||||||
label meshFacei = cycPatch.start()+i;
|
const label meshFacei = cycPatch.start()+i;
|
||||||
|
|
||||||
Type& currentWallInfo = allFaceInfo_[meshFacei];
|
const Type& newInfo = receiveInfo[i];
|
||||||
|
|
||||||
if
|
Type& currInfo = allFaceInfo_[meshFacei];
|
||||||
(
|
|
||||||
receiveInfo[i].valid(td_)
|
if (newInfo.valid(td_) && !currInfo.equal(newInfo, td_))
|
||||||
&& !currentWallInfo.equal(receiveInfo[i], td_)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
updateFace
|
updateFace
|
||||||
(
|
(
|
||||||
meshFacei,
|
meshFacei,
|
||||||
receiveInfo[i],
|
newInfo,
|
||||||
propagationTol_,
|
propagationTol_,
|
||||||
currentWallInfo
|
currInfo
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -814,73 +825,50 @@ void Foam::FaceCellWave<Type, TrackingData>::handleAMICyclicPatches()
|
|||||||
template<class Type, class TrackingData>
|
template<class Type, class TrackingData>
|
||||||
void Foam::FaceCellWave<Type, TrackingData>::handleExplicitConnections()
|
void Foam::FaceCellWave<Type, TrackingData>::handleExplicitConnections()
|
||||||
{
|
{
|
||||||
// Collect changed information
|
changedBaffles_.clear();
|
||||||
|
|
||||||
DynamicList<label> f0Baffle(explicitConnections_.size());
|
// Collect all/any changed information touching a baffle
|
||||||
DynamicList<Type> f0Info(explicitConnections_.size());
|
for (const labelPair& baffle : explicitConnections_)
|
||||||
|
|
||||||
DynamicList<label> f1Baffle(explicitConnections_.size());
|
|
||||||
DynamicList<Type> f1Info(explicitConnections_.size());
|
|
||||||
|
|
||||||
forAll(explicitConnections_, connI)
|
|
||||||
{
|
{
|
||||||
const labelPair& baffle = explicitConnections_[connI];
|
const label f0 = baffle.first();
|
||||||
|
const label f1 = baffle.second();
|
||||||
|
|
||||||
label f0 = baffle[0];
|
|
||||||
if (changedFace_.test(f0))
|
if (changedFace_.test(f0))
|
||||||
{
|
{
|
||||||
f0Baffle.append(connI);
|
// f0 changed. Update information on f1.
|
||||||
f0Info.append(allFaceInfo_[f0]);
|
changedBaffles_.append(taggedInfoType(f1, allFaceInfo_[f0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
label f1 = baffle[1];
|
|
||||||
if (changedFace_.test(f1))
|
if (changedFace_.test(f1))
|
||||||
{
|
{
|
||||||
f1Baffle.append(connI);
|
// f1 changed. Update information on f0.
|
||||||
f1Info.append(allFaceInfo_[f1]);
|
changedBaffles_.append(taggedInfoType(f0, allFaceInfo_[f1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update other side with changed information
|
// Update other side with changed information
|
||||||
|
|
||||||
forAll(f1Info, index)
|
for (const taggedInfoType& updated : changedBaffles_)
|
||||||
{
|
{
|
||||||
const labelPair& baffle = explicitConnections_[f1Baffle[index]];
|
const label tgtFace = updated.first;
|
||||||
|
const Type& newInfo = updated.second;
|
||||||
|
|
||||||
label f0 = baffle[0];
|
Type& currInfo = allFaceInfo_[tgtFace];
|
||||||
Type& currentWallInfo = allFaceInfo_[f0];
|
|
||||||
|
|
||||||
if (!currentWallInfo.equal(f1Info[index], td_))
|
if (!currInfo.equal(newInfo, td_))
|
||||||
{
|
{
|
||||||
updateFace
|
updateFace
|
||||||
(
|
(
|
||||||
f0,
|
tgtFace,
|
||||||
f1Info[index],
|
newInfo,
|
||||||
propagationTol_,
|
propagationTol_,
|
||||||
currentWallInfo
|
currInfo
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(f0Info, index)
|
changedBaffles_.clear();
|
||||||
{
|
|
||||||
const labelPair& baffle = explicitConnections_[f0Baffle[index]];
|
|
||||||
|
|
||||||
label f1 = baffle[1];
|
|
||||||
Type& currentWallInfo = allFaceInfo_[f1];
|
|
||||||
|
|
||||||
if (!currentWallInfo.equal(f0Info[index], td_))
|
|
||||||
{
|
|
||||||
updateFace
|
|
||||||
(
|
|
||||||
f1,
|
|
||||||
f0Info[index],
|
|
||||||
propagationTol_,
|
|
||||||
currentWallInfo
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -896,14 +884,15 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
explicitConnections_(0),
|
explicitConnections_(),
|
||||||
allFaceInfo_(allFaceInfo),
|
allFaceInfo_(allFaceInfo),
|
||||||
allCellInfo_(allCellInfo),
|
allCellInfo_(allCellInfo),
|
||||||
td_(td),
|
td_(td),
|
||||||
changedFace_(mesh_.nFaces(), false),
|
changedFace_(mesh_.nFaces(), false),
|
||||||
changedFaces_(mesh_.nFaces()),
|
|
||||||
changedCell_(mesh_.nCells(), false),
|
changedCell_(mesh_.nCells(), false),
|
||||||
|
changedFaces_(mesh_.nFaces()),
|
||||||
changedCells_(mesh_.nCells()),
|
changedCells_(mesh_.nCells()),
|
||||||
|
changedBaffles_(2*explicitConnections_.size()),
|
||||||
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
|
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
|
||||||
hasCyclicAMIPatches_
|
hasCyclicAMIPatches_
|
||||||
(
|
(
|
||||||
@ -920,12 +909,11 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "face and cell storage not the size of mesh faces, cells:"
|
<< "face and cell storage not the size of mesh faces, cells:" << nl
|
||||||
<< endl
|
<< " allFaceInfo :" << allFaceInfo.size() << nl
|
||||||
<< " allFaceInfo :" << allFaceInfo.size() << endl
|
<< " mesh_.nFaces():" << mesh_.nFaces() << nl
|
||||||
<< " mesh_.nFaces():" << mesh_.nFaces() << endl
|
<< " allCellInfo :" << allCellInfo.size() << nl
|
||||||
<< " allCellInfo :" << allCellInfo.size() << endl
|
<< " mesh_.nCells():" << mesh_.nCells() << endl
|
||||||
<< " mesh_.nCells():" << mesh_.nCells()
|
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -935,7 +923,7 @@ template<class Type, class TrackingData>
|
|||||||
Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const labelList& changedFaces,
|
const labelUList& changedFaces,
|
||||||
const List<Type>& changedFacesInfo,
|
const List<Type>& changedFacesInfo,
|
||||||
UList<Type>& allFaceInfo,
|
UList<Type>& allFaceInfo,
|
||||||
UList<Type>& allCellInfo,
|
UList<Type>& allCellInfo,
|
||||||
@ -944,14 +932,15 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
|||||||
)
|
)
|
||||||
:
|
:
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
explicitConnections_(0),
|
explicitConnections_(),
|
||||||
allFaceInfo_(allFaceInfo),
|
allFaceInfo_(allFaceInfo),
|
||||||
allCellInfo_(allCellInfo),
|
allCellInfo_(allCellInfo),
|
||||||
td_(td),
|
td_(td),
|
||||||
changedFace_(mesh_.nFaces(), false),
|
changedFace_(mesh_.nFaces(), false),
|
||||||
changedFaces_(mesh_.nFaces()),
|
|
||||||
changedCell_(mesh_.nCells(), false),
|
changedCell_(mesh_.nCells(), false),
|
||||||
|
changedFaces_(mesh_.nFaces()),
|
||||||
changedCells_(mesh_.nCells()),
|
changedCells_(mesh_.nCells()),
|
||||||
|
changedBaffles_(2*explicitConnections_.size()),
|
||||||
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
|
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
|
||||||
hasCyclicAMIPatches_
|
hasCyclicAMIPatches_
|
||||||
(
|
(
|
||||||
@ -968,12 +957,11 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "face and cell storage not the size of mesh faces, cells:"
|
<< "face and cell storage not the size of mesh faces, cells:" << nl
|
||||||
<< endl
|
<< " allFaceInfo :" << allFaceInfo.size() << nl
|
||||||
<< " allFaceInfo :" << allFaceInfo.size() << endl
|
<< " mesh_.nFaces():" << mesh_.nFaces() << nl
|
||||||
<< " mesh_.nFaces():" << mesh_.nFaces() << endl
|
<< " allCellInfo :" << allCellInfo.size() << nl
|
||||||
<< " allCellInfo :" << allCellInfo.size() << endl
|
<< " mesh_.nCells():" << mesh_.nCells() << endl
|
||||||
<< " mesh_.nCells():" << mesh_.nCells()
|
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,14 +969,14 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
|||||||
setFaceInfo(changedFaces, changedFacesInfo);
|
setFaceInfo(changedFaces, changedFacesInfo);
|
||||||
|
|
||||||
// Iterate until nothing changes
|
// Iterate until nothing changes
|
||||||
label iter = iterate(maxIter);
|
const label iter = iterate(maxIter);
|
||||||
|
|
||||||
if ((maxIter > 0) && (iter >= maxIter))
|
if ((maxIter > 0) && (iter >= maxIter))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Maximum number of iterations reached. Increase maxIter." << endl
|
<< "Maximum number of iterations reached. Increase maxIter." << nl
|
||||||
<< " maxIter:" << maxIter << endl
|
<< " maxIter:" << maxIter << nl
|
||||||
<< " nChangedCells:" << changedCells_.size() << endl
|
<< " nChangedCells:" << changedCells_.size() << nl
|
||||||
<< " nChangedFaces:" << changedFaces_.size() << endl
|
<< " nChangedFaces:" << changedFaces_.size() << endl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
@ -1001,7 +989,7 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
|||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const labelPairList& explicitConnections,
|
const labelPairList& explicitConnections,
|
||||||
const bool handleCyclicAMI,
|
const bool handleCyclicAMI,
|
||||||
const labelList& changedFaces,
|
const labelUList& changedFaces,
|
||||||
const List<Type>& changedFacesInfo,
|
const List<Type>& changedFacesInfo,
|
||||||
UList<Type>& allFaceInfo,
|
UList<Type>& allFaceInfo,
|
||||||
UList<Type>& allCellInfo,
|
UList<Type>& allCellInfo,
|
||||||
@ -1015,9 +1003,10 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
|||||||
allCellInfo_(allCellInfo),
|
allCellInfo_(allCellInfo),
|
||||||
td_(td),
|
td_(td),
|
||||||
changedFace_(mesh_.nFaces(), false),
|
changedFace_(mesh_.nFaces(), false),
|
||||||
changedFaces_(mesh_.nFaces()),
|
|
||||||
changedCell_(mesh_.nCells(), false),
|
changedCell_(mesh_.nCells(), false),
|
||||||
|
changedFaces_(mesh_.nFaces()),
|
||||||
changedCells_(mesh_.nCells()),
|
changedCells_(mesh_.nCells()),
|
||||||
|
changedBaffles_(2*explicitConnections_.size()),
|
||||||
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
|
hasCyclicPatches_(hasPatch<cyclicPolyPatch>()),
|
||||||
hasCyclicAMIPatches_
|
hasCyclicAMIPatches_
|
||||||
(
|
(
|
||||||
@ -1035,12 +1024,11 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "face and cell storage not the size of mesh faces, cells:"
|
<< "face and cell storage not the size of mesh faces, cells:" << nl
|
||||||
<< endl
|
<< " allFaceInfo :" << allFaceInfo.size() << nl
|
||||||
<< " allFaceInfo :" << allFaceInfo.size() << endl
|
<< " mesh_.nFaces():" << mesh_.nFaces() << nl
|
||||||
<< " mesh_.nFaces():" << mesh_.nFaces() << endl
|
<< " allCellInfo :" << allCellInfo.size() << nl
|
||||||
<< " allCellInfo :" << allCellInfo.size() << endl
|
<< " mesh_.nCells():" << mesh_.nCells() << endl
|
||||||
<< " mesh_.nCells():" << mesh_.nCells()
|
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1048,14 +1036,14 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
|||||||
setFaceInfo(changedFaces, changedFacesInfo);
|
setFaceInfo(changedFaces, changedFacesInfo);
|
||||||
|
|
||||||
// Iterate until nothing changes
|
// Iterate until nothing changes
|
||||||
label iter = iterate(maxIter);
|
const label iter = iterate(maxIter);
|
||||||
|
|
||||||
if ((maxIter > 0) && (iter >= maxIter))
|
if ((maxIter > 0) && (iter >= maxIter))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Maximum number of iterations reached. Increase maxIter." << endl
|
<< "Maximum number of iterations reached. Increase maxIter." << nl
|
||||||
<< " maxIter:" << maxIter << endl
|
<< " maxIter:" << maxIter << nl
|
||||||
<< " nChangedCells:" << changedCells_.size() << endl
|
<< " nChangedCells:" << changedCells_.size() << nl
|
||||||
<< " nChangedFaces:" << changedFaces_.size() << endl
|
<< " nChangedFaces:" << changedFaces_.size() << endl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
@ -1065,14 +1053,14 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
|||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type, class TrackingData>
|
template<class Type, class TrackingData>
|
||||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::getUnsetCells() const
|
Foam::label Foam::FaceCellWave<Type, TrackingData>::nUnvisitedCells() const
|
||||||
{
|
{
|
||||||
return nUnvisitedCells_;
|
return nUnvisitedCells_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class TrackingData>
|
template<class Type, class TrackingData>
|
||||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::getUnsetFaces() const
|
Foam::label Foam::FaceCellWave<Type, TrackingData>::nUnvisitedFaces() const
|
||||||
{
|
{
|
||||||
return nUnvisitedFaces_;
|
return nUnvisitedFaces_;
|
||||||
}
|
}
|
||||||
@ -1085,11 +1073,10 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell()
|
|||||||
|
|
||||||
const labelList& owner = mesh_.faceOwner();
|
const labelList& owner = mesh_.faceOwner();
|
||||||
const labelList& neighbour = mesh_.faceNeighbour();
|
const labelList& neighbour = mesh_.faceNeighbour();
|
||||||
label nInternalFaces = mesh_.nInternalFaces();
|
const label nInternalFaces = mesh_.nInternalFaces();
|
||||||
|
|
||||||
forAll(changedFaces_, changedFacei)
|
for (const label facei : changedFaces_)
|
||||||
{
|
{
|
||||||
label facei = changedFaces_[changedFacei];
|
|
||||||
if (!changedFace_.test(facei))
|
if (!changedFace_.test(facei))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
@ -1098,42 +1085,43 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell()
|
|||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Type& newInfo = allFaceInfo_[facei];
|
||||||
const Type& neighbourWallInfo = allFaceInfo_[facei];
|
|
||||||
|
|
||||||
// Evaluate all connected cells
|
// Evaluate all connected cells
|
||||||
|
|
||||||
// Owner
|
// Owner
|
||||||
label celli = owner[facei];
|
{
|
||||||
Type& currentWallInfo = allCellInfo_[celli];
|
const label celli = owner[facei];
|
||||||
|
Type& currInfo = allCellInfo_[celli];
|
||||||
|
|
||||||
if (!currentWallInfo.equal(neighbourWallInfo, td_))
|
if (!currInfo.equal(newInfo, td_))
|
||||||
{
|
{
|
||||||
updateCell
|
updateCell
|
||||||
(
|
(
|
||||||
celli,
|
celli,
|
||||||
facei,
|
facei,
|
||||||
neighbourWallInfo,
|
newInfo,
|
||||||
propagationTol_,
|
propagationTol_,
|
||||||
currentWallInfo
|
currInfo
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Neighbour.
|
// Neighbour.
|
||||||
if (facei < nInternalFaces)
|
if (facei < nInternalFaces)
|
||||||
{
|
{
|
||||||
celli = neighbour[facei];
|
const label celli = neighbour[facei];
|
||||||
Type& currentWallInfo2 = allCellInfo_[celli];
|
Type& currInfo = allCellInfo_[celli];
|
||||||
|
|
||||||
if (!currentWallInfo2.equal(neighbourWallInfo, td_))
|
if (!currInfo.equal(newInfo, td_))
|
||||||
{
|
{
|
||||||
updateCell
|
updateCell
|
||||||
(
|
(
|
||||||
celli,
|
celli,
|
||||||
facei,
|
facei,
|
||||||
neighbourWallInfo,
|
newInfo,
|
||||||
propagationTol_,
|
propagationTol_,
|
||||||
currentWallInfo2
|
currInfo
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1150,12 +1138,8 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell()
|
|||||||
Pout<< " Changed cells : " << changedCells_.size() << endl;
|
Pout<< " Changed cells : " << changedCells_.size() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sum changedCells over all procs
|
// Number of changedCells over all procs
|
||||||
label totNChanged = changedCells_.size();
|
return returnReduce(changedCells_.size(), sumOp<label>());
|
||||||
|
|
||||||
reduce(totNChanged, sumOp<label>());
|
|
||||||
|
|
||||||
return totNChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1166,35 +1150,33 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::cellToFace()
|
|||||||
|
|
||||||
const cellList& cells = mesh_.cells();
|
const cellList& cells = mesh_.cells();
|
||||||
|
|
||||||
forAll(changedCells_, changedCelli)
|
for (const label celli : changedCells_)
|
||||||
{
|
{
|
||||||
label celli = changedCells_[changedCelli];
|
if (!changedCell_.test(celli))
|
||||||
if (!changedCell_[celli])
|
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Cell " << celli << " not marked as having been changed"
|
<< "Cell " << celli << " not marked as having been changed"
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Type& neighbourWallInfo = allCellInfo_[celli];
|
const Type& newInfo = allCellInfo_[celli];
|
||||||
|
|
||||||
// Evaluate all connected faces
|
// Evaluate all connected faces
|
||||||
|
|
||||||
const labelList& faceLabels = cells[celli];
|
const labelList& faceLabels = cells[celli];
|
||||||
forAll(faceLabels, faceLabelI)
|
for (const label facei : faceLabels)
|
||||||
{
|
{
|
||||||
label facei = faceLabels[faceLabelI];
|
Type& currInfo = allFaceInfo_[facei];
|
||||||
Type& currentWallInfo = allFaceInfo_[facei];
|
|
||||||
|
|
||||||
if (!currentWallInfo.equal(neighbourWallInfo, td_))
|
if (!currInfo.equal(newInfo, td_))
|
||||||
{
|
{
|
||||||
updateFace
|
updateFace
|
||||||
(
|
(
|
||||||
facei,
|
facei,
|
||||||
celli,
|
celli,
|
||||||
neighbourWallInfo,
|
newInfo,
|
||||||
propagationTol_,
|
propagationTol_,
|
||||||
currentWallInfo
|
currInfo
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1212,7 +1194,6 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::cellToFace()
|
|||||||
|
|
||||||
if (hasCyclicPatches_)
|
if (hasCyclicPatches_)
|
||||||
{
|
{
|
||||||
// Transfer changed faces across cyclic halves
|
|
||||||
handleCyclicPatches();
|
handleCyclicPatches();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1223,7 +1204,6 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::cellToFace()
|
|||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Transfer changed faces from neighbouring processors.
|
|
||||||
handleProcPatches();
|
handleProcPatches();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1232,12 +1212,9 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::cellToFace()
|
|||||||
Pout<< " Changed faces : " << changedFaces_.size() << endl;
|
Pout<< " Changed faces : " << changedFaces_.size() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sum nChangedFaces over all procs
|
|
||||||
label totNChanged = changedFaces_.size();
|
|
||||||
|
|
||||||
reduce(totNChanged, sumOp<label>());
|
// Number of changedFaces over all procs
|
||||||
|
return returnReduce(changedFaces_.size(), sumOp<label>());
|
||||||
return totNChanged;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1245,9 +1222,13 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::cellToFace()
|
|||||||
template<class Type, class TrackingData>
|
template<class Type, class TrackingData>
|
||||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::iterate(const label maxIter)
|
Foam::label Foam::FaceCellWave<Type, TrackingData>::iterate(const label maxIter)
|
||||||
{
|
{
|
||||||
|
if (maxIter < 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (hasCyclicPatches_)
|
if (hasCyclicPatches_)
|
||||||
{
|
{
|
||||||
// Transfer changed faces across cyclic halves
|
|
||||||
handleCyclicPatches();
|
handleCyclicPatches();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1258,13 +1239,12 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::iterate(const label maxIter)
|
|||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
// Transfer changed faces from neighbouring processors.
|
|
||||||
handleProcPatches();
|
handleProcPatches();
|
||||||
}
|
}
|
||||||
|
|
||||||
label iter = 0;
|
label iter = 0;
|
||||||
|
|
||||||
while (iter < maxIter)
|
for (/*nil*/; iter < maxIter; ++iter)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -1272,35 +1252,23 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::iterate(const label maxIter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nEvals_ = 0;
|
nEvals_ = 0;
|
||||||
|
const label nCells = faceToCell();
|
||||||
label nCells = faceToCell();
|
const label nFaces = nCells ? cellToFace() : 0;
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< " Total changed cells : " << nCells << endl;
|
Info<< " Total evaluations : "
|
||||||
|
<< nEvals_ << nl
|
||||||
|
<< " Changed cells / faces : "
|
||||||
|
<< nCells << " / " << nFaces << nl
|
||||||
|
<< " Pending cells / faces : "
|
||||||
|
<< nUnvisitedCells_ << " / " << nUnvisitedFaces_ << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nCells == 0)
|
if (!nCells || !nFaces)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
label nFaces = cellToFace();
|
|
||||||
|
|
||||||
if (debug)
|
|
||||||
{
|
|
||||||
Info<< " Total changed faces : " << nFaces << nl
|
|
||||||
<< " Total evaluations : " << nEvals_ << nl
|
|
||||||
<< " Remaining unvisited cells: " << nUnvisitedCells_ << nl
|
|
||||||
<< " Remaining unvisited faces: " << nUnvisitedFaces_ << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nFaces == 0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
++iter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return iter;
|
return iter;
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -57,7 +57,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
// Forward declaration of classes
|
// Forward declarations
|
||||||
class polyMesh;
|
class polyMesh;
|
||||||
class polyPatch;
|
class polyPatch;
|
||||||
|
|
||||||
@ -79,16 +79,21 @@ class FaceCellWave
|
|||||||
{
|
{
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Disallow default bitwise copy construct
|
//- No copy construct
|
||||||
FaceCellWave(const FaceCellWave&);
|
FaceCellWave(const FaceCellWave&) = delete;
|
||||||
|
|
||||||
//- Disallow default bitwise assignment
|
//- No copy assignment
|
||||||
void operator=(const FaceCellWave&);
|
void operator=(const FaceCellWave&) = delete;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// Protected data
|
//- Information tagged with a source or destination id.
|
||||||
|
// With std::pair as lightweight, moveable container.
|
||||||
|
typedef std::pair<label,Type> taggedInfoType;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected Data
|
||||||
|
|
||||||
//- Reference to mesh
|
//- Reference to mesh
|
||||||
const polyMesh& mesh_;
|
const polyMesh& mesh_;
|
||||||
@ -108,15 +113,18 @@ protected:
|
|||||||
//- Has face changed
|
//- Has face changed
|
||||||
bitSet changedFace_;
|
bitSet changedFace_;
|
||||||
|
|
||||||
//- List of changed faces
|
|
||||||
DynamicList<label> changedFaces_;
|
|
||||||
|
|
||||||
//- Has cell changed
|
//- Has cell changed
|
||||||
bitSet changedCell_;
|
bitSet changedCell_;
|
||||||
|
|
||||||
|
//- List of changed faces
|
||||||
|
DynamicList<label> changedFaces_;
|
||||||
|
|
||||||
// Cells that have changed
|
// Cells that have changed
|
||||||
DynamicList<label> changedCells_;
|
DynamicList<label> changedCells_;
|
||||||
|
|
||||||
|
// Information exchange for explicit baffle connections
|
||||||
|
// Max capacity = 2x number of explicit connections
|
||||||
|
DynamicList<taggedInfoType> changedBaffles_;
|
||||||
|
|
||||||
//- Contains cyclics
|
//- Contains cyclics
|
||||||
const bool hasCyclicPatches_;
|
const bool hasCyclicPatches_;
|
||||||
@ -132,8 +140,10 @@ protected:
|
|||||||
label nUnvisitedFaces_;
|
label nUnvisitedFaces_;
|
||||||
|
|
||||||
|
|
||||||
//- Updates cellInfo with information from neighbour. Updates all
|
// Protected Member Functions
|
||||||
// statistics.
|
|
||||||
|
//- Updates cellInfo with information from neighbour.
|
||||||
|
// Updates all statistics.
|
||||||
bool updateCell
|
bool updateCell
|
||||||
(
|
(
|
||||||
const label celli,
|
const label celli,
|
||||||
@ -143,8 +153,8 @@ protected:
|
|||||||
Type& cellInfo
|
Type& cellInfo
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Updates faceInfo with information from neighbour. Updates all
|
//- Updates faceInfo with information from neighbour.
|
||||||
// statistics.
|
// Updates all statistics.
|
||||||
bool updateFace
|
bool updateFace
|
||||||
(
|
(
|
||||||
const label facei,
|
const label facei,
|
||||||
@ -154,8 +164,8 @@ protected:
|
|||||||
Type& faceInfo
|
Type& faceInfo
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Updates faceInfo with information from same face. Updates all
|
//- Updates faceInfo with information from same face.
|
||||||
// statistics.
|
// Updates all statistics.
|
||||||
bool updateFace
|
bool updateFace
|
||||||
(
|
(
|
||||||
const label facei,
|
const label facei,
|
||||||
@ -179,8 +189,8 @@ protected:
|
|||||||
(
|
(
|
||||||
const polyPatch& patch,
|
const polyPatch& patch,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const labelList&,
|
const labelUList& changedFaces,
|
||||||
const List<Type>&
|
const List<Type>& changedFacesInfo
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Extract info for single patch only
|
//- Extract info for single patch only
|
||||||
@ -198,7 +208,7 @@ protected:
|
|||||||
(
|
(
|
||||||
const polyPatch& patch,
|
const polyPatch& patch,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const labelList& faceLabels,
|
const labelUList& faceLabels,
|
||||||
List<Type>& faceInfo
|
List<Type>& faceInfo
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -207,7 +217,7 @@ protected:
|
|||||||
(
|
(
|
||||||
const polyPatch& patch,
|
const polyPatch& patch,
|
||||||
const label nFaces,
|
const label nFaces,
|
||||||
const labelList& faceLabels,
|
const labelUList& faceLabels,
|
||||||
List<Type>& faceInfo
|
List<Type>& faceInfo
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -229,16 +239,18 @@ protected:
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Merge data from across processor boundaries
|
//- Merge data from across processor boundaries
|
||||||
|
// Transfer changed faces from neighbouring processors.
|
||||||
void handleProcPatches();
|
void handleProcPatches();
|
||||||
|
|
||||||
//- Merge data from across cyclics
|
//- Merge data from across cyclics
|
||||||
|
// Transfer changed faces across cyclic halves
|
||||||
void handleCyclicPatches();
|
void handleCyclicPatches();
|
||||||
|
|
||||||
//- Merge data from across AMI cyclics
|
//- Merge data from across AMI cyclics
|
||||||
void handleAMICyclicPatches();
|
void handleAMICyclicPatches();
|
||||||
|
|
||||||
//- Merge data across explicitly provided local connections (usually
|
//- Merge data across explicitly provided local connections
|
||||||
// baffles)
|
// These are usually baffles
|
||||||
void handleExplicitConnections();
|
void handleExplicitConnections();
|
||||||
|
|
||||||
|
|
||||||
@ -271,11 +283,11 @@ public:
|
|||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
// Construct from mesh. Use setFaceInfo and iterate() to do actual
|
//- Construct from mesh.
|
||||||
// calculation.
|
//- Use setFaceInfo and iterate() to do actual calculation.
|
||||||
FaceCellWave
|
FaceCellWave
|
||||||
(
|
(
|
||||||
const polyMesh&,
|
const polyMesh& mesh,
|
||||||
UList<Type>& allFaceInfo,
|
UList<Type>& allFaceInfo,
|
||||||
UList<Type>& allCellInfo,
|
UList<Type>& allCellInfo,
|
||||||
TrackingData& td = dummyTrackData_
|
TrackingData& td = dummyTrackData_
|
||||||
@ -283,11 +295,11 @@ public:
|
|||||||
|
|
||||||
//- Construct from mesh and list of changed faces with the Type
|
//- Construct from mesh and list of changed faces with the Type
|
||||||
// for these faces. Iterates until nothing changes or maxIter reached.
|
// for these faces. Iterates until nothing changes or maxIter reached.
|
||||||
// (maxIter can be 0)
|
// (maxIter can be 0 or negative). 0 initializes, -1 does not
|
||||||
FaceCellWave
|
FaceCellWave
|
||||||
(
|
(
|
||||||
const polyMesh&,
|
const polyMesh& mesh,
|
||||||
const labelList& initialChangedFaces,
|
const labelUList& initialChangedFaces,
|
||||||
const List<Type>& changedFacesInfo,
|
const List<Type>& changedFacesInfo,
|
||||||
UList<Type>& allFaceInfo,
|
UList<Type>& allFaceInfo,
|
||||||
UList<Type>& allCellInfo,
|
UList<Type>& allCellInfo,
|
||||||
@ -298,13 +310,13 @@ public:
|
|||||||
//- Construct from mesh and explicitly connected boundary faces
|
//- Construct from mesh and explicitly connected boundary faces
|
||||||
// and list of changed faces with the Type
|
// and list of changed faces with the Type
|
||||||
// for these faces. Iterates until nothing changes or maxIter reached.
|
// for these faces. Iterates until nothing changes or maxIter reached.
|
||||||
// (maxIter can be 0)
|
// (maxIter can be 0 or negative). 0 initializes, -1 does not
|
||||||
FaceCellWave
|
FaceCellWave
|
||||||
(
|
(
|
||||||
const polyMesh&,
|
const polyMesh& mesh,
|
||||||
const labelPairList& explicitConnections,
|
const labelPairList& explicitConnections,
|
||||||
const bool handleCyclicAMI,
|
const bool handleCyclicAMI,
|
||||||
const labelList& initialChangedFaces,
|
const labelUList& initialChangedFaces,
|
||||||
const List<Type>& changedFacesInfo,
|
const List<Type>& changedFacesInfo,
|
||||||
UList<Type>& allFaceInfo,
|
UList<Type>& allFaceInfo,
|
||||||
UList<Type>& allCellInfo,
|
UList<Type>& allCellInfo,
|
||||||
@ -314,8 +326,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~FaceCellWave()
|
virtual ~FaceCellWave() = default;
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -346,38 +357,44 @@ public:
|
|||||||
return mesh_;
|
return mesh_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get number of unvisited cells, i.e. cells that were not (yet)
|
//- Get number of unvisited cells,
|
||||||
// reached from walking across mesh. This can happen from
|
//- i.e. cells that were not (yet) reached from walking across mesh.
|
||||||
|
// This can happen from
|
||||||
// - not enough iterations done
|
// - not enough iterations done
|
||||||
// - a disconnected mesh
|
// - a disconnected mesh
|
||||||
// - a mesh without walls in it
|
// - a mesh without walls in it
|
||||||
label getUnsetCells() const;
|
label nUnvisitedCells() const;
|
||||||
|
|
||||||
//- Get number of unvisited faces
|
//- Get number of unvisited faces
|
||||||
label getUnsetFaces() const;
|
label nUnvisitedFaces() const;
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
|
//- Set single initial changed face.
|
||||||
|
// This is a noop if the face had already been visited
|
||||||
|
void setFaceInfo(const label facei, const Type& faceInfo);
|
||||||
|
|
||||||
//- Set initial changed faces
|
//- Set initial changed faces
|
||||||
void setFaceInfo
|
void setFaceInfo
|
||||||
(
|
(
|
||||||
const labelList& changedFaces,
|
const labelUList& changedFaces,
|
||||||
const List<Type>& changedFacesInfo
|
const List<Type>& changedFacesInfo
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Propagate from face to cell. Returns total number of cells
|
//- Propagate from face to cell.
|
||||||
// (over all processors) changed.
|
// \return total number of cells (over all processors) changed.
|
||||||
virtual label faceToCell();
|
virtual label faceToCell();
|
||||||
|
|
||||||
//- Propagate from cell to face. Returns total number of faces
|
//- Propagate from cell to face.
|
||||||
// (over all processors) changed. (Faces on processorpatches are
|
// \return total number of faces (over all processors) changed.
|
||||||
// counted double)
|
// Note that faces on processor patches are counted twice.
|
||||||
virtual label cellToFace();
|
virtual label cellToFace();
|
||||||
|
|
||||||
//- Iterate until no changes or maxIter reached. Returns actual
|
//- Iterate until no changes or maxIter reached.
|
||||||
// number of iterations.
|
// \return the number of iterations taken.
|
||||||
virtual label iterate(const label maxIter);
|
virtual label iterate(const label maxIter);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -141,20 +141,20 @@ public:
|
|||||||
return calc_.iterate(maxIter);
|
return calc_.iterate(maxIter);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get number of unvisited cells, i.e. cells that were not (yet)
|
//- Number of unvisited cells, i.e. cells that were not (yet)
|
||||||
// reached from walking across mesh. This can happen from
|
// reached from walking across mesh. This can happen from
|
||||||
// - not enough iterations done
|
// - not enough iterations done
|
||||||
// - a disconnected mesh
|
// - a disconnected mesh
|
||||||
// - a mesh without walls in it
|
// - a mesh without walls in it
|
||||||
label getUnsetCells() const
|
label nUnvisitedCells() const
|
||||||
{
|
{
|
||||||
return calc_.getUnsetCells();
|
return calc_.nUnvisitedCells();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get number of unvisited faces
|
//- Number of unvisited faces
|
||||||
label getUnsetFaces() const
|
label nUnvisitedFaces() const
|
||||||
{
|
{
|
||||||
return calc_.getUnsetFaces();
|
return calc_.nUnvisitedFaces();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -420,7 +420,7 @@ template
|
|||||||
class TrackingData
|
class TrackingData
|
||||||
>
|
>
|
||||||
Foam::label Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
|
Foam::label Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
|
||||||
getUnsetEdges() const
|
nUnvisitedEdges() const
|
||||||
{
|
{
|
||||||
return nUnvisitedEdges_;
|
return nUnvisitedEdges_;
|
||||||
}
|
}
|
||||||
@ -433,7 +433,7 @@ template
|
|||||||
class TrackingData
|
class TrackingData
|
||||||
>
|
>
|
||||||
Foam::label Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
|
Foam::label Foam::PatchEdgeFaceWave<PrimitivePatchType, Type, TrackingData>::
|
||||||
getUnsetFaces() const
|
nUnvisitedFaces() const
|
||||||
{
|
{
|
||||||
return nUnvisitedFaces_;
|
return nUnvisitedFaces_;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -226,14 +226,14 @@ public:
|
|||||||
return td_;
|
return td_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get number of unvisited faces, i.e. faces that were not (yet)
|
//- Number of unvisited faces, i.e. faces that were not (yet)
|
||||||
// reached from walking across patch. This can happen from
|
// reached from walking across patch. This can happen from
|
||||||
// - not enough iterations done
|
// - not enough iterations done
|
||||||
// - a disconnected patch
|
// - a disconnected patch
|
||||||
// - a patch without walls in it
|
// - a patch without walls in it
|
||||||
label getUnsetFaces() const;
|
label nUnvisitedFaces() const;
|
||||||
|
|
||||||
label getUnsetEdges() const;
|
label nUnvisitedEdges() const;
|
||||||
|
|
||||||
//- Copy initial data into allEdgeInfo_
|
//- Copy initial data into allEdgeInfo_
|
||||||
void setEdgeInfo
|
void setEdgeInfo
|
||||||
|
|||||||
@ -714,14 +714,14 @@ Foam::PointEdgeWave<Type, TrackingData>::~PointEdgeWave()
|
|||||||
|
|
||||||
|
|
||||||
template<class Type, class TrackingData>
|
template<class Type, class TrackingData>
|
||||||
Foam::label Foam::PointEdgeWave<Type, TrackingData>::getUnsetPoints() const
|
Foam::label Foam::PointEdgeWave<Type, TrackingData>::nUnvisitedPoints() const
|
||||||
{
|
{
|
||||||
return nUnvisitedPoints_;
|
return nUnvisitedPoints_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class TrackingData>
|
template<class Type, class TrackingData>
|
||||||
Foam::label Foam::PointEdgeWave<Type, TrackingData>::getUnsetEdges() const
|
Foam::label Foam::PointEdgeWave<Type, TrackingData>::nUnvisitedEdges() const
|
||||||
{
|
{
|
||||||
return nUnvisitedEdges_;
|
return nUnvisitedEdges_;
|
||||||
}
|
}
|
||||||
@ -737,9 +737,9 @@ void Foam::PointEdgeWave<Type, TrackingData>::setPointInfo
|
|||||||
{
|
{
|
||||||
forAll(changedPoints, changedPointi)
|
forAll(changedPoints, changedPointi)
|
||||||
{
|
{
|
||||||
label pointi = changedPoints[changedPointi];
|
const label pointi = changedPoints[changedPointi];
|
||||||
|
|
||||||
bool wasValid = allPointInfo_[pointi].valid(td_);
|
const bool wasValid = allPointInfo_[pointi].valid(td_);
|
||||||
|
|
||||||
// Copy info for pointi
|
// Copy info for pointi
|
||||||
allPointInfo_[pointi] = changedPointsInfo[changedPointi];
|
allPointInfo_[pointi] = changedPointsInfo[changedPointi];
|
||||||
|
|||||||
@ -287,14 +287,14 @@ public:
|
|||||||
return td_;
|
return td_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Get number of unvisited edges, i.e. edges that were not (yet)
|
//- Number of unvisited edges, i.e. edges that were not (yet)
|
||||||
// reached from walking across mesh. This can happen from
|
// reached from walking across mesh. This can happen from
|
||||||
// - not enough iterations done
|
// - not enough iterations done
|
||||||
// - a disconnected mesh
|
// - a disconnected mesh
|
||||||
// - a mesh without walls in it
|
// - a mesh without walls in it
|
||||||
label getUnsetEdges() const;
|
label nUnvisitedEdges() const;
|
||||||
|
|
||||||
label getUnsetPoints() const;
|
label nUnvisitedPoints() const;
|
||||||
|
|
||||||
//- Copy initial data into allPointInfo_
|
//- Copy initial data into allPointInfo_
|
||||||
void setPointInfo
|
void setPointInfo
|
||||||
|
|||||||
@ -239,7 +239,7 @@ Foam::labelList Foam::structuredRenumber::renumber
|
|||||||
deltaCalc.iterate(nLayers_);
|
deltaCalc.iterate(nLayers_);
|
||||||
|
|
||||||
Info<< type() << " : did not visit "
|
Info<< type() << " : did not visit "
|
||||||
<< deltaCalc.getUnsetCells()
|
<< deltaCalc.nUnvisitedCells()
|
||||||
<< " cells out of " << nTotalCells
|
<< " cells out of " << nTotalCells
|
||||||
<< "; using " << method_().type() << " renumbering for these" << endl;
|
<< "; using " << method_().type() << " renumbering for these" << endl;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user