diff --git a/src/OpenFOAM/fields/GeometricFields/pointFields/pointFields.H b/src/OpenFOAM/fields/GeometricFields/pointFields/pointFields.H index 63516ea58f..6341817897 100644 --- a/src/OpenFOAM/fields/GeometricFields/pointFields/pointFields.H +++ b/src/OpenFOAM/fields/GeometricFields/pointFields/pointFields.H @@ -43,25 +43,6 @@ SourceFiles // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -typedef GeometricField pointScalarField; -typedef GeometricField pointVectorField; -typedef GeometricField - pointSphericalTensorField; -typedef GeometricField - pointSymmTensorField; -typedef GeometricField pointTensorField; - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/pointFields/pointFieldsFwd.H b/src/OpenFOAM/fields/GeometricFields/pointFields/pointFieldsFwd.H index 0aee941c05..5fbcb0d7cb 100644 --- a/src/OpenFOAM/fields/GeometricFields/pointFields/pointFieldsFwd.H +++ b/src/OpenFOAM/fields/GeometricFields/pointFields/pointFieldsFwd.H @@ -47,14 +47,16 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Forward Declarations class pointMesh; -template -class pointPatchField; +template class pointPatchField; template class PatchField, class GeoMesh> class GeometricField; +// Typedefs + typedef GeometricField pointScalarField; typedef GeometricField pointVectorField; typedef GeometricField diff --git a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C index 1f0f9f1921..f8dff17d4c 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C +++ b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.C @@ -61,7 +61,6 @@ Foam::pointBoundaryMesh::pointBoundaryMesh // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - Foam::labelList Foam::pointBoundaryMesh::indices ( const keyType& key, diff --git a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H index c7941f0839..a7a852ae09 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H +++ b/src/OpenFOAM/meshes/pointMesh/pointBoundaryMesh/pointBoundaryMesh.H @@ -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 diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index 022ac5a30c..67c4cb10ad 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -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) diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H index 1107e36238..8f7e9c86b8 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H @@ -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, diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C index 6fd52f11e2..4b49f25bdc 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C @@ -485,6 +485,11 @@ Foam::label Foam::ZoneMesh::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::cfindZone const word& zoneName ) const { + if (zoneName.empty()) + { + return nullptr; + } + const PtrList& zones = *this; for (auto iter = zones.begin(); iter != zones.end(); ++iter) @@ -585,6 +595,7 @@ Foam::bitSet Foam::ZoneMesh::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::selection const wordRes& matcher ) const { + // matcher.empty() is handled by indices() return this->selection(this->indices(matcher)); } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H index 4161f9d1ea..dc7968c09e 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H @@ -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; diff --git a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C index 80fea6ac54..2e7a61c724 100644 --- a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C +++ b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.C @@ -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); } diff --git a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H index 7dd8fb88d3..579fdbbbcb 100644 --- a/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H +++ b/src/finiteArea/faMesh/faBoundaryMesh/faBoundaryMesh.H @@ -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 diff --git a/src/finiteArea/fields/areaFields/areaFieldsFwd.H b/src/finiteArea/fields/areaFields/areaFieldsFwd.H index a7c94e78b7..784ea98b64 100644 --- a/src/finiteArea/fields/areaFields/areaFieldsFwd.H +++ b/src/finiteArea/fields/areaFields/areaFieldsFwd.H @@ -44,14 +44,16 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Forward Declarations class areaMesh; -template -class faPatchField; +template class faPatchField; template class PatchField, class GeoMesh> class GeometricField; +// Typedefs + typedef GeometricField areaScalarField; typedef GeometricField areaVectorField; typedef GeometricField @@ -60,7 +62,6 @@ typedef GeometricField areaSymmTensorField; typedef GeometricField areaTensorField; - /*---------------------------------------------------------------------------*\ Namespace fieldTypes Declaration \*---------------------------------------------------------------------------*/ diff --git a/src/finiteArea/fields/edgeFields/edgeFieldsFwd.H b/src/finiteArea/fields/edgeFields/edgeFieldsFwd.H index fd51202522..ab85d286d9 100644 --- a/src/finiteArea/fields/edgeFields/edgeFieldsFwd.H +++ b/src/finiteArea/fields/edgeFields/edgeFieldsFwd.H @@ -43,14 +43,16 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Forward Declarations class edgeMesh; -template -class faePatchField; +template class faePatchField; template class PatchField, class GeoMesh> class GeometricField; +// Typedefs + typedef GeometricField edgeScalarField; typedef GeometricField edgeVectorField; typedef GeometricField diff --git a/src/finiteVolume/fields/surfaceFields/surfaceFieldsFwd.H b/src/finiteVolume/fields/surfaceFields/surfaceFieldsFwd.H index 817e16133a..1127044043 100644 --- a/src/finiteVolume/fields/surfaceFields/surfaceFieldsFwd.H +++ b/src/finiteVolume/fields/surfaceFields/surfaceFieldsFwd.H @@ -45,14 +45,16 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Forward Declarations class surfaceMesh; -template -class fvsPatchField; +template class fvsPatchField; template class PatchField, class GeoMesh> class GeometricField; +// Typedefs + typedef GeometricField surfaceScalarField; typedef GeometricField surfaceVectorField; typedef GeometricField diff --git a/src/finiteVolume/fields/volFields/volFieldsFwd.H b/src/finiteVolume/fields/volFields/volFieldsFwd.H index 108d6daee3..b6a202c0b1 100644 --- a/src/finiteVolume/fields/volFields/volFieldsFwd.H +++ b/src/finiteVolume/fields/volFields/volFieldsFwd.H @@ -48,14 +48,16 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Forward Declarations class volMesh; -template -class fvPatchField; +template class fvPatchField; template class PatchField, class GeoMesh> class GeometricField; +// Typedefs + typedef GeometricField volScalarField; typedef GeometricField volVectorField; typedef GeometricField diff --git a/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.C b/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.C index 3b35625a05..0377d7c10b 100644 --- a/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.C +++ b/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.C @@ -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) diff --git a/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H b/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H index 4472e44654..568e3fbe9a 100644 --- a/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H +++ b/src/finiteVolume/fvMesh/fvBoundaryMesh/fvBoundaryMesh.H @@ -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 diff --git a/src/meshTools/coordinate/systems/coordinateSystems.C b/src/meshTools/coordinate/systems/coordinateSystems.C index 3f387ca4c0..339a41e2f5 100644 --- a/src/meshTools/coordinate/systems/coordinateSystems.C +++ b/src/meshTools/coordinate/systems/coordinateSystems.C @@ -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); } diff --git a/src/meshTools/coordinate/systems/coordinateSystems.H b/src/meshTools/coordinate/systems/coordinateSystems.H index f16aeda05c..d1af2a795b 100644 --- a/src/meshTools/coordinate/systems/coordinateSystems.H +++ b/src/meshTools/coordinate/systems/coordinateSystems.H @@ -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