ENH: improve PrimitivePatch access for edges

- return internalEdges() and boundaryEdges() sub lists directly

- calculate and return boundaryFaces() to identify faces attached to
  boundary edges.

- minor code cleanup, and add PrimitivePatchBase class for
  non-templated code.

STYLE: mark unused parameter in globalMeshData mergePoints
This commit is contained in:
Mark Olesen
2021-05-10 13:38:02 +02:00
parent ea2bf72740
commit 3bc8ab2839
17 changed files with 322 additions and 296 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -34,6 +34,7 @@ Description
#include "polyMesh.H"
#include "primitiveFacePatch.H"
#include "primitivePatch.H"
#include "IndirectList.H"
#include "Fstream.H"
using namespace Foam;
@ -242,6 +243,28 @@ int main(int argc, char *argv[])
writeEdgeFaces(localPoints, localFaces, edges, edgeFaces);
writeFaceFaces(localPoints, localFaces, faceFaces);
const labelList bndFaceIds(pp.boundaryFaces());
Info<< "Have: " << bndFaceIds.size() << " boundary faces" << nl;
// Can calculate by hand
if (!pp.hasFaceCentres())
{
pointField boundaryCentres(bndFaceIds.size());
forAll(bndFaceIds, facei)
{
boundaryCentres[facei] =
pp[bndFaceIds[facei]].centre(pp.points());
}
Info << "calc faceCentres:"
<< boundaryCentres << nl;
}
// But will often use the cached information
Info<< "faceCentres:"
<< UIndirectList<point>(pp.faceCentres(), bndFaceIds) << nl;
}
// Move construct

View File

@ -655,7 +655,7 @@ $(mapPolyMesh)/mapDistribute/IOmapDistribute.C
$(mapPolyMesh)/mapAddedPolyMesh.C
PrimitivePatch = $(primitiveMesh)/PrimitivePatch
$(PrimitivePatch)/PrimitivePatchName.C
$(PrimitivePatch)/PrimitivePatchBase.C
pointMesh = meshes/pointMesh
$(pointMesh)/pointMesh.C

View File

@ -2507,7 +2507,7 @@ Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints
Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints
(
const labelList& meshPoints,
const Map<label>& meshPointMap,
const Map<label>& /* unused: meshPointMap */,
labelList& pointToGlobal,
labelList& uniqueMeshPoints
) const

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -342,7 +342,7 @@ public:
// Access
//- Return the mesh reference
const polyMesh& mesh() const
const polyMesh& mesh() const noexcept
{
return mesh_;
}
@ -351,25 +351,25 @@ public:
// not running parallel)
bool parallel() const
{
return processorPatches_.size() > 0;
return !processorPatches_.empty();
}
//- Return total number of points in decomposed mesh. Not
// compensated for duplicate points!
label nTotalPoints() const
label nTotalPoints() const noexcept
{
return nTotalPoints_;
}
//- Return total number of faces in decomposed mesh. Not
// compensated for duplicate faces!
label nTotalFaces() const
label nTotalFaces() const noexcept
{
return nTotalFaces_;
}
//- Return total number of cells in decomposed mesh.
label nTotalCells() const
label nTotalCells() const noexcept
{
return nTotalCells_;
}
@ -379,7 +379,7 @@ public:
//- Return list of processor patch labels
// (size of list = number of processor patches)
const labelList& processorPatches() const
const labelList& processorPatches() const noexcept
{
return processorPatches_;
}
@ -387,14 +387,14 @@ public:
//- Return list of indices into processorPatches_ for each patch.
// Index = -1 for non-processor parches.
// (size of list = number of patches)
const labelList& processorPatchIndices() const
const labelList& processorPatchIndices() const noexcept
{
return processorPatchIndices_;
}
//- Return processorPatchIndices of the neighbours
// processor patches. -1 if not running parallel.
const labelList& processorPatchNeighbours() const
const labelList& processorPatchNeighbours() const noexcept
{
return processorPatchNeighbours_;
}
@ -577,7 +577,7 @@ public:
autoPtr<globalIndex> mergePoints
(
const labelList& meshPoints,
const Map<label>& meshPointMap,
const Map<label>& meshPointMap, //!< currently unused
labelList& pointToGlobal,
labelList& uniqueMeshPoints
) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -130,7 +130,6 @@ Foam::PrimitivePatch<FaceList, PointField>::PrimitivePatch
const PrimitivePatch<FaceList, PointField>& pp
)
:
PrimitivePatchName(),
FaceList(pp),
points_(pp.points_),
edgesPtr_(nullptr),
@ -173,13 +172,7 @@ Foam::PrimitivePatch<FaceList, PointField>::movePoints
const Field<point_type>&
)
{
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
<< "movePoints() : "
<< "recalculating PrimitivePatch geometry following mesh motion"
<< endl;
}
DebugInFunction << "Recalculating geometry following mesh motion" << endl;
clearGeom();
}
@ -198,6 +191,24 @@ Foam::PrimitivePatch<FaceList, PointField>::edges() const
}
template<class FaceList, class PointField>
const Foam::edgeList::subList
Foam::PrimitivePatch<FaceList, PointField>::internalEdges() const
{
const edgeList& allEdges = this->edges(); // Force demand-driven
return edgeList::subList(allEdges, nInternalEdges());
}
template<class FaceList, class PointField>
const Foam::edgeList::subList
Foam::PrimitivePatch<FaceList, PointField>::boundaryEdges() const
{
const edgeList& allEdges = this->edges(); // Force demand-driven
return edgeList::subList(allEdges, nBoundaryEdges(), nInternalEdges());
}
template<class FaceList, class PointField>
Foam::label
Foam::PrimitivePatch<FaceList, PointField>::nInternalEdges() const
@ -211,6 +222,15 @@ Foam::PrimitivePatch<FaceList, PointField>::nInternalEdges() const
}
template<class FaceList, class PointField>
Foam::label
Foam::PrimitivePatch<FaceList, PointField>::nBoundaryEdges() const
{
const edgeList& allEdges = this->edges(); // Force demand-driven
return (allEdges.size() - this->nInternalEdges());
}
template<class FaceList, class PointField>
const Foam::labelList&
Foam::PrimitivePatch<FaceList, PointField>::boundaryPoints() const
@ -496,6 +516,7 @@ Foam::PrimitivePatch<FaceList, PointField>::operator=
#include "PrimitivePatchAddressing.C"
#include "PrimitivePatchEdgeLoops.C"
#include "PrimitivePatchClear.C"
#include "PrimitivePatchBdryFaces.C"
#include "PrimitivePatchBdryPoints.C"
#include "PrimitivePatchLocalPointOrder.C"
#include "PrimitivePatchMeshData.C"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,16 +36,16 @@ Description
using List and pointField.
SourceFiles
PrimitivePatchAddressing.C
PrimitivePatchBdryPoints.C
PrimitivePatch.C
PrimitivePatchAddressing.C
PrimitivePatchBdryFaces.C
PrimitivePatchBdryPoints.C
PrimitivePatchCheck.C
PrimitivePatchClear.C
PrimitivePatchEdgeLoops.C
PrimitivePatchLocalPointOrder.C
PrimitivePatchMeshData.C
PrimitivePatchMeshEdges.C
PrimitivePatchName.C
PrimitivePatchPointAddressing.C
PrimitivePatchProjectPoints.C
@ -61,6 +61,7 @@ SourceFiles
#include "intersection.H"
#include "HashSet.H"
#include "objectHit.H"
#include "PrimitivePatchBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -71,13 +72,6 @@ namespace Foam
class face;
template<class T> class Map;
/*---------------------------------------------------------------------------*\
Class PrimitivePatchName Declaration
\*---------------------------------------------------------------------------*/
TemplateName(PrimitivePatch);
/*---------------------------------------------------------------------------*\
Class PrimitivePatch Declaration
\*---------------------------------------------------------------------------*/
@ -85,7 +79,7 @@ TemplateName(PrimitivePatch);
template<class FaceList, class PointField>
class PrimitivePatch
:
public PrimitivePatchName,
public PrimitivePatchBase,
public FaceList
{
public:
@ -129,7 +123,7 @@ private:
PointField points_;
// Demand driven private data
// Demand-driven Private Data
//- Edges of the patch; address into local point list;
// sorted with internal edges first in upper-triangular order
@ -194,10 +188,10 @@ private:
// Private Member Functions
//- Calculate edges of the patch
void calcIntBdryEdges() const;
//- Calculate internal points on a patch
void calcInternPoints() const;
//- Calculated boundary points on a patch
//- Calculate boundary points on a patch
void calcBdryPoints() const;
//- Calculate addressing
@ -308,18 +302,24 @@ public:
return points_;
}
//- Number of faces in the patch
label nFaces() const
{
return FaceList::size();
}
// Access functions for demand-driven data
// Topological data; no mesh required.
//- Return number of points supporting patch faces
//- Number of points supporting patch faces
label nPoints() const
{
return meshPoints().size();
}
//- Return number of edges in patch
//- Number of edges in patch
label nEdges() const
{
return edges().size();
@ -328,9 +328,18 @@ public:
//- Return list of edges, address into LOCAL point list
const edgeList& edges() const;
//- Return sub-list of internal edges, address into LOCAL point list
const edgeList::subList internalEdges() const;
//- Return sub-list of boundary edges, address into LOCAL point list
const edgeList::subList boundaryEdges() const;
//- Number of internal edges
label nInternalEdges() const;
//- Number of boundary edges == (nEdges() - nInternalEdges())
label nBoundaryEdges() const;
//- Is internal edge?
bool isInternalEdge(const label edgei) const
{
@ -358,6 +367,10 @@ public:
//- Return patch faces addressing into local point list
const List<face_type>& localFaces() const;
//- Calculate and return list of local boundary faces.
// These are the faces attached to boundary edges.
labelList boundaryFaces() const;
// Addressing into mesh
@ -382,7 +395,7 @@ public:
//- Given an edge in local point labels, return its
//- index in the edge list. If the edge is not found, return -1
label whichEdge(const edge&) const;
label whichEdge(const edge& e) const;
//- Return labels of patch edges in the global edge list using
//- cell addressing

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -76,40 +76,29 @@ Foam::PrimitivePatch<FaceList, PointField>::calcAddressing() const
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_.reset(new labelListList(locFcs.size()));
auto& faceEdges = *faceEdgesPtr_;
// count the number of face neighbours
labelList noFaceFaces(locFcs.size());
// initialise the lists of subshapes for each face to avoid duplication
edgeListList faceIntoEdges(locFcs.size());
forAll(locFcs, facei)
{
faceIntoEdges[facei] = locFcs[facei].edges();
labelList& curFaceEdges = faceEdges[facei];
curFaceEdges.setSize(faceIntoEdges[facei].size());
forAll(curFaceEdges, faceEdgeI)
{
curFaceEdges[faceEdgeI] = -1;
}
faceEdges[facei].resize(faceIntoEdges[facei].size(), -1);
}
// faceFaces created using a dynamic list. Cannot guess size because
// of multiple connections
List<DynamicList<label>> ff(locFcs.size());
// This algorithm will produce a separated list of edges, internal edges
// starting from 0 and boundary edges starting from the top and
// growing down.
label nEdges = 0;
bool found = false;
// Note that faceIntoEdges is sorted acc. to local vertex numbering
// in face (i.e. curEdges[0] is edge between f[0] and f[1])
@ -132,8 +121,6 @@ Foam::PrimitivePatch<FaceList, PointField>::calcAddressing() const
// If the edge is already detected, skip
if (faceEdges[facei][edgeI] >= 0) continue;
found = false;
// Set reference to the current edge
const edge& e = curEdges[edgeI];
@ -141,6 +128,8 @@ Foam::PrimitivePatch<FaceList, PointField>::calcAddressing() const
const labelList& nbrFaces = pf[e.start()];
bool found = false;
forAll(nbrFaces, nbrFacei)
{
// set reference to the current neighbour
@ -212,7 +201,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcAddressing() const
// Set edge-face addressing
labelList& curEf = edgeFaces[nEdges];
curEf.setSize(cnf.size() + 1);
curEf.resize(cnf.size() + 1);
curEf[0] = facei;
forAll(cnf, cnfI)
@ -256,7 +245,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcAddressing() const
// Add edgeFace
labelList& curEf = edgeFaces[nEdges];
curEf.setSize(1);
curEf.resize(1);
curEf[0] = facei;
nEdges++;
@ -265,10 +254,10 @@ Foam::PrimitivePatch<FaceList, PointField>::calcAddressing() const
}
// edges
edges.setSize(nEdges);
edges.resize(nEdges);
// edgeFaces list
edgeFaces.setSize(nEdges);
edgeFaces.resize(nEdges);
// faceFaces list
faceFacesPtr_.reset(new labelListList(locFcs.size()));

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -25,13 +26,13 @@ License
\*---------------------------------------------------------------------------*/
#include "PrimitivePatch.H"
#include "PrimitivePatchBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(PrimitivePatchName, 0);
defineTypeNameAndDebug(PrimitivePatchBase, 0);
}

View File

@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::PrimitivePatchBase
Description
Non-templated base elements for PrimitivePatch
SourceFiles
PrimitivePatchBase.C
\*---------------------------------------------------------------------------*/
#ifndef PrimitivePatchBase_H
#define PrimitivePatchBase_H
#include "className.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class PrimitivePatchBase Declaration
\*---------------------------------------------------------------------------*/
class PrimitivePatchBase
{
public:
//- Runtime type information
ClassName("PrimitivePatch");
// Constructors
//- Default construct
PrimitivePatchBase() = default;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
#endif
// ************************************************************************* //

View File

@ -0,0 +1,53 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "PrimitivePatch.H"
#include "HashSet.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class FaceList, class PointField>
Foam::labelList
Foam::PrimitivePatch<FaceList, PointField>::boundaryFaces() const
{
// By definition boundary edges have a _single_ face attached,
// but a face can easily have multiple boundary edges.
const labelListList& edgeToFace = edgeFaces();
labelHashSet bndFaces(2*nBoundaryEdges());
for (label edgei = nInternalEdges(); edgei < edgeToFace.size(); ++edgei)
{
bndFaces.insert(edgeToFace[edgei][0]);
}
return bndFaces.sortedToc();
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -45,16 +45,12 @@ Foam::PrimitivePatch<FaceList, PointField>::calcBdryPoints() const
<< abort(FatalError);
}
const edgeList& e = edges();
labelHashSet bp(2*nEdges());
labelHashSet bp(2*e.size());
for (label edgeI = nInternalEdges_; edgeI < e.size(); edgeI++)
for (const edge& e : boundaryEdges())
{
const edge& curEdge = e[edgeI];
bp.insert(curEdge.start());
bp.insert(curEdge.end());
bp.insert(e.first());
bp.insert(e.second());
}
boundaryPointsPtr_.reset(new labelList(bp.sortedToc()));

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,12 +49,15 @@ Foam::PrimitivePatch<FaceList, PointField>::calcEdgeLoops() const
}
const edgeList& patchEdges = edges();
label nIntEdges = nInternalEdges();
label nBdryEdges = patchEdges.size() - nIntEdges;
const label nIntEdges = nInternalEdges();
const label nBdryEdges = patchEdges.size() - nIntEdges;
// Size return list plenty big
edgeLoopsPtr_.reset(new labelListList(nBdryEdges));
auto& edgeLoops = *edgeLoopsPtr_;
if (nBdryEdges == 0)
{
edgeLoopsPtr_.reset(new labelListList(0));
return;
}
@ -68,11 +71,6 @@ Foam::PrimitivePatch<FaceList, PointField>::calcEdgeLoops() const
// Loop per (boundary) edge.
labelList loopNumber(nBdryEdges, -1);
// Size return list plenty big
edgeLoopsPtr_.reset(new labelListList(nBdryEdges));
auto& edgeLoops = *edgeLoopsPtr_;
// Current loop number.
label loopI = 0;

View File

@ -41,13 +41,7 @@ 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<FaceList, PointField>::"
<< "calcLocalPointOrder() : "
<< "calculating local point order"
<< endl;
}
DebugInFunction << "Calculating local point order" << endl;
if (localPointOrderPtr_)
{
@ -116,13 +110,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcLocalPointOrder() const
}
}
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
<< "calcLocalPointOrder() "
<< "finished calculating local point order"
<< endl;
}
DebugInfo << "Calculated local point order" << endl;
}

View File

@ -35,13 +35,7 @@ template<class FaceList, class PointField>
void
Foam::PrimitivePatch<FaceList, PointField>::calcMeshData() const
{
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMeshData() : "
"calculating mesh data in PrimitivePatch"
<< endl;
}
DebugInFunction << "Calculating mesh data" << endl;
if (meshPointsPtr_ || localFacesPtr_)
{
@ -117,13 +111,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcMeshData() const
}
}
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMeshData() : "
"finished calculating mesh data in PrimitivePatch"
<< endl;
}
DebugInfo << "Calculated mesh data" << endl;
}
@ -131,13 +119,7 @@ template<class FaceList, class PointField>
void
Foam::PrimitivePatch<FaceList, PointField>::calcMeshPointMap() const
{
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMeshPointMap() : "
"calculating mesh point map in PrimitivePatch"
<< endl;
}
DebugInFunction << "Calculating mesh point map" << endl;
if (meshPointMapPtr_)
{
@ -157,13 +139,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcMeshPointMap() const
mpMap.insert(mp[i], i);
}
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMeshPointMap() : "
"finished calculating mesh point map in PrimitivePatch"
<< endl;
}
DebugInfo << "Calculated mesh point map" << endl;
}
@ -171,13 +147,7 @@ template<class FaceList, class PointField>
void
Foam::PrimitivePatch<FaceList, PointField>::calcLocalPoints() const
{
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcLocalPoints() : "
"calculating localPoints in PrimitivePatch"
<< endl;
}
DebugInFunction << "Calculating localPoints" << endl;
if (localPointsPtr_)
{
@ -197,13 +167,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcLocalPoints() const
locPts[pointi] = points_[meshPts[pointi]];
}
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
<< "calcLocalPoints() : "
<< "finished calculating localPoints in PrimitivePatch"
<< endl;
}
DebugInfo << "Calculated localPoints" << endl;
}
@ -211,13 +175,7 @@ template<class FaceList, class PointField>
void
Foam::PrimitivePatch<FaceList, PointField>::calcPointNormals() const
{
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcPointNormals() : "
"calculating pointNormals in PrimitivePatch"
<< endl;
}
DebugInFunction << "Calculating pointNormals" << endl;
if (pointNormalsPtr_)
{
@ -248,13 +206,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcPointNormals() const
curNormal.normalise();
}
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcPointNormals() : "
"finished calculating pointNormals in PrimitivePatch"
<< endl;
}
DebugInfo << "Calculated pointNormals" << endl;
}
@ -262,13 +214,7 @@ template<class FaceList, class PointField>
void
Foam::PrimitivePatch<FaceList, PointField>::calcFaceCentres() const
{
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceCentres() : "
"calculating faceCentres in PrimitivePatch"
<< endl;
}
DebugInFunction << "Calculating faceCentres" << endl;
if (faceCentresPtr_)
{
@ -286,13 +232,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcFaceCentres() const
c[facei] = this->operator[](facei).centre(points_);
}
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceCentres() : "
"finished calculating faceCentres in PrimitivePatch"
<< endl;
}
DebugInfo << "Calculated faceCentres" << endl;
}
@ -300,13 +240,7 @@ template<class FaceList, class PointField>
void
Foam::PrimitivePatch<FaceList, PointField>::calcMagFaceAreas() const
{
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMagFaceAreas() : "
"calculating magFaceAreas in PrimitivePatch"
<< endl;
}
DebugInFunction << "Calculating magFaceAreas" << endl;
if (magFaceAreasPtr_)
{
@ -324,13 +258,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcMagFaceAreas() const
a[facei] = this->operator[](facei).mag(points_);
}
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcMagFaceAreas() : "
"finished calculating magFaceAreas in PrimitivePatch"
<< endl;
}
DebugInfo << "Calculated magFaceAreas" << endl;
}
@ -338,13 +266,7 @@ template<class FaceList, class PointField>
void
Foam::PrimitivePatch<FaceList, PointField>::calcFaceAreas() const
{
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceAreas() : "
"calculating faceAreas in PrimitivePatch"
<< endl;
}
DebugInFunction << "Calculating faceAreas" << endl;
if (faceAreasPtr_)
{
@ -362,13 +284,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcFaceAreas() const
n[facei] = this->operator[](facei).areaNormal(points_);
}
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceAreas() : "
"finished calculating faceAreas in PrimitivePatch"
<< endl;
}
DebugInfo << "Calculated faceAreas" << endl;
}
@ -376,13 +292,7 @@ template<class FaceList, class PointField>
void
Foam::PrimitivePatch<FaceList, PointField>::calcFaceNormals() const
{
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceNormals() : "
"calculating faceNormals in PrimitivePatch"
<< endl;
}
DebugInFunction << "Calculating faceNormals" << endl;
if (faceNormalsPtr_)
{
@ -400,13 +310,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcFaceNormals() const
n[facei] = this->operator[](facei).unitNormal(points_);
}
if (debug)
{
Pout<< "PrimitivePatch<FaceList, PointField>::"
"calcFaceNormals() : "
"finished calculating faceNormals in PrimitivePatch"
<< endl;
}
DebugInfo << "Calculated faceNormals" << endl;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,47 +43,38 @@ meshEdges
DebugInFunction
<< "Calculating labels of patch edges in mesh edge list" << nl;
// get reference to the list of edges on the patch
// The list of edges on the patch
const edgeList& PatchEdges = edges();
// The output storage
labelList meshEdges(PatchEdges.size());
const labelListList& EdgeFaces = edgeFaces();
// create the storage
labelList meshEdges(PatchEdges.size());
bool found = false;
// get reference to the points on the patch
// The mesh points associated with the patch
const labelList& pp = meshPoints();
// WARNING: Remember that local edges address into local point list;
// local-to-global point label translation is necessary
forAll(PatchEdges, edgeI)
forAll(PatchEdges, edgei)
{
const edge curEdge
(pp[PatchEdges[edgeI].start()], pp[PatchEdges[edgeI].end()]);
bool found = false;
found = false;
const edge globalEdge(pp, PatchEdges[edgei]);
// get the patch faces sharing the edge
const labelList& curFaces = EdgeFaces[edgeI];
forAll(curFaces, facei)
// For each patch face sharing the edge
for (const label patchFacei : EdgeFaces[edgei])
{
// get the cell next to the face
label curCell = faceCells[curFaces[facei]];
// The cell next to the face
const label curCelli = faceCells[patchFacei];
// get reference to edges on the cell
const labelList& ce = cellEdges[curCell];
forAll(ce, cellEdgeI)
// Check the cell edges
for (const label cellEdgei : cellEdges[curCelli])
{
if (allEdges[ce[cellEdgeI]] == curEdge)
if (allEdges[cellEdgei] == globalEdge)
{
found = true;
meshEdges[edgeI] = ce[cellEdgeI];
meshEdges[edgei] = cellEdgei;
break;
}
}
@ -107,29 +98,27 @@ Foam::PrimitivePatch<FaceList, PointField>::meshEdges
DebugInFunction
<< "Calculating labels of patch edges in mesh edge list" << nl;
// get reference to the list of edges on the patch
// The list of edges on the patch
const edgeList& PatchEdges = edges();
// create the storage
// The output storage
labelList meshEdges(PatchEdges.size());
// get reference to the points on the patch
// The mesh points associated with the patch
const labelList& pp = meshPoints();
// WARNING: Remember that local edges address into local point list;
// local-to-global point label translation is necessary
forAll(PatchEdges, edgeI)
forAll(PatchEdges, edgei)
{
const label globalPointi = pp[PatchEdges[edgeI].start()];
const edge curEdge(globalPointi, pp[PatchEdges[edgeI].end()]);
const edge globalEdge(pp, PatchEdges[edgei]);
const labelList& pe = pointEdges[globalPointi];
forAll(pe, i)
// Check the attached edges
for (const label patchEdgei : pointEdges[globalEdge.start()])
{
if (allEdges[pe[i]] == curEdge)
if (allEdges[patchEdgei] == globalEdge)
{
meshEdges[edgeI] = pe[i];
meshEdges[edgei] = patchEdgei;
break;
}
}
@ -148,18 +137,16 @@ Foam::PrimitivePatch<FaceList, PointField>::whichEdge
const edge& e
) const
{
if (e.start() >= 0 && e.start() < nPoints())
{
// Get pointEdges from the starting point and search all the candidates
const edgeList& Edges = edges();
if (e.start() > -1 && e.start() < nPoints())
for (const label patchEdgei : pointEdges()[e.start()])
{
const labelList& pe = pointEdges()[e.start()];
forAll(pe, peI)
if (e == Edges[patchEdgei])
{
if (e == Edges[pe[peI]])
{
return pe[peI];
return patchEdgei;
}
}
}

View File

@ -54,8 +54,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcPointEdges() const
invertManyToMany(pe.size(), edges(), pe);
DebugInfo
<< " Finished." << endl;
DebugInfo << " Finished." << endl;
}
@ -81,9 +80,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcPointFaces() const
forAll(locFcs, facei)
{
const face_type& curPoints = locFcs[facei];
for (const label pointi : curPoints)
for (const label pointi : locFcs[facei])
{
pointFcs[pointi].append(facei);
}
@ -98,8 +95,7 @@ Foam::PrimitivePatch<FaceList, PointField>::calcPointFaces() const
pf[pointi] = pointFcs[pointi];
}
DebugInfo
<< " Finished." << endl;
DebugInfo << " Finished." << endl;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -200,7 +200,7 @@ Foam::PrimitivePatch<FaceList, PointField>::projectPoints
}
}
if (debug) Info<< ".";
DebugInfo << '.';
} while (closer);
}
@ -211,10 +211,7 @@ Foam::PrimitivePatch<FaceList, PointField>::projectPoints
{
nNSquaredSearches++;
if (debug)
{
Info<< "p " << curLocalPointLabel << ": ";
}
DebugInfo << "p " << curLocalPointLabel << ": ";
result[curLocalPointLabel] = objectHit(false, -1);
scalar minDistance = GREAT;
@ -254,23 +251,18 @@ Foam::PrimitivePatch<FaceList, PointField>::projectPoints
}
}
if (debug)
{
Info<< result[curLocalPointLabel] << nl;
}
DebugInfo << result[curLocalPointLabel] << nl;
}
else
{
if (debug) Info<< "x";
DebugInfo << 'x';
}
}
if (debug)
{
Info<< nl << "Executed " << nNSquaredSearches
DebugInfo
<< nl << "Executed " << nNSquaredSearches
<< " n-squared searches out of total of "
<< nPoints() << endl;
}
return result;
}
@ -439,7 +431,7 @@ Foam::PrimitivePatch<FaceList, PointField>::projectFaceCentres
}
}
if (debug) Info<< ".";
DebugInfo << '.';
} while (closer);
}
@ -447,10 +439,7 @@ Foam::PrimitivePatch<FaceList, PointField>::projectFaceCentres
{
nNSquaredSearches++;
if (debug)
{
Info<< "p " << curLocalFaceLabel << ": ";
}
DebugInfo << "p " << curLocalFaceLabel << ": ";
result[curLocalFaceLabel] = objectHit(false, -1);
scalar minDistance = GREAT;
@ -490,23 +479,19 @@ Foam::PrimitivePatch<FaceList, PointField>::projectFaceCentres
}
}
if (debug)
{
Info<< result[curLocalFaceLabel] << nl;
}
DebugInfo << result[curLocalFaceLabel] << nl;
}
else
{
if (debug) Info<< "x";
DebugInfo << 'x';
}
}
if (debug)
{
Info<< nl << "Executed " << nNSquaredSearches
DebugInfo
<< nl
<< "Executed " << nNSquaredSearches
<< " n-squared searches out of total of "
<< this->size() << endl;
}
return result;
}