mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: cyclicAMI: handle FaceCellWave (e.g. wall distance)
This commit is contained in:
@ -1,971 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "FaceCellWave.H"
|
||||
#include "polyMesh.H"
|
||||
#include "processorPolyPatch.H"
|
||||
#include "cyclicPolyPatch.H"
|
||||
#include "OPstream.H"
|
||||
#include "IPstream.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
#include "debug.H"
|
||||
#include "typeInfo.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
const Foam::scalar Foam::FaceCellWave<Type, TrackingData>::geomTol_ = 1e-6;
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
Foam::scalar Foam::FaceCellWave<Type, TrackingData>::propagationTol_ = 0.01;
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::dummyTrackData_ = 12345;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
// Update info for cellI, at position pt, with information from
|
||||
// neighbouring face/cell.
|
||||
// Updates:
|
||||
// - changedCell_, changedCells_, nChangedCells_,
|
||||
// - statistics: nEvals_, nUnvisitedCells_
|
||||
template <class Type, class TrackingData>
|
||||
bool Foam::FaceCellWave<Type, TrackingData>::updateCell
|
||||
(
|
||||
const label cellI,
|
||||
const label neighbourFaceI,
|
||||
const Type& neighbourInfo,
|
||||
const scalar tol,
|
||||
Type& cellInfo
|
||||
)
|
||||
{
|
||||
nEvals_++;
|
||||
|
||||
bool wasValid = cellInfo.valid(td_);
|
||||
|
||||
bool propagate =
|
||||
cellInfo.updateCell
|
||||
(
|
||||
mesh_,
|
||||
cellI,
|
||||
neighbourFaceI,
|
||||
neighbourInfo,
|
||||
tol,
|
||||
td_
|
||||
);
|
||||
|
||||
if (propagate)
|
||||
{
|
||||
if (!changedCell_[cellI])
|
||||
{
|
||||
changedCell_[cellI] = true;
|
||||
changedCells_[nChangedCells_++] = cellI;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wasValid && cellInfo.valid(td_))
|
||||
{
|
||||
--nUnvisitedCells_;
|
||||
}
|
||||
|
||||
return propagate;
|
||||
}
|
||||
|
||||
|
||||
// Update info for faceI, at position pt, with information from
|
||||
// neighbouring face/cell.
|
||||
// Updates:
|
||||
// - changedFace_, changedFaces_, nChangedFaces_,
|
||||
// - statistics: nEvals_, nUnvisitedFaces_
|
||||
template <class Type, class TrackingData>
|
||||
bool Foam::FaceCellWave<Type, TrackingData>::updateFace
|
||||
(
|
||||
const label faceI,
|
||||
const label neighbourCellI,
|
||||
const Type& neighbourInfo,
|
||||
const scalar tol,
|
||||
Type& faceInfo
|
||||
)
|
||||
{
|
||||
nEvals_++;
|
||||
|
||||
bool wasValid = faceInfo.valid(td_);
|
||||
|
||||
bool propagate =
|
||||
faceInfo.updateFace
|
||||
(
|
||||
mesh_,
|
||||
faceI,
|
||||
neighbourCellI,
|
||||
neighbourInfo,
|
||||
tol,
|
||||
td_
|
||||
);
|
||||
|
||||
if (propagate)
|
||||
{
|
||||
if (!changedFace_[faceI])
|
||||
{
|
||||
changedFace_[faceI] = true;
|
||||
changedFaces_[nChangedFaces_++] = faceI;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wasValid && faceInfo.valid(td_))
|
||||
{
|
||||
--nUnvisitedFaces_;
|
||||
}
|
||||
|
||||
return propagate;
|
||||
}
|
||||
|
||||
|
||||
// Update info for faceI, at position pt, with information from
|
||||
// same face.
|
||||
// Updates:
|
||||
// - changedFace_, changedFaces_, nChangedFaces_,
|
||||
// - statistics: nEvals_, nUnvisitedFaces_
|
||||
template <class Type, class TrackingData>
|
||||
bool Foam::FaceCellWave<Type, TrackingData>::updateFace
|
||||
(
|
||||
const label faceI,
|
||||
const Type& neighbourInfo,
|
||||
const scalar tol,
|
||||
Type& faceInfo
|
||||
)
|
||||
{
|
||||
nEvals_++;
|
||||
|
||||
bool wasValid = faceInfo.valid(td_);
|
||||
|
||||
bool propagate =
|
||||
faceInfo.updateFace
|
||||
(
|
||||
mesh_,
|
||||
faceI,
|
||||
neighbourInfo,
|
||||
tol,
|
||||
td_
|
||||
);
|
||||
|
||||
if (propagate)
|
||||
{
|
||||
if (!changedFace_[faceI])
|
||||
{
|
||||
changedFace_[faceI] = true;
|
||||
changedFaces_[nChangedFaces_++] = faceI;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wasValid && faceInfo.valid(td_))
|
||||
{
|
||||
--nUnvisitedFaces_;
|
||||
}
|
||||
|
||||
return propagate;
|
||||
}
|
||||
|
||||
|
||||
// For debugging: check status on both sides of cyclic
|
||||
template <class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::checkCyclic
|
||||
(
|
||||
const polyPatch& patch
|
||||
) const
|
||||
{
|
||||
const cyclicPolyPatch& nbrPatch =
|
||||
refCast<const cyclicPolyPatch>(patch).neighbPatch();
|
||||
|
||||
forAll(patch, patchFaceI)
|
||||
{
|
||||
label i1 = patch.start() + patchFaceI;
|
||||
label i2 = nbrPatch.start() + patchFaceI;
|
||||
|
||||
if
|
||||
(
|
||||
!allFaceInfo_[i1].sameGeometry
|
||||
(
|
||||
mesh_,
|
||||
allFaceInfo_[i2],
|
||||
geomTol_,
|
||||
td_
|
||||
)
|
||||
)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"FaceCellWave<Type, TrackingData>"
|
||||
"::checkCyclic(const polyPatch&)"
|
||||
) << "problem: i:" << i1 << " otheri:" << i2
|
||||
<< " faceInfo:" << allFaceInfo_[i1]
|
||||
<< " otherfaceInfo:" << allFaceInfo_[i2]
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
if (changedFace_[i1] != changedFace_[i2])
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"FaceCellWave<Type, TrackingData>"
|
||||
"::checkCyclic(const polyPatch&)"
|
||||
) << " problem: i:" << i1 << " otheri:" << i2
|
||||
<< " faceInfo:" << allFaceInfo_[i1]
|
||||
<< " otherfaceInfo:" << allFaceInfo_[i2]
|
||||
<< " changedFace:" << changedFace_[i1]
|
||||
<< " otherchangedFace:" << changedFace_[i2]
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check if has cyclic patches
|
||||
template <class Type, class TrackingData>
|
||||
bool Foam::FaceCellWave<Type, TrackingData>::hasCyclicPatch() const
|
||||
{
|
||||
forAll(mesh_.boundaryMesh(), patchI)
|
||||
{
|
||||
if (isA<cyclicPolyPatch>(mesh_.boundaryMesh()[patchI]))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Copy face information into member data
|
||||
template <class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::setFaceInfo
|
||||
(
|
||||
const labelList& changedFaces,
|
||||
const List<Type>& changedFacesInfo
|
||||
)
|
||||
{
|
||||
forAll(changedFaces, changedFaceI)
|
||||
{
|
||||
label faceI = changedFaces[changedFaceI];
|
||||
|
||||
bool wasValid = allFaceInfo_[faceI].valid(td_);
|
||||
|
||||
// Copy info for faceI
|
||||
allFaceInfo_[faceI] = changedFacesInfo[changedFaceI];
|
||||
|
||||
// Maintain count of unset faces
|
||||
if (!wasValid && allFaceInfo_[faceI].valid(td_))
|
||||
{
|
||||
--nUnvisitedFaces_;
|
||||
}
|
||||
|
||||
// Mark faceI as changed, both on list and on face itself.
|
||||
|
||||
changedFace_[faceI] = true;
|
||||
changedFaces_[nChangedFaces_++] = faceI;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Merge face information into member data
|
||||
template <class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::mergeFaceInfo
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label nFaces,
|
||||
const labelList& changedFaces,
|
||||
const List<Type>& changedFacesInfo
|
||||
)
|
||||
{
|
||||
for (label changedFaceI = 0; changedFaceI < nFaces; changedFaceI++)
|
||||
{
|
||||
const Type& neighbourWallInfo = changedFacesInfo[changedFaceI];
|
||||
label patchFaceI = changedFaces[changedFaceI];
|
||||
|
||||
label meshFaceI = patch.start() + patchFaceI;
|
||||
|
||||
Type& currentWallInfo = allFaceInfo_[meshFaceI];
|
||||
|
||||
if (!currentWallInfo.equal(neighbourWallInfo, td_))
|
||||
{
|
||||
updateFace
|
||||
(
|
||||
meshFaceI,
|
||||
neighbourWallInfo,
|
||||
propagationTol_,
|
||||
currentWallInfo
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Construct compact patchFace change arrays for a (slice of a) single patch.
|
||||
// changedPatchFaces in local patch numbering.
|
||||
// Return length of arrays.
|
||||
template <class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::getChangedPatchFaces
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label startFaceI,
|
||||
const label nFaces,
|
||||
labelList& changedPatchFaces,
|
||||
List<Type>& changedPatchFacesInfo
|
||||
) const
|
||||
{
|
||||
label nChangedPatchFaces = 0;
|
||||
|
||||
for (label i = 0; i < nFaces; i++)
|
||||
{
|
||||
label patchFaceI = i + startFaceI;
|
||||
|
||||
label meshFaceI = patch.start() + patchFaceI;
|
||||
|
||||
if (changedFace_[meshFaceI])
|
||||
{
|
||||
changedPatchFaces[nChangedPatchFaces] = patchFaceI;
|
||||
changedPatchFacesInfo[nChangedPatchFaces] = allFaceInfo_[meshFaceI];
|
||||
nChangedPatchFaces++;
|
||||
}
|
||||
}
|
||||
return nChangedPatchFaces;
|
||||
}
|
||||
|
||||
|
||||
// Handle leaving domain. Implementation referred to Type
|
||||
template <class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::leaveDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label nFaces,
|
||||
const labelList& faceLabels,
|
||||
List<Type>& faceInfo
|
||||
) const
|
||||
{
|
||||
const vectorField& fc = mesh_.faceCentres();
|
||||
|
||||
for (label i = 0; i < nFaces; i++)
|
||||
{
|
||||
label patchFaceI = faceLabels[i];
|
||||
|
||||
label meshFaceI = patch.start() + patchFaceI;
|
||||
faceInfo[i].leaveDomain(mesh_, patch, patchFaceI, fc[meshFaceI], td_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle entering domain. Implementation referred to Type
|
||||
template <class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::enterDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label nFaces,
|
||||
const labelList& faceLabels,
|
||||
List<Type>& faceInfo
|
||||
) const
|
||||
{
|
||||
const vectorField& fc = mesh_.faceCentres();
|
||||
|
||||
for (label i = 0; i < nFaces; i++)
|
||||
{
|
||||
label patchFaceI = faceLabels[i];
|
||||
|
||||
label meshFaceI = patch.start() + patchFaceI;
|
||||
faceInfo[i].enterDomain(mesh_, patch, patchFaceI, fc[meshFaceI], td_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Transform. Implementation referred to Type
|
||||
template <class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::transform
|
||||
(
|
||||
const tensorField& rotTensor,
|
||||
const label nFaces,
|
||||
List<Type>& faceInfo
|
||||
)
|
||||
{
|
||||
if (rotTensor.size() == 1)
|
||||
{
|
||||
const tensor& T = rotTensor[0];
|
||||
|
||||
for (label faceI = 0; faceI < nFaces; faceI++)
|
||||
{
|
||||
faceInfo[faceI].transform(mesh_, T, td_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (label faceI = 0; faceI < nFaces; faceI++)
|
||||
{
|
||||
faceInfo[faceI].transform(mesh_, rotTensor[faceI], td_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Offset mesh face. Used for transferring from one cyclic half to the other.
|
||||
template <class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::offset
|
||||
(
|
||||
const polyPatch&,
|
||||
const label cycOffset,
|
||||
const label nFaces,
|
||||
labelList& faces
|
||||
)
|
||||
{
|
||||
for (label faceI = 0; faceI < nFaces; faceI++)
|
||||
{
|
||||
faces[faceI] += cycOffset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Tranfer all the information to/from neighbouring processors
|
||||
template <class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::handleProcPatches()
|
||||
{
|
||||
// Send all
|
||||
|
||||
PstreamBuffers pBufs(Pstream::nonBlocking);
|
||||
|
||||
forAll(mesh_.boundaryMesh(), patchI)
|
||||
{
|
||||
const polyPatch& patch = mesh_.boundaryMesh()[patchI];
|
||||
|
||||
if (isA<processorPolyPatch>(patch))
|
||||
{
|
||||
// Allocate buffers
|
||||
label nSendFaces;
|
||||
labelList sendFaces(patch.size());
|
||||
List<Type> sendFacesInfo(patch.size());
|
||||
|
||||
// Determine which faces changed on current patch
|
||||
nSendFaces = getChangedPatchFaces
|
||||
(
|
||||
patch,
|
||||
0,
|
||||
patch.size(),
|
||||
sendFaces,
|
||||
sendFacesInfo
|
||||
);
|
||||
|
||||
// Adapt wallInfo for leaving domain
|
||||
leaveDomain
|
||||
(
|
||||
patch,
|
||||
nSendFaces,
|
||||
sendFaces,
|
||||
sendFacesInfo
|
||||
);
|
||||
|
||||
const processorPolyPatch& procPatch =
|
||||
refCast<const processorPolyPatch>(patch);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " Processor patch " << patchI << ' ' << patch.name()
|
||||
<< " communicating with " << procPatch.neighbProcNo()
|
||||
<< " Sending:" << nSendFaces
|
||||
<< endl;
|
||||
}
|
||||
|
||||
UOPstream toNeighbour(procPatch.neighbProcNo(), pBufs);
|
||||
//writeFaces(nSendFaces, sendFaces, sendFacesInfo, toNeighbour);
|
||||
toNeighbour
|
||||
<< SubList<label>(sendFaces, nSendFaces)
|
||||
<< SubList<Type>(sendFacesInfo, nSendFaces);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
pBufs.finishedSends();
|
||||
|
||||
// Receive all
|
||||
|
||||
forAll(mesh_.boundaryMesh(), patchI)
|
||||
{
|
||||
const polyPatch& patch = mesh_.boundaryMesh()[patchI];
|
||||
|
||||
if (isA<processorPolyPatch>(patch))
|
||||
{
|
||||
const processorPolyPatch& procPatch =
|
||||
refCast<const processorPolyPatch>(patch);
|
||||
|
||||
// Allocate buffers
|
||||
labelList receiveFaces;
|
||||
List<Type> receiveFacesInfo;
|
||||
|
||||
{
|
||||
UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs);
|
||||
fromNeighbour >> receiveFaces >> receiveFacesInfo;
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " Processor patch " << patchI << ' ' << patch.name()
|
||||
<< " communicating with " << procPatch.neighbProcNo()
|
||||
<< " Receiving:" << receiveFaces.size()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Apply transform to received data for non-parallel planes
|
||||
if (!procPatch.parallel())
|
||||
{
|
||||
transform
|
||||
(
|
||||
procPatch.forwardT(),
|
||||
receiveFaces.size(),
|
||||
receiveFacesInfo
|
||||
);
|
||||
}
|
||||
|
||||
// Adapt wallInfo for entering domain
|
||||
enterDomain
|
||||
(
|
||||
patch,
|
||||
receiveFaces.size(),
|
||||
receiveFaces,
|
||||
receiveFacesInfo
|
||||
);
|
||||
|
||||
// Merge received info
|
||||
mergeFaceInfo
|
||||
(
|
||||
patch,
|
||||
receiveFaces.size(),
|
||||
receiveFaces,
|
||||
receiveFacesInfo
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Transfer information across cyclic halves.
|
||||
template <class Type, class TrackingData>
|
||||
void Foam::FaceCellWave<Type, TrackingData>::handleCyclicPatches()
|
||||
{
|
||||
forAll(mesh_.boundaryMesh(), patchI)
|
||||
{
|
||||
const polyPatch& patch = mesh_.boundaryMesh()[patchI];
|
||||
|
||||
if (isA<cyclicPolyPatch>(patch))
|
||||
{
|
||||
const cyclicPolyPatch& nbrPatch =
|
||||
refCast<const cyclicPolyPatch>(patch).neighbPatch();
|
||||
|
||||
// Allocate buffers
|
||||
label nReceiveFaces;
|
||||
labelList receiveFaces(patch.size());
|
||||
List<Type> receiveFacesInfo(patch.size());
|
||||
|
||||
// Determine which faces changed
|
||||
nReceiveFaces = getChangedPatchFaces
|
||||
(
|
||||
nbrPatch,
|
||||
0,
|
||||
nbrPatch.size(),
|
||||
receiveFaces,
|
||||
receiveFacesInfo
|
||||
);
|
||||
|
||||
// Adapt wallInfo for leaving domain
|
||||
leaveDomain
|
||||
(
|
||||
nbrPatch,
|
||||
nReceiveFaces,
|
||||
receiveFaces,
|
||||
receiveFacesInfo
|
||||
);
|
||||
|
||||
const cyclicPolyPatch& cycPatch =
|
||||
refCast<const cyclicPolyPatch>(patch);
|
||||
|
||||
if (!cycPatch.parallel())
|
||||
{
|
||||
// received data from other half
|
||||
transform
|
||||
(
|
||||
cycPatch.forwardT(),
|
||||
nReceiveFaces,
|
||||
receiveFacesInfo
|
||||
);
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " Cyclic patch " << patchI << ' ' << cycPatch.name()
|
||||
<< " Changed : " << nReceiveFaces
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Half2: Adapt wallInfo for entering domain
|
||||
enterDomain
|
||||
(
|
||||
cycPatch,
|
||||
nReceiveFaces,
|
||||
receiveFaces,
|
||||
receiveFacesInfo
|
||||
);
|
||||
|
||||
// Merge into global storage
|
||||
mergeFaceInfo
|
||||
(
|
||||
cycPatch,
|
||||
nReceiveFaces,
|
||||
receiveFaces,
|
||||
receiveFacesInfo
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
checkCyclic(cycPatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Set up only. Use setFaceInfo and iterate() to do actual calculation.
|
||||
template <class Type, class TrackingData>
|
||||
Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
UList<Type>& allFaceInfo,
|
||||
UList<Type>& allCellInfo,
|
||||
TrackingData& td
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
allFaceInfo_(allFaceInfo),
|
||||
allCellInfo_(allCellInfo),
|
||||
td_(td),
|
||||
changedFace_(mesh_.nFaces(), false),
|
||||
changedFaces_(mesh_.nFaces()),
|
||||
nChangedFaces_(0),
|
||||
changedCell_(mesh_.nCells(), false),
|
||||
changedCells_(mesh_.nCells()),
|
||||
nChangedCells_(0),
|
||||
hasCyclicPatches_(hasCyclicPatch()),
|
||||
nEvals_(0),
|
||||
nUnvisitedCells_(mesh_.nCells()),
|
||||
nUnvisitedFaces_(mesh_.nFaces())
|
||||
{}
|
||||
|
||||
|
||||
// Iterate, propagating changedFacesInfo across mesh, until no change (or
|
||||
// maxIter reached). Initial cell values specified.
|
||||
template <class Type, class TrackingData>
|
||||
Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& changedFaces,
|
||||
const List<Type>& changedFacesInfo,
|
||||
UList<Type>& allFaceInfo,
|
||||
UList<Type>& allCellInfo,
|
||||
const label maxIter,
|
||||
TrackingData& td
|
||||
)
|
||||
:
|
||||
mesh_(mesh),
|
||||
allFaceInfo_(allFaceInfo),
|
||||
allCellInfo_(allCellInfo),
|
||||
td_(td),
|
||||
changedFace_(mesh_.nFaces(), false),
|
||||
changedFaces_(mesh_.nFaces()),
|
||||
nChangedFaces_(0),
|
||||
changedCell_(mesh_.nCells(), false),
|
||||
changedCells_(mesh_.nCells()),
|
||||
nChangedCells_(0),
|
||||
hasCyclicPatches_(hasCyclicPatch()),
|
||||
nEvals_(0),
|
||||
nUnvisitedCells_(mesh_.nCells()),
|
||||
nUnvisitedFaces_(mesh_.nFaces())
|
||||
{
|
||||
// Copy initial changed faces data
|
||||
setFaceInfo(changedFaces, changedFacesInfo);
|
||||
|
||||
// Iterate until nothing changes
|
||||
label iter = iterate(maxIter);
|
||||
|
||||
if ((maxIter > 0) && (iter >= maxIter))
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"FaceCellWave<Type, TrackingData>::FaceCellWave"
|
||||
"(const polyMesh&, const labelList&, const List<Type>,"
|
||||
" UList<Type>&, UList<Type>&, const label maxIter)"
|
||||
)
|
||||
<< "Maximum number of iterations reached. Increase maxIter." << endl
|
||||
<< " maxIter:" << maxIter << endl
|
||||
<< " nChangedCells:" << nChangedCells_ << endl
|
||||
<< " nChangedFaces:" << nChangedFaces_ << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::getUnsetCells() const
|
||||
{
|
||||
return nUnvisitedCells_;
|
||||
}
|
||||
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::getUnsetFaces() const
|
||||
{
|
||||
return nUnvisitedFaces_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Propagate cell to face
|
||||
template <class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell()
|
||||
{
|
||||
const labelList& owner = mesh_.faceOwner();
|
||||
const labelList& neighbour = mesh_.faceNeighbour();
|
||||
label nInternalFaces = mesh_.nInternalFaces();
|
||||
|
||||
for
|
||||
(
|
||||
label changedFaceI = 0;
|
||||
changedFaceI < nChangedFaces_;
|
||||
changedFaceI++
|
||||
)
|
||||
{
|
||||
label faceI = changedFaces_[changedFaceI];
|
||||
if (!changedFace_[faceI])
|
||||
{
|
||||
FatalErrorIn("FaceCellWave<Type, TrackingData>::faceToCell()")
|
||||
<< "Face " << faceI
|
||||
<< " not marked as having been changed"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
const Type& neighbourWallInfo = allFaceInfo_[faceI];
|
||||
|
||||
// Evaluate all connected cells
|
||||
|
||||
// Owner
|
||||
label cellI = owner[faceI];
|
||||
Type& currentWallInfo = allCellInfo_[cellI];
|
||||
|
||||
if (!currentWallInfo.equal(neighbourWallInfo, td_))
|
||||
{
|
||||
updateCell
|
||||
(
|
||||
cellI,
|
||||
faceI,
|
||||
neighbourWallInfo,
|
||||
propagationTol_,
|
||||
currentWallInfo
|
||||
);
|
||||
}
|
||||
|
||||
// Neighbour.
|
||||
if (faceI < nInternalFaces)
|
||||
{
|
||||
cellI = neighbour[faceI];
|
||||
Type& currentWallInfo2 = allCellInfo_[cellI];
|
||||
|
||||
if (!currentWallInfo2.equal(neighbourWallInfo, td_))
|
||||
{
|
||||
updateCell
|
||||
(
|
||||
cellI,
|
||||
faceI,
|
||||
neighbourWallInfo,
|
||||
propagationTol_,
|
||||
currentWallInfo2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset status of face
|
||||
changedFace_[faceI] = false;
|
||||
}
|
||||
|
||||
// Handled all changed faces by now
|
||||
nChangedFaces_ = 0;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " Changed cells : " << nChangedCells_ << endl;
|
||||
}
|
||||
|
||||
// Sum nChangedCells over all procs
|
||||
label totNChanged = nChangedCells_;
|
||||
|
||||
reduce(totNChanged, sumOp<label>());
|
||||
|
||||
return totNChanged;
|
||||
}
|
||||
|
||||
|
||||
// Propagate cell to face
|
||||
template <class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::cellToFace()
|
||||
{
|
||||
const cellList& cells = mesh_.cells();
|
||||
|
||||
for
|
||||
(
|
||||
label changedCellI = 0;
|
||||
changedCellI < nChangedCells_;
|
||||
changedCellI++
|
||||
)
|
||||
{
|
||||
label cellI = changedCells_[changedCellI];
|
||||
if (!changedCell_[cellI])
|
||||
{
|
||||
FatalErrorIn("FaceCellWave<Type, TrackingData>::cellToFace()")
|
||||
<< "Cell " << cellI << " not marked as having been changed"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
const Type& neighbourWallInfo = allCellInfo_[cellI];
|
||||
|
||||
// Evaluate all connected faces
|
||||
|
||||
const labelList& faceLabels = cells[cellI];
|
||||
forAll(faceLabels, faceLabelI)
|
||||
{
|
||||
label faceI = faceLabels[faceLabelI];
|
||||
Type& currentWallInfo = allFaceInfo_[faceI];
|
||||
|
||||
if (!currentWallInfo.equal(neighbourWallInfo, td_))
|
||||
{
|
||||
updateFace
|
||||
(
|
||||
faceI,
|
||||
cellI,
|
||||
neighbourWallInfo,
|
||||
propagationTol_,
|
||||
currentWallInfo
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset status of cell
|
||||
changedCell_[cellI] = false;
|
||||
}
|
||||
|
||||
// Handled all changed cells by now
|
||||
nChangedCells_ = 0;
|
||||
|
||||
if (hasCyclicPatches_)
|
||||
{
|
||||
// Transfer changed faces across cyclic halves
|
||||
handleCyclicPatches();
|
||||
}
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Transfer changed faces from neighbouring processors.
|
||||
handleProcPatches();
|
||||
}
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " Changed faces : " << nChangedFaces_ << endl;
|
||||
}
|
||||
|
||||
// Sum nChangedFaces over all procs
|
||||
label totNChanged = nChangedFaces_;
|
||||
|
||||
reduce(totNChanged, sumOp<label>());
|
||||
|
||||
return totNChanged;
|
||||
}
|
||||
|
||||
|
||||
// Iterate
|
||||
template <class Type, class TrackingData>
|
||||
Foam::label Foam::FaceCellWave<Type, TrackingData>::iterate(const label maxIter)
|
||||
{
|
||||
if (hasCyclicPatches_)
|
||||
{
|
||||
// Transfer changed faces across cyclic halves
|
||||
handleCyclicPatches();
|
||||
}
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
// Transfer changed faces from neighbouring processors.
|
||||
handleProcPatches();
|
||||
}
|
||||
|
||||
label iter = 0;
|
||||
|
||||
while (iter < maxIter)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " Iteration " << iter << endl;
|
||||
}
|
||||
|
||||
nEvals_ = 0;
|
||||
|
||||
label nCells = faceToCell();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " Total changed cells : " << nCells << endl;
|
||||
}
|
||||
|
||||
if (nCells == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
label nFaces = cellToFace();
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " 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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,362 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::FaceCellWave
|
||||
|
||||
Description
|
||||
Wave propagation of information through grid. Every iteration
|
||||
information goes through one layer of cells. Templated on information
|
||||
that is transferred.
|
||||
|
||||
Handles parallel and cyclics and non-parallel cyclics.
|
||||
|
||||
Note: whether to propagate depends on the return value of Type::update
|
||||
which returns true (i.e. propagate) if the value changes by more than a
|
||||
certain tolerance.
|
||||
This tolerance can be very strict for normal face-cell and parallel
|
||||
cyclics (we use a value of 0.01 just to limit propagation of small changes)
|
||||
but for non-parallel cyclics this tolerance can be critical and if chosen
|
||||
too small can lead to non-convergence.
|
||||
|
||||
SourceFiles
|
||||
FaceCellWave.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef FaceCellWave_H
|
||||
#define FaceCellWave_H
|
||||
|
||||
#include "boolList.H"
|
||||
#include "labelList.H"
|
||||
#include "primitiveFieldsFwd.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class polyMesh;
|
||||
class polyPatch;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class FaceCellWaveName Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
TemplateName(FaceCellWave);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class FaceCellWave Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class Type, class TrackingData = int>
|
||||
class FaceCellWave
|
||||
:
|
||||
public FaceCellWaveName
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to mesh
|
||||
const polyMesh& mesh_;
|
||||
|
||||
//- Information for all faces
|
||||
UList<Type>& allFaceInfo_;
|
||||
|
||||
//- Information for all cells
|
||||
UList<Type>& allCellInfo_;
|
||||
|
||||
//- Additional data to be passed into container
|
||||
TrackingData& td_;
|
||||
|
||||
//- Has face changed
|
||||
boolList changedFace_;
|
||||
|
||||
//- List of changed faces
|
||||
labelList changedFaces_;
|
||||
|
||||
//- Number of changed faces
|
||||
label nChangedFaces_;
|
||||
|
||||
// Cells that have changed
|
||||
boolList changedCell_;
|
||||
labelList changedCells_;
|
||||
label nChangedCells_;
|
||||
|
||||
//- Contains cyclics
|
||||
bool hasCyclicPatches_;
|
||||
|
||||
//- Number of evaluations
|
||||
label nEvals_;
|
||||
|
||||
//- Number of unvisited cells/faces
|
||||
label nUnvisitedCells_;
|
||||
label nUnvisitedFaces_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
FaceCellWave(const FaceCellWave&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const FaceCellWave&);
|
||||
|
||||
|
||||
//- Updates cellInfo with information from neighbour. Updates all
|
||||
// statistics.
|
||||
bool updateCell
|
||||
(
|
||||
const label cellI,
|
||||
const label neighbourFaceI,
|
||||
const Type& neighbourInfo,
|
||||
const scalar tol,
|
||||
Type& cellInfo
|
||||
);
|
||||
|
||||
//- Updates faceInfo with information from neighbour. Updates all
|
||||
// statistics.
|
||||
bool updateFace
|
||||
(
|
||||
const label faceI,
|
||||
const label neighbourCellI,
|
||||
const Type& neighbourInfo,
|
||||
const scalar tol,
|
||||
Type& faceInfo
|
||||
);
|
||||
|
||||
//- Updates faceInfo with information from same face. Updates all
|
||||
// statistics.
|
||||
bool updateFace
|
||||
(
|
||||
const label faceI,
|
||||
const Type& neighbourInfo,
|
||||
const scalar tol,
|
||||
Type& faceInfo
|
||||
);
|
||||
|
||||
|
||||
// Parallel, cyclic
|
||||
|
||||
//- Debugging: check info on both sides of cyclic
|
||||
void checkCyclic(const polyPatch& pPatch) const;
|
||||
|
||||
//- Has cyclic patch?
|
||||
bool hasCyclicPatch() const;
|
||||
|
||||
//- Merge received patch data into global data
|
||||
void mergeFaceInfo
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label nFaces,
|
||||
const labelList&,
|
||||
const List<Type>&
|
||||
);
|
||||
|
||||
//- Extract info for single patch only
|
||||
label getChangedPatchFaces
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label startFaceI,
|
||||
const label nFaces,
|
||||
labelList& changedPatchFaces,
|
||||
List<Type>& changedPatchFacesInfo
|
||||
) const;
|
||||
|
||||
//- Handle leaving domain. Implementation referred to Type
|
||||
void leaveDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label nFaces,
|
||||
const labelList& faceLabels,
|
||||
List<Type>& faceInfo
|
||||
) const;
|
||||
|
||||
//- Handle leaving domain. Implementation referred to Type
|
||||
void enterDomain
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label nFaces,
|
||||
const labelList& faceLabels,
|
||||
List<Type>& faceInfo
|
||||
) const;
|
||||
|
||||
//- Offset face labels by constant value
|
||||
static void offset
|
||||
(
|
||||
const polyPatch& patch,
|
||||
const label off,
|
||||
const label nFaces,
|
||||
labelList& faces
|
||||
);
|
||||
|
||||
//- Apply transformation to Type
|
||||
void transform
|
||||
(
|
||||
const tensorField& rotTensor,
|
||||
const label nFaces,
|
||||
List<Type>& faceInfo
|
||||
);
|
||||
|
||||
//- Merge data from across processor boundaries
|
||||
void handleProcPatches();
|
||||
|
||||
//- Merge data from across cyclics
|
||||
void handleCyclicPatches();
|
||||
|
||||
|
||||
// Private static data
|
||||
|
||||
static const scalar geomTol_;
|
||||
static scalar propagationTol_;
|
||||
|
||||
//- Used as default trackdata value to satisfy default template
|
||||
// argument.
|
||||
static label dummyTrackData_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Static Functions
|
||||
|
||||
//- Access to tolerance
|
||||
static scalar propagationTol()
|
||||
{
|
||||
return propagationTol_;
|
||||
}
|
||||
|
||||
//- Change tolerance
|
||||
static void setPropagationTol(const scalar tol)
|
||||
{
|
||||
propagationTol_ = tol;
|
||||
}
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
// Construct from mesh. Use setFaceInfo and iterate() to do actual
|
||||
// calculation.
|
||||
FaceCellWave
|
||||
(
|
||||
const polyMesh&,
|
||||
UList<Type>& allFaceInfo,
|
||||
UList<Type>& allCellInfo,
|
||||
TrackingData& td = dummyTrackData_
|
||||
);
|
||||
|
||||
//- Construct from mesh and list of changed faces with the Type
|
||||
// for these faces. Iterates until nothing changes or maxIter reached.
|
||||
// (maxIter can be 0)
|
||||
FaceCellWave
|
||||
(
|
||||
const polyMesh&,
|
||||
const labelList& initialChangedFaces,
|
||||
const List<Type>& changedFacesInfo,
|
||||
UList<Type>& allFaceInfo,
|
||||
UList<Type>& allCellInfo,
|
||||
const label maxIter,
|
||||
TrackingData& td = dummyTrackData_
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Access allFaceInfo
|
||||
UList<Type>& allFaceInfo()
|
||||
{
|
||||
return allFaceInfo_;
|
||||
}
|
||||
|
||||
//- Access allCellInfo
|
||||
UList<Type>& allCellInfo()
|
||||
{
|
||||
return allCellInfo_;
|
||||
}
|
||||
|
||||
//- Additional data to be passed into container
|
||||
const TrackingData& data() const
|
||||
{
|
||||
return td_;
|
||||
}
|
||||
|
||||
//- Access mesh
|
||||
const polyMesh& mesh() const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
//- Get number of unvisited cells, i.e. cells that were not (yet)
|
||||
// reached from walking across mesh. This can happen from
|
||||
// - not enough iterations done
|
||||
// - a disconnected mesh
|
||||
// - a mesh without walls in it
|
||||
label getUnsetCells() const;
|
||||
|
||||
//- Get number of unvisited faces
|
||||
label getUnsetFaces() const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Set initial changed faces
|
||||
void setFaceInfo
|
||||
(
|
||||
const labelList& changedFaces,
|
||||
const List<Type>& changedFacesInfo
|
||||
);
|
||||
|
||||
//- Propagate from face to cell. Returns total number of cells
|
||||
// (over all processors) changed.
|
||||
label faceToCell();
|
||||
|
||||
//- Propagate from cell to face. Returns total number of faces
|
||||
// (over all processors) changed. (Faces on processorpatches are
|
||||
// counted double)
|
||||
label cellToFace();
|
||||
|
||||
//- Iterate until no changes or maxIter reached. Returns actual
|
||||
// number of iterations.
|
||||
label iterate(const label maxIter);
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "FaceCellWave.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,32 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "FaceCellWave.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::FaceCellWaveName, 0);
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,96 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "MeshWave.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type, class TrackingData>
|
||||
Foam::label Foam::MeshWave<Type, TrackingData>::dummyTrackData_ = 12345;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Iterate, propagating changedFacesInfo across mesh, until no change (or
|
||||
// maxIter reached).
|
||||
template <class Type, class TrackingData>
|
||||
Foam::MeshWave<Type, TrackingData>::MeshWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& changedFaces,
|
||||
const List<Type>& changedFacesInfo,
|
||||
const label maxIter,
|
||||
TrackingData& td
|
||||
)
|
||||
:
|
||||
allFaceInfo_(mesh.nFaces()),
|
||||
allCellInfo_(mesh.nCells()),
|
||||
calc_
|
||||
(
|
||||
mesh,
|
||||
changedFaces,
|
||||
changedFacesInfo,
|
||||
allFaceInfo_,
|
||||
allCellInfo_,
|
||||
maxIter,
|
||||
td
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// Iterate, propagating changedFacesInfo across mesh, until no change (or
|
||||
// maxIter reached). Initial cell values specified.
|
||||
template <class Type, class TrackingData>
|
||||
Foam::MeshWave<Type, TrackingData>::MeshWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& changedFaces,
|
||||
const List<Type>& changedFacesInfo,
|
||||
const List<Type>& allCellInfo,
|
||||
const label maxIter,
|
||||
TrackingData& td
|
||||
)
|
||||
:
|
||||
allFaceInfo_(mesh.nFaces()),
|
||||
allCellInfo_(allCellInfo),
|
||||
calc_
|
||||
(
|
||||
mesh,
|
||||
changedFaces,
|
||||
changedFacesInfo,
|
||||
allFaceInfo_,
|
||||
allCellInfo_,
|
||||
maxIter,
|
||||
td
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,177 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::MeshWave
|
||||
|
||||
Description
|
||||
FaceCellWave plus data
|
||||
|
||||
SourceFiles
|
||||
MeshWave.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef MeshWave_H
|
||||
#define MeshWave_H
|
||||
|
||||
#include "FaceCellWave.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class MeshWaveName Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
TemplateName(MeshWave);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class MeshWave Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template <class Type, class TrackingData = int>
|
||||
class MeshWave
|
||||
:
|
||||
public MeshWaveName
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Wall information for all faces
|
||||
List<Type> allFaceInfo_;
|
||||
|
||||
//- Wall information for all cells
|
||||
List<Type> allCellInfo_;
|
||||
|
||||
//- Wave calculation engine.
|
||||
FaceCellWave<Type, TrackingData> calc_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
MeshWave(const MeshWave&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const MeshWave&);
|
||||
|
||||
// Private static data
|
||||
|
||||
//- Used as default trackdata value to satisfy default template
|
||||
// argument.
|
||||
static label dummyTrackData_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from mesh and list of changed faces with the Type
|
||||
// for these faces. Iterates until nothing changes or maxIter reached.
|
||||
// (maxIter can be 0)
|
||||
MeshWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& initialChangedFaces,
|
||||
const List<Type>& changedFacesInfo,
|
||||
const label maxIter,
|
||||
TrackingData& td = dummyTrackData_
|
||||
);
|
||||
|
||||
//- Construct from mesh, list of changed faces with the Type
|
||||
// for these faces and initial field.
|
||||
// Iterates until nothing changes or maxIter reached.
|
||||
// (maxIter can be 0)
|
||||
MeshWave
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& initialChangedFaces,
|
||||
const List<Type>& changedFacesInfo,
|
||||
const List<Type>& allCellInfo,
|
||||
const label maxIter,
|
||||
TrackingData& td = dummyTrackData_
|
||||
);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Get allFaceInfo
|
||||
const List<Type>& allFaceInfo() const
|
||||
{
|
||||
return allFaceInfo_;
|
||||
}
|
||||
|
||||
//- Get allCellInfo
|
||||
const List<Type>& allCellInfo() const
|
||||
{
|
||||
return allCellInfo_;
|
||||
}
|
||||
|
||||
//- Additional data to be passed into container
|
||||
const TrackingData& data() const
|
||||
{
|
||||
return calc_.data();
|
||||
}
|
||||
|
||||
//- Iterate until no changes or maxIter reached. Returns actual
|
||||
// number of iterations.
|
||||
label iterate(const label maxIter)
|
||||
{
|
||||
return calc_.iterate(maxIter);
|
||||
}
|
||||
|
||||
//- Get number of unvisited cells, i.e. cells that were not (yet)
|
||||
// reached from walking across mesh. This can happen from
|
||||
// - not enough iterations done
|
||||
// - a disconnected mesh
|
||||
// - a mesh without walls in it
|
||||
label getUnsetCells() const
|
||||
{
|
||||
return calc_.getUnsetCells();
|
||||
}
|
||||
|
||||
//- Get number of unvisited faces
|
||||
label getUnsetFaces() const
|
||||
{
|
||||
return calc_.getUnsetFaces();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "MeshWave.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,32 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "MeshWave.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(Foam::MeshWaveName, 0);
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user