ENH: topoDistanceData: templated on passive data type.

Also adds pointTopoDistance, edgeTopoDistance.
This commit is contained in:
mattijs
2020-04-24 11:49:59 +01:00
parent 9b4462e07b
commit c3571b7357
23 changed files with 871 additions and 270 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -88,12 +88,12 @@ labelList nearestPatch(const polyMesh& mesh, const labelList& patchIDs)
} }
// Field on cells and faces. // Field on cells and faces.
List<topoDistanceData> cellData(mesh.nCells()); List<topoDistanceData<label>> cellData(mesh.nCells());
List<topoDistanceData> faceData(mesh.nFaces()); List<topoDistanceData<label>> faceData(mesh.nFaces());
// Start of changes // Start of changes
labelList patchFaces(nFaces); labelList patchFaces(nFaces);
List<topoDistanceData> patchData(nFaces); List<topoDistanceData<label>> patchData(nFaces);
nFaces = 0; nFaces = 0;
for (const label patchi : patchIDs) for (const label patchi : patchIDs)
{ {
@ -102,13 +102,13 @@ labelList nearestPatch(const polyMesh& mesh, const labelList& patchIDs)
forAll(pp, i) forAll(pp, i)
{ {
patchFaces[nFaces] = pp.start()+i; patchFaces[nFaces] = pp.start()+i;
patchData[nFaces] = topoDistanceData(patchi, 0); patchData[nFaces] = topoDistanceData<label>(0, patchi);
++nFaces; ++nFaces;
} }
} }
// Propagate information inwards // Propagate information inwards
FaceCellWave<topoDistanceData> deltaCalc FaceCellWave<topoDistanceData<label>> deltaCalc
( (
mesh, mesh,
patchFaces, patchFaces,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -34,7 +34,7 @@ License
#include "syncTools.H" #include "syncTools.H"
#include "meshTools.H" #include "meshTools.H"
#include "PatchEdgeFaceWave.H" #include "PatchEdgeFaceWave.H"
#include "patchEdgeFaceRegion.H" #include "edgeTopoDistanceData.H"
#include "globalIndex.H" #include "globalIndex.H"
#include "OBJstream.H" #include "OBJstream.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
@ -511,8 +511,8 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
// Data on all edges and faces // Data on all edges and faces
List<patchEdgeFaceRegion> allEdgeInfo(patch.nEdges()); List<edgeTopoDistanceData<label>> allEdgeInfo(patch.nEdges());
List<patchEdgeFaceRegion> allFaceInfo(patch.size()); List<edgeTopoDistanceData<label>> allFaceInfo(patch.size());
bool search = true; bool search = true;
@ -528,12 +528,12 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
while (search) while (search)
{ {
DynamicList<label> changedEdges; DynamicList<label> changedEdges;
DynamicList<patchEdgeFaceRegion> changedInfo; DynamicList<edgeTopoDistanceData<label>> changedInfo;
label seedFacei = labelMax; label seedFacei = labelMax;
for (; oldFaceID < patch.size(); oldFaceID++) for (; oldFaceID < patch.size(); oldFaceID++)
{ {
if (allFaceInfo[oldFaceID].region() == -1) if (allFaceInfo[oldFaceID].data() == -1)
{ {
seedFacei = globalFaces.toGlobal(oldFaceID); seedFacei = globalFaces.toGlobal(oldFaceID);
break; break;
@ -553,7 +553,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
forAll(fEdges, i) forAll(fEdges, i)
{ {
if (allEdgeInfo[fEdges[i]].region() != -1) if (allEdgeInfo[fEdges[i]].data() != -1)
{ {
WarningInFunction WarningInFunction
<< "Problem in edge face wave: attempted to assign a " << "Problem in edge face wave: attempted to assign a "
@ -563,7 +563,14 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
} }
changedEdges.append(fEdges[i]); changedEdges.append(fEdges[i]);
changedInfo.append(regioni); changedInfo.append
(
edgeTopoDistanceData<label>
(
0, // distance
regioni
)
);
} }
} }
@ -571,7 +578,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
PatchEdgeFaceWave PatchEdgeFaceWave
< <
indirectPrimitivePatch, indirectPrimitivePatch,
patchEdgeFaceRegion edgeTopoDistanceData<label>
> calc > calc
( (
mesh_, mesh_,
@ -588,7 +595,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
label nCells = 0; label nCells = 0;
forAll(allFaceInfo, facei) forAll(allFaceInfo, facei)
{ {
if (allFaceInfo[facei].region() == regioni) if (allFaceInfo[facei].data() == regioni)
{ {
nCells++; nCells++;
} }
@ -611,7 +618,7 @@ void Foam::functionObjects::fluxSummary::initialiseCellZoneAndDirection
forAll(allFaceInfo, facei) forAll(allFaceInfo, facei)
{ {
regioni = allFaceInfo[facei].region(); regioni = allFaceInfo[facei].data();
regionFaceIDs[regioni].append(faceLocalPatchIDs[facei]); regionFaceIDs[regioni].append(faceLocalPatchIDs[facei]);
regionFacePatchIDs[regioni].append(facePatchIDs[facei]); regionFacePatchIDs[regioni].append(facePatchIDs[facei]);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -417,12 +417,12 @@ Foam::labelList Foam::meshRefinement::nearestPatch
} }
// Field on cells and faces. // Field on cells and faces.
List<topoDistanceData> cellData(mesh_.nCells()); List<topoDistanceData<label>> cellData(mesh_.nCells());
List<topoDistanceData> faceData(mesh_.nFaces()); List<topoDistanceData<label>> faceData(mesh_.nFaces());
// Start of changes // Start of changes
labelList patchFaces(nFaces); labelList patchFaces(nFaces);
List<topoDistanceData> patchData(nFaces); List<topoDistanceData<label>> patchData(nFaces);
nFaces = 0; nFaces = 0;
forAll(adaptPatchIDs, i) forAll(adaptPatchIDs, i)
{ {
@ -432,13 +432,13 @@ Foam::labelList Foam::meshRefinement::nearestPatch
forAll(pp, i) forAll(pp, i)
{ {
patchFaces[nFaces] = pp.start()+i; patchFaces[nFaces] = pp.start()+i;
patchData[nFaces] = topoDistanceData(patchi, 0); patchData[nFaces] = topoDistanceData<label>(0, patchi);
nFaces++; nFaces++;
} }
} }
// Propagate information inwards // Propagate information inwards
FaceCellWave<topoDistanceData> deltaCalc FaceCellWave<topoDistanceData<label>> deltaCalc
( (
mesh_, mesh_,
patchFaces, patchFaces,
@ -542,12 +542,12 @@ Foam::labelList Foam::meshRefinement::nearestIntersection
labelList nearestRegion(mesh_.nFaces(), defaultRegion); labelList nearestRegion(mesh_.nFaces(), defaultRegion);
// Field on cells and faces. // Field on cells and faces.
List<topoDistanceData> cellData(mesh_.nCells()); List<topoDistanceData<label>> cellData(mesh_.nCells());
List<topoDistanceData> faceData(mesh_.nFaces()); List<topoDistanceData<label>> faceData(mesh_.nFaces());
// Start walking from all intersected faces // Start walking from all intersected faces
DynamicList<label> patchFaces(start.size()); DynamicList<label> patchFaces(start.size());
DynamicList<topoDistanceData> patchData(start.size()); DynamicList<topoDistanceData<label>> patchData(start.size());
forAll(start, i) forAll(start, i)
{ {
label facei = testFaces[i]; label facei = testFaces[i];
@ -555,18 +555,18 @@ Foam::labelList Foam::meshRefinement::nearestIntersection
{ {
patchFaces.append(facei); patchFaces.append(facei);
label regioni = surfaces_.globalRegion(surface1[i], region1[i]); label regioni = surfaces_.globalRegion(surface1[i], region1[i]);
patchData.append(topoDistanceData(regioni, 0)); patchData.append(topoDistanceData<label>(0, regioni));
} }
else if (surface2[i] != -1) else if (surface2[i] != -1)
{ {
patchFaces.append(facei); patchFaces.append(facei);
label regioni = surfaces_.globalRegion(surface2[i], region2[i]); label regioni = surfaces_.globalRegion(surface2[i], region2[i]);
patchData.append(topoDistanceData(regioni, 0)); patchData.append(topoDistanceData<label>(0, regioni));
} }
} }
// Propagate information inwards // Propagate information inwards
FaceCellWave<topoDistanceData> deltaCalc FaceCellWave<topoDistanceData<label>> deltaCalc
( (
mesh_, mesh_,
patchFaces, patchFaces,

View File

@ -47,7 +47,7 @@ License
#include "OBJstream.H" #include "OBJstream.H"
#include "patchFaceOrientation.H" #include "patchFaceOrientation.H"
#include "PatchEdgeFaceWave.H" #include "PatchEdgeFaceWave.H"
#include "patchEdgeFaceRegion.H" #include "edgeTopoDistanceData.H"
#include "polyMeshAdder.H" #include "polyMeshAdder.H"
#include "IOmanip.H" #include "IOmanip.H"
#include "refinementParameters.H" #include "refinementParameters.H"
@ -3507,8 +3507,8 @@ Foam::label Foam::meshRefinement::markPatchZones
labelList& faceToZone labelList& faceToZone
) const ) const
{ {
List<patchEdgeFaceRegion> allEdgeInfo(patch.nEdges()); List<edgeTopoDistanceData<label>> allEdgeInfo(patch.nEdges());
List<patchEdgeFaceRegion> allFaceInfo(patch.size()); List<edgeTopoDistanceData<label>> allFaceInfo(patch.size());
// Protect all non-manifold edges // Protect all non-manifold edges
@ -3519,7 +3519,7 @@ Foam::label Foam::meshRefinement::markPatchZones
{ {
if (nMasterFacesPerEdge[edgeI] > 2) if (nMasterFacesPerEdge[edgeI] > 2)
{ {
allEdgeInfo[edgeI] = -2; allEdgeInfo[edgeI] = edgeTopoDistanceData<label>(0, -2);
nProtected++; nProtected++;
} }
} }
@ -3532,12 +3532,12 @@ Foam::label Foam::meshRefinement::markPatchZones
// Hand out zones // Hand out zones
DynamicList<label> changedEdges; DynamicList<label> changedEdges;
DynamicList<patchEdgeFaceRegion> changedInfo; DynamicList<edgeTopoDistanceData<label>> changedInfo;
const scalar tol = PatchEdgeFaceWave const scalar tol = PatchEdgeFaceWave
< <
indirectPrimitivePatch, indirectPrimitivePatch,
patchEdgeFaceRegion edgeTopoDistanceData<label>
>::propagationTol(); >::propagationTol();
int dummyTrackData; int dummyTrackData;
@ -3577,11 +3577,11 @@ Foam::label Foam::meshRefinement::markPatchZones
if (procI == Pstream::myProcNo()) if (procI == Pstream::myProcNo())
{ {
patchEdgeFaceRegion& faceInfo = allFaceInfo[seedFaceI]; edgeTopoDistanceData<label>& faceInfo = allFaceInfo[seedFaceI];
// Set face // Set face
faceInfo = currentZoneI; faceInfo = edgeTopoDistanceData<label>(0, currentZoneI);
// .. and seed its edges // .. and seed its edges
const labelList& fEdges = patch.faceEdges()[seedFaceI]; const labelList& fEdges = patch.faceEdges()[seedFaceI];
@ -3589,7 +3589,7 @@ Foam::label Foam::meshRefinement::markPatchZones
{ {
label edgeI = fEdges[fEdgeI]; label edgeI = fEdges[fEdgeI];
patchEdgeFaceRegion& edgeInfo = allEdgeInfo[edgeI]; edgeTopoDistanceData<label>& edgeInfo = allEdgeInfo[edgeI];
if if
( (
@ -3622,7 +3622,7 @@ Foam::label Foam::meshRefinement::markPatchZones
PatchEdgeFaceWave PatchEdgeFaceWave
< <
indirectPrimitivePatch, indirectPrimitivePatch,
patchEdgeFaceRegion edgeTopoDistanceData<label>
> calc > calc
( (
mesh_, mesh_,
@ -3648,7 +3648,7 @@ Foam::label Foam::meshRefinement::markPatchZones
<< " at " << patch.faceCentres()[faceI] << " at " << patch.faceCentres()[faceI]
<< exit(FatalError); << exit(FatalError);
} }
faceToZone[faceI] = allFaceInfo[faceI].region(); faceToZone[faceI] = allFaceInfo[faceI].data();
} }
return currentZoneI; return currentZoneI;

View File

@ -94,7 +94,6 @@ patchWave = $(algorithms)/PatchEdgeFaceWave
$(patchWave)/PatchEdgeFaceWaveName.C $(patchWave)/PatchEdgeFaceWaveName.C
$(patchWave)/patchEdgeFaceInfo.C $(patchWave)/patchEdgeFaceInfo.C
$(patchWave)/patchPatchDist.C $(patchWave)/patchPatchDist.C
$(patchWave)/patchEdgeFaceRegion.C
$(patchWave)/patchEdgeFaceRegions.C $(patchWave)/patchEdgeFaceRegions.C
@ -297,8 +296,6 @@ PatchFunction1/makePatchFunction1s.C
PatchFunction1/coordinateLabelScaling.C PatchFunction1/coordinateLabelScaling.C
meshStructure/meshStructure.C meshStructure/meshStructure.C
meshStructure/topoDistanceData.C
meshStructure/pointTopoDistanceData.C
output/foamVtkIndPatchWriter.C output/foamVtkIndPatchWriter.C
output/foamVtkWriteTopoSet.C output/foamVtkWriteTopoSet.C

View File

@ -0,0 +1,52 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
template<class Type, class PrimitivePatchType>
Foam::Ostream& Foam::operator<<
(
Foam::Ostream& os,
const Foam::edgeTopoDistanceData<Type, PrimitivePatchType>& wDist
)
{
return os << wDist.distance_ << token::SPACE << wDist.data_;
}
template<class Type, class PrimitivePatchType>
Foam::Istream& Foam::operator>>
(
Foam::Istream& is,
Foam::edgeTopoDistanceData<Type, PrimitivePatchType>& wDist
)
{
return is >> wDist.distance_ >> wDist.data_;
}
// ************************************************************************* //

View File

@ -0,0 +1,253 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2019,2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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::edgeTopoDistanceData
Description
For use with PatchEdgeFaceWave. Determines topological distance to
starting edges. Templated on passive transported data.
SourceFiles
edgeTopoDistanceDataI.H
edgeTopoDistanceData.C
\*---------------------------------------------------------------------------*/
#ifndef edgeTopoDistanceData_H
#define edgeTopoDistanceData_H
#include "point.H"
#include "tensor.H"
#include "indirectPrimitivePatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward Declarations
class polyPatch;
class polyMesh;
template<class Type, class PrimitivePatchType>
class edgeTopoDistanceData;
template<class Type, class PrimitivePatchType>
Istream& operator>>
(
Istream&,
edgeTopoDistanceData<Type, PrimitivePatchType>&
);
template<class Type, class PrimitivePatchType>
Ostream& operator<<
(
Ostream&,
const edgeTopoDistanceData<Type, PrimitivePatchType>&
);
/*---------------------------------------------------------------------------*\
Class edgeTopoDistanceData Declaration
\*---------------------------------------------------------------------------*/
template<class Type, class PrimitivePatchType = indirectPrimitivePatch>
class edgeTopoDistanceData
{
protected:
// Protected data
//- Distance
label distance_;
//- Starting data
Type data_;
public:
typedef Type dataType;
// Constructors
//- Construct null with invalid (-1) for distance, null constructor
// for data
inline edgeTopoDistanceData();
//- Construct from distance, data
inline edgeTopoDistanceData
(
const label distance,
const Type& data
);
// Member Functions
// Access
inline label distance() const
{
return distance_;
}
inline const Type& data() const
{
return data_;
}
// Needed by PatchEdgeFaceWave
//- Check whether origin has been changed at all or
// still contains original (invalid) value.
template<class TrackingData>
inline bool valid(TrackingData& td) const;
//- Apply rotation matrix
template<class TrackingData>
inline void transform
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const tensor& rotTensor,
const scalar tol,
TrackingData& td
);
//- Influence of face on edge
template<class TrackingData>
inline bool updateEdge
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const label edgeI,
const label facei,
const edgeTopoDistanceData<Type, PrimitivePatchType>& faceInfo,
const scalar tol,
TrackingData& td
);
//- New information for edge (from e.g. coupled edge)
template<class TrackingData>
inline bool updateEdge
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const edgeTopoDistanceData<Type, PrimitivePatchType>& edgeInfo,
const bool sameOrientation,
const scalar tol,
TrackingData& td
);
//- Influence of edge on face.
template<class TrackingData>
inline bool updateFace
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const label facei,
const label edgeI,
const edgeTopoDistanceData<Type, PrimitivePatchType>& edgeInfo,
const scalar tol,
TrackingData& td
);
//- Same (like operator==)
template<class TrackingData>
inline bool equal
(
const edgeTopoDistanceData<Type, PrimitivePatchType>&,
TrackingData&
) const;
// Member Operators
// Needed for List IO
inline bool operator==
(
const edgeTopoDistanceData<Type, PrimitivePatchType>&
) const;
inline bool operator!=
(
const edgeTopoDistanceData<Type, PrimitivePatchType>&
) const;
// IOstream Operators
friend Ostream& operator<< <Type, PrimitivePatchType>
(
Ostream&,
const edgeTopoDistanceData<Type, PrimitivePatchType>&
);
friend Istream& operator>> <Type, PrimitivePatchType>
(
Istream&,
edgeTopoDistanceData<Type, PrimitivePatchType>&
);
};
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
//- Data are contiguous if data type is contiguous
template<class Type, class PrimitivePatchType>
struct is_contiguous<edgeTopoDistanceData<Type, PrimitivePatchType>> :
is_contiguous<Type> {};
//- Data are contiguous label if data type is label
template<class Type, class PrimitivePatchType>
struct is_contiguous_label<edgeTopoDistanceData<Type, PrimitivePatchType>> :
is_contiguous_label<Type> {};
//- Data are contiguous scalar if data type is scalar
template<class Type, class PrimitivePatchType>
struct is_contiguous_scalar<edgeTopoDistanceData<Type, PrimitivePatchType>> :
is_contiguous_scalar<Type>{};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "edgeTopoDistanceData.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "edgeTopoDistanceDataI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,188 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "polyMesh.H"
#include "transform.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type, class PrimitivePatchType>
inline
Foam::edgeTopoDistanceData<Type, PrimitivePatchType>::edgeTopoDistanceData()
:
distance_(-1),
data_()
{}
template<class Type, class PrimitivePatchType>
inline
Foam::edgeTopoDistanceData<Type, PrimitivePatchType>::edgeTopoDistanceData
(
const label distance,
const Type& data
)
:
distance_(distance),
data_(data)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type, class PrimitivePatchType>
template<class TrackingData>
inline bool Foam::edgeTopoDistanceData<Type, PrimitivePatchType>::valid
(
TrackingData& td
) const
{
return distance_ != -1;
}
template<class Type, class PrimitivePatchType>
template<class TrackingData>
inline void Foam::edgeTopoDistanceData<Type, PrimitivePatchType>::transform
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const tensor& rotTensor,
const scalar tol,
TrackingData& td
)
{}
template<class Type, class PrimitivePatchType>
template<class TrackingData>
inline bool Foam::edgeTopoDistanceData<Type, PrimitivePatchType>::updateEdge
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const label edgeI,
const label facei,
const edgeTopoDistanceData<Type, PrimitivePatchType>& faceInfo,
const scalar tol,
TrackingData& td
)
{
// From face to edge
if (distance_ == -1)
{
data_ = faceInfo.data_;
distance_ = faceInfo.distance_ + 1;
return true;
}
return false;
}
template<class Type, class PrimitivePatchType>
template<class TrackingData>
inline bool Foam::edgeTopoDistanceData<Type, PrimitivePatchType>::updateEdge
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const edgeTopoDistanceData<Type, PrimitivePatchType>& edgeInfo,
const bool sameOrientation,
const scalar tol,
TrackingData& td
)
{
// From edge to edge (e.g. coupled edges)
if (distance_ == -1)
{
this->operator=(edgeInfo);
return true;
}
return false;
}
template<class Type, class PrimitivePatchType>
template<class TrackingData>
inline bool Foam::edgeTopoDistanceData<Type, PrimitivePatchType>::updateFace
(
const polyMesh& mesh,
const PrimitivePatchType& patch,
const label facei,
const label edgeI,
const edgeTopoDistanceData<Type, PrimitivePatchType>& edgeInfo,
const scalar tol,
TrackingData& td
)
{
// From edge to face
if (distance_ == -1)
{
this->operator=(edgeInfo);
return true;
}
return false;
}
template<class Type, class PrimitivePatchType>
template<class TrackingData>
inline bool Foam::edgeTopoDistanceData<Type, PrimitivePatchType>::equal
(
const edgeTopoDistanceData<Type, PrimitivePatchType>& rhs,
TrackingData& td
) const
{
return operator==(rhs);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type, class PrimitivePatchType>
inline bool Foam::edgeTopoDistanceData<Type, PrimitivePatchType>::operator==
(
const Foam::edgeTopoDistanceData<Type, PrimitivePatchType>& rhs
) const
{
return distance() == rhs.distance() && data() == rhs.data();
}
template<class Type, class PrimitivePatchType>
inline bool Foam::edgeTopoDistanceData<Type, PrimitivePatchType>::operator!=
(
const Foam::edgeTopoDistanceData<Type, PrimitivePatchType>& rhs
) const
{
return !(*this == rhs);
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2013-2016 OpenFOAM Foundation Copyright (C) 2013-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -110,8 +110,8 @@ void Foam::meshStructure::correct
) )
{ {
// Field on cells and faces. // Field on cells and faces.
List<topoDistanceData> cellData(mesh.nCells()); List<topoDistanceData<label>> cellData(mesh.nCells());
List<topoDistanceData> faceData(mesh.nFaces()); List<topoDistanceData<label>> faceData(mesh.nFaces());
{ {
if (debug) if (debug)
@ -124,20 +124,20 @@ void Foam::meshStructure::correct
// Start of changes // Start of changes
labelList patchFaces(pp.size()); labelList patchFaces(pp.size());
List<topoDistanceData> patchData(pp.size()); List<topoDistanceData<label>> patchData(pp.size());
forAll(pp, patchFacei) forAll(pp, patchFacei)
{ {
patchFaces[patchFacei] = pp.addressing()[patchFacei]; patchFaces[patchFacei] = pp.addressing()[patchFacei];
patchData[patchFacei] = topoDistanceData patchData[patchFacei] = topoDistanceData<label>
( (
globalFaces.toGlobal(patchFacei), 0, // distance
0 globalFaces.toGlobal(patchFacei) // passive data
); );
} }
// Propagate information inwards // Propagate information inwards
FaceCellWave<topoDistanceData> distanceCalc FaceCellWave<topoDistanceData<label>> distanceCalc
( (
mesh, mesh,
patchFaces, patchFaces,
@ -232,25 +232,25 @@ void Foam::meshStructure::correct
} }
// Field on edges and points. // Field on edges and points.
List<pointTopoDistanceData> edgeData(mesh.nEdges()); List<pointTopoDistanceData<label>> edgeData(mesh.nEdges());
List<pointTopoDistanceData> pointData(mesh.nPoints()); List<pointTopoDistanceData<label>> pointData(mesh.nPoints());
// Start of changes // Start of changes
labelList patchPoints(pp.nPoints()); labelList patchPoints(pp.nPoints());
List<pointTopoDistanceData> patchData(pp.nPoints()); List<pointTopoDistanceData<label>> patchData(pp.nPoints());
forAll(pp.meshPoints(), patchPointi) forAll(pp.meshPoints(), patchPointi)
{ {
patchPoints[patchPointi] = pp.meshPoints()[patchPointi]; patchPoints[patchPointi] = pp.meshPoints()[patchPointi];
patchData[patchPointi] = pointTopoDistanceData patchData[patchPointi] = pointTopoDistanceData<label>
( (
globalPoints.toGlobal(patchPointi), 0, // distance
0 globalPoints.toGlobal(patchPointi) // passive data
); );
} }
// Walk // Walk
PointEdgeWave<pointTopoDistanceData> distanceCalc PointEdgeWave<pointTopoDistanceData<label>> distanceCalc
( (
mesh, mesh,
patchPoints, patchPoints,
@ -308,7 +308,8 @@ void Foam::meshStructure::correct
// << " at:" << mesh.faceCentres()[facei] // << " at:" << mesh.faceCentres()[facei]
// << " data:" << faceData[facei] // << " data:" << faceData[facei]
// << " pointDatas:" // << " pointDatas:"
// << UIndirectList<pointTopoDistanceData>(pointData, f) // << UIndirectList<pointTopoDistanceData<label>>
// (pointData, f)
// << endl; // << endl;
label patchFacei = faceData[facei].data(); label patchFacei = faceData[facei].data();

View File

@ -26,27 +26,27 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "pointTopoDistanceData.H" // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::operator<< Foam::Ostream& Foam::operator<<
( (
Ostream& os, Foam::Ostream& os,
const pointTopoDistanceData& rhs const Foam::pointTopoDistanceData<Type>& wDist
) )
{ {
return os << rhs.data_ << token::SPACE << rhs.distance_; return os << wDist.distance_ << token::SPACE << wDist.data_;
} }
template<class Type>
Foam::Istream& Foam::operator>> Foam::Istream& Foam::operator>>
( (
Istream& is, Foam::Istream& is,
pointTopoDistanceData& rhs Foam::pointTopoDistanceData<Type>& wDist
) )
{ {
return is >> rhs.data_ >> rhs.distance_; return is >> wDist.distance_ >> wDist.data_;
} }

View File

@ -29,7 +29,7 @@ Class
Description Description
For use with PointEdgeWave. Determines topological distance to For use with PointEdgeWave. Determines topological distance to
starting points starting points. Templated on passive transported data.
SourceFiles SourceFiles
pointTopoDistanceDataI.H pointTopoDistanceDataI.H
@ -51,38 +51,45 @@ namespace Foam
// Forward Declarations // Forward Declarations
class polyPatch; class polyPatch;
class polyMesh; class polyMesh;
class pointTopoDistanceData; template<class Type> class pointTopoDistanceData;
template<class Type>
Istream& operator>>(Istream&, pointTopoDistanceData&); Istream& operator>>(Istream&, pointTopoDistanceData<Type>&);
Ostream& operator<<(Ostream&, const pointTopoDistanceData&); template<class Type>
Ostream& operator<<(Ostream&, const pointTopoDistanceData<Type>&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class pointTopoDistanceData Declaration Class pointTopoDistanceData Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Type>
class pointTopoDistanceData class pointTopoDistanceData
{ {
// Private Data
//- Starting data // Protected data
label data_;
//- Distance //- Distance
label distance_; label distance_;
//- Starting data
Type data_;
public: public:
typedef Type dataType;
// Constructors // Constructors
//- Default construct, with invalid (-1) for data and distance //- Construct null with invalid (-1) for distance, null constructor
// for data
inline pointTopoDistanceData(); inline pointTopoDistanceData();
//- Construct from components //- Construct from components
inline pointTopoDistanceData inline pointTopoDistanceData
( (
const label data, const label distance,
const label distance const Type& data
); );
@ -90,16 +97,16 @@ public:
// Access // Access
label data() const inline label distance() const
{
return data_;
}
label distance() const
{ {
return distance_; return distance_;
} }
inline const Type& data() const
{
return data_;
}
// Needed by PointEdgeWave // Needed by PointEdgeWave
@ -111,7 +118,7 @@ public:
template<class TrackingData> template<class TrackingData>
inline bool sameGeometry inline bool sameGeometry
( (
const pointTopoDistanceData&, const pointTopoDistanceData<Type>&,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
) const; ) const;
@ -152,7 +159,7 @@ public:
const polyMesh& mesh, const polyMesh& mesh,
const label pointi, const label pointi,
const label edgeI, const label edgeI,
const pointTopoDistanceData& edgeInfo, const pointTopoDistanceData<Type>& edgeInfo,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
); );
@ -164,7 +171,7 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointi, const label pointi,
const pointTopoDistanceData& newPointInfo, const pointTopoDistanceData<Type>& newPointInfo,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
); );
@ -174,7 +181,7 @@ public:
template<class TrackingData> template<class TrackingData>
inline bool updatePoint inline bool updatePoint
( (
const pointTopoDistanceData& newPointInfo, const pointTopoDistanceData<Type>& newPointInfo,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
); );
@ -186,44 +193,54 @@ public:
const polyMesh& mesh, const polyMesh& mesh,
const label edgeI, const label edgeI,
const label pointi, const label pointi,
const pointTopoDistanceData& pointInfo, const pointTopoDistanceData<Type>& pointInfo,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
); );
//- Test for equality, with TrackingData //- Test for equality, with TrackingData
template<class TrackingData> template<class TrackingData>
inline bool equal(const pointTopoDistanceData&, TrackingData&) inline bool equal(const pointTopoDistanceData<Type>&, TrackingData&)
const; const;
// Member Operators // Member Operators
//- Test for equality // Needed for List IO
inline bool operator==(const pointTopoDistanceData&) const; inline bool operator==(const pointTopoDistanceData<Type>&) const;
inline bool operator!=(const pointTopoDistanceData<Type>&) const;
//- Test for inequality
inline bool operator!=(const pointTopoDistanceData&) const;
// IOstream Operators // IOstream Operators
friend Ostream& operator<<(Ostream&, const pointTopoDistanceData&); friend Ostream& operator<< <Type>
friend Istream& operator>>(Istream&, pointTopoDistanceData&); (
Ostream&,
const pointTopoDistanceData<Type>&
);
friend Istream& operator>> <Type>
(
Istream&,
pointTopoDistanceData<Type>&
);
}; };
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
//- Contiguous data for pointTopoDistanceData //- Data are contiguous if data type is contiguous
template<> struct is_contiguous<pointTopoDistanceData> : std::true_type {}; template<class Type>
struct is_contiguous<pointTopoDistanceData<Type>> : is_contiguous<Type> {};
//- Contiguous label data for pointTopoDistanceData //- Data are contiguous label if data type is label
template<> struct is_contiguous_label<pointTopoDistanceData> template<class Type>
: struct is_contiguous_label<pointTopoDistanceData<Type>> :
std::true_type is_contiguous_label<Type> {};
{};
//- Data are contiguous scalar if data type is scalar
template<class Type>
struct is_contiguous_scalar<pointTopoDistanceData<Type>> :
is_contiguous_scalar<Type>{};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -231,6 +248,12 @@ template<> struct is_contiguous_label<pointTopoDistanceData>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "pointTopoDistanceData.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pointTopoDistanceDataI.H" #include "pointTopoDistanceDataI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -30,38 +30,42 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::pointTopoDistanceData::pointTopoDistanceData() template<class Type>
inline Foam::pointTopoDistanceData<Type>::pointTopoDistanceData()
: :
data_(-1), distance_(-1),
distance_(-1) data_()
{} {}
inline Foam::pointTopoDistanceData::pointTopoDistanceData template<class Type>
inline Foam::pointTopoDistanceData<Type>::pointTopoDistanceData
( (
const label data, const label distance,
const label distance const Type& data
) )
: :
data_(data), distance_(distance),
distance_(distance) data_(data)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::pointTopoDistanceData::valid(TrackingData& td) const inline bool Foam::pointTopoDistanceData<Type>::valid(TrackingData& td) const
{ {
return distance_ != -1; return distance_ != -1;
} }
// No geometric data so never any problem on cyclics // No geometric data so never any problem on cyclics
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::pointTopoDistanceData::sameGeometry inline bool Foam::pointTopoDistanceData<Type>::sameGeometry
( (
const pointTopoDistanceData&, const pointTopoDistanceData<Type>&,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
) const ) const
@ -71,8 +75,9 @@ inline bool Foam::pointTopoDistanceData::sameGeometry
// No geometric data. // No geometric data.
template<class Type>
template<class TrackingData> template<class TrackingData>
inline void Foam::pointTopoDistanceData::leaveDomain inline void Foam::pointTopoDistanceData<Type>::leaveDomain
( (
const polyPatch& patch, const polyPatch& patch,
const label patchPointi, const label patchPointi,
@ -83,8 +88,9 @@ inline void Foam::pointTopoDistanceData::leaveDomain
// No geometric data. // No geometric data.
template<class Type>
template<class TrackingData> template<class TrackingData>
inline void Foam::pointTopoDistanceData::transform inline void Foam::pointTopoDistanceData<Type>::transform
( (
const tensor& rotTensor, const tensor& rotTensor,
TrackingData& td TrackingData& td
@ -93,8 +99,9 @@ inline void Foam::pointTopoDistanceData::transform
// No geometric data. // No geometric data.
template<class Type>
template<class TrackingData> template<class TrackingData>
inline void Foam::pointTopoDistanceData::enterDomain inline void Foam::pointTopoDistanceData<Type>::enterDomain
( (
const polyPatch& patch, const polyPatch& patch,
const label patchPointi, const label patchPointi,
@ -105,21 +112,22 @@ inline void Foam::pointTopoDistanceData::enterDomain
// Update this with information from connected edge // Update this with information from connected edge
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::pointTopoDistanceData::updatePoint inline bool Foam::pointTopoDistanceData<Type>::updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointi, const label pointi,
const label edgeI, const label edgeI,
const pointTopoDistanceData& edgeInfo, const pointTopoDistanceData<Type>& edgeInfo,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
) )
{ {
if (distance_ == -1) if (distance_ == -1)
{ {
data_ = edgeInfo.data_;
distance_ = edgeInfo.distance_ + 1; distance_ = edgeInfo.distance_ + 1;
data_ = edgeInfo.data_;
return true; return true;
} }
@ -128,19 +136,21 @@ inline bool Foam::pointTopoDistanceData::updatePoint
// Update this with new information on same point // Update this with new information on same point
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::pointTopoDistanceData::updatePoint inline bool Foam::pointTopoDistanceData<Type>::updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointi, const label pointi,
const pointTopoDistanceData& newPointInfo, const pointTopoDistanceData<Type>& newPointInfo,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
) )
{ {
if (distance_ == -1) if (distance_ == -1)
{ {
operator=(newPointInfo); distance_ = newPointInfo.distance_;
data_ = newPointInfo.data_;
return true; return true;
} }
@ -149,17 +159,19 @@ inline bool Foam::pointTopoDistanceData::updatePoint
// Update this with new information on same point. No extra information. // Update this with new information on same point. No extra information.
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::pointTopoDistanceData::updatePoint inline bool Foam::pointTopoDistanceData<Type>::updatePoint
( (
const pointTopoDistanceData& newPointInfo, const pointTopoDistanceData<Type>& newPointInfo,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
) )
{ {
if (distance_ == -1) if (distance_ == -1)
{ {
operator=(newPointInfo); distance_ = newPointInfo.distance_;
data_ = newPointInfo.data_;
return true; return true;
} }
@ -168,20 +180,22 @@ inline bool Foam::pointTopoDistanceData::updatePoint
// Update this with information from connected point // Update this with information from connected point
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::pointTopoDistanceData::updateEdge inline bool Foam::pointTopoDistanceData<Type>::updateEdge
( (
const polyMesh& mesh, const polyMesh& mesh,
const label edgeI, const label edgeI,
const label pointi, const label pointi,
const pointTopoDistanceData& pointInfo, const pointTopoDistanceData<Type>& pointInfo,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
) )
{ {
if (distance_ == -1) if (distance_ == -1)
{ {
operator=(pointInfo); distance_ = pointInfo.distance_;
data_ = pointInfo.data_;
return true; return true;
} }
@ -189,10 +203,11 @@ inline bool Foam::pointTopoDistanceData::updateEdge
} }
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::pointTopoDistanceData::equal inline bool Foam::pointTopoDistanceData<Type>::equal
( (
const pointTopoDistanceData& rhs, const pointTopoDistanceData<Type>& rhs,
TrackingData& td TrackingData& td
) const ) const
{ {
@ -202,18 +217,20 @@ inline bool Foam::pointTopoDistanceData::equal
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::pointTopoDistanceData::operator== template<class Type>
inline bool Foam::pointTopoDistanceData<Type>::operator==
( (
const pointTopoDistanceData& rhs const Foam::pointTopoDistanceData<Type>& rhs
) const ) const
{ {
return data_ == rhs.data_ && distance_ == rhs.distance_; return distance() == rhs.distance() && data() == rhs.data();
} }
inline bool Foam::pointTopoDistanceData::operator!= template<class Type>
inline bool Foam::pointTopoDistanceData<Type>::operator!=
( (
const pointTopoDistanceData& rhs const Foam::pointTopoDistanceData<Type>& rhs
) const ) const
{ {
return !(*this == rhs); return !(*this == rhs);

View File

@ -30,23 +30,25 @@ License
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::operator<< Foam::Ostream& Foam::operator<<
( (
Ostream& os, Foam::Ostream& os,
const topoDistanceData& rhs const Foam::topoDistanceData<Type>& wDist
) )
{ {
return os << rhs.data_ << token::SPACE << rhs.distance_; return os << wDist.distance_ << token::SPACE << wDist.data_;
} }
template<class Type>
Foam::Istream& Foam::operator>> Foam::Istream& Foam::operator>>
( (
Istream& is, Foam::Istream& is,
topoDistanceData& rhs Foam::topoDistanceData<Type>& wDist
) )
{ {
return is >> rhs.data_ >> rhs.distance_; return is >> wDist.distance_ >> wDist.data_;
} }

View File

@ -28,7 +28,8 @@ Class
Foam::topoDistanceData Foam::topoDistanceData
Description Description
For use with FaceCellWave. Determines topological distance to starting faces For use with FaceCellWave. Determines topological distance to starting
faces. Templated on passive transported data.
SourceFiles SourceFiles
topoDistanceDataI.H topoDistanceDataI.H
@ -50,38 +51,42 @@ namespace Foam
// Forward Declarations // Forward Declarations
class polyPatch; class polyPatch;
class polyMesh; class polyMesh;
class topoDistanceData; template<class Type> class topoDistanceData;
Istream& operator>>(Istream&, topoDistanceData&); template<class Type>
Ostream& operator<<(Ostream&, const topoDistanceData&); Istream& operator>>(Istream&, topoDistanceData<Type>&);
template<class Type>
Ostream& operator<<(Ostream&, const topoDistanceData<Type>&);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class topoDistanceData Declaration Class topoDistanceData Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Type>
class topoDistanceData class topoDistanceData
{ {
// Private Data // Private Data
//- Starting data
label data_;
//- Distance //- Distance
label distance_; label distance_;
//- Starting data
Type data_;
public: public:
// Constructors // Constructors
//- Default construct, with invalid (-1) for data and distance //- Construct null with invalid (-1) for distance, null constructor
// for data
inline topoDistanceData(); inline topoDistanceData();
//- Construct from components //- Construct from components
inline topoDistanceData inline topoDistanceData
( (
const label data, const label distance,
const label distance const Type& data
); );
@ -89,16 +94,16 @@ public:
// Access // Access
label data() const inline label distance() const
{
return data_;
}
label distance() const
{ {
return distance_; return distance_;
} }
inline const Type& data() const
{
return data_;
}
// Needed by FaceCellWave // Needed by FaceCellWave
@ -111,7 +116,7 @@ public:
inline bool sameGeometry inline bool sameGeometry
( (
const polyMesh&, const polyMesh&,
const topoDistanceData&, const topoDistanceData<Type>&,
const scalar, const scalar,
TrackingData& td TrackingData& td
) const; ) const;
@ -155,7 +160,7 @@ public:
const polyMesh&, const polyMesh&,
const label thisCelli, const label thisCelli,
const label neighbourFacei, const label neighbourFacei,
const topoDistanceData& neighbourInfo, const topoDistanceData<Type>& neighbourInfo,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
); );
@ -167,7 +172,7 @@ public:
const polyMesh&, const polyMesh&,
const label thisFacei, const label thisFacei,
const label neighbourCelli, const label neighbourCelli,
const topoDistanceData& neighbourInfo, const topoDistanceData<Type>& neighbourInfo,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
); );
@ -178,40 +183,58 @@ public:
( (
const polyMesh&, const polyMesh&,
const label thisFacei, const label thisFacei,
const topoDistanceData& neighbourInfo, const topoDistanceData<Type>& neighbourInfo,
const scalar tol, const scalar tol,
TrackingData& td TrackingData& td
); );
//- Test for equality, with TrackingData //- Test for equality, with TrackingData
template<class TrackingData> template<class TrackingData>
inline bool equal(const topoDistanceData&, TrackingData& td) const; inline bool equal
(
const topoDistanceData<Type>&,
TrackingData& td
) const;
// Member Operators // Member Operators
//- Test for equality // Needed for List IO
inline bool operator==(const topoDistanceData&) const; inline bool operator==(const topoDistanceData<Type>&) const;
//- Test for inequality inline bool operator!=(const topoDistanceData<Type>&) const;
inline bool operator!=(const topoDistanceData&) const;
// IOstream Operators // IOstream Operators
friend Ostream& operator<<(Ostream&, const topoDistanceData&); friend Ostream& operator<< <Type>
friend Istream& operator>>(Istream&, topoDistanceData&); (
Ostream&,
const topoDistanceData<Type>&
);
friend Istream& operator>> <Type>
(
Istream&,
topoDistanceData<Type>&
);
}; };
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
//- Contiguous data for topoDistanceData //- Data are contiguous if data type is contiguous
template<> struct is_contiguous<topoDistanceData> : std::true_type {}; template<class Type>
struct is_contiguous<topoDistanceData<Type>> : is_contiguous<Type> {};
//- Contiguous label data for topoDistanceData //- Data are contiguous label if data type is label
template<> struct is_contiguous_label<topoDistanceData> : std::true_type {}; template<class Type>
struct is_contiguous_label<topoDistanceData<Type>> :
is_contiguous_label<Type> {};
//- Data are contiguous scalar if data type is scalar
template<class Type>
struct is_contiguous_scalar<topoDistanceData<Type>> :
is_contiguous_scalar<Type>{};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -219,6 +242,12 @@ template<> struct is_contiguous_label<topoDistanceData> : std::true_type {};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "topoDistanceData.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "topoDistanceDataI.H" #include "topoDistanceDataI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -30,39 +30,43 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::topoDistanceData::topoDistanceData() template<class Type>
inline Foam::topoDistanceData<Type>::topoDistanceData()
: :
data_(-1), distance_(-1),
distance_(-1) data_()
{} {}
inline Foam::topoDistanceData::topoDistanceData template<class Type>
inline Foam::topoDistanceData<Type>::topoDistanceData
( (
const label data, const label distance,
const label distance const Type& data
) )
: :
data_(data), distance_(distance),
distance_(distance) data_(data)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::topoDistanceData::valid(TrackingData& td) const inline bool Foam::topoDistanceData<Type>::valid(TrackingData& td) const
{ {
return distance_ != -1; return distance_ != -1;
} }
// No geometric data so never any problem on cyclics // No geometric data so never any problem on cyclics
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::topoDistanceData::sameGeometry inline bool Foam::topoDistanceData<Type>::sameGeometry
( (
const polyMesh&, const polyMesh&,
const topoDistanceData&, const topoDistanceData<Type>&,
const scalar, const scalar,
TrackingData& TrackingData&
) const ) const
@ -72,8 +76,9 @@ inline bool Foam::topoDistanceData::sameGeometry
// No geometric data. // No geometric data.
template<class Type>
template<class TrackingData> template<class TrackingData>
inline void Foam::topoDistanceData::leaveDomain inline void Foam::topoDistanceData<Type>::leaveDomain
( (
const polyMesh&, const polyMesh&,
const polyPatch& patch, const polyPatch& patch,
@ -85,8 +90,9 @@ inline void Foam::topoDistanceData::leaveDomain
// No geometric data. // No geometric data.
template<class Type>
template<class TrackingData> template<class TrackingData>
inline void Foam::topoDistanceData::transform inline void Foam::topoDistanceData<Type>::transform
( (
const polyMesh&, const polyMesh&,
const tensor& rotTensor, const tensor& rotTensor,
@ -96,8 +102,9 @@ inline void Foam::topoDistanceData::transform
// No geometric data. // No geometric data.
template<class Type>
template<class TrackingData> template<class TrackingData>
inline void Foam::topoDistanceData::enterDomain inline void Foam::topoDistanceData<Type>::enterDomain
( (
const polyMesh&, const polyMesh&,
const polyPatch& patch, const polyPatch& patch,
@ -109,20 +116,21 @@ inline void Foam::topoDistanceData::enterDomain
// Update cell with neighbouring face information // Update cell with neighbouring face information
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::topoDistanceData::updateCell inline bool Foam::topoDistanceData<Type>::updateCell
( (
const polyMesh&, const polyMesh&,
const label thisCelli, const label thisCelli,
const label neighbourFacei, const label neighbourFacei,
const topoDistanceData& neighbourInfo, const topoDistanceData<Type>& neighbourInfo,
const scalar tol, const scalar tol,
TrackingData& TrackingData&
) )
{ {
if (distance_ == -1) if (distance_ == -1)
{ {
operator=(neighbourInfo); this->operator=(neighbourInfo);
return true; return true;
} }
@ -131,13 +139,14 @@ inline bool Foam::topoDistanceData::updateCell
// Update face with neighbouring cell information // Update face with neighbouring cell information
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::topoDistanceData::updateFace inline bool Foam::topoDistanceData<Type>::updateFace
( (
const polyMesh& mesh, const polyMesh& mesh,
const label thisFacei, const label thisFacei,
const label neighbourCelli, const label neighbourCelli,
const topoDistanceData& neighbourInfo, const topoDistanceData<Type>& neighbourInfo,
const scalar tol, const scalar tol,
TrackingData& TrackingData&
) )
@ -146,8 +155,8 @@ inline bool Foam::topoDistanceData::updateFace
if (distance_ == -1) if (distance_ == -1)
{ {
data_ = neighbourInfo.data_;
distance_ = neighbourInfo.distance_ + 1; distance_ = neighbourInfo.distance_ + 1;
data_ = neighbourInfo.data_;
return true; return true;
} }
@ -156,12 +165,13 @@ inline bool Foam::topoDistanceData::updateFace
// Update face with coupled face information // Update face with coupled face information
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::topoDistanceData::updateFace inline bool Foam::topoDistanceData<Type>::updateFace
( (
const polyMesh&, const polyMesh&,
const label thisFacei, const label thisFacei,
const topoDistanceData& neighbourInfo, const topoDistanceData<Type>& neighbourInfo,
const scalar tol, const scalar tol,
TrackingData& TrackingData&
) )
@ -169,7 +179,7 @@ inline bool Foam::topoDistanceData::updateFace
// From face to face (e.g. coupled faces) // From face to face (e.g. coupled faces)
if (distance_ == -1) if (distance_ == -1)
{ {
operator=(neighbourInfo); this->operator=(neighbourInfo);
return true; return true;
} }
@ -177,10 +187,11 @@ inline bool Foam::topoDistanceData::updateFace
} }
template<class Type>
template<class TrackingData> template<class TrackingData>
inline bool Foam::topoDistanceData::equal inline bool Foam::topoDistanceData<Type>::equal
( (
const topoDistanceData& rhs, const topoDistanceData<Type>& rhs,
TrackingData& td TrackingData& td
) const ) const
{ {
@ -190,18 +201,20 @@ inline bool Foam::topoDistanceData::equal
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::topoDistanceData::operator== template<class Type>
inline bool Foam::topoDistanceData<Type>::operator==
( (
const topoDistanceData& rhs const Foam::topoDistanceData<Type>& rhs
) const ) const
{ {
return data_ == rhs.data_ && distance_ == rhs.distance_; return distance() == rhs.distance() && data() == rhs.data();
} }
inline bool Foam::topoDistanceData::operator!= template<class Type>
inline bool Foam::topoDistanceData<Type>::operator!=
( (
const topoDistanceData& rhs const Foam::topoDistanceData<Type>& rhs
) const ) const
{ {
return !(*this == rhs); return !(*this == rhs);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,7 +28,7 @@ License
#include "regionSplit2D.H" #include "regionSplit2D.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "PatchEdgeFaceWave.H" #include "PatchEdgeFaceWave.H"
#include "Time.H" #include "edgeTopoDistanceData.H"
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
@ -45,10 +45,10 @@ Foam::regionSplit2D::regionSplit2D
{ {
globalIndex globalFaces(blockedFaces.size()); globalIndex globalFaces(blockedFaces.size());
label regionI = globalFaces.toGlobal(0); label regionI = globalFaces.toGlobal(0);
List<patchEdgeFaceRegion> allEdgeInfo(patch.nEdges()); List<edgeTopoDistanceData<label>> allEdgeInfo(patch.nEdges());
List<patchEdgeFaceRegion> allFaceInfo(patch.size()); List<edgeTopoDistanceData<label>> allFaceInfo(patch.size());
DynamicList<label> changedEdges; DynamicList<label> changedEdges;
DynamicList<patchEdgeFaceRegion> changedRegions; DynamicList<edgeTopoDistanceData<label>> changedRegions;
label nBlockedFaces = 0; label nBlockedFaces = 0;
forAll(blockedFaces, faceI) forAll(blockedFaces, faceI)
{ {
@ -60,7 +60,14 @@ Foam::regionSplit2D::regionSplit2D
changedEdges.append(fEdges[feI]); changedEdges.append(fEdges[feI]);
// Append globally unique value // Append globally unique value
changedRegions.append(regionI); changedRegions.append
(
edgeTopoDistanceData<label>
(
0, // distance
regionI // passive data
)
);
} }
nBlockedFaces++; nBlockedFaces++;
regionI++; regionI++;
@ -68,7 +75,11 @@ Foam::regionSplit2D::regionSplit2D
else else
{ {
// Block all non-seeded faces from the walk // Block all non-seeded faces from the walk
allFaceInfo[faceI] = -2; allFaceInfo[faceI] = edgeTopoDistanceData<label>
(
0, // distance
-2 // passive data
);
} }
} }
@ -81,7 +92,7 @@ Foam::regionSplit2D::regionSplit2D
PatchEdgeFaceWave PatchEdgeFaceWave
< <
indirectPrimitivePatch, indirectPrimitivePatch,
patchEdgeFaceRegion edgeTopoDistanceData<label>
> >
( (
mesh, mesh,
@ -100,7 +111,7 @@ Foam::regionSplit2D::regionSplit2D
label compactRegionI = 0; label compactRegionI = 0;
forAll(allFaceInfo, faceI) forAll(allFaceInfo, faceI)
{ {
label regionI = allFaceInfo[faceI].region(); label regionI = allFaceInfo[faceI].data();
if if
( (
globalFaces.isLocal(regionI) globalFaces.isLocal(regionI)
@ -129,7 +140,7 @@ Foam::regionSplit2D::regionSplit2D
// Set the region index per face // Set the region index per face
forAll(allFaceInfo, faceI) forAll(allFaceInfo, faceI)
{ {
label regionI = allFaceInfo[faceI].region(); label regionI = allFaceInfo[faceI].data();
if (regionI >= 0) if (regionI >= 0)
{ {
this->operator[](faceI) = regionToCompactAddr[regionI] + offset; this->operator[](faceI) = regionToCompactAddr[regionI] + offset;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015 OpenCFD Ltd. Copyright (C) 2015-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -42,7 +42,6 @@ SourceFiles
#include "boolList.H" #include "boolList.H"
#include "labelList.H" #include "labelList.H"
#include "indirectPrimitivePatch.H" #include "indirectPrimitivePatch.H"
#include "patchEdgeFaceRegion.H"
#include "globalIndex.H" #include "globalIndex.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -34,7 +34,7 @@ License
#include "PatchTools.H" #include "PatchTools.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "PatchEdgeFaceWave.H" #include "PatchEdgeFaceWave.H"
#include "patchEdgeFaceRegion.H" #include "edgeTopoDistanceData.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -83,11 +83,11 @@ void Foam::regionToFace::markZone
) const ) const
{ {
// Data on all edges and faces // Data on all edges and faces
List<patchEdgeFaceRegion> allEdgeInfo(patch.nEdges()); List<edgeTopoDistanceData<label>> allEdgeInfo(patch.nEdges());
List<patchEdgeFaceRegion> allFaceInfo(patch.size()); List<edgeTopoDistanceData<label>> allFaceInfo(patch.size());
DynamicList<label> changedEdges; DynamicList<label> changedEdges;
DynamicList<patchEdgeFaceRegion> changedInfo; DynamicList<edgeTopoDistanceData<label>> changedInfo;
if (Pstream::myProcNo() == proci) if (Pstream::myProcNo() == proci)
{ {
@ -95,7 +95,14 @@ void Foam::regionToFace::markZone
for (const label edgei : fEdges) for (const label edgei : fEdges)
{ {
changedEdges.append(edgei); changedEdges.append(edgei);
changedInfo.append(zoneI); changedInfo.append
(
edgeTopoDistanceData<label>
(
0, // distance
zoneI
)
);
} }
} }
@ -103,7 +110,7 @@ void Foam::regionToFace::markZone
PatchEdgeFaceWave PatchEdgeFaceWave
< <
indirectPrimitivePatch, indirectPrimitivePatch,
patchEdgeFaceRegion edgeTopoDistanceData<label>
> calc > calc
( (
mesh_, mesh_,
@ -117,7 +124,7 @@ void Foam::regionToFace::markZone
forAll(allFaceInfo, facei) forAll(allFaceInfo, facei)
{ {
if (allFaceInfo[facei].region() == zoneI) if (allFaceInfo[facei].data() == zoneI)
{ {
faceZone[facei] = zoneI; faceZone[facei] = zoneI;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -113,12 +113,12 @@ Foam::labelList Foam::structuredDecomp::decompose
} }
// Field on cells and faces. // Field on cells and faces.
List<topoDistanceData> cellData(mesh.nCells()); List<topoDistanceData<label>> cellData(mesh.nCells());
List<topoDistanceData> faceData(mesh.nFaces()); List<topoDistanceData<label>> faceData(mesh.nFaces());
// Start of changes // Start of changes
labelList patchFaces(nFaces); labelList patchFaces(nFaces);
List<topoDistanceData> patchData(nFaces); List<topoDistanceData<label>> patchData(nFaces);
nFaces = 0; nFaces = 0;
for (const label patchi : patchIDs) for (const label patchi : patchIDs)
{ {
@ -127,13 +127,13 @@ Foam::labelList Foam::structuredDecomp::decompose
forAll(fc, i) forAll(fc, i)
{ {
patchFaces[nFaces] = pp.start()+i; patchFaces[nFaces] = pp.start()+i;
patchData[nFaces] = topoDistanceData(finalDecomp[fc[i]], 0); patchData[nFaces] = topoDistanceData<label>(0, finalDecomp[fc[i]]);
nFaces++; nFaces++;
} }
} }
// Propagate information inwards // Propagate information inwards
FaceCellWave<topoDistanceData> deltaCalc FaceCellWave<topoDistanceData<label>> deltaCalc
( (
mesh, mesh,
patchFaces, patchFaces,

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -72,8 +72,8 @@ bool Foam::structuredRenumber::layerLess::operator()
const label b const label b
) )
{ {
const topoDistanceData& ta = distance_[a]; const topoDistanceData<label>& ta = distance_[a];
const topoDistanceData& tb = distance_[b]; const topoDistanceData<label>& tb = distance_[b];
int dummy; int dummy;
@ -209,7 +209,7 @@ Foam::labelList Foam::structuredRenumber::renumber
// Walk sub-ordering (=column index) out. // Walk sub-ordering (=column index) out.
labelList patchFaces(nFaces); labelList patchFaces(nFaces);
List<topoDistanceData> patchData(nFaces); List<topoDistanceData<label>> patchData(nFaces);
nFaces = 0; nFaces = 0;
for (const label patchi : patchIDs) for (const label patchi : patchIDs)
{ {
@ -218,21 +218,21 @@ Foam::labelList Foam::structuredRenumber::renumber
forAll(fc, i) forAll(fc, i)
{ {
patchFaces[nFaces] = pp.start()+i; patchFaces[nFaces] = pp.start()+i;
patchData[nFaces] = topoDistanceData patchData[nFaces] = topoDistanceData<label>
( (
orderedToOld[fc[i]],// passive data: global column 0, // distance: layer
0 // distance: layer orderedToOld[fc[i]] // passive data: global column
); );
nFaces++; nFaces++;
} }
} }
// Field on cells and faces. // Field on cells and faces.
List<topoDistanceData> cellData(mesh.nCells()); List<topoDistanceData<label>> cellData(mesh.nCells());
List<topoDistanceData> faceData(mesh.nFaces()); List<topoDistanceData<label>> faceData(mesh.nFaces());
// Propagate information inwards // Propagate information inwards
OppositeFaceCellWave<topoDistanceData> deltaCalc OppositeFaceCellWave<topoDistanceData<label>> deltaCalc
( (
mesh, mesh,
patchFaces, patchFaces,

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -43,11 +44,12 @@ SourceFiles
#define structuredRenumber_H #define structuredRenumber_H
#include "renumberMethod.H" #include "renumberMethod.H"
#include "topoDistanceData.H"
namespace Foam namespace Foam
{ {
template<class Type> class topoDistanceData;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class structuredRenumber Declaration Class structuredRenumber Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -66,7 +68,7 @@ public:
{ {
const bool depthFirst_; const bool depthFirst_;
const labelList& order_; const labelList& order_;
const List<topoDistanceData>& distance_; const List<topoDistanceData<label>>& distance_;
public: public:
@ -74,7 +76,7 @@ public:
( (
const bool depthFirst, const bool depthFirst,
const labelList& order, const labelList& order,
const List<topoDistanceData>& distance const List<topoDistanceData<label>>& distance
) )
: :
depthFirst_(depthFirst), depthFirst_(depthFirst),

View File

@ -54,7 +54,7 @@ Foam::label Foam::shortestPathSet::findMinFace
( (
const polyMesh& mesh, const polyMesh& mesh,
const label cellI, const label cellI,
const List<topoDistanceData>& allFaceInfo, const List<topoDistanceData<label>>& allFaceInfo,
const bitSet& isLeakPoint, const bitSet& isLeakPoint,
const bool distanceMode, const bool distanceMode,
const point& origin const point& origin
@ -70,7 +70,7 @@ Foam::label Foam::shortestPathSet::findMinFace
forAll(cFaces2, i) forAll(cFaces2, i)
{ {
label faceI = cFaces2[i]; label faceI = cFaces2[i];
const topoDistanceData& info = allFaceInfo[faceI]; const topoDistanceData<label>& info = allFaceInfo[faceI];
if (info.distance() < minDist) if (info.distance() < minDist)
{ {
minDist = info.distance(); minDist = info.distance();
@ -146,14 +146,14 @@ void Foam::shortestPathSet::calculateDistance
const polyMesh& mesh, const polyMesh& mesh,
const label cellI, const label cellI,
List<topoDistanceData>& allFaceInfo, List<topoDistanceData<label>>& allFaceInfo,
List<topoDistanceData>& allCellInfo List<topoDistanceData<label>>& allCellInfo
) const ) const
{ {
int dummyTrackData = 0; int dummyTrackData = 0;
// Seed faces on cell1 // Seed faces on cell1
DynamicList<topoDistanceData> faceDist; DynamicList<topoDistanceData<label>> faceDist;
DynamicList<label> cFaces1; DynamicList<label> cFaces1;
if (cellI != -1) if (cellI != -1)
@ -167,7 +167,7 @@ void Foam::shortestPathSet::calculateDistance
if (!allFaceInfo[facei].valid(dummyTrackData)) if (!allFaceInfo[facei].valid(dummyTrackData))
{ {
cFaces1.append(facei); cFaces1.append(facei);
faceDist.append(topoDistanceData(123, 0)); faceDist.append(topoDistanceData<label>(0, 123));
} }
} }
} }
@ -177,7 +177,7 @@ void Foam::shortestPathSet::calculateDistance
// Walk through face-cell wave till all cells are reached // Walk through face-cell wave till all cells are reached
FaceCellWave FaceCellWave
< <
topoDistanceData topoDistanceData<label>
> wallDistCalc > wallDistCalc
( (
mesh, mesh,
@ -215,7 +215,7 @@ void Foam::shortestPathSet::calculateDistance
forAll(fld.boundaryField(), patchi) forAll(fld.boundaryField(), patchi)
{ {
const polyPatch& pp = mesh.boundaryMesh()[patchi]; const polyPatch& pp = mesh.boundaryMesh()[patchi];
SubList<topoDistanceData> p(pp.patchSlice(allFaceInfo)); SubList<topoDistanceData<label>> p(pp.patchSlice(allFaceInfo));
scalarField pfld(fld.boundaryField()[patchi].size()); scalarField pfld(fld.boundaryField()[patchi].size());
forAll(pfld, i) forAll(pfld, i)
{ {
@ -398,18 +398,18 @@ bool Foam::shortestPathSet::genSingleLeakPath
bitSet& isLeakPoint, bitSet& isLeakPoint,
// Work storage // Work storage
List<topoDistanceData>& allFaceInfo, List<topoDistanceData<label>>& allFaceInfo,
List<topoDistanceData>& allCellInfo List<topoDistanceData<label>>& allCellInfo
) const ) const
{ {
const polyBoundaryMesh& pbm = mesh.boundaryMesh(); const polyBoundaryMesh& pbm = mesh.boundaryMesh();
const topoDistanceData maxData(labelMax, labelMax); const topoDistanceData<label> maxData(labelMax, labelMax);
allFaceInfo.setSize(mesh.nFaces()); allFaceInfo.setSize(mesh.nFaces());
allFaceInfo = topoDistanceData(); allFaceInfo = topoDistanceData<label>();
allCellInfo.setSize(mesh.nCells()); allCellInfo.setSize(mesh.nCells());
allCellInfo = topoDistanceData(); allCellInfo = topoDistanceData<label>();
// Mark blocked faces with high distance // Mark blocked faces with high distance
forAll(isBlockedFace, facei) forAll(isBlockedFace, facei)
@ -597,8 +597,8 @@ bool Foam::shortestPathSet::genSingleLeakPath
origin origin
); );
const topoDistanceData& cInfo = allCellInfo[frontCellI]; const topoDistanceData<label>& cInfo = allCellInfo[frontCellI];
const topoDistanceData& fInfo = allFaceInfo[frontFaceI]; const topoDistanceData<label>& fInfo = allFaceInfo[frontFaceI];
if (fInfo.distance() <= cInfo.distance()) if (fInfo.distance() <= cInfo.distance())
{ {
@ -715,7 +715,7 @@ bool Foam::shortestPathSet::genSingleLeakPath
&& allCellInfo[frontCellI].distance() < minCellDistance && allCellInfo[frontCellI].distance() < minCellDistance
) )
{ {
const topoDistanceData& cInfo = allCellInfo[frontCellI]; const topoDistanceData<label>& cInfo = allCellInfo[frontCellI];
samplingPts.append(mesh.cellCentres()[frontCellI]); samplingPts.append(mesh.cellCentres()[frontCellI]);
samplingCells.append(frontCellI); samplingCells.append(frontCellI);
@ -935,7 +935,7 @@ void Foam::shortestPathSet::genSamples
// - isLeakPoint : is point on a leakFace // - isLeakPoint : is point on a leakFace
const topoDistanceData maxData(labelMax, labelMax); const topoDistanceData<label> maxData(labelMax, labelMax);
// Get the target point // Get the target point
const label outsideCelli = mesh.findCell(outsidePoint); const label outsideCelli = mesh.findCell(outsidePoint);
@ -943,8 +943,8 @@ void Foam::shortestPathSet::genSamples
// Maintain overall track length. Used to make curveDist continuous. // Maintain overall track length. Used to make curveDist continuous.
scalar trackLength = 0; scalar trackLength = 0;
List<topoDistanceData> allFaceInfo(mesh.nFaces()); List<topoDistanceData<label>> allFaceInfo(mesh.nFaces());
List<topoDistanceData> allCellInfo(mesh.nCells()); List<topoDistanceData<label>> allCellInfo(mesh.nCells());
// Boundary face + additional temporary blocks (to force leakpath to // Boundary face + additional temporary blocks (to force leakpath to

View File

@ -82,7 +82,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
class topoDistanceData; template<class Type> class topoDistanceData;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class shortestPathSet Declaration Class shortestPathSet Declaration
@ -111,7 +111,7 @@ class shortestPathSet
( (
const polyMesh& mesh, const polyMesh& mesh,
const label cellI, const label cellI,
const List<topoDistanceData>& allFaceInfo, const List<topoDistanceData<label>>& allFaceInfo,
const bitSet& isLeakPoint, const bitSet& isLeakPoint,
const bool minDistance, const bool minDistance,
const point& origin const point& origin
@ -135,8 +135,8 @@ class shortestPathSet
const polyMesh& mesh, const polyMesh& mesh,
const label cellI, const label cellI,
List<topoDistanceData>& allFaceInfo, List<topoDistanceData<label>>& allFaceInfo,
List<topoDistanceData>& allCellInfo List<topoDistanceData<label>>& allCellInfo
) const; ) const;
//- Checks if face uses a leak point //- Checks if face uses a leak point
@ -192,8 +192,8 @@ class shortestPathSet
bitSet& isLeakPoint, bitSet& isLeakPoint,
// Work storage // Work storage
List<topoDistanceData>& allFaceInfo, List<topoDistanceData<label>>& allFaceInfo,
List<topoDistanceData>& allCellInfo List<topoDistanceData<label>>& allCellInfo
) const; ) const;
//- Calculate path between insideCelli (-1 if not on current processor) //- Calculate path between insideCelli (-1 if not on current processor)