PrimitivePatchExtra - adjusted template args to match PrimitivePatch

This commit is contained in:
Mark Olesen
2008-11-16 00:00:34 +01:00
parent c651a0ba29
commit d56220c34a
5 changed files with 78 additions and 77 deletions

View File

@ -38,18 +38,18 @@ License
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
PrimitivePatchExtra PrimitivePatchExtra
( (
const ListType<Face>& faces, const FaceList<Face>& faces,
const pointField& points const Field<PointType>& points
) )
: :
PrimitivePatch<Face, ListType, PointField, PointType>(faces, points), PrimitivePatch<Face, FaceList, PointField, PointType>(faces, points),
sortedEdgeFacesPtr_(NULL), sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL) edgeOwnerPtr_(NULL)
{} {}
@ -59,17 +59,17 @@ PrimitivePatchExtra
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
PrimitivePatchExtra PrimitivePatchExtra
( (
const PrimitivePatchExtra<Face, ListType, PointField, PointType>& pp const PrimitivePatchExtra<Face, FaceList, PointField, PointType>& pp
) )
: :
PrimitivePatch<Face, ListType, PointField, PointType>(pp), PrimitivePatch<Face, FaceList, PointField, PointType>(pp),
sortedEdgeFacesPtr_(NULL), sortedEdgeFacesPtr_(NULL),
edgeOwnerPtr_(NULL) edgeOwnerPtr_(NULL)
{} {}
@ -80,11 +80,11 @@ PrimitivePatchExtra
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
~PrimitivePatchExtra() ~PrimitivePatchExtra()
{ {
clearOut(); clearOut();
@ -95,14 +95,14 @@ Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>::
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
void Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
clearOut() clearOut()
{ {
PrimitivePatch<Face, ListType, PointField, PointType>::clearOut(); PrimitivePatch<Face, FaceList, PointField, PointType>::clearOut();
clearTopology(); clearTopology();
} }
@ -110,14 +110,14 @@ clearOut()
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
void Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
clearTopology() clearTopology()
{ {
PrimitivePatch<Face, ListType, PointField, PointType>::clearTopology(); PrimitivePatch<Face, FaceList, PointField, PointType>::clearTopology();
deleteDemandDrivenData(sortedEdgeFacesPtr_); deleteDemandDrivenData(sortedEdgeFacesPtr_);
deleteDemandDrivenData(edgeOwnerPtr_); deleteDemandDrivenData(edgeOwnerPtr_);
} }
@ -126,12 +126,12 @@ clearTopology()
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
const Foam::labelListList& const Foam::labelListList&
Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
sortedEdgeFaces() const sortedEdgeFaces() const
{ {
if (!sortedEdgeFacesPtr_) if (!sortedEdgeFacesPtr_)
@ -146,12 +146,12 @@ sortedEdgeFaces() const
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
const Foam::labelList& const Foam::labelList&
Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
edgeOwner() const edgeOwner() const
{ {
if (!edgeOwnerPtr_) if (!edgeOwnerPtr_)

View File

@ -50,13 +50,13 @@ namespace Foam
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType=point class PointType=point
> >
class PrimitivePatchExtra class PrimitivePatchExtra
: :
public PrimitivePatch<Face, ListType, PointField, PointType> public PrimitivePatch<Face, FaceList, PointField, PointType>
{ {
public: public:
@ -64,13 +64,13 @@ public:
// Public typedefs // Public typedefs
typedef Face FaceType; typedef Face FaceType;
typedef ListType<Face> FaceListType; typedef FaceList<Face> FaceListType;
typedef PointField PointFieldType; typedef PointField PointFieldType;
private: private:
// Private typedefs // Private typedefs
typedef PrimitivePatch<Face, ListType, PointField, PointType> TemplateType; typedef PrimitivePatch<Face, FaceList, PointField, PointType> TemplateType;
// Private data // Private data
@ -99,14 +99,14 @@ public:
//- Construct from components //- Construct from components
PrimitivePatchExtra PrimitivePatchExtra
( (
const ListType<Face>& faces, const FaceList<Face>& faces,
const pointField& points const Field<PointType>& points
); );
//- Construct as copy //- Construct as copy
PrimitivePatchExtra PrimitivePatchExtra
( (
const PrimitivePatchExtra<Face, ListType, PointField, PointType>& const PrimitivePatchExtra<Face, FaceList, PointField, PointType>&
); );
@ -161,7 +161,7 @@ public:
// Note: faceZone has to be sized nFaces before calling. // Note: faceZone has to be sized nFaces before calling.
void markZone void markZone
( (
const boolList& borderEdge, const UList<bool>& borderEdge,
const label faceI, const label faceI,
const label currentZone, const label currentZone,
labelList& faceZone labelList& faceZone
@ -172,17 +172,17 @@ public:
// (bool for every edge in surface). Returns number of zones. // (bool for every edge in surface). Returns number of zones.
label markZones label markZones
( (
const boolList& borderEdge, const UList<bool>& borderEdge,
labelList& faceZone labelList& faceZone
) const; ) const;
//- Determine the mapping for a sub-mesh. //- Determine the mapping for a sub-mesh.
// Only include faces for which boolList entry is true // Only include faces for which bool List entry is true
// @param[out] pointMap mapping new to old localPoints // @param[out] pointMap mapping new to old localPoints
// @param[out] faceMap mapping new to old faces // @param[out] faceMap mapping new to old faces
void subsetMap void subsetMap
( (
const boolList& include, const UList<bool>& include,
labelList& pointMap, labelList& pointMap,
labelList& faceMap labelList& faceMap
) const; ) const;

View File

@ -40,16 +40,16 @@ Description
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
void Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
calcSortedEdgeFaces() const calcSortedEdgeFaces() const
{ {
if (sortedEdgeFacesPtr_) if (sortedEdgeFacesPtr_)
{ {
FatalErrorIn("PrimitivePatchExtra<Face, ListType, PointField>::calcSortedEdgeFaces()") FatalErrorIn("PrimitivePatchExtra<Face, FaceList, PointField>::calcSortedEdgeFaces()")
<< "sortedEdgeFacesPtr_ already set" << "sortedEdgeFacesPtr_ already set"
<< abort(FatalError); << abort(FatalError);
} }
@ -57,7 +57,7 @@ calcSortedEdgeFaces() const
const labelListList& eFaces = TemplateType::edgeFaces(); const labelListList& eFaces = TemplateType::edgeFaces();
const edgeList& edgeLst = TemplateType::edges(); const edgeList& edgeLst = TemplateType::edges();
const pointField& locPointLst = TemplateType::localPoints(); const pointField& locPointLst = TemplateType::localPoints();
const List<FaceType>& locFaceLst = TemplateType::localFaces(); const List<Face>& locFaceLst = TemplateType::localFaces();
// create the lists for the various results. (resized on completion) // create the lists for the various results. (resized on completion)
sortedEdgeFacesPtr_ = new labelListList(eFaces.size()); sortedEdgeFacesPtr_ = new labelListList(eFaces.size());
@ -101,7 +101,7 @@ calcSortedEdgeFaces() const
for (label nbI = 1; nbI < myFaceNbs.size(); nbI++) for (label nbI = 1; nbI < myFaceNbs.size(); nbI++)
{ {
// Get opposite vertex // Get opposite vertex
const FaceType& f = locFaceLst[myFaceNbs[nbI]]; const Face& f = locFaceLst[myFaceNbs[nbI]];
label fp0 = findIndex(f, e[0]); label fp0 = findIndex(f, e[0]);
label fp1 = f.fcIndex(fp0); label fp1 = f.fcIndex(fp0);
label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1)); label vertI = (f[fp1] != e[1] ? f[fp1] : f.fcIndex(fp1));
@ -137,16 +137,16 @@ calcSortedEdgeFaces() const
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
void Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
calcEdgeOwner() const calcEdgeOwner() const
{ {
if (edgeOwnerPtr_) if (edgeOwnerPtr_)
{ {
FatalErrorIn("PrimitivePatchExtra<Face, ListType, PointField>::calcEdgeOwner()") FatalErrorIn("PrimitivePatchExtra<Face, FaceList, PointField>::calcEdgeOwner()")
<< "edgeOwnerPtr_ already set" << "edgeOwnerPtr_ already set"
<< abort(FatalError); << abort(FatalError);
} }
@ -160,7 +160,7 @@ calcEdgeOwner() const
const edgeList& edgeLst = TemplateType::edges(); const edgeList& edgeLst = TemplateType::edges();
const labelListList& eFaces = TemplateType::edgeFaces(); const labelListList& eFaces = TemplateType::edgeFaces();
const List<FaceType>& locFaceLst = TemplateType::localFaces(); const List<Face>& locFaceLst = TemplateType::localFaces();
forAll(edgeLst, edgeI) forAll(edgeLst, edgeI)
@ -181,7 +181,7 @@ calcEdgeOwner() const
forAll(myFaces, i) forAll(myFaces, i)
{ {
const FaceType& f = locFaceLst[myFaces[i]]; const Face& f = locFaceLst[myFaces[i]];
if (f.findEdge(e) > 0) if (f.findEdge(e) > 0)
{ {
@ -192,11 +192,11 @@ calcEdgeOwner() const
if (edgeOwner[edgeI] == -1) if (edgeOwner[edgeI] == -1)
{ {
FatalErrorIn("PrimitivePatchExtra<Face, ListType, PointField>::calcEdgeOwner()") FatalErrorIn("PrimitivePatchExtra<Face, FaceList, PointField>::calcEdgeOwner()")
<< "Edge " << edgeI << " vertices:" << e << "Edge " << edgeI << " vertices:" << e
<< " is used by faces " << myFaces << " is used by faces " << myFaces
<< " vertices:" << " vertices:"
<< IndirectList<FaceType>(locFaceLst, myFaces)() << IndirectList<Face>(locFaceLst, myFaces)()
<< " none of which use the edge vertices in the same order" << " none of which use the edge vertices in the same order"
<< nl << "I give up" << abort(FatalError); << nl << "I give up" << abort(FatalError);
} }

View File

@ -34,11 +34,11 @@ License
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
void Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
checkEdges checkEdges
( (
const bool verbose const bool verbose
@ -77,18 +77,18 @@ checkEdges
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
Foam::boolList Foam::boolList
Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
checkOrientation checkOrientation
( (
const bool verbose const bool verbose
) const ) const
{ {
const ListType<FaceType>& faceLst = *this; const FaceList<Face>& faceLst = *this;
const edgeList& edgeLst = TemplateType::edges(); const edgeList& edgeLst = TemplateType::edges();
const labelListList& faceEs = TemplateType::faceEdges(); const labelListList& faceEs = TemplateType::faceEdges();
const label numEdges = TemplateType::nEdges(); const label numEdges = TemplateType::nEdges();
@ -133,7 +133,7 @@ checkOrientation
// //
//- Compute normal from 3 points, use the first as the origin //- Compute normal from 3 points, use the first as the origin
// minor warpage should not be a problem // minor warpage should not be a problem
const FaceType& f = faceLst[faceI]; const Face& f = faceLst[faceI];
const point p0(pointLst[f[0]]); const point p0(pointLst[f[0]]);
const point p1(pointLst[f[1]]); const point p1(pointLst[f[1]]);
const point p2(pointLst[f[f.size()-1]]); const point p2(pointLst[f[f.size()-1]]);
@ -156,8 +156,8 @@ checkOrientation
const labelListList& eFaces = TemplateType::edgeFaces(); const labelListList& eFaces = TemplateType::edgeFaces();
const pointField& locPointsLst = TemplateType::localPoints(); const pointField& locPointsLst = TemplateType::localPoints();
// Storage for holding status of edge. True if normal flips across this // Storage for holding status of edge.
// edge // True if normal flips across this edge
boolList borderEdge(numEdges, false); boolList borderEdge(numEdges, false);
forAll(edgeLst, edgeI) forAll(edgeLst, edgeI)
@ -167,8 +167,8 @@ checkOrientation
if (neighbours.size() == 2) if (neighbours.size() == 2)
{ {
const FaceType& faceA = faceLst[neighbours[0]]; const Face& faceA = faceLst[neighbours[0]];
const FaceType& faceB = faceLst[neighbours[1]]; const Face& faceB = faceLst[neighbours[1]];
// The edge cannot be going in the same direction if both faces // The edge cannot be going in the same direction if both faces
// are oriented counterclockwise. // are oriented counterclockwise.

View File

@ -33,13 +33,13 @@ License
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
void Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>::markZone void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::markZone
( (
const boolList& borderEdge, const UList<bool>& borderEdge,
const label faceI, const label faceI,
const label currentZone, const label currentZone,
labelList& faceZone labelList& faceZone
@ -62,9 +62,9 @@ void Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>::markZone
const labelList& fEdges = faceEs[faceI]; const labelList& fEdges = faceEs[faceI];
forAll(fEdges, i) forAll(fEdges, fEdgeI)
{ {
label edgeI = fEdges[i]; label edgeI = fEdges[fEdgeI];
if (!borderEdge[edgeI]) if (!borderEdge[edgeI])
{ {
@ -83,7 +83,7 @@ void Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>::markZone
{ {
FatalErrorIn FatalErrorIn
( (
"PrimitivePatchExtra<Face, ListType, PointField>::markZone" "PrimitivePatchExtra<Face, FaceList, PointField>::markZone"
"(const boolList&, const label, const label, labelList&) const" "(const boolList&, const label, const label, labelList&) const"
) )
<< "Zones " << faceZone[nbrFaceI] << "Zones " << faceZone[nbrFaceI]
@ -113,28 +113,25 @@ void Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>::markZone
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
Foam::label Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: Foam::label Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
markZones markZones
( (
const boolList& borderEdge, const UList<bool>& borderEdge,
labelList& faceZone labelList& faceZone
) const ) const
{ {
const label numEdges = TemplateType::nEdges(); const label numEdges = TemplateType::nEdges();
const label numFaces = TemplateType::size(); const label numFaces = TemplateType::size();
faceZone.setSize(numFaces);
faceZone = -1;
if (borderEdge.size() != numEdges) if (borderEdge.size() != numEdges)
{ {
FatalErrorIn FatalErrorIn
( (
"PrimitivePatchExtra<Face, ListType, PointField>::markZones" "PrimitivePatchExtra<Face, FaceList, PointField>::markZones"
"(const boolList&, labelList&)" "(const boolList&, labelList&)"
) )
<< "borderEdge boolList not same size as number of edges" << endl << "borderEdge boolList not same size as number of edges" << endl
@ -143,28 +140,32 @@ markZones
<< exit(FatalError); << exit(FatalError);
} }
faceZone.setSize(numFaces);
faceZone = -1;
label zoneI = 0; label zoneI = 0;
label startFaceI = 0; label startFaceI = 0;
for (;;zoneI++) while (true)
{ {
// Find first non-coloured face // Find first non-visited face
for (; startFaceI < numFaces; startFaceI++) for (; startFaceI < numFaces; startFaceI++)
{ {
if (faceZone[startFaceI] == -1) if (faceZone[startFaceI] == -1)
{ {
faceZone[startFaceI] = zoneI;
markZone(borderEdge, startFaceI, zoneI, faceZone);
break; break;
} }
} }
if (startFaceI >= numFaces) if (startFaceI >= numFaces)
{ {
// Finished
break; break;
} }
faceZone[startFaceI] = zoneI; zoneI++;
markZone(borderEdge, startFaceI, zoneI, faceZone);
} }
return zoneI; return zoneI;
@ -177,19 +178,19 @@ markZones
template template
< <
class Face, class Face,
template<class> class ListType, template<class> class FaceList,
class PointField, class PointField,
class PointType class PointType
> >
void Foam::PrimitivePatchExtra<Face, ListType, PointField, PointType>:: void Foam::PrimitivePatchExtra<Face, FaceList, PointField, PointType>::
subsetMap subsetMap
( (
const boolList& include, const UList<bool>& include,
labelList& pointMap, labelList& pointMap,
labelList& faceMap labelList& faceMap
) const ) const
{ {
const List<FaceType>& locFaces = TemplateType::localFaces(); const List<Face>& locFaces = TemplateType::localFaces();
const label numPoints = TemplateType::nPoints(); const label numPoints = TemplateType::nPoints();
label faceI = 0; label faceI = 0;
@ -208,7 +209,7 @@ subsetMap
faceMap[faceI++] = oldFaceI; faceMap[faceI++] = oldFaceI;
// Renumber labels for face // Renumber labels for face
const FaceType& f = locFaces[oldFaceI]; const Face& f = locFaces[oldFaceI];
forAll(f, fp) forAll(f, fp)
{ {