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

View File

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

View File

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

View File

@ -198,10 +198,7 @@ int main(int argc, char *argv[])
for (label z = 0; z < nZones; z++)
{
boolList include(faceZone.size(), false);
labelList pointMap;
labelList faceMap;
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 =
outFileBaseName

View File

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

View File

@ -2,10 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -91,12 +89,6 @@ Foam::surfZoneIdentifier::surfZoneIdentifier
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::surfZoneIdentifier::~surfZoneIdentifier()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
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)
{
is >> obj.name_ >> obj.geometricType_;
is >> obj.name() >> obj.geometricType();
return is;
}
@ -139,7 +131,7 @@ Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj)
Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& obj)
{
// 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);
return os;
}

View File

@ -2,10 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -48,14 +46,9 @@ SourceFiles
namespace Foam
{
// Forward declarations
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
\*---------------------------------------------------------------------------*/
@ -84,7 +77,7 @@ public:
// Constructors
//- Construct null
//- Construct null, with index zero
surfZoneIdentifier();
//- Construct null with specified index
@ -115,7 +108,7 @@ public:
//- Destructor
virtual ~surfZoneIdentifier();
virtual ~surfZoneIdentifier() = default;
// Member Functions
@ -159,29 +152,19 @@ public:
//- Write identifier as a dictionary
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
// 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
bool operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b);

View File

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

View File

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

View File

@ -54,6 +54,7 @@ SourceFiles
#include "pointField.H"
#include "face.H"
#include "labelledTri.H"
#include "bitSet.H"
#include "HashSet.H"
#include "surfZoneList.H"
#include "surfaceFormatsCore.H"
@ -464,20 +465,23 @@ public:
virtual label triangulate(List<label>& faceMap);
//- 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
(
const labelHashSet& include,
const BoolListType& include,
labelList& pointMap,
labelList& faceMap
) const;
//- Return new surface.
MeshedSurface subsetMesh
(
const labelHashSet& include
) const;
//- Return new surface
MeshedSurface subsetMesh(const bitSet& include) const;
//- Return new surface
MeshedSurface subsetMesh(const labelHashSet& include) const;
//- Swap contents
void swap(MeshedSurface<Face>& surf);

View File

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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -332,19 +332,22 @@ public:
virtual void clear();
//- 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
(
const labelHashSet& include,
const BoolListType& include,
labelList& pointMap,
labelList& faceMap
) const;
//- Return new surface.
UnsortedMeshedSurface subsetMesh
(
const labelHashSet& include
) const;
//- Return new surface
UnsortedMeshedSurface subsetMesh(const bitSet& include) const;
//- Return new surface
UnsortedMeshedSurface subsetMesh(const labelHashSet& include) const;
//- Swap contents - disabled

View File

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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
@ -784,7 +784,7 @@ void Foam::triSurface::subsetMeshMap
pointMap.setSize(nPoints());
bitSet pointHad(nPoints(), false);
bitSet pointHad(nPoints());
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)
{
clearOut(); // Topology changes

View File

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