ENH: accept bitSet for MeshedSurface::subsetMesh

- add triSurface::subsetMesh single-parameter variant
This commit is contained in:
Mark Olesen
2019-07-12 08:54:34 +02:00
committed by Andrew Heather
parent 4380349f45
commit f1a48a3c2f
15 changed files with 89 additions and 124 deletions

View File

@ -177,18 +177,7 @@ void writeParts
} }
} }
labelList pointMap; triSurface subSurf(surf.subsetMesh(includeMap));
labelList faceMap;
triSurface subSurf
(
surf.subsetMesh
(
includeMap,
pointMap,
faceMap
)
);
fileName subName fileName subName
( (
@ -483,17 +472,7 @@ int main(int argc, char *argv[])
boolList isIllegalFace(surf.size(), false); boolList isIllegalFace(surf.size(), false);
UIndirectList<bool>(isIllegalFace, illegalFaces) = true; UIndirectList<bool>(isIllegalFace, illegalFaces) = true;
labelList pointMap; triSurface subSurf(surf.subsetMesh(isIllegalFace));
labelList faceMap;
triSurface subSurf
(
surf.subsetMesh
(
isIllegalFace,
pointMap,
faceMap
)
);
// Transcribe faces // Transcribe faces

View File

@ -64,9 +64,7 @@ using namespace Foam;
// } // }
// } // }
// //
// labelList pointMap, faceMap; // triSurface regionSurf(surf.subsetMesh(include));
//
// triSurface regionSurf(surf.subsetMesh(include, pointMap, faceMap));
// //
// Pout<< "Region " << regionI << " surface:" << nl; // Pout<< "Region " << regionI << " surface:" << nl;
// regionSurf.writeStats(Pout); // regionSurf.writeStats(Pout);

View File

@ -99,18 +99,8 @@ int main(int argc, char *argv[])
} }
// Subset triSurface // Subset triSurface
labelList pointMap;
labelList faceMap;
triSurface subSurf triSurface subSurf(surf.subsetMesh(includeMap));
(
surf.subsetMesh
(
includeMap,
pointMap,
faceMap
)
);
subSurf.write(outFile); subSurf.write(outFile);
} }

View File

@ -198,10 +198,7 @@ int main(int argc, char *argv[])
for (label z = 0; z < nZones; z++) for (label z = 0; z < nZones; z++)
{ {
boolList include(faceZone.size(), false); boolList include(faceZone.size(), false);
labelList pointMap;
labelList faceMap;
forAll(faceZone, f) forAll(faceZone, f)
{ {
@ -211,8 +208,7 @@ int main(int argc, char *argv[])
} }
} }
triSurface zoneSurf = surf.subsetMesh(include, pointMap, faceMap); triSurface zoneSurf = surf.subsetMesh(include);
fileName remainingPartFileName = fileName remainingPartFileName =
outFileBaseName outFileBaseName

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -379,12 +379,7 @@ int main(int argc, char *argv[])
// Create subsetted surface // Create subsetted surface
labelList pointMap; triSurface surf2(surf1.subsetMesh(facesToSubset));
labelList faceMap;
triSurface surf2
(
surf1.subsetMesh(facesToSubset, pointMap, faceMap)
);
Info<< "Subset:" << endl; Info<< "Subset:" << endl;
surf2.writeStats(Info); surf2.writeStats(Info);

View File

@ -2,10 +2,8 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2009-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -91,12 +89,6 @@ Foam::surfZoneIdentifier::surfZoneIdentifier
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfZoneIdentifier::~surfZoneIdentifier()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfZoneIdentifier::write(Ostream& os) const void Foam::surfZoneIdentifier::write(Ostream& os) const
@ -127,11 +119,11 @@ bool Foam::operator!=(const surfZoneIdentifier& a, const surfZoneIdentifier& b)
} }
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj) Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj)
{ {
is >> obj.name_ >> obj.geometricType_; is >> obj.name() >> obj.geometricType();
return is; return is;
} }
@ -139,7 +131,7 @@ Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj)
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& obj) Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& obj)
{ {
// Newlines to separate, since that is what triSurface currently expects // Newlines to separate, since that is what triSurface currently expects
os << nl << obj.name_ << nl << obj.geometricType_; os << nl << obj.name() << nl << obj.geometricType();
os.check(FUNCTION_NAME); os.check(FUNCTION_NAME);
return os; return os;
} }

View File

@ -2,10 +2,8 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd. \\ / A nd | Copyright (C) 2009-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -48,14 +46,9 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declarations
class dictionary; class dictionary;
// Forward declaration of friend functions and operators
class surfZoneIdentifier;
Istream& operator>>(Istream& is, surfZoneIdentifier& p);
Ostream& operator<<(Ostream& os, const surfZoneIdentifier& p);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class surfZoneIdentifier Declaration Class surfZoneIdentifier Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -84,7 +77,7 @@ public:
// Constructors // Constructors
//- Construct null //- Construct null, with index zero
surfZoneIdentifier(); surfZoneIdentifier();
//- Construct null with specified index //- Construct null with specified index
@ -115,7 +108,7 @@ public:
//- Destructor //- Destructor
virtual ~surfZoneIdentifier(); virtual ~surfZoneIdentifier() = default;
// Member Functions // Member Functions
@ -159,29 +152,19 @@ public:
//- Write identifier as a dictionary //- Write identifier as a dictionary
void write(Ostream& os) const; void write(Ostream& os) const;
// Ostream Operator
//- Read name/type.
friend Istream& operator>>
(
Istream& is,
surfZoneIdentifier& ob
);
//- Write name/type.
friend Ostream& operator<<
(
Ostream& os,
const surfZoneIdentifier& obj
);
}; };
// Global Operators // Global Operators
// Ostream Operator
//- Read name/type
Istream& operator>>(Istream& is, surfZoneIdentifier& obj);
//- Write name/type
Ostream& operator<<(Ostream& os, const surfZoneIdentifier& obj);
//- Compare zone indentifiers for equality //- Compare zone indentifiers for equality
bool operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b); bool operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -118,9 +118,7 @@ Foam::triSurface Foam::subTriSurfaceMesh::subset
} }
} }
labelList pointMap; return s.subsetMesh(isSelected);
labelList faceMap;
return s.subsetMesh(isSelected, pointMap, faceMap);
} }

View File

@ -994,9 +994,10 @@ Foam::label Foam::MeshedSurface<Face>::triangulate
template<class Face> template<class Face>
template<class BoolListType>
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
( (
const labelHashSet& include, const BoolListType& include,
labelList& pointMap, labelList& pointMap,
labelList& faceMap labelList& faceMap
) const ) const
@ -1069,8 +1070,7 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
zone.size() = newFacei - zone.start(); zone.size() = newFacei - zone.start();
} }
// Construct a sub-surface
// construct a sub-surface
return MeshedSurface<Face> return MeshedSurface<Face>
( (
std::move(newPoints), std::move(newPoints),
@ -1083,7 +1083,7 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
template<class Face> template<class Face>
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
( (
const labelHashSet& include const bitSet& include
) const ) const
{ {
labelList pointMap, faceMap; labelList pointMap, faceMap;
@ -1091,6 +1091,16 @@ Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
} }
template<class Face>
Foam::MeshedSurface<Face> Foam::MeshedSurface<Face>::subsetMesh
(
const labelHashSet& include
) const
{
labelList pointMap, faceMap;
return subsetMesh(include, pointMap, faceMap);
}
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::swap void Foam::MeshedSurface<Face>::swap

View File

@ -54,6 +54,7 @@ SourceFiles
#include "pointField.H" #include "pointField.H"
#include "face.H" #include "face.H"
#include "labelledTri.H" #include "labelledTri.H"
#include "bitSet.H"
#include "HashSet.H" #include "HashSet.H"
#include "surfZoneList.H" #include "surfZoneList.H"
#include "surfaceFormatsCore.H" #include "surfaceFormatsCore.H"
@ -464,20 +465,23 @@ public:
virtual label triangulate(List<label>& faceMap); virtual label triangulate(List<label>& faceMap);
//- Return new surface. //- Return new surface.
// Returns return pointMap, faceMap from subsetMeshMap //
// \param[in] include the faces to select
// \param[out] pointMap from subsetMeshMap
// \param[out] faceMap from subsetMeshMap
template<class BoolListType>
MeshedSurface subsetMesh MeshedSurface subsetMesh
( (
const labelHashSet& include, const BoolListType& include,
labelList& pointMap, labelList& pointMap,
labelList& faceMap labelList& faceMap
) const; ) const;
//- Return new surface. //- Return new surface
MeshedSurface subsetMesh MeshedSurface subsetMesh(const bitSet& include) const;
(
const labelHashSet& include
) const;
//- Return new surface
MeshedSurface subsetMesh(const labelHashSet& include) const;
//- Swap contents //- Swap contents
void swap(MeshedSurface<Face>& surf); void swap(MeshedSurface<Face>& surf);

View File

@ -528,10 +528,11 @@ Foam::surfZoneList Foam::UnsortedMeshedSurface<Face>::sortedZones
template<class Face> template<class Face>
template<class BoolListType>
Foam::UnsortedMeshedSurface<Face> Foam::UnsortedMeshedSurface<Face>
Foam::UnsortedMeshedSurface<Face>::subsetMesh Foam::UnsortedMeshedSurface<Face>::subsetMesh
( (
const labelHashSet& include, const BoolListType& include,
labelList& pointMap, labelList& pointMap,
labelList& faceMap labelList& faceMap
) const ) const

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -332,19 +332,22 @@ public:
virtual void clear(); virtual void clear();
//- Return new surface. //- Return new surface.
// Returns return pointMap, faceMap from subsetMeshMap // \param[in] include the faces to select
// \param[out] pointMap from subsetMeshMap
// \param[out] faceMap from subsetMeshMap
template<class BoolListType>
UnsortedMeshedSurface subsetMesh UnsortedMeshedSurface subsetMesh
( (
const labelHashSet& include, const BoolListType& include,
labelList& pointMap, labelList& pointMap,
labelList& faceMap labelList& faceMap
) const; ) const;
//- Return new surface. //- Return new surface
UnsortedMeshedSurface subsetMesh UnsortedMeshedSurface subsetMesh(const bitSet& include) const;
(
const labelHashSet& include //- Return new surface
) const; UnsortedMeshedSurface subsetMesh(const labelHashSet& include) const;
//- Swap contents - disabled //- Swap contents - disabled

View File

@ -83,7 +83,7 @@ public:
// Constructors // Constructors
//- Construct null //- Construct null with zero start, size
surfZone(); surfZone();
//- Construct from components //- Construct from components

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -784,7 +784,7 @@ void Foam::triSurface::subsetMeshMap
pointMap.setSize(nPoints()); pointMap.setSize(nPoints());
bitSet pointHad(nPoints(), false); bitSet pointHad(nPoints());
forAll(include, oldFacei) forAll(include, oldFacei)
{ {
@ -854,6 +854,13 @@ Foam::triSurface Foam::triSurface::subsetMesh
} }
Foam::triSurface Foam::triSurface::subsetMesh(const boolList& include) const
{
labelList pointMap, faceMap;
return subsetMesh(include, pointMap, faceMap);
}
void Foam::triSurface::swapFaces(List<labelledTri>& faceLst) void Foam::triSurface::swapFaces(List<labelledTri>& faceLst)
{ {
clearOut(); // Topology changes clearOut(); // Topology changes

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -418,10 +418,11 @@ public:
labelList& faceZone labelList& faceZone
) const; ) const;
//- 'Create' sub mesh, including only faces for which boolList //- 'Create' sub mesh
//- entry is true //
// Sets: pointMap: from new to old localPoints // \param[in] include the faces to select
// faceMap: new to old faces // \param[out] pointMap from new to old localPoints
// \param[out] faceMap from new to old faces
void subsetMeshMap void subsetMeshMap
( (
const boolList& include, const boolList& include,
@ -429,8 +430,11 @@ public:
labelList& faceMap labelList& faceMap
) const; ) const;
//- Return new surface. Returns pointMap, faceMap from //- Return new surface
// subsetMeshMap //
// \param[in] include the faces to select
// \param[out] pointMap from subsetMeshMap
// \param[out] faceMap from subsetMeshMap
triSurface subsetMesh triSurface subsetMesh
( (
const boolList& include, const boolList& include,
@ -438,6 +442,11 @@ public:
labelList& faceMap labelList& faceMap
) const; ) const;
//- Return new surface
//
// \param[in] include the faces to select
triSurface subsetMesh(const boolList& include) const;
//- Swap the list of faces being addressed //- Swap the list of faces being addressed
void swapFaces(List<labelledTri>& faceLst); void swapFaces(List<labelledTri>& faceLst);