Commit 1aea998b authored by mattijs's avatar mattijs
Browse files

ENH: FaceCellWave : additional trackData like argument for passing in non-cell data

parent 7364bc2c
......@@ -29,7 +29,7 @@ Description
#include "fvCFD.H"
#include "wallFvPatch.H"
#include "MeshWave.H"
#include "FaceCellWave.H"
#include "wallPoint.H"
......@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
forAll(allCellInfo, cellI)
{
scalar dist = allCellInfo[cellI].distSqr();
if (allCellInfo[cellI].valid())
if (allCellInfo[cellI].valid(wallDistCalc.data()))
{
wallDistUncorrected[cellI] = Foam::sqrt(dist);
}
......@@ -180,7 +180,7 @@ int main(int argc, char *argv[])
const label meshFaceI = patchField.patch().start() + patchFaceI;
scalar dist = allFaceInfo[meshFaceI].distSqr();
if (allFaceInfo[meshFaceI].valid())
if (allFaceInfo[meshFaceI].valid(wallDistCalc.data()))
{
patchField[patchFaceI] = Foam::sqrt(dist);
}
......
......@@ -299,7 +299,7 @@ label selectOutsideCells
mesh,
outsideFaces.shrink(),
outsideFacesInfo.shrink(),
mesh.globalData().nTotalCells()+1 // max iterations
mesh.globalData().nTotalCells()+1 // max iterations
);
// Now regionCalc should hold info on cells that are reachable from
......
......@@ -71,7 +71,7 @@ TemplateName(FaceCellWave);
Class FaceCellWave Declaration
\*---------------------------------------------------------------------------*/
template <class Type>
template<class Type, class TrackingData = int>
class FaceCellWave
:
public FaceCellWaveName
......@@ -87,6 +87,9 @@ class FaceCellWave
//- Information for all cells
UList<Type>& allCellInfo_;
//- Additional data to be passed into container
TrackingData& td_;
//- Has face changed
boolList changedFace_;
......@@ -115,27 +118,6 @@ class FaceCellWave
label iter_;
// Static Functions
//- Write faces info
static Ostream& writeFaces
(
const label nFaces,
const labelList& faceLabels,
const List<Type>& faceInfo,
Ostream& os
);
//- Read faces info
static Istream& readFaces
(
label& nFaces,
labelList& faceLabels,
List<Type>& faceInfo,
Istream& is
);
// Private Member Functions
//- Disallow default bitwise copy construct
......@@ -250,7 +232,12 @@ class FaceCellWave
// Private static data
static const scalar geomTol_;
static scalar propagationTol_;
static const scalar propagationTol_;
//- Used as default trackdata value to satisfy default template
// argument.
static label dummyTrackData_;
public:
......@@ -277,7 +264,8 @@ public:
(
const polyMesh&,
UList<Type>& allFaceInfo,
UList<Type>& allCellInfo
UList<Type>& allCellInfo,
TrackingData& td = dummyTrackData_
);
//- Construct from mesh and list of changed faces with the Type
......@@ -290,7 +278,8 @@ public:
const List<Type>& changedFacesInfo,
UList<Type>& allFaceInfo,
UList<Type>& allCellInfo,
const label maxIter
const label maxIter,
TrackingData& td = dummyTrackData_
);
......@@ -310,6 +299,12 @@ public:
return allCellInfo_;
}
//- Additional data to be passed into container
const TrackingData& data() const
{
return td_;
}
//- Access mesh
const polyMesh& mesh() const
{
......
......@@ -26,17 +26,25 @@ License
#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>
Foam::MeshWave<Type>::MeshWave
template <class Type, class TrackingData>
Foam::MeshWave<Type, TrackingData>::MeshWave
(
const polyMesh& mesh,
const labelList& changedFaces,
const List<Type>& changedFacesInfo,
const label maxIter
const label maxIter,
TrackingData& td
)
:
allFaceInfo_(mesh.nFaces()),
......@@ -48,21 +56,23 @@ Foam::MeshWave<Type>::MeshWave
changedFacesInfo,
allFaceInfo_,
allCellInfo_,
maxIter
maxIter,
td
)
{}
// Iterate, propagating changedFacesInfo across mesh, until no change (or
// maxIter reached). Initial cell values specified.
template <class Type>
Foam::MeshWave<Type>::MeshWave
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
const label maxIter,
TrackingData& td
)
:
allFaceInfo_(mesh.nFaces()),
......@@ -74,7 +84,8 @@ Foam::MeshWave<Type>::MeshWave
changedFacesInfo,
allFaceInfo_,
allCellInfo_,
maxIter
maxIter,
td
)
{}
......
......@@ -53,7 +53,7 @@ TemplateName(MeshWave);
Class MeshWave Declaration
\*---------------------------------------------------------------------------*/
template <class Type>
template <class Type, class TrackingData = int>
class MeshWave
:
public MeshWaveName
......@@ -67,7 +67,7 @@ class MeshWave
List<Type> allCellInfo_;
//- Wave calculation engine.
FaceCellWave<Type> calc_;
FaceCellWave<Type, TrackingData> calc_;
// Private Member Functions
......@@ -77,6 +77,12 @@ class 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
......@@ -89,7 +95,8 @@ public:
const polyMesh& mesh,
const labelList& initialChangedFaces,
const List<Type>& changedFacesInfo,
const label maxIter
const label maxIter,
TrackingData& td = dummyTrackData_
);
//- Construct from mesh, list of changed faces with the Type
......@@ -102,7 +109,8 @@ public:
const labelList& initialChangedFaces,
const List<Type>& changedFacesInfo,
const List<Type>& allCellInfo,
const label maxIter
const label maxIter,
TrackingData& td = dummyTrackData_
);
......@@ -120,6 +128,11 @@ public:
return allCellInfo_;
}
//- Additional data to be passed into container
const TrackingData& data() const
{
return calc_.data();
}
//- Iterate until no changes or maxIter reached. Returns number of
// unset cells (see getUnsetCells)
......
......@@ -25,35 +25,13 @@ License
\*---------------------------------------------------------------------------*/
#include "directionInfo.H"
#include "hexMatcher.H"
#include "meshTools.H"
//#include "hexMatcher.H"
//#include "meshTools.H"
#include "polyMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::directionInfo::equal(const edge& e, const label v0, const label v1)
{
return
(e.start() == v0 && e.end() == v1)
|| (e.start() == v1 && e.end() == v0);
}
Foam::point Foam::directionInfo::eMid
(
const primitiveMesh& mesh,
const label edgeI
)
{
const edge& e = mesh.edges()[edgeI];
return
0.5
* (mesh.points()[e.start()] + mesh.points()[e.end()]);
}
// Find edge among edgeLabels that uses v0 and v1
Foam::label Foam::directionInfo::findEdge
(
......@@ -67,9 +45,7 @@ Foam::label Foam::directionInfo::findEdge
{
label edgeI = edgeLabels[edgeLabelI];
const edge& e = mesh.edges()[edgeI];
if (equal(e, v0, v1))
if (mesh.edges()[edgeI] == edge(v0, v1))
{
return edgeI;
}
......@@ -225,159 +201,6 @@ Foam::label Foam::directionInfo::edgeToFaceIndex
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Update this cell with neighbouring face information
bool Foam::directionInfo::updateCell
(
const polyMesh& mesh,
const label thisCellI,
const label neighbourFaceI,
const directionInfo& neighbourInfo,
const scalar // tol
)
{
if (index_ >= -2)
{
// Already determined.
return false;
}
if (hexMatcher().isA(mesh, thisCellI))
{
const face& f = mesh.faces()[neighbourFaceI];
if (neighbourInfo.index() == -2)
{
// Geometric information from neighbour
index_ = -2;
}
else if (neighbourInfo.index() == -1)
{
// Cut tangential to face. Take any edge connected to face
// but not used in face.
// Get first edge on face.
label edgeI = mesh.faceEdges()[neighbourFaceI][0];
const edge& e = mesh.edges()[edgeI];
// Find face connected to face through edgeI and on same cell.
label faceI =
meshTools::otherFace
(
mesh,
thisCellI,
neighbourFaceI,
edgeI
);
// Find edge on faceI which is connected to e.start() but not edgeI.
index_ =
meshTools::otherEdge
(
mesh,
mesh.faceEdges()[faceI],
edgeI,
e.start()
);
}
else
{
// Index is a vertex on the face. Convert to mesh edge.
// Get mesh edge between f[index_] and f[index_+1]
label v0 = f[neighbourInfo.index()];
label v1 = f[(neighbourInfo.index() + 1) % f.size()];
index_ = findEdge(mesh, mesh.faceEdges()[neighbourFaceI], v0, v1);
}
}
else
{
// Not a hex so mark this as geometric.
index_ = -2;
}
n_ = neighbourInfo.n();
return true;
}
// Update this face with neighbouring cell information
bool Foam::directionInfo::updateFace
(
const polyMesh& mesh,
const label thisFaceI,
const label neighbourCellI,
const directionInfo& neighbourInfo,
const scalar // tol
)
{
// Handle special cases first
if (index_ >= -2)
{
// Already determined
return false;
}
// Handle normal cases where topological or geometrical info comes from
// neighbouring cell
if (neighbourInfo.index() >= 0)
{
// Neighbour has topological direction (and hence is hex). Find cut
// edge on face.
index_ =
edgeToFaceIndex
(
mesh,
neighbourCellI,
thisFaceI,
neighbourInfo.index()
);
}
else
{
// Neighbour has geometric information. Use.
index_ = -2;
}
n_ = neighbourInfo.n();
return true;
}
// Merge this with information on same face
bool Foam::directionInfo::updateFace
(
const polyMesh& mesh,
const label, // thisFaceI
const directionInfo& neighbourInfo,
const scalar // tol
)
{
if (index_ >= -2)
{
// Already visited.
return false;
}
else
{
index_ = neighbourInfo.index();
n_ = neighbourInfo.n();
return true;
}
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<
......
......@@ -86,12 +86,6 @@ class directionInfo
// Private Member Functions
//- edge uses two labels
static bool equal(const edge& e, const label, const label);
//- Calculate mid point of edge.
static point eMid(const primitiveMesh& mesh, const label edgeI);
//- Find edge among edgeLabels that uses v0 and v1
static label findEdge
(
......@@ -158,71 +152,90 @@ public:
//- Check whether origin has been changed at all or
// still contains original (invalid) value.
inline bool valid() const;
template<class TrackingData>
inline bool valid(TrackingData& td) const;
//- Check for identical geometrical data. Used for cyclics checking.
template<class TrackingData>
inline bool sameGeometry
(
const polyMesh&,
const directionInfo&,
const scalar
const scalar,
TrackingData& td
) const;
//- Convert any absolute coordinates into relative to (patch)face
// centre
template<class TrackingData>
inline void leaveDomain
(
const polyMesh&,
const polyPatch&,
const label patchFaceI,
const point& faceCentre
const point& faceCentre,
TrackingData& td
);
//- Reverse of leaveDomain
template<class TrackingData>
inline void enterDomain
(
const polyMesh&,
const polyPatch&,
const label patchFaceI,
const point& faceCentre
const point& faceCentre,
TrackingData& td
);
//- Apply rotation matrix to any coordinates
template<class TrackingData>
inline void transform
(
const polyMesh&,
const tensor&
const tensor&,
TrackingData& td
);
//- Influence of neighbouring face.
bool updateCell
template<class TrackingData>
inline bool updateCell
(
const polyMesh&,
const label thisCellI,
const label neighbourFaceI,
const directionInfo& neighbourInfo,
const scalar tol
const scalar tol,
TrackingData& td
);
//- Influence of neighbouring cell.
bool updateFace
template<class TrackingData>
inline bool updateFace
(
const polyMesh&,
const label thisFaceI,
const label neighbourCellI,
const directionInfo& neighbourInfo,
const scalar tol
const scalar tol,
TrackingData& td
);
//- Influence of different value on same face.
bool updateFace
template<class TrackingData>
inline bool updateFace
(
const polyMesh&,
const label thisFaceI,
const directionInfo& neighbourInfo,
const scalar tol
const scalar tol,
TrackingData& td
);
//- Same (like operator==)
template<class TrackingData>
inline bool equal(const directionInfo&, TrackingData& td) const;
// Member Operators
// Needed for List IO
......
......@@ -24,9 +24,8 @@ License
\*---------------------------------------------------------------------------*/
#include "polyMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
#include "meshTools.H"
#include "hexMatcher.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -60,18 +59,21 @@ inline Foam::directionInfo::directionInfo(const directionInfo& w2)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline bool Foam::directionInfo::valid() const
template<class TrackingData>
inline bool Foam::directionInfo::valid(TrackingData& td) const
{