STYLE: update PrimitivePatch (#1648)

- simplified templating, which cleans up code and does not appear to
  break any normal user coding.

ENH: unique_ptr instead of homegrown demand-driven handling.
This commit is contained in:
Mark Olesen
2020-04-30 12:46:00 +02:00
parent 5c9f07df7a
commit 8a5d108fd2
44 changed files with 553 additions and 1118 deletions

View File

@ -249,7 +249,7 @@ int main(int argc, char *argv[])
faceList patchFaces(patch);
pointField allPoints(patch.points());
PrimitivePatch<face, List, pointField, point> storedPatch
PrimitivePatch<List<face>, pointField> storedPatch
(
patchFaces,
allPoints,

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,7 +54,7 @@ class extrudedMesh
:
public polyMesh
{
// Private data
// Private Data
const extrudeModel& model_;
@ -64,26 +65,26 @@ class extrudedMesh
static bool sameOrder(const face&, const edge&);
//- Construct and return the extruded mesh points
template<class Face, template<class> class FaceList, class PointField>
template<class FaceList, class PointField>
pointField extrudedPoints
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const PrimitivePatch<FaceList, PointField>& extrudePatch,
const extrudeModel&
);
//- Construct and return the extruded mesh faces
template<class Face, template<class> class FaceList, class PointField>
template<class FaceList, class PointField>
faceList extrudedFaces
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const PrimitivePatch<FaceList, PointField>& extrudePatch,
const extrudeModel&
);
//- Construct and return the extruded mesh cells
template<class Face, template<class> class FaceList, class PointField>
template<class FaceList, class PointField>
cellList extrudedCells
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const PrimitivePatch<FaceList, PointField>& extrudePatch,
const extrudeModel&
);
@ -100,11 +101,11 @@ public:
// Constructors
//- Construct from the primitivePatch to extrude
template<class Face, template<class> class FaceList, class PointField>
template<class FaceList, class PointField>
extrudedMesh
(
const IOobject&,
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const PrimitivePatch<FaceList, PointField>& extrudePatch,
const extrudeModel&
);
};

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,15 +31,10 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField
>
template<class FaceList, class PointField>
Foam::pointField Foam::extrudedMesh::extrudedPoints
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const PrimitivePatch<FaceList, PointField>& extrudePatch,
const extrudeModel& model
)
{
@ -68,10 +64,10 @@ Foam::pointField Foam::extrudedMesh::extrudedPoints
}
template<class Face, template<class> class FaceList, class PointField>
template<class FaceList, class PointField>
Foam::faceList Foam::extrudedMesh::extrudedFaces
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const PrimitivePatch<FaceList, PointField>& extrudePatch,
const extrudeModel& model
)
{
@ -194,10 +190,10 @@ Foam::faceList Foam::extrudedMesh::extrudedFaces
}
template<class Face, template<class> class FaceList, class PointField>
template<class FaceList, class PointField>
Foam::cellList Foam::extrudedMesh::extrudedCells
(
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const PrimitivePatch<FaceList, PointField>& extrudePatch,
const extrudeModel& model
)
{
@ -302,16 +298,11 @@ Foam::cellList Foam::extrudedMesh::extrudedCells
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField
>
template<class FaceList, class PointField>
Foam::extrudedMesh::extrudedMesh
(
const IOobject& io,
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const PrimitivePatch<FaceList, PointField>& extrudePatch,
const extrudeModel& model
)
:

View File

@ -81,7 +81,7 @@ SourceFiles
namespace Foam
{
typedef PrimitivePatch<face, List, const pointField, point> bPatch;
typedef PrimitivePatch<::Foam::List<face>, const pointField> bPatch;
typedef treeDataPrimitivePatch<bPatch> treeDataBPatch;
class Time;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -199,7 +199,7 @@ Foam::tmp<Foam::triSurfacePointScalarField> Foam::automatic::load()
PrimitivePatchInterpolation
<
PrimitivePatch<labelledTri, ::Foam::List, pointField, point>
PrimitivePatch<::Foam::List<labelledTri>, pointField>
> patchInterpolate(surface_);
const Map<label>& meshPointMap = surface_.meshPointMap();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,11 +61,11 @@ class nonUniformField
protected:
// Private typedef
// Typedefs
typedef PrimitivePatchInterpolation
<
PrimitivePatch<labelledTri, List, pointField, point>
PrimitivePatch<::Foam::List<labelledTri>, pointField>
> primitivePatchInterpolation;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,7 +58,7 @@ SourceFiles
namespace Foam
{
// Forward declarations
// Forward Declarations
class polyMesh;
class bitSet;
class boundBox;
@ -73,16 +74,10 @@ public:
//- Check for orientation issues.
// Returns true if problems were found.
// If a normal flips across an edge, places it in the HashSet
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
static bool checkOrientation
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
const PrimitivePatch<FaceList, PointField>&,
const bool report = false,
labelHashSet* marked = 0
);
@ -91,17 +86,10 @@ public:
//- Fill faceZone with currentZone for every face reachable
// from facei without crossing edge marked in borderEdge.
// Note: faceZone has to be sized nFaces before calling.
template
<
class BoolListType,
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class BoolListType, class FaceList, class PointField>
static void markZone
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
const PrimitivePatch<FaceList, PointField>&,
const BoolListType& borderEdge,
const label facei,
const label currentZone,
@ -111,17 +99,10 @@ public:
//- Size and fills faceZone with zone of face.
// Zone is area reachable by edge crossing without crossing borderEdge.
// Returns number of zones.
template
<
class BoolListType,
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class BoolListType, class FaceList, class PointField>
static label markZones
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
const PrimitivePatch<FaceList, PointField>&,
const BoolListType& borderEdge,
labelList& faceZone
);
@ -132,78 +113,47 @@ public:
// \param[in] includeFaces faces to include
// \param[out] pointMap mapping new to old localPoints
// \param[out] faceMap mapping new to old faces
template
<
class BoolListType,
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class BoolListType, class FaceList, class PointField>
static void subsetMap
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const PrimitivePatch<FaceList, PointField>& p,
const BoolListType& includeFaces,
labelList& pointMap,
labelList& faceMap
);
//-
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
static void calcBounds
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const PrimitivePatch<FaceList, PointField>& p,
boundBox& bb,
label& nPoints
);
//- Return edge-face addressing sorted by angle around the edge.
// Orientation is anticlockwise looking from edge.vec(localPoints())
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
static labelListList sortedEdgeFaces
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&
const PrimitivePatch<FaceList, PointField>&
);
//- Return point-edge addressing sorted by order around the point.
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
static labelListList sortedPointEdges
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&
const PrimitivePatch<FaceList, PointField>&
);
//- If 2 face neighbours: label of face where ordering of edge
// is consistent with righthand walk.
// If 1 neighbour: label of only face.
// If >2 neighbours: undetermined.
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
static labelList edgeOwner
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&
const PrimitivePatch<FaceList, PointField>&
);
@ -212,19 +162,13 @@ public:
// p2PointLabels : corresponding points on p2
template
<
class Face1,
template<class> class FaceList1,
class PointField1,
class PointType1,
class Face2,
template<class> class FaceList2,
class PointField2,
class PointType2
class FaceList1, class PointField1,
class FaceList2, class PointField2
>
static void matchPoints
(
const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
const PrimitivePatch<FaceList1, PointField1>& p1,
const PrimitivePatch<FaceList2, PointField2>& p2,
labelList& p1PointLabels,
labelList& p2PointLabels
@ -236,19 +180,13 @@ public:
// sameOrientation : same orientation?
template
<
class Face1,
template<class> class FaceList1,
class PointField1,
class PointType1,
class Face2,
template<class> class FaceList2,
class PointField2,
class PointType2
class FaceList1, class PointField1,
class FaceList2, class PointField2
>
static void matchEdges
(
const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
const PrimitivePatch<FaceList1, PointField1>& p1,
const PrimitivePatch<FaceList2, PointField2>& p2,
labelList& p1EdgeLabels,
labelList& p2EdgeLabels,
@ -257,33 +195,21 @@ public:
//- Return parallel consistent point normals for patches using mesh points.
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
static tmp<pointField> pointNormals
(
const polyMesh&,
const PrimitivePatch<Face, FaceList, PointField, PointType>&
const PrimitivePatch<FaceList, PointField>&
);
//- Return parallel consistent edge normals for patches using mesh points.
// Supply with patch matching info from matchEdges.
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
static tmp<pointField> edgeNormals
(
const polyMesh&,
const PrimitivePatch<Face, FaceList, PointField, PointType>&,
const PrimitivePatch<FaceList, PointField>&,
const labelList& patchEdges,
const labelList& coupledEdges
);
@ -291,19 +217,19 @@ public:
//- Gather points and faces onto master and merge into single patch.
// Note: uses faces/points, not localFaces/localPoints.
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
static void gatherAndMerge
(
const scalar mergeDist,
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
Field<PointType>& mergedPoints,
List<Face>& mergedFaces,
const PrimitivePatch<FaceList, PointField>& p,
Field
<
typename PrimitivePatch<FaceList, PointField>::point_type
>& mergedPoints,
List
<
typename PrimitivePatch<FaceList, PointField>::face_type
>& mergedFaces,
labelList& pointMergeMap
);

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,22 +30,17 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
bool
Foam::PatchTools::checkOrientation
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const PrimitivePatch<FaceList, PointField>& p,
const bool report,
labelHashSet* setPtr
)
{
typedef typename PrimitivePatch<FaceList, PointField>::face_type FaceType;
bool foundError = false;
// Check edge normals, face normals, point normals.
@ -93,7 +89,7 @@ Foam::PatchTools::checkOrientation
//
//- Compute normal from 3 points, use the first as the origin
// minor warpage should not be a problem
const Face& f = p[facei];
const FaceType& f = p[facei];
const point& p0 = p.points()[f[0]];
const point& p1 = p.points()[f[1]];
const point& p2 = p.points()[f.last()];
@ -126,8 +122,8 @@ Foam::PatchTools::checkOrientation
{
// we use localFaces() since edges() are LOCAL
// these are both already available
const Face& faceA = p.localFaces()[neighbouringFaces[0]];
const Face& faceB = p.localFaces()[neighbouringFaces[1]];
const FaceType& faceA = p.localFaces()[neighbouringFaces[0]];
const FaceType& faceB = p.localFaces()[neighbouringFaces[1]];
// If the faces are correctly oriented, the edges must go in
// different directions on connected faces.

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,23 +30,18 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
Foam::labelList
Foam::PatchTools::edgeOwner
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
const PrimitivePatch<FaceList, PointField>& p
)
{
typedef typename PrimitivePatch<FaceList, PointField>::face_type FaceType;
const edgeList& edges = p.edges();
const labelListList& edgeFaces = p.edgeFaces();
const List<Face>& localFaces = p.localFaces();
const List<FaceType>& localFaces = p.localFaces();
// create the owner list
labelList edgeOwner(edges.size(), -1);
@ -62,13 +58,13 @@ Foam::PatchTools::edgeOwner
{
// Find the first face whose vertices are aligned with the edge.
// with multiply connected edges, this is the best we can do
forAll(nbrFaces, i)
for (const label nbrFacei : nbrFaces)
{
const Face& f = localFaces[nbrFaces[i]];
const FaceType& f = localFaces[nbrFacei];
if (f.edgeDirection(edges[edgeI]) > 0)
{
edgeOwner[edgeI] = nbrFaces[i];
edgeOwner[edgeI] = nbrFacei;
break;
}
}
@ -79,7 +75,7 @@ Foam::PatchTools::edgeOwner
<< "Edge " << edgeI << " vertices:" << edges[edgeI]
<< " is used by faces " << nbrFaces
<< " vertices:"
<< UIndirectList<Face>(localFaces, nbrFaces)
<< UIndirectList<FaceType>(localFaces, nbrFaces)
<< " none of which use the edge vertices in the same order"
<< nl << "I give up" << abort(FatalError);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,22 +33,25 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void Foam::PatchTools::gatherAndMerge
(
const scalar mergeDist,
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
Field<PointType>& mergedPoints,
List<Face>& mergedFaces,
const PrimitivePatch<FaceList, PointField>& p,
Field
<
typename PrimitivePatch<FaceList, PointField>::point_type
>& mergedPoints,
List
<
typename PrimitivePatch<FaceList, PointField>::face_type
>& mergedFaces,
labelList& pointMergeMap
)
{
typedef typename PrimitivePatch<FaceList,PointField>::face_type FaceType;
typedef typename PrimitivePatch<FaceList,PointField>::point_type PointType;
// Collect points from all processors
labelList pointSizes;
{
@ -62,20 +65,20 @@ void Foam::PatchTools::gatherAndMerge
// Collect faces from all processors and renumber using sizes of
// gathered points
{
List<List<Face>> gatheredFaces(Pstream::nProcs());
List<List<FaceType>> gatheredFaces(Pstream::nProcs());
gatheredFaces[Pstream::myProcNo()] = p;
Pstream::gatherList(gatheredFaces);
if (Pstream::master())
{
mergedFaces = static_cast<const List<Face>&>
mergedFaces = static_cast<const List<FaceType>&>
(
ListListOps::combineOffset<List<Face>>
ListListOps::combineOffset<List<FaceType>>
(
gatheredFaces,
pointSizes,
accessOp<List<Face>>(),
offsetOp<Face>()
accessOp<List<FaceType>>(),
offsetOp<FaceType>()
)
);
}
@ -104,11 +107,9 @@ void Foam::PatchTools::gatherAndMerge
mergedPoints.transfer(newPoints);
// Relabel faces
List<Face>& faces = mergedFaces;
forAll(faces, facei)
for (auto& f : mergedFaces)
{
inplaceRenumber(pointMergeMap, faces[facei]);
inplaceRenumber(pointMergeMap, f);
}
}
}
@ -151,9 +152,9 @@ void Foam::PatchTools::gatherAndMerge
// Get renumbered local data
pointField myPoints(mesh.points(), uniqueMeshPointLabels);
List<FaceType> myFaces(localFaces);
forAll(myFaces, i)
for (auto& f : myFaces)
{
inplaceRenumber(pointToGlobal, myFaces[i]);
inplaceRenumber(pointToGlobal, f);
}
@ -190,9 +191,9 @@ void Foam::PatchTools::gatherAndMerge
// Get renumbered local data
pointField myPoints(mesh.points(), uniqueMeshPointLabels);
List<FaceType> myFaces(localFaces);
forAll(myFaces, i)
for (auto& f : myFaces)
{
inplaceRenumber(pointToGlobal, myFaces[i]);
inplaceRenumber(pointToGlobal, f);
}
// Construct processor stream with estimate of size. Could

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -32,19 +32,13 @@ License
template
<
class Face1,
template<class> class FaceList1,
class PointField1,
class PointType1,
class Face2,
template<class> class FaceList2,
class PointField2,
class PointType2
class FaceList1, class PointField1,
class FaceList2, class PointField2
>
void Foam::PatchTools::matchPoints
(
const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
const PrimitivePatch<FaceList1, PointField1>& p1,
const PrimitivePatch<FaceList2, PointField2>& p2,
labelList& p1PointLabels,
labelList& p2PointLabels
@ -75,19 +69,13 @@ void Foam::PatchTools::matchPoints
template
<
class Face1,
template<class> class FaceList1,
class PointField1,
class PointType1,
class Face2,
template<class> class FaceList2,
class PointField2,
class PointType2
class FaceList1, class PointField1,
class FaceList2, class PointField2
>
void Foam::PatchTools::matchEdges
(
const PrimitivePatch<Face1, FaceList1, PointField1, PointType1>& p1,
const PrimitivePatch<Face2, FaceList2, PointField2, PointType2>& p2,
const PrimitivePatch<FaceList1, PointField1>& p1,
const PrimitivePatch<FaceList2, PointField2>& p2,
labelList& p1EdgeLabels,
labelList& p2EdgeLabels,

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,19 +33,12 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
Foam::tmp<Foam::pointField>
Foam::PatchTools::pointNormals
(
const polyMesh& mesh,
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
const PrimitivePatch<FaceList, PointField>& p
)
{
const globalMeshData& globalData = mesh.globalData();
@ -196,27 +189,21 @@ Foam::PatchTools::pointNormals
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
Foam::tmp<Foam::pointField>
Foam::PatchTools::edgeNormals
(
const polyMesh& mesh,
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const PrimitivePatch<FaceList, PointField>& p,
const labelList& patchEdges,
const labelList& coupledEdges
)
{
// 1. Start off with local normals
tmp<pointField> tedgeNormals(new pointField(p.nEdges(), Zero));
pointField& edgeNormals = tedgeNormals.ref();
auto tedgeNormals = tmp<pointField>::New(p.nEdges(), Zero);
auto& edgeNormals = tedgeNormals.ref();
{
const labelListList& edgeFaces = p.edgeFaces();
const vectorField& faceNormals = p.faceNormals();

View File

@ -35,17 +35,10 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
class BoolListType,
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class BoolListType, class FaceList, class PointField>
void Foam::PatchTools::markZone
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const PrimitivePatch<FaceList, PointField>& p,
const BoolListType& borderEdge,
const label facei,
const label currentZone,
@ -111,19 +104,11 @@ void Foam::PatchTools::markZone
}
template
<
class BoolListType,
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class BoolListType, class FaceList, class PointField>
Foam::label
Foam::PatchTools::markZones
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const PrimitivePatch<FaceList, PointField>& p,
const BoolListType& borderEdge,
labelList& faceZone
)
@ -151,25 +136,17 @@ Foam::PatchTools::markZones
}
template
<
class BoolListType,
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class BoolListType, class FaceList, class PointField>
void
Foam::PatchTools::subsetMap
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const PrimitivePatch<FaceList, PointField>& p,
const BoolListType& includeFaces,
labelList& pointMap,
labelList& faceMap
)
{
const List<Face>& localFaces = p.localFaces();
const auto& localFaces = p.localFaces();
faceMap.resize(localFaces.size());
pointMap.clear();
@ -196,16 +173,10 @@ Foam::PatchTools::subsetMap
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void Foam::PatchTools::calcBounds
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p,
const PrimitivePatch<FaceList, PointField>& p,
boundBox& bb,
label& nPoints
)

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,24 +32,17 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
Foam::labelListList
Foam::PatchTools::sortedEdgeFaces
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
const PrimitivePatch<FaceList, PointField>& p
)
{
const edgeList& edges = p.edges();
const labelListList& edgeFaces = p.edgeFaces();
const List<Face>& localFaces = p.localFaces();
const Field<PointType>& localPoints = p.localPoints();
const auto& localFaces = p.localFaces();
const auto& localPoints = p.localPoints();
// create the lists for the various results. (resized on completion)
labelListList sortedEdgeFaces(edgeFaces.size());
@ -69,7 +63,7 @@ Foam::PatchTools::sortedEdgeFaces
// Get the vertex on 0th face that forms a vector with the first
// edge point that has the largest angle with the edge
const Face& f0 = localFaces[faceNbs[0]];
const auto& f0 = localFaces[faceNbs[0]];
scalar maxAngle = GREAT;
vector maxAngleEdgeDir(vector::max);
@ -110,7 +104,7 @@ Foam::PatchTools::sortedEdgeFaces
{
// Get the vertex on face that forms a vector with the first
// edge point that has the largest angle with the edge
const Face& f = localFaces[faceNbs[nbI]];
const auto& f = localFaces[faceNbs[nbI]];
maxAngle = GREAT;
maxAngleEdgeDir = vector::max;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,18 +30,11 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
Foam::labelListList
Foam::PatchTools::sortedPointEdges
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
const PrimitivePatch<FaceList, PointField>& p
)
{
// Now order the edges of each point according to whether they share a

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,21 +30,14 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
PrimitivePatch
template<class FaceList, class PointField>
Foam::PrimitivePatch<FaceList, PointField>::PrimitivePatch
(
const FaceList<Face>& faces,
const Field<PointType>& points
const FaceList& faces,
const PointField& points
)
:
FaceList<Face>(faces),
FaceList(faces),
points_(points),
edgesPtr_(nullptr),
nInternalEdges_(-1),
@ -67,21 +61,14 @@ PrimitivePatch
{}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
PrimitivePatch
template<class FaceList, class PointField>
Foam::PrimitivePatch<FaceList, PointField>::PrimitivePatch
(
FaceList<Face>&& faces,
const Field<PointType>& points
FaceList&& faces,
const PointField& points
)
:
FaceList<Face>(std::move(faces)),
FaceList(std::move(faces)),
points_(points),
edgesPtr_(nullptr),
nInternalEdges_(-1),
@ -105,22 +92,15 @@ PrimitivePatch
{}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
PrimitivePatch
template<class FaceList, class PointField>
Foam::PrimitivePatch<FaceList, PointField>::PrimitivePatch
(
FaceList<Face>& faces,
Field<PointType>& points,
FaceList& faces,
PointField& points,
const bool reuse
)
:
FaceList<Face>(faces, reuse),
FaceList(faces, reuse),
points_(points, reuse),
edgesPtr_(nullptr),
nInternalEdges_(-1),
@ -144,21 +124,14 @@ PrimitivePatch
{}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
PrimitivePatch
template<class FaceList, class PointField>
Foam::PrimitivePatch<FaceList, PointField>::PrimitivePatch
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
const PrimitivePatch<FaceList, PointField>& pp
)
:
PrimitivePatchName(),
FaceList<Face>(pp),
FaceList(pp),
points_(pp.points_),
edgesPtr_(nullptr),
nInternalEdges_(-1),
@ -184,15 +157,8 @@ PrimitivePatch
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
~PrimitivePatch()
template<class FaceList, class PointField>
Foam::PrimitivePatch<FaceList, PointField>::PrimitivePatch::~PrimitivePatch()
{
clearOut();
}
@ -200,23 +166,16 @@ Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
movePoints
Foam::PrimitivePatch<FaceList, PointField>::movePoints
(
const Field<PointType>&
const Field<point_type>&
)
{
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
<< "movePoints() : "
<< "recalculating PrimitivePatch geometry following mesh motion"
<< endl;
@ -226,16 +185,9 @@ movePoints
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::edgeList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
edges() const
Foam::PrimitivePatch<FaceList, PointField>::edges() const
{
if (!edgesPtr_)
{
@ -246,16 +198,9 @@ edges() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
Foam::label
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
nInternalEdges() const
Foam::PrimitivePatch<FaceList, PointField>::nInternalEdges() const
{
if (!edgesPtr_)
{
@ -266,16 +211,9 @@ nInternalEdges() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::labelList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
boundaryPoints() const
Foam::PrimitivePatch<FaceList, PointField>::boundaryPoints() const
{
if (!boundaryPointsPtr_)
{
@ -286,16 +224,9 @@ boundaryPoints() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceFaces() const
Foam::PrimitivePatch<FaceList, PointField>::faceFaces() const
{
if (!faceFacesPtr_)
{
@ -306,16 +237,9 @@ faceFaces() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
edgeFaces() const
Foam::PrimitivePatch<FaceList, PointField>::edgeFaces() const
{
if (!edgeFacesPtr_)
{
@ -326,16 +250,9 @@ edgeFaces() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceEdges() const
Foam::PrimitivePatch<FaceList, PointField>::faceEdges() const
{
if (!faceEdgesPtr_)
{
@ -346,16 +263,9 @@ faceEdges() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
pointEdges() const
Foam::PrimitivePatch<FaceList, PointField>::pointEdges() const
{
if (!pointEdgesPtr_)
{
@ -366,16 +276,9 @@ pointEdges() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
pointFaces() const
Foam::PrimitivePatch<FaceList, PointField>::pointFaces() const
{
if (!pointFacesPtr_)
{
@ -386,16 +289,12 @@ pointFaces() const
}
template
template<class FaceList, class PointField>
const Foam::List
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
const Foam::List<Face>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
localFaces() const
typename Foam::PrimitivePatch<FaceList, PointField>::face_type
>&
Foam::PrimitivePatch<FaceList, PointField>::localFaces() const
{
if (!localFacesPtr_)
{
@ -406,16 +305,9 @@ localFaces() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::labelList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
meshPoints() const
Foam::PrimitivePatch<FaceList, PointField>::meshPoints() const
{
if (!meshPointsPtr_)
{
@ -426,16 +318,9 @@ meshPoints() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::Map<Foam::label>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
meshPointMap() const
Foam::PrimitivePatch<FaceList, PointField>::meshPointMap() const
{
if (!meshPointMapPtr_)
{
@ -446,16 +331,12 @@ meshPointMap() const
}
template
template<class FaceList, class PointField>
const Foam::Field
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
localPoints() const
typename Foam::PrimitivePatch<FaceList, PointField>::point_type
>&
Foam::PrimitivePatch<FaceList, PointField>::localPoints() const
{
if (!localPointsPtr_)
{
@ -466,16 +347,9 @@ localPoints() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::labelList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
localPointOrder() const
Foam::PrimitivePatch<FaceList, PointField>::localPointOrder() const
{
if (!localPointOrderPtr_)
{
@ -486,16 +360,9 @@ localPointOrder() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
Foam::label
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
whichPoint
Foam::PrimitivePatch<FaceList, PointField>::whichPoint
(
const label gp
) const
@ -505,16 +372,12 @@ whichPoint
}
template
template<class FaceList, class PointField>
const Foam::Field
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceCentres() const
typename Foam::PrimitivePatch<FaceList, PointField>::point_type
>&
Foam::PrimitivePatch<FaceList, PointField>::faceCentres() const
{
if (!faceCentresPtr_)
{
@ -525,16 +388,12 @@ faceCentres() const
}
template
template<class FaceList, class PointField>
const Foam::Field
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceAreas() const
typename Foam::PrimitivePatch<FaceList, PointField>::point_type
>&
Foam::PrimitivePatch<FaceList, PointField>::faceAreas() const
{
if (!faceAreasPtr_)
{
@ -545,16 +404,9 @@ faceAreas() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::Field<Foam::scalar>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
magFaceAreas() const
Foam::PrimitivePatch<FaceList, PointField>::magFaceAreas() const
{
if (!magFaceAreasPtr_)
{
@ -565,16 +417,12 @@ magFaceAreas() const
}
template
template<class FaceList, class PointField>
const Foam::Field
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
faceNormals() const
typename Foam::PrimitivePatch<FaceList, PointField>::point_type
>&
Foam::PrimitivePatch<FaceList, PointField>::faceNormals() const
{
if (!faceNormalsPtr_)
{
@ -585,16 +433,12 @@ faceNormals() const
}
template
template<class FaceList, class PointField>
const Foam::Field
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
const Foam::Field<PointType>&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
pointNormals() const
typename Foam::PrimitivePatch<FaceList, PointField>::point_type
>&
Foam::PrimitivePatch<FaceList, PointField>::pointNormals() const
{
if (!pointNormalsPtr_)
{
@ -607,23 +451,43 @@ pointNormals() const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
operator=
Foam::PrimitivePatch<FaceList, PointField>::operator=
(
const PrimitivePatch<Face, FaceList, PointField, PointType>& pp
const PrimitivePatch<FaceList, PointField>& rhs
)
{
if (&rhs == this)
{
return;
}
clearOut();
FaceList<Face>::shallowCopy(pp);
FaceList::shallowCopy(rhs);
// Cannot copy assign points (could be const reference)
}
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<FaceList, PointField>::operator=
(
PrimitivePatch<FaceList, PointField>&& rhs
)
{
if (&rhs == this)
{
return;
}
clearOut();
FaceList::operator=(std::move(rhs));
// Cannot move assign points (could be const reference)
}

View File

@ -67,6 +67,7 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class face;
template<class T> class Map;
@ -81,38 +82,33 @@ TemplateName(PrimitivePatch);
Class PrimitivePatch Declaration
\*---------------------------------------------------------------------------*/
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType=point
>
template<class FaceList, class PointField>
class PrimitivePatch
:
public PrimitivePatchName,
public FaceList<Face>
public FaceList
{
public:
// Public Typedefs
//- The face type
typedef Face face_type;
typedef typename
std::remove_reference<FaceList>::type::value_type face_type;
//- The point type
typedef PointType point_type;
typedef typename
std::remove_reference<PointField>::type::value_type point_type;
//- The face list type
typedef FaceList<Face> FaceListType;
typedef FaceList FaceListType;
//- The point field type
typedef PointField PointFieldType;
//- Deprecated(2020-03) prefer face_type typedef
// \deprecated(2020-03) prefer face_type typedef
typedef Face FaceType;
typedef face_type FaceType;
// Public Data Types
@ -138,62 +134,62 @@ private:
//- Edges of the patch; address into local point list;
// sorted with internal edges first in upper-triangular order
// and external edges last.
mutable edgeList* edgesPtr_;
mutable unique_ptr<edgeList> edgesPtr_;
//- Which part of edgesPtr_ is internal edges.
mutable label nInternalEdges_;
//- Boundary point labels, addressing into local point list
mutable labelList* boundaryPointsPtr_;
mutable unique_ptr<labelList> boundaryPointsPtr_;
//- Face-face addressing
mutable labelListList* faceFacesPtr_;
mutable unique_ptr<labelListList> faceFacesPtr_;
//- Edge-face addressing
mutable labelListList* edgeFacesPtr_;
mutable unique_ptr<labelListList> edgeFacesPtr_;
//- Face-edge addressing
mutable labelListList* faceEdgesPtr_;
mutable unique_ptr<labelListList> faceEdgesPtr_;
//- Point-edge addressing
mutable labelListList* pointEdgesPtr_;
mutable unique_ptr<labelListList> pointEdgesPtr_;
//- Point-face addressing
mutable labelListList* pointFacesPtr_;
mutable unique_ptr<labelListList> pointFacesPtr_;
//- Faces addressing into local point list
mutable List<Face>* localFacesPtr_;
mutable unique_ptr<List<face_type>> localFacesPtr_;
//- Labels of mesh points
mutable labelList* meshPointsPtr_;
mutable unique_ptr<labelList> meshPointsPtr_;
//- Mesh point map. Given the global point index find its
//- location in the patch
mutable Map<label>* meshPointMapPtr_;
mutable unique_ptr<Map<label>> meshPointMapPtr_;
//- Outside edge loops
mutable labelListList* edgeLoopsPtr_;
mutable unique_ptr<labelListList> edgeLoopsPtr_;
//- Points local to patch
mutable Field<PointType>* localPointsPtr_;
mutable unique_ptr<Field<point_type>> localPointsPtr_;
//- Local point order for most efficient search
mutable labelList* localPointOrderPtr_;
mutable unique_ptr<labelList> localPointOrderPtr_;
//- Face centres
mutable Field<PointType>* faceCentresPtr_;
mutable unique_ptr<Field<point_type>> faceCentresPtr_;
//- Face area vectors
mutable Field<PointType>* faceAreasPtr_;
mutable unique_ptr<Field<point_type>> faceAreasPtr_;
//- Mag face area
mutable Field<scalar>* magFaceAreasPtr_;
mutable unique_ptr<Field<scalar>> magFaceAreasPtr_;
//- Face unit normals
mutable Field<PointType>* faceNormalsPtr_;
mutable unique_ptr<Field<point_type>> faceNormalsPtr_;
//- Point unit normals
mutable Field<PointType>* pointNormalsPtr_;
mutable unique_ptr<Field<point_type>> pointNormalsPtr_;
// Private Member Functions
@ -263,30 +259,27 @@ public:
//- Construct from components
PrimitivePatch
(
const FaceList<Face>& faces,
const Field<PointType>& points
const FaceList& faces,
const PointField& points
);
//- Construct from components, transferring faces
PrimitivePatch
(
FaceList<Face>&& faces,
const Field<PointType>& points
FaceList&& faces,
const PointField& points
);
//- Construct from components, reuse storage
PrimitivePatch
(
FaceList<Face>& faces,
Field<PointType>& points,
FaceList& faces,
PointField& points,
const bool reuse
);
//- Construct as copy
PrimitivePatch
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&
);
//- Copy construct
PrimitivePatch(const PrimitivePatch<FaceList, PointField>& pp);
//- Destructor
@ -310,7 +303,7 @@ public:
// Access
//- Return reference to global points
const Field<PointType>& points() const
const Field<point_type>& points() const
{
return points_;
}
@ -363,7 +356,7 @@ public:
const labelListList& pointFaces() const;
//- Return patch faces addressing into local point list
const List<Face>& localFaces() const;
const List<face_type>& localFaces() const;
// Addressing into mesh
@ -378,7 +371,7 @@ public:
const Map<label>& meshPointMap() const;
//- Return pointField of points in patch
const Field<PointType>& localPoints() const;
const Field<point_type>& localPoints() const;
//- Return orders the local points for most efficient search
const labelList& localPointOrder() const;
@ -409,27 +402,27 @@ public:
) const;
//- Return face centres for patch
const Field<PointType>& faceCentres() const;
const Field<point_type>& faceCentres() const;
//- Return face area vectors for patch
const Field<PointType>& faceAreas() const;
const Field<point_type>& faceAreas() const;
//- Return face area magnitudes for patch
const Field<scalar>& magFaceAreas() const;
//- Return face unit normals for patch
const Field<PointType>& faceNormals() const;
const Field<point_type>& faceNormals() const;
//- Return point normals for patch
const Field<PointType>& pointNormals() const;
const Field<point_type>& pointNormals() const;
// Storage Management
inline bool hasFaceAreas() const { return faceAreasPtr_; }
inline bool hasFaceCentres() const { return faceCentresPtr_; }
inline bool hasFaceNormals() const { return faceNormalsPtr_; }
inline bool hasPointNormals() const { return pointNormalsPtr_; }
bool hasFaceAreas() const { return bool(faceAreasPtr_); }
bool hasFaceCentres() const { return bool(faceCentresPtr_); }
bool hasFaceNormals() const { return bool(faceNormalsPtr_); }
bool hasPointNormals() const { return bool(pointNormalsPtr_); }
// Other patch operations
@ -439,7 +432,7 @@ public:
List<objectHit> projectPoints
(
const ToPatch& targetPatch,
const Field<PointType>& projectionDirection,
const Field<point_type>& projectionDirection,
const intersection::algorithm = intersection::FULL_RAY,
const intersection::direction = intersection::VECTOR
) const;
@ -449,7 +442,7 @@ public:
List<objectHit> projectFaceCentres
(
const ToPatch& targetPatch,
const Field<PointType>& projectionDirection,
const Field<point_type>& projectionDirection,
const intersection::algorithm = intersection::FULL_RAY,
const intersection::direction = intersection::VECTOR
) const;
@ -494,16 +487,16 @@ public:
// Edit
//- Correct patch after moving points
virtual void movePoints(const Field<PointType>&);
virtual void movePoints(const Field<point_type>&);
// Member Operators
//- Assignment
void operator=
(
const PrimitivePatch<Face, FaceList, PointField, PointType>&
);
//- Copy assign faces. Leave points alone (could be a reference).
void operator=(const PrimitivePatch<FaceList, PointField>& rhs);
//- Move assign faces. Leave points alone (could be a reference).
void operator=(PrimitivePatch<FaceList, PointField>&& rhs);
};

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,26 +40,13 @@ Description
#include "PrimitivePatch.H"
#include "DynamicList.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcAddressing() const
Foam::PrimitivePatch<FaceList, PointField>::calcAddressing() const
{
if (debug)
{
Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
<< "calcAddressing() : calculating patch addressing"
<< endl;
}
DebugInFunction << "Calculating patch addressing" << nl;
if (edgesPtr_ || faceFacesPtr_ || edgeFacesPtr_ || faceEdgesPtr_)
{
@ -69,31 +57,31 @@ calcAddressing() const
}
// get reference to localFaces
const List<Face>& locFcs = localFaces();
const List<face_type>& locFcs = localFaces();
// get reference to pointFaces
const labelListList& pf = pointFaces();
// Guess the max number of edges and neighbours for a face
label maxEdges = 0;
forAll(locFcs, facei)
for (const auto& f : locFcs)
{
maxEdges += locFcs[facei].size();
maxEdges += f.size();
}
// create the lists for the various results. (resized on completion)
edgesPtr_ = new edgeList(maxEdges);
edgeList& edges = *edgesPtr_;
edgesPtr_.reset(new edgeList(maxEdges));
auto& edges = *edgesPtr_;
edgeFacesPtr_ = new labelListList(maxEdges);
labelListList& edgeFaces = *edgeFacesPtr_;
edgeFacesPtr_.reset(new labelListList(maxEdges));
auto& edgeFaces = *edgeFacesPtr_;
// faceFaces created using a dynamic list. Cannot guess size because
// of multiple connections
List<DynamicList<label>> ff(locFcs.size());
faceEdgesPtr_ = new labelListList(locFcs.size());
labelListList& faceEdges = *faceEdgesPtr_;
faceEdgesPtr_.reset(new labelListList(locFcs.size()));
auto& faceEdges = *faceEdgesPtr_;
// count the number of face neighbours
labelList noFaceFaces(locFcs.size());
@ -129,7 +117,7 @@ calcAddressing() const
forAll(locFcs, facei)
{
// Get reference to vertices of current face and corresponding edges.
const Face& curF = locFcs[facei];
const face_type& curF = locFcs[facei];
const edgeList& curEdges = faceIntoEdges[facei];
// Record the neighbour face. Multiple connectivity allowed
@ -283,8 +271,8 @@ calcAddressing() const
edgeFaces.setSize(nEdges);
// faceFaces list
faceFacesPtr_ = new labelListList(locFcs.size());
labelListList& faceFaces = *faceFacesPtr_;
faceFacesPtr_.reset(new labelListList(locFcs.size()));
auto& faceFaces = *faceFacesPtr_;
forAll(faceFaces, facei)
{
@ -292,12 +280,7 @@ calcAddressing() const
}
if (debug)
{
Info<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
<< "calcAddressing() : finished calculating patch addressing"
<< endl;
}
DebugInFunction << "Calculated patch addressing" << nl;
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,21 +31,11 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcBdryPoints() const
Foam::PrimitivePatch<FaceList, PointField>::calcBdryPoints() const
{
if (debug)
{
InfoInFunction << "Calculating boundary points" << endl;
}
DebugInFunction << "Calculating boundary points" << nl;
if (boundaryPointsPtr_)
{
@ -66,12 +57,9 @@ calcBdryPoints() const
bp.insert(curEdge.end());
}
boundaryPointsPtr_ = new labelList(bp.sortedToc());
boundaryPointsPtr_.reset(new labelList(bp.sortedToc()));
if (debug)
{
Info<< " Finished." << endl;
}
DebugInfo << " Finished." << nl;
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,16 +35,9 @@ Description
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
visitPointRegion
Foam::PrimitivePatch<FaceList, PointField>::visitPointRegion
(
const label pointi,
const labelList& pFaces,
@ -109,22 +103,11 @@ visitPointRegion
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
typename
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::surfaceTopo
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
surfaceType() const
template<class FaceList, class PointField>
typename Foam::PrimitivePatch<FaceList, PointField>::surfaceTopo
Foam::PrimitivePatch<FaceList, PointField>::surfaceType() const
{
if (debug)
{
InfoInFunction << "Calculating patch topology" << endl;
}
DebugInFunction << "Calculating patch topology" << nl;
const labelListList& edgeFcs = edgeFaces();
@ -148,34 +131,21 @@ surfaceType() const
}
}
if (debug)
{
Info<< " Finished." << endl;
}
DebugInFunction << "Calculated patch topology" << nl;
return pType;
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
bool
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
checkTopology
Foam::PrimitivePatch<FaceList, PointField>::checkTopology
(
const bool report,
labelHashSet* setPtr
) const
{
if (debug)
{
InfoInFunction << "Checking patch topology" << endl;
}
DebugInFunction << "Checking patch topology" << nl;
// Check edgeFaces
@ -208,25 +178,15 @@ checkTopology
}
}
if (debug)
{
Info<< " Finished." << endl;
}
DebugInFunction << "Checked patch topology" << nl;
return illegalTopo;
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
bool
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
checkPointManifold
Foam::PrimitivePatch<FaceList, PointField>::checkPointManifold
(
const bool report,
labelHashSet* setPtr

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,108 +27,62 @@ License
\*---------------------------------------------------------------------------*/
#include "PrimitivePatch.H"
#include "demandDrivenData.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearGeom()
Foam::PrimitivePatch<FaceList, PointField>::clearGeom()
{
if (debug)
{
InfoInFunction << "Clearing geometric data" << endl;
}
DebugInFunction << "Clearing geometric data" << nl;
deleteDemandDrivenData(localPointsPtr_);
deleteDemandDrivenData(faceCentresPtr_);
deleteDemandDrivenData(faceAreasPtr_);
deleteDemandDrivenData(magFaceAreasPtr_);
deleteDemandDrivenData(faceNormalsPtr_);
deleteDemandDrivenData(pointNormalsPtr_);
localPointsPtr_.reset(nullptr);
faceCentresPtr_.reset(nullptr);
faceAreasPtr_.reset(nullptr);
magFaceAreasPtr_.reset(nullptr);
faceNormalsPtr_.reset(nullptr);
pointNormalsPtr_.reset(nullptr);
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearTopology()
Foam::PrimitivePatch<FaceList, PointField>::clearTopology()
{
if (debug)
{
InfoInFunction << "Clearing patch addressing" << endl;
}
DebugInFunction << "Clearing patch addressing" << nl;
// group created and destroyed together
if (edgesPtr_ && faceFacesPtr_ && edgeFacesPtr_ && faceEdgesPtr_)
{
delete edgesPtr_;
edgesPtr_ = nullptr;
delete faceFacesPtr_;
faceFacesPtr_ = nullptr;
delete edgeFacesPtr_;
edgeFacesPtr_ = nullptr;
delete faceEdgesPtr_;
faceEdgesPtr_ = nullptr;
edgesPtr_.reset(nullptr);
faceFacesPtr_.reset(nullptr);
edgeFacesPtr_.reset(nullptr);
faceEdgesPtr_.reset(nullptr);
}
deleteDemandDrivenData(boundaryPointsPtr_);
deleteDemandDrivenData(pointEdgesPtr_);
deleteDemandDrivenData(pointFacesPtr_);
deleteDemandDrivenData(edgeLoopsPtr_);
deleteDemandDrivenData(localPointOrderPtr_);
boundaryPointsPtr_.reset(nullptr);
pointEdgesPtr_.reset(nullptr);
pointFacesPtr_.reset(nullptr);
edgeLoopsPtr_.reset(nullptr);
localPointOrderPtr_.reset(nullptr);
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearPatchMeshAddr()
Foam::PrimitivePatch<FaceList, PointField>::clearPatchMeshAddr()
{
if (debug)
{
InfoInFunction << "Clearing patch-mesh addressing" << endl;
}
DebugInFunction << "Clearing patch-mesh addressing" << nl;
deleteDemandDrivenData(meshPointsPtr_);
deleteDemandDrivenData(meshPointMapPtr_);
deleteDemandDrivenData(localFacesPtr_);
meshPointsPtr_.reset(nullptr);
meshPointMapPtr_.reset(nullptr);
localFacesPtr_.reset(nullptr);
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
clearOut()
Foam::PrimitivePatch<FaceList, PointField>::clearOut()
{
clearGeom();
clearTopology();

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,24 +32,13 @@ Description
#include "PrimitivePatch.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcEdgeLoops() const
Foam::PrimitivePatch<FaceList, PointField>::calcEdgeLoops() const
{
if (debug)
{
InfoInFunction << "Calculating boundary edge loops" << endl;
}
DebugInFunction << "Calculating boundary edge loops" << endl;
if (edgeLoopsPtr_)
{
@ -64,7 +54,7 @@ calcEdgeLoops() const
if (nBdryEdges == 0)
{
edgeLoopsPtr_ = new labelListList(0);
edgeLoopsPtr_.reset(new labelListList(0));
return;
}
@ -79,8 +69,8 @@ calcEdgeLoops() const
labelList loopNumber(nBdryEdges, -1);
// Size return list plenty big
edgeLoopsPtr_ = new labelListList(nBdryEdges);
labelListList& edgeLoops = *edgeLoopsPtr_;
edgeLoopsPtr_.reset(new labelListList(nBdryEdges));
auto& edgeLoops = *edgeLoopsPtr_;
// Current loop number.
@ -149,23 +139,13 @@ calcEdgeLoops() const
edgeLoops.setSize(loopI);
if (debug)
{
Info<< " Finished." << endl;
}
DebugInFunction << "Calculated boundary edge loops" << nl;
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
const Foam::labelListList&
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
edgeLoops() const
Foam::PrimitivePatch<FaceList, PointField>::edgeLoops() const
{
if (!edgeLoopsPtr_)
{

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,24 +34,16 @@ Description
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcLocalPointOrder() const
Foam::PrimitivePatch<FaceList, PointField>::calcLocalPointOrder() const
{
// Note: Cannot use bandCompressing as point-point addressing does
// not exist and is not considered generally useful.
//
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
<< "calcLocalPointOrder() : "
<< "calculating local point order"
<< endl;
@ -64,15 +57,14 @@ calcLocalPointOrder() const
<< abort(FatalError);
}
const List<Face>& lf = localFaces();
const List<face_type>& lf = localFaces();
const labelListList& ff = faceFaces();
boolList visitedFace(lf.size(), false);
localPointOrderPtr_ = new labelList(meshPoints().size(), -1);
labelList& pointOrder = *localPointOrderPtr_;
localPointOrderPtr_.reset(new labelList(meshPoints().size(), -1));
auto& pointOrder = *localPointOrderPtr_;
boolList visitedPoint(pointOrder.size(), false);
@ -126,7 +118,7 @@ calcLocalPointOrder() const
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
<< "calcLocalPointOrder() "
<< "finished calculating local point order"
<< endl;

View File

@ -31,20 +31,13 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcMeshData() const
Foam::PrimitivePatch<FaceList, PointField>::calcMeshData() const
{
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMeshData() : "
"calculating mesh data in PrimitivePatch"
<< endl;
@ -73,7 +66,7 @@ calcMeshData() const
//// if the point is used, set the mark to 1
//forAll(*this, facei)
//{
// const Face& curPoints = this->operator[](facei);
// const face_type& curPoints = this->operator[](facei);
//
// forAll(curPoints, pointi)
// {
@ -83,8 +76,8 @@ calcMeshData() const
//
//// Create the storage and store the meshPoints. Mesh points are
//// the ones marked by the usage loop above
//meshPointsPtr_ = new labelList(markedPoints.toc());
//labelList& pointPatch = *meshPointsPtr_;
//meshPointsPtr_.reset(new labelList(markedPoints.toc()));
//auto& pointPatch = *meshPointsPtr_;
//
//// Sort the list to preserve compatibility with the old ordering
//sort(pointPatch);
@ -97,42 +90,36 @@ calcMeshData() const
//- Unsorted version:
DynamicList<label> meshPoints(2*this->size());
forAll(*this, facei)
for (const face_type& f : *this)
{
const Face& curPoints = this->operator[](facei);
forAll(curPoints, pointi)
for (const label pointi : f)
{
if (markedPoints.insert(curPoints[pointi], meshPoints.size()))
if (markedPoints.insert(pointi, meshPoints.size()))
{
meshPoints.append(curPoints[pointi]);
meshPoints.append(pointi);
}
}
}
// Transfer to straight list (reuses storage)
meshPointsPtr_ = new labelList(meshPoints, true);
meshPointsPtr_.reset(new labelList(meshPoints, true));
// Create local faces. Deep-copy original faces to retain additional
// data (e.g. region number of labelledTri)
// The vertices will be overwritten later
localFacesPtr_.reset(new List<face_type>(*this));
auto& locFaces = *localFacesPtr_;
// Create local faces. Note that we start off from copy of original face
// list (even though vertices are overwritten below). This is done so
// additional data gets copied (e.g. region number of labelledTri)
localFacesPtr_ = new List<Face>(*this);
List<Face>& lf = *localFacesPtr_;
forAll(*this, facei)
for (face_type& f : locFaces)
{
const Face& curFace = this->operator[](facei);
lf[facei].setSize(curFace.size());
forAll(curFace, labelI)
for (label& pointi : f)
{
lf[facei][labelI] = markedPoints.find(curFace[labelI])();
pointi = *(markedPoints.cfind(pointi));
}
}
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMeshData() : "
"finished calculating mesh data in PrimitivePatch"
<< endl;
@ -140,20 +127,13 @@ calcMeshData() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcMeshPointMap() const
Foam::PrimitivePatch<FaceList, PointField>::calcMeshPointMap() const
{
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMeshPointMap() : "
"calculating mesh point map in PrimitivePatch"
<< endl;
@ -169,8 +149,8 @@ calcMeshPointMap() const
const labelList& mp = meshPoints();
meshPointMapPtr_ = new Map<label>(2*mp.size());
Map<label>& mpMap = *meshPointMapPtr_;
meshPointMapPtr_.reset(new Map<label>(2*mp.size()));
auto& mpMap = *meshPointMapPtr_;
forAll(mp, i)
{
@ -179,7 +159,7 @@ calcMeshPointMap() const
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMeshPointMap() : "
"finished calculating mesh point map in PrimitivePatch"
<< endl;
@ -187,20 +167,13 @@ calcMeshPointMap() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcLocalPoints() const
Foam::PrimitivePatch<FaceList, PointField>::calcLocalPoints() const
{
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcLocalPoints() : "
"calculating localPoints in PrimitivePatch"
<< endl;
@ -216,9 +189,8 @@ calcLocalPoints() const
const labelList& meshPts = meshPoints();
localPointsPtr_ = new Field<PointType>(meshPts.size());
Field<PointType>& locPts = *localPointsPtr_;
localPointsPtr_.reset(new Field<point_type>(meshPts.size()));
auto& locPts = *localPointsPtr_;
forAll(meshPts, pointi)
{
@ -227,7 +199,7 @@ calcLocalPoints() const
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
<< "calcLocalPoints() : "
<< "finished calculating localPoints in PrimitivePatch"
<< endl;
@ -235,20 +207,13 @@ calcLocalPoints() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcPointNormals() const
Foam::PrimitivePatch<FaceList, PointField>::calcPointNormals() const
{
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcPointNormals() : "
"calculating pointNormals in PrimitivePatch"
<< endl;
@ -262,21 +227,16 @@ calcPointNormals() const
<< abort(FatalError);
}
const Field<PointType>& faceUnitNormals = faceNormals();
const auto& faceUnitNormals = faceNormals();
const labelListList& pf = pointFaces();
pointNormalsPtr_ = new Field<PointType>
(
meshPoints().size(),
PointType::zero
);
Field<PointType>& n = *pointNormalsPtr_;
pointNormalsPtr_.reset(new Field<point_type>(meshPoints().size(), Zero));
auto& n = *pointNormalsPtr_;
forAll(pf, pointi)
{
PointType& curNormal = n[pointi];
point_type& curNormal = n[pointi];
const labelList& curFaces = pf[pointi];
@ -290,7 +250,7 @@ calcPointNormals() const
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcPointNormals() : "
"finished calculating pointNormals in PrimitivePatch"
<< endl;
@ -298,20 +258,13 @@ calcPointNormals() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcFaceCentres() const
Foam::PrimitivePatch<FaceList, PointField>::calcFaceCentres() const
{
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceCentres() : "
"calculating faceCentres in PrimitivePatch"
<< endl;
@ -325,9 +278,8 @@ calcFaceCentres() const
<< abort(FatalError);
}
faceCentresPtr_ = new Field<PointType>(this->size());
Field<PointType>& c = *faceCentresPtr_;
faceCentresPtr_.reset(new Field<point_type>(this->size()));
auto& c = *faceCentresPtr_;
forAll(c, facei)
{
@ -336,7 +288,7 @@ calcFaceCentres() const
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceCentres() : "
"finished calculating faceCentres in PrimitivePatch"
<< endl;
@ -344,20 +296,13 @@ calcFaceCentres() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcMagFaceAreas() const
Foam::PrimitivePatch<FaceList, PointField>::calcMagFaceAreas() const
{
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMagFaceAreas() : "
"calculating magFaceAreas in PrimitivePatch"
<< endl;
@ -371,8 +316,8 @@ calcMagFaceAreas() const
<< abort(FatalError);
}
magFaceAreasPtr_ = new Field<scalar>(this->size());
Field<scalar>& a = *magFaceAreasPtr_;
magFaceAreasPtr_.reset(new Field<scalar>(this->size()));
auto& a = *magFaceAreasPtr_;
forAll(a, facei)
{
@ -381,7 +326,7 @@ calcMagFaceAreas() const
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMagFaceAreas() : "
"finished calculating magFaceAreas in PrimitivePatch"
<< endl;
@ -389,20 +334,13 @@ calcMagFaceAreas() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcFaceAreas() const
Foam::PrimitivePatch<FaceList, PointField>::calcFaceAreas() const
{
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceAreas() : "
"calculating faceAreas in PrimitivePatch"
<< endl;
@ -416,9 +354,8 @@ calcFaceAreas() const
<< abort(FatalError);
}
faceAreasPtr_ = new Field<PointType>(this->size());
Field<PointType>& n = *faceAreasPtr_;
faceAreasPtr_.reset(new Field<point_type>(this->size()));
auto& n = *faceAreasPtr_;
forAll(n, facei)
{
@ -427,7 +364,7 @@ calcFaceAreas() const
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceAreas() : "
"finished calculating faceAreas in PrimitivePatch"
<< endl;
@ -435,20 +372,13 @@ calcFaceAreas() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcFaceNormals() const
Foam::PrimitivePatch<FaceList, PointField>::calcFaceNormals() const
{
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceNormals() : "
"calculating faceNormals in PrimitivePatch"
<< endl;
@ -462,9 +392,8 @@ calcFaceNormals() const
<< abort(FatalError);
}
faceNormalsPtr_ = new Field<PointType>(this->size());
Field<PointType>& n = *faceNormalsPtr_;
faceNormalsPtr_.reset(new Field<point_type>(this->size()));
auto& n = *faceNormalsPtr_;
forAll(n, facei)
{
@ -473,7 +402,7 @@ calcFaceNormals() const
if (debug)
{
Pout<< "PrimitivePatch<Face, FaceList, PointField, PointType>::"
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceNormals() : "
"finished calculating faceNormals in PrimitivePatch"
<< endl;

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,18 +28,11 @@ License
#include "PrimitivePatch.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
Foam::labelList
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
Foam::PrimitivePatch<FaceList, PointField>::
meshEdges
(
const edgeList& allEdges,
@ -46,13 +40,8 @@ meshEdges
const labelList& faceCells
) const
{
if (debug)
{
Info<< "labelList PrimitivePatch<Face, FaceList, PointField, PointType>"
<< "::meshEdges() : "
<< "calculating labels of patch edges in mesh edge list"
<< endl;
}
DebugInFunction
<< "Calculating labels of patch edges in mesh edge list" << nl;
// get reference to the list of edges on the patch
const edgeList& PatchEdges = edges();
@ -107,28 +96,16 @@ meshEdges
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
Foam::labelList
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
meshEdges
Foam::PrimitivePatch<FaceList, PointField>::meshEdges
(
const edgeList& allEdges,
const labelListList& pointEdges
) const
{
if (debug)
{
Info<< "labelList PrimitivePatch<Face, FaceList, PointField, PointType>"
<< "::meshEdges() : "
<< "calculating labels of patch edges in mesh edge list"
<< endl;
}
DebugInFunction
<< "Calculating labels of patch edges in mesh edge list" << nl;
// get reference to the list of edges on the patch
const edgeList& PatchEdges = edges();
@ -164,16 +141,9 @@ meshEdges
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
Foam::label
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
whichEdge
Foam::PrimitivePatch<FaceList, PointField>::whichEdge
(
const edge& e
) const

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -35,19 +35,11 @@ Description
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcPointEdges() const
Foam::PrimitivePatch<FaceList, PointField>::calcPointEdges() const
{
DebugInFunction
<< "Calculating pointEdges" << endl;
DebugInFunction << "Calculating pointEdges" << endl;
if (pointEdgesPtr_)
{
@ -57,9 +49,8 @@ calcPointEdges() const
<< abort(FatalError);
}
pointEdgesPtr_ = new labelListList(meshPoints().size());
labelListList& pe = *pointEdgesPtr_;
pointEdgesPtr_.reset(new labelListList(meshPoints().size()));
auto& pe = *pointEdgesPtr_;
invertManyToMany(pe.size(), edges(), pe);
@ -68,16 +59,9 @@ calcPointEdges() const
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
void
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
calcPointFaces() const
Foam::PrimitivePatch<FaceList, PointField>::calcPointFaces() const
{
DebugInFunction
<< "Calculating pointFaces" << endl;
@ -90,14 +74,14 @@ calcPointFaces() const
<< abort(FatalError);
}
const List<Face>& f = localFaces();
const List<face_type>& locFcs = localFaces();
// set up storage for pointFaces
List<SLList<label>> pointFcs(meshPoints().size());
forAll(f, facei)
forAll(locFcs, facei)
{
const Face& curPoints = f[facei];
const face_type& curPoints = locFcs[facei];
for (const label pointi : curPoints)
{
@ -105,20 +89,13 @@ calcPointFaces() const
}
}
// sort out the list
pointFacesPtr_ = new labelListList(pointFcs.size());
labelListList& pf = *pointFacesPtr_;
// Copy the list
pointFacesPtr_.reset(new labelListList(pointFcs.size()));
auto& pf = *pointFacesPtr_;
forAll(pointFcs, pointi)
{
pf[pointi].setSize(pointFcs[pointi].size());
label i = 0;
for (const label facei : pointFcs[pointi])
{
pf[pointi][i++] = facei;
}
pf[pointi] = pointFcs[pointi];
}
DebugInfo

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,20 +37,16 @@ Description
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
template<class ToPatch>
Foam::List<Foam::objectHit>
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
projectPoints
Foam::PrimitivePatch<FaceList, PointField>::projectPoints
(
const ToPatch& targetPatch,
const Field<PointType>& projectionDirection,
const Field
<
typename Foam::PrimitivePatch<FaceList, PointField>::point_type
>& projectionDirection,
const intersection::algorithm alg,
const intersection::direction dir
) const
@ -77,10 +74,10 @@ projectPoints
const ToPatch& masterFaces = targetPatch;
const Field<PointType>& masterPoints = targetPatch.points();
const Field<point_type>& masterPoints = targetPatch.points();
// Estimate face centre of target side
Field<PointType> masterFaceCentres(targetPatch.size());
Field<point_type> masterFaceCentres(targetPatch.size());
forAll(masterFaceCentres, facei)
{
@ -104,10 +101,10 @@ projectPoints
// Pick up slave point and direction
const label curLocalPointLabel = slavePointOrder[pointi];
const PointType& curPoint =
const point_type& curPoint =
points_[slaveMeshPoints[curLocalPointLabel]];
const PointType& curProjectionDir =
const point_type& curProjectionDir =
projectionDirection[curLocalPointLabel];
bool closer;
@ -133,7 +130,7 @@ projectPoints
doNSquaredSearch = false;
// Calculate intersection with curFace
PointHit<PointType> curHit =
PointHit<point_type> curHit =
masterFaces[curFace].ray
(
curPoint,
@ -169,7 +166,7 @@ projectPoints
// face. This is cooked (illogical!) for fastest
// surface walk.
//
PointType missPlanePoint =
point_type missPlanePoint =
curPoint + curProjectionDir*curHit.distance();
const labelList& masterNbrs = masterFaceFaces[curFace];
@ -224,7 +221,7 @@ projectPoints
forAll(masterFaces, facei)
{
PointHit<PointType> curHit =
PointHit<point_type> curHit =
masterFaces[facei].ray
(
curPoint,
@ -279,20 +276,16 @@ projectPoints
}
template
<
class Face,
template<class> class FaceList,
class PointField,
class PointType
>
template<class FaceList, class PointField>
template<class ToPatch>
Foam::List<Foam::objectHit>
Foam::PrimitivePatch<Face, FaceList, PointField, PointType>::
projectFaceCentres
Foam::PrimitivePatch<FaceList, PointField>::projectFaceCentres
(
const ToPatch& targetPatch,
const Field<PointType>& projectionDirection,
const Field
<
typename Foam::PrimitivePatch<FaceList, PointField>::point_type
>& projectionDirection,
const intersection::algorithm alg,
const intersection::direction dir
) const
@ -311,7 +304,7 @@ projectFaceCentres
labelList slaveFaceOrder = bandCompression(faceFaces());
// calculate master face centres
Field<PointType> masterFaceCentres(targetPatch.size());
Field<point_type> masterFaceCentres(targetPatch.size());
const labelListList& masterFaceFaces = targetPatch.faceFaces();
@ -328,8 +321,7 @@ projectFaceCentres
// Result
List<objectHit> result(this->size());
const PrimitivePatch<Face, FaceList, PointField, PointType>& slaveFaces =
*this;
const PrimitivePatch<FaceList, PointField>& slaveFaces = *this;
const PointField& slaveGlobalPoints = points();
@ -378,7 +370,7 @@ projectFaceCentres
doNSquaredSearch = false;
// Calculate intersection with curFace
PointHit<PointType> curHit =
PointHit<point_type> curHit =
masterFaces[curFace].ray
(
curFaceCentre,
@ -413,7 +405,7 @@ projectFaceCentres
// Calculate the miss point. This is
// cooked (illogical!) for fastest surface walk.
//
PointType missPlanePoint =
point_type missPlanePoint =
curFaceCentre + curProjectionDir*curHit.distance();
sqrDistance =
@ -465,7 +457,7 @@ projectFaceCentres
forAll(masterFaces, facei)
{
PointHit<PointType> curHit =
PointHit<point_type> curHit =
masterFaces[facei].ray
(
curFaceCentre,

View File

@ -45,7 +45,7 @@ Description
namespace Foam
{
typedef PrimitivePatch<face, IndirectList, const pointField&>
typedef PrimitivePatch<IndirectList<face>, const pointField&>
indirectPrimitivePatch;
}

View File

@ -47,7 +47,7 @@ Description
namespace Foam
{
typedef PrimitivePatch<face, List, const pointField&>
typedef PrimitivePatch<List<face>, const pointField&>
primitiveFacePatch;
}

View File

@ -47,7 +47,7 @@ Description
namespace Foam
{
typedef PrimitivePatch<face, SubList, const pointField&>
typedef PrimitivePatch<SubList<face>, const pointField&>
primitivePatch;
}

View File

@ -45,7 +45,7 @@ Description
namespace Foam
{
typedef PrimitivePatch<face, UIndirectList, const pointField&>
typedef PrimitivePatch<UIndirectList<face>, const pointField&>
uindirectPrimitivePatch;
}

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -44,7 +45,7 @@ Description
namespace Foam
{
typedef PrimitivePatch<face, List, const pointField> bMesh;
typedef PrimitivePatch<List<face>, const pointField> bMesh;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -56,7 +56,7 @@ class pairPatchAgglomeration
{
protected:
typedef PrimitivePatch<face, List, const pointField> bPatch;
typedef PrimitivePatch<List<face>, const pointField> bPatch;
// Protected data

View File

@ -541,7 +541,7 @@ Foam::extendedEdgeMesh::extendedEdgeMesh
Foam::extendedEdgeMesh::extendedEdgeMesh
(
const PrimitivePatch<face, List, pointField, point>& surf,
const PrimitivePatch<faceList, pointField>& surf,
const labelUList& featureEdges,
const labelUList& regionFeatureEdges,
const labelUList& featurePoints

View File

@ -308,7 +308,7 @@ public:
//- Construct from PrimitivePatch
extendedEdgeMesh
(
const PrimitivePatch<face, List, pointField, point>& surf,
const PrimitivePatch<faceList, pointField>& surf,
const labelUList& featureEdges,
const labelUList& regionFeatureEdges,
const labelUList& featurePoints

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -122,7 +123,7 @@ Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
(
const IOobject& io,
const PrimitivePatch<face, List, pointField, point>& surf,
const PrimitivePatch<faceList, pointField>& surf,
const labelUList& featureEdges,
const labelUList& regionFeatureEdges,
const labelUList& featurePoints

View File

@ -94,7 +94,7 @@ public:
extendedFeatureEdgeMesh
(
const IOobject& io,
const PrimitivePatch<face, List, pointField, point>& surf,
const PrimitivePatch<faceList, pointField>& surf,
const labelUList& featureEdges,
const labelUList& regionFeatureEdges,
const labelUList& featurePoints

View File

@ -554,7 +554,7 @@ Foam::tmp<Foam::pointField> Foam::triSurfaceMesh::coordinates() const
// Calculate face centres from a copy to avoid incurring
// additional storage
pts = PrimitivePatch<labelledTri, SubList, const pointField&>
pts = PrimitivePatch<FaceListType, const pointField&>
(
FaceListType(*this, triSurface::size()),
triSurface::points()

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,14 +60,10 @@ class triSurfaceRegionSearch
:
public triSurfaceSearch
{
// Private typedefs
// Private Typedefs
typedef PrimitivePatch
<
labelledTri,
IndirectList,
const pointField&
> indirectTriSurface;
typedef PrimitivePatch<IndirectList<labelledTri>, const pointField&>
indirectTriSurface;
typedef treeDataPrimitivePatch<indirectTriSurface>
treeDataIndirectTriSurface;

View File

@ -95,7 +95,7 @@ Ostream& operator<<(Ostream&, const MeshedSurface<Face>&);
template<class Face>
class MeshedSurface
:
public PrimitivePatch<Face, ::Foam::List, pointField, point>,
public PrimitivePatch<::Foam::List<Face>, pointField>,
public fileFormats::surfaceFormatsCore
{
// Friends, regardless of face representations
@ -111,7 +111,7 @@ private:
// Private Typedefs (convenience)
//- Internal mesh storage type
typedef PrimitivePatch<Face, ::Foam::List, pointField, point>
typedef PrimitivePatch<::Foam::List<Face>, pointField>
MeshReference;
typedef UnsortedMeshedSurface<Face> FriendType;

View File

@ -68,7 +68,7 @@ template<class Face> class MeshedSurface;
class polySurface
:
public objectRegistry,
public PrimitivePatch<face, ::Foam::List, pointField, point>,
public PrimitivePatch<::Foam::List<face>, pointField>,
public meshedSurf
{
public:
@ -88,7 +88,7 @@ private:
// Private Typedefs
//- Internal mesh storage type
typedef PrimitivePatch<face, ::Foam::List, pointField, point>
typedef PrimitivePatch<::Foam::List<face>, pointField>
MeshReference;

View File

@ -65,7 +65,7 @@ class surfMesh
:
public surfaceRegistry,
private Detail::MeshedSurfaceIOAllocator,
public PrimitivePatch<face, UList, const pointField&, point>
public PrimitivePatch<::Foam::UList<face>, const pointField&>
{
public:
@ -91,7 +91,7 @@ private:
typedef Detail::MeshedSurfaceIOAllocator Allocator;
//- Internal mesh storage type
typedef PrimitivePatch<face, UList, const pointField&, point>
typedef PrimitivePatch<::Foam::UList<face>, const pointField&>
MeshReference;

View File

@ -335,7 +335,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
if (zones.size() == 1)
{
PrimitivePatch<Face, UList, const pointField&> patch
PrimitivePatch<UList<Face>, const pointField&> patch
(
faceLst, pointLst
);
@ -349,10 +349,13 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
{
if (useFaceMap)
{
typedef UIndirectList<Face> FaceListType;
SubList<label> zoneMap(surf.faceMap(), zone.range());
PrimitivePatch<Face, UIndirectList, const pointField&> patch
PrimitivePatch<FaceListType, const pointField&> patch
(
UIndirectList<Face>(faceLst, zoneMap),
FaceListType(faceLst, zoneMap),
pointLst
);
@ -360,9 +363,11 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
}
else
{
PrimitivePatch<Face, UList, const pointField&> patch
typedef SubList<Face> FaceListType;
PrimitivePatch<FaceListType, const pointField&> patch
(
SubList<Face>(faceLst, zone.range()),
FaceListType(faceLst, zone.range()),
pointLst
);
@ -416,10 +421,13 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
label zoneIndex = 0;
for (const surfZone& zone : zoneLst)
{
typedef UIndirectList<Face> FaceListType;
SubList<label> zoneMap(faceMap, zone.range());
PrimitivePatch<Face, UIndirectList, const pointField&> patch
PrimitivePatch<FaceListType, const pointField&> patch
(
UIndirectList<Face>(surf.surfFaces(), zoneMap),
FaceListType(surf.surfFaces(), zoneMap),
surf.points()
);

View File

@ -76,12 +76,12 @@ Ostream& operator<<(Ostream&, const triSurface&);
class triSurface
:
public PrimitivePatch<labelledTri, ::Foam::List, pointField, point>
public PrimitivePatch<::Foam::List<labelledTri>, pointField>
{
// Private Typedefs
//- Internal mesh storage type
typedef PrimitivePatch<labelledTri, ::Foam::List, pointField, point>
typedef PrimitivePatch<::Foam::List<labelledTri>, pointField>
MeshReference;