mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: more explicit about handling empty matchers for index lookup
- for boundary meshes, zones etc. The behaviour with an empty matcher was either not properly documented, and looped through all names just to establish there was no match. STYLE: removed redundant typedefs for point fields
This commit is contained in:
@ -43,25 +43,6 @@ SourceFiles
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef GeometricField<scalar, pointPatchField, pointMesh> pointScalarField;
|
||||
typedef GeometricField<vector, pointPatchField, pointMesh> pointVectorField;
|
||||
typedef GeometricField<sphericalTensor, pointPatchField, pointMesh>
|
||||
pointSphericalTensorField;
|
||||
typedef GeometricField<symmTensor, pointPatchField, pointMesh>
|
||||
pointSymmTensorField;
|
||||
typedef GeometricField<tensor, pointPatchField, pointMesh> pointTensorField;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -47,14 +47,16 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Forward Declarations
|
||||
class pointMesh;
|
||||
|
||||
template<class Type>
|
||||
class pointPatchField;
|
||||
template<class Type> class pointPatchField;
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
class GeometricField;
|
||||
|
||||
// Typedefs
|
||||
|
||||
typedef GeometricField<scalar, pointPatchField, pointMesh> pointScalarField;
|
||||
typedef GeometricField<vector, pointPatchField, pointMesh> pointVectorField;
|
||||
typedef GeometricField<sphericalTensor, pointPatchField, pointMesh>
|
||||
|
||||
@ -61,7 +61,6 @@ Foam::pointBoundaryMesh::pointBoundaryMesh
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
Foam::labelList Foam::pointBoundaryMesh::indices
|
||||
(
|
||||
const keyType& key,
|
||||
|
||||
@ -45,7 +45,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class pointMesh;
|
||||
class polyBoundaryMesh;
|
||||
|
||||
@ -57,7 +57,7 @@ class pointBoundaryMesh
|
||||
:
|
||||
public pointPatchList
|
||||
{
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- Reference to mesh
|
||||
const pointMesh& mesh_;
|
||||
@ -100,9 +100,11 @@ public:
|
||||
}
|
||||
|
||||
//- Find patch indices given a name
|
||||
// A no-op (returns empty list) for an empty key
|
||||
labelList indices(const keyType& key, const bool useGroups) const;
|
||||
|
||||
//- Find patch index given a name
|
||||
// A no-op (returns -1) for an empty patchName
|
||||
label findPatchID(const word& patchName) const;
|
||||
|
||||
//- Correct polyBoundaryMesh after moving points
|
||||
|
||||
@ -768,6 +768,11 @@ Foam::label Foam::polyBoundaryMesh::findPatchID
|
||||
bool allowNotFound
|
||||
) const
|
||||
{
|
||||
if (patchName.empty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
const label patchId = findIndexImpl(*this, patchName);
|
||||
|
||||
if (patchId >= 0)
|
||||
|
||||
@ -49,7 +49,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class polyMesh;
|
||||
class wordRe;
|
||||
|
||||
@ -194,6 +194,7 @@ public:
|
||||
|
||||
//- Return patch indices for all matches.
|
||||
// Optionally matches patchGroups
|
||||
// A no-op (returns empty list) for an empty key
|
||||
labelList indices
|
||||
(
|
||||
const keyType& key,
|
||||
@ -202,9 +203,11 @@ public:
|
||||
|
||||
|
||||
//- Return patch index for the first match, return -1 if not found
|
||||
// A no-op (returns -1) for an empty key
|
||||
label findIndex(const keyType& key) const;
|
||||
|
||||
//- Find patch index given a name, return -1 if not found
|
||||
// A no-op (returns -1) for an empty patchName
|
||||
label findPatchID
|
||||
(
|
||||
const word& patchName,
|
||||
|
||||
@ -485,6 +485,11 @@ Foam::label Foam::ZoneMesh<ZoneType, MeshType>::findZoneID
|
||||
const word& zoneName
|
||||
) const
|
||||
{
|
||||
if (zoneName.empty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
label zoneId = findIndexImpl(*this, zoneName);
|
||||
|
||||
if (zoneId < 0)
|
||||
@ -514,6 +519,11 @@ const ZoneType* Foam::ZoneMesh<ZoneType, MeshType>::cfindZone
|
||||
const word& zoneName
|
||||
) const
|
||||
{
|
||||
if (zoneName.empty())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const PtrList<ZoneType>& zones = *this;
|
||||
|
||||
for (auto iter = zones.begin(); iter != zones.end(); ++iter)
|
||||
@ -585,6 +595,7 @@ Foam::bitSet Foam::ZoneMesh<ZoneType, MeshType>::selection
|
||||
const keyType& key
|
||||
) const
|
||||
{
|
||||
// key.empty() is handled by indices()
|
||||
return this->selection(this->indices(key));
|
||||
}
|
||||
|
||||
@ -595,6 +606,7 @@ Foam::bitSet Foam::ZoneMesh<ZoneType, MeshType>::selection
|
||||
const wordRes& matcher
|
||||
) const
|
||||
{
|
||||
// matcher.empty() is handled by indices()
|
||||
return this->selection(this->indices(matcher));
|
||||
}
|
||||
|
||||
|
||||
@ -193,24 +193,31 @@ public:
|
||||
|
||||
|
||||
//- Return zone indices for all matches
|
||||
// A no-op (returns empty list) for an empty key
|
||||
labelList indices(const keyType& key) const;
|
||||
|
||||
//- Return zone indices for all matches
|
||||
// A no-op (returns empty list) for an empty matcher
|
||||
labelList indices(const wordRes& matcher) const;
|
||||
|
||||
//- Zone index for the first match, return -1 if not found
|
||||
// A no-op (returns -1) for an empty key
|
||||
label findIndex(const keyType& key) const;
|
||||
|
||||
//- Zone index for the first match, return -1 if not found
|
||||
// A no-op (returns -1) for an empty matcher
|
||||
label findIndex(const wordRes& matcher) const;
|
||||
|
||||
//- Find zone index by name, return -1 if not found
|
||||
// A no-op (returns -1) for an empty zoneName
|
||||
label findZoneID(const word& zoneName) const;
|
||||
|
||||
//- Find zone by name and return const pointer, nullptr on error
|
||||
// A no-op (returns nullptr) for an empty zoneName
|
||||
const ZoneType* cfindZone(const word& zoneName) const;
|
||||
|
||||
//- Find zone by name and return pointer, nullptr on error
|
||||
// A no-op (returns nullptr) for an empty zoneName
|
||||
ZoneType* findZone(const word& zoneName);
|
||||
|
||||
|
||||
@ -224,12 +231,14 @@ public:
|
||||
//- specification as a bitSet.
|
||||
// The bitSet is empty (zero-size) if there are no elements matched
|
||||
// anywhere.
|
||||
// A no-op (returns empty bitSet) for an empty key
|
||||
bitSet selection(const keyType& key) const;
|
||||
|
||||
//- Return all elements (cells, faces, points) that match the zone
|
||||
//- specification as a bitSet.
|
||||
// The bitSet is empty (zero-size) if there are no elements matched
|
||||
// anywhere.
|
||||
// A no-op (returns empty bitSet) for an empty matcher
|
||||
bitSet selection(const wordRes& matcher) const;
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2017 Wikki Ltd
|
||||
Copyright (C) 2018-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -289,6 +289,11 @@ Foam::label Foam::faBoundaryMesh::findIndex(const keyType& key) const
|
||||
|
||||
Foam::label Foam::faBoundaryMesh::findPatchID(const word& patchName) const
|
||||
{
|
||||
if (patchName.empty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return findIndexImpl(*this, patchName);
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class faMesh;
|
||||
class faBoundaryMesh;
|
||||
Ostream& operator<<(Ostream&, const faBoundaryMesh&);
|
||||
@ -121,7 +121,7 @@ public:
|
||||
const faMesh& mesh() const;
|
||||
|
||||
//- Return a list of pointers for each patch
|
||||
// with only those pointing to interfaces being set
|
||||
//- with only those pointing to interfaces being set
|
||||
lduInterfacePtrsList interfaces() const;
|
||||
|
||||
//- Return a list of patch names
|
||||
@ -131,7 +131,8 @@ public:
|
||||
wordList types() const;
|
||||
|
||||
//- Return patch indices for all matches.
|
||||
// \not Matching patchGroups currently not supported
|
||||
// A no-op (returns -1) for an empty key
|
||||
// \note Matching patchGroups currently not supported
|
||||
labelList indices
|
||||
(
|
||||
const keyType& key,
|
||||
@ -139,9 +140,11 @@ public:
|
||||
) const;
|
||||
|
||||
//- Return patch index for the first match, return -1 if not found
|
||||
// A no-op (returns -1) for an empty key
|
||||
label findIndex(const keyType& key) const;
|
||||
|
||||
//- Find patch index given a name, return -1 if not found
|
||||
// A no-op (returns -1) for an empty name
|
||||
label findPatchID(const word& patchName) const;
|
||||
|
||||
//- Return patch index for a given edge label
|
||||
|
||||
@ -44,14 +44,16 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Forward Declarations
|
||||
class areaMesh;
|
||||
|
||||
template<class Type>
|
||||
class faPatchField;
|
||||
template<class Type> class faPatchField;
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
class GeometricField;
|
||||
|
||||
// Typedefs
|
||||
|
||||
typedef GeometricField<scalar, faPatchField, areaMesh> areaScalarField;
|
||||
typedef GeometricField<vector, faPatchField, areaMesh> areaVectorField;
|
||||
typedef GeometricField<sphericalTensor, faPatchField, areaMesh>
|
||||
@ -60,7 +62,6 @@ typedef GeometricField<symmTensor, faPatchField, areaMesh> areaSymmTensorField;
|
||||
typedef GeometricField<tensor, faPatchField, areaMesh> areaTensorField;
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Namespace fieldTypes Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -43,14 +43,16 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Forward Declarations
|
||||
class edgeMesh;
|
||||
|
||||
template<class Type>
|
||||
class faePatchField;
|
||||
template<class Type> class faePatchField;
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
class GeometricField;
|
||||
|
||||
// Typedefs
|
||||
|
||||
typedef GeometricField<scalar, faePatchField, edgeMesh> edgeScalarField;
|
||||
typedef GeometricField<vector, faePatchField, edgeMesh> edgeVectorField;
|
||||
typedef GeometricField<sphericalTensor, faePatchField, edgeMesh>
|
||||
|
||||
@ -45,14 +45,16 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Forward Declarations
|
||||
class surfaceMesh;
|
||||
|
||||
template<class Type>
|
||||
class fvsPatchField;
|
||||
template<class Type> class fvsPatchField;
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
class GeometricField;
|
||||
|
||||
// Typedefs
|
||||
|
||||
typedef GeometricField<scalar, fvsPatchField, surfaceMesh> surfaceScalarField;
|
||||
typedef GeometricField<vector, fvsPatchField, surfaceMesh> surfaceVectorField;
|
||||
typedef GeometricField<sphericalTensor, fvsPatchField, surfaceMesh>
|
||||
|
||||
@ -48,14 +48,16 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Forward Declarations
|
||||
class volMesh;
|
||||
|
||||
template<class Type>
|
||||
class fvPatchField;
|
||||
template<class Type> class fvPatchField;
|
||||
|
||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||
class GeometricField;
|
||||
|
||||
// Typedefs
|
||||
|
||||
typedef GeometricField<scalar, fvPatchField, volMesh> volScalarField;
|
||||
typedef GeometricField<vector, fvPatchField, volMesh> volVectorField;
|
||||
typedef GeometricField<sphericalTensor, fvPatchField, volMesh>
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2018 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -85,6 +85,11 @@ Foam::labelList Foam::fvBoundaryMesh::indices
|
||||
|
||||
Foam::label Foam::fvBoundaryMesh::findPatchID(const word& patchName) const
|
||||
{
|
||||
if (patchName.empty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
const fvPatchList& patches = *this;
|
||||
|
||||
forAll(patches, patchi)
|
||||
|
||||
@ -46,8 +46,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
|
||||
// Forward Declarations
|
||||
class fvMesh;
|
||||
class polyBoundaryMesh;
|
||||
|
||||
@ -59,7 +58,7 @@ class fvBoundaryMesh
|
||||
:
|
||||
public fvPatchList
|
||||
{
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
//- Reference to mesh
|
||||
const fvMesh& mesh_;
|
||||
@ -107,13 +106,15 @@ public:
|
||||
}
|
||||
|
||||
//- Return a list of pointers for each patch
|
||||
// with only those pointing to interfaces being set
|
||||
//- with only those pointing to interfaces being set
|
||||
lduInterfacePtrsList interfaces() const;
|
||||
|
||||
//- Return patch indices for all matches.
|
||||
// A no-op (returns empty list) for an empty key
|
||||
labelList indices(const keyType& key, const bool useGroups) const;
|
||||
|
||||
//- Find patch index given a name
|
||||
// A no-op (returns -1) for an empty patchName
|
||||
label findPatchID(const word& patchName) const;
|
||||
|
||||
//- Correct patches after moving points
|
||||
|
||||
@ -291,6 +291,10 @@ Foam::labelList Foam::coordinateSystems::indices(const keyType& key) const
|
||||
|
||||
Foam::labelList Foam::coordinateSystems::indices(const wordRes& matcher) const
|
||||
{
|
||||
if (matcher.empty())
|
||||
{
|
||||
return labelList();
|
||||
}
|
||||
return indicesImpl(*this, matcher);
|
||||
}
|
||||
|
||||
@ -319,6 +323,10 @@ Foam::label Foam::coordinateSystems::findIndex(const keyType& key) const
|
||||
|
||||
Foam::label Foam::coordinateSystems::findIndex(const wordRes& matcher) const
|
||||
{
|
||||
if (matcher.empty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return findIndexImpl(*this, matcher);
|
||||
}
|
||||
|
||||
|
||||
@ -133,15 +133,19 @@ public:
|
||||
// Member Functions
|
||||
|
||||
//- Find and return indices for all matches
|
||||
// A no-op (returns empty list) for an empty key
|
||||
labelList indices(const keyType& key) const;
|
||||
|
||||
//- Find and return indices for all matches
|
||||
// A no-op (returns empty list) for an empty matcher
|
||||
labelList indices(const wordRes& matcher) const;
|
||||
|
||||
//- Find and return index for the first match, return -1 if not found
|
||||
// A no-op (returns -1) for an empty key
|
||||
label findIndex(const keyType& key) const;
|
||||
|
||||
//- Find and return index for the first match, return -1 if not found
|
||||
// A no-op (returns -1) for an empty matcher
|
||||
label findIndex(const wordRes& matcher) const;
|
||||
|
||||
//- Search if given key exists
|
||||
|
||||
Reference in New Issue
Block a user