diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify.C index 5859077437..0c785baf25 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -550,9 +550,9 @@ int main(int argc, char *argv[]) { patches[nRegions] = geometricSurfacePatch ( - "patch", geometry[surfaces[i]].name() + "_" + regions[regionI], - nRegions + nRegions, + "patch" ); nRegions++; } diff --git a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C index e731760397..986417f9d5 100644 --- a/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C +++ b/applications/utilities/mesh/generation/foamyMesh/foamyHexMeshSurfaceSimplify/foamyHexMeshSurfaceSimplify_non_octree.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -262,9 +263,9 @@ int main(int argc, char *argv[]) { patches[nRegions] = geometricSurfacePatch ( - "patch", geometry[surfaces[i]].name() + "_" + regions[regionI], - nRegions + nRegions, + "patch" ); nRegions++; } diff --git a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/autoPatch.C b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/autoPatch.C index 07285eba72..9e0f1e788b 100644 --- a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/autoPatch.C +++ b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/autoPatch.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -121,9 +122,9 @@ bool Foam::searchableSurfaceModifiers::autoPatch::modify { geometricSurfacePatch patch ( - surf.patches()[regionI].geometricType(), surf.patches()[regionI].name() + Foam::name(subI), - surf.patches().size() + surf.patches().size(), + surf.patches()[regionI].geometricType() ); diff --git a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/cut.C b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/cut.C index a6db3a8bed..e90c555508 100644 --- a/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/cut.C +++ b/applications/utilities/surface/surfacePatch/searchableSurfaceModifier/cut.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -73,13 +74,12 @@ void Foam::searchableSurfaceModifiers::cut::triangulate } } geometricSurfacePatchList patches(fcs.size()); - forAll(patches, patchI) + forAll(patches, patchi) { - patches[patchI] = geometricSurfacePatch + patches[patchi] = geometricSurfacePatch ( - "", - "patch" + Foam::name(patchI), - patchI + "patch" + Foam::name(patchi), + patchi ); } cutSurf = triSurface(tris, patches, pts, true); @@ -345,9 +345,9 @@ bool Foam::searchableSurfaceModifiers::cut::modify newPatches.setSize(sz+1); newPatches[sz] = geometricSurfacePatch ( - newPatches[sz-1].geometricType(), newPatches[sz-1].name() + "_inside", - newPatches[sz-1].index() + newPatches[sz-1].index(), + newPatches[sz-1].geometricType() ); Info<< "Moving " << nInside << " out of " << surf3.size() diff --git a/etc/controlDict b/etc/controlDict index c092f25511..be616aa963 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -588,7 +588,6 @@ DebugSwitches generic 0; genericPatch 0; geomCellLooper 0; - geometricSurfacePatch 0; global 0; globalIndexAndTransform 0; globalMeshData 0; @@ -880,7 +879,6 @@ DebugSwitches surfaceInterpolationScheme 0; surfaceIntersection 0; surfaceNormalFixedValue 0; - surfacePatch 0; surfaceScalarField 0; surfaceScalarField::Internal 0; surfaceSlipDisplacement 0; diff --git a/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C b/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C index 93c13c35ac..d099fe18f7 100644 --- a/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C +++ b/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.C @@ -49,8 +49,7 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID << exit(FatalError); } - HashTable::const_iterator fnd = - pbm.groupPatchIDs().find(name()); + const auto fnd = pbm.groupPatchIDs().cfind(name()); if (!fnd.found()) { @@ -131,18 +130,6 @@ Foam::label Foam::coupleGroupIdentifier::findOtherPatchID // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::coupleGroupIdentifier::coupleGroupIdentifier() -: - name_() -{} - - -Foam::coupleGroupIdentifier::coupleGroupIdentifier(const word& patchGroupName) -: - name_(patchGroupName) -{} - - Foam::coupleGroupIdentifier::coupleGroupIdentifier(const dictionary& dict) : name_() @@ -232,7 +219,7 @@ void Foam::coupleGroupIdentifier::write(Ostream& os) const } -// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // Foam::Ostream& Foam::operator<<(Ostream& os, const coupleGroupIdentifier& p) { diff --git a/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.H b/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.H index 9d92c5fb0f..fd95e43185 100644 --- a/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.H +++ b/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifier.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,12 +28,11 @@ Class Foam::coupleGroupIdentifier Description - Encapsulates using patchGroups to specify coupled patch + Encapsulates using "patchGroups" to specify coupled patch SourceFiles coupleGroupIdentifierI.H coupleGroupIdentifier.C - coupleGroupIdentifierIO.C \*---------------------------------------------------------------------------*/ @@ -47,16 +47,10 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward Declarations class dictionary; class polyMesh; class polyPatch; -class Ostream; - -// Forward declaration of friend functions and operators -class coupleGroupIdentifier; -Ostream& operator<<(Ostream& os, const coupleGroupIdentifier& p); - /*---------------------------------------------------------------------------*\ Class coupleGroupIdentifier Declaration @@ -64,7 +58,7 @@ Ostream& operator<<(Ostream& os, const coupleGroupIdentifier& p); class coupleGroupIdentifier { - // Private data + // Private Data //- Name of patchGroup word name_; @@ -72,7 +66,8 @@ class coupleGroupIdentifier // Private Member Functions - //- Find other patch in specified mesh. Returns index of patch or -1. + //- Find other patch in specified mesh. + // \return index of patch or -1 label findOtherPatchID ( const polyMesh& mesh, @@ -82,16 +77,19 @@ class coupleGroupIdentifier public: + // Generated Methods + + //- Default construct + coupleGroupIdentifier() = default; + + // Constructors - //- Construct null - coupleGroupIdentifier(); - //- Construct from components - coupleGroupIdentifier(const word& patchGroupName); + inline explicit coupleGroupIdentifier(const word& patchGroupName); //- Construct from dictionary - coupleGroupIdentifier(const dictionary& dict); + explicit coupleGroupIdentifier(const dictionary& dict); // Member Functions @@ -102,31 +100,30 @@ public: //- Is a valid patchGroup inline bool valid() const; - //- Find other patch in same region. Returns index of patch or -1. + //- Find other patch in same region. + // \return index of patch or -1. label findOtherPatchID(const polyPatch& thisPatch) const; - //- Find other patch and region. Returns index of patch and sets - // otherRegion to name of region. Fatal error if patch not found + //- Find other patch and region. + // Returns index of patch and sets otherRegion to name of region. + // FatalError if patch not found label findOtherPatchID ( const polyPatch& thisPatch, word& otherRegion ) const; - //- Write the data as a dictionary + //- Write the coupleGroup dictionary entry void write(Ostream& os) const; - - - // IOstream Operators - - friend Ostream& operator<< - ( - Ostream& os, - const coupleGroupIdentifier& p - ); }; +// Global Operators + +//- Write the coupleGroup dictionary entry +Ostream& operator<<(Ostream& os, const coupleGroupIdentifier& p); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifierI.H b/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifierI.H index 7dc5bc4026..29c4e53123 100644 --- a/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifierI.H +++ b/src/OpenFOAM/meshes/Identifiers/patch/coupleGroupIdentifierI.H @@ -25,7 +25,16 @@ License \*---------------------------------------------------------------------------*/ -#include "coupleGroupIdentifier.H" +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +inline Foam::coupleGroupIdentifier::coupleGroupIdentifier +( + const word& patchGroupName +) +: + name_(patchGroupName) +{} + // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C b/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C index 8bd3a0a75a..48ed341ec2 100644 --- a/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C +++ b/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,10 +28,27 @@ License #include "patchIdentifier.H" #include "dictionary.H" -#include "ListOps.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::patchIdentifier::patchIdentifier() +: + name_(), + index_(0) +{} + + +Foam::patchIdentifier::patchIdentifier +( + const word& name, + const label index +) +: + name_(name), + index_(index) +{} + + Foam::patchIdentifier::patchIdentifier ( const word& name, @@ -53,8 +71,7 @@ Foam::patchIdentifier::patchIdentifier const label index ) : - name_(name), - index_(index) + patchIdentifier(name, index) { dict.readIfPresent("physicalType", physicalType_); dict.readIfPresent("inGroups", inGroups_); @@ -76,18 +93,13 @@ Foam::patchIdentifier::patchIdentifier // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool Foam::patchIdentifier::inGroup(const word& name) const -{ - return inGroups_.found(name); -} - - void Foam::patchIdentifier::write(Ostream& os) const { if (physicalType_.size()) { os.writeEntry("physicalType", physicalType_); } + if (inGroups_.size()) { os.writeKeyword("inGroups"); @@ -97,7 +109,7 @@ void Foam::patchIdentifier::write(Ostream& os) const } -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // Foam::Ostream& Foam::operator<<(Ostream& os, const patchIdentifier& p) { diff --git a/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.H b/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.H index dcdbb63783..57244522fa 100644 --- a/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.H +++ b/src/OpenFOAM/meshes/Identifiers/patch/patchIdentifier.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2013 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -38,18 +39,14 @@ SourceFiles #define patchIdentifier_H #include "wordList.H" -#include "label.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// Forward declarations +// Forward Declarations class dictionary; -class patchIdentifier; -Ostream& operator<<(Ostream& os, const patchIdentifier& p); - /*---------------------------------------------------------------------------*\ Class patchIdentifier Declaration @@ -57,7 +54,7 @@ Ostream& operator<<(Ostream& os, const patchIdentifier& p); class patchIdentifier { - // Private data + // Private Data //- Name of patch word name_; @@ -73,14 +70,32 @@ class patchIdentifier public: + // Generated Methods + + //- Copy construct + patchIdentifier(const patchIdentifier&) = default; + + //- Copy assignment + patchIdentifier& operator=(const patchIdentifier&) = default; + + //- Destructor + virtual ~patchIdentifier() = default; + + // Constructors + //- Default construct, with index zero + patchIdentifier(); + + //- Construct from mandatory components + patchIdentifier(const word& name, const label index); + //- Construct from components patchIdentifier ( const word& name, const label index, - const word& physicalType = word::null, + const word& physicalType, const wordList& inGroups = wordList() ); @@ -100,13 +115,9 @@ public: ); - //- Destructor - virtual ~patchIdentifier() = default; - - // Member Functions - //- Return the patch name + //- The patch name const word& name() const { return name_; @@ -118,13 +129,13 @@ public: return name_; } - //- The optional physical type of the patch + //- The (optional) physical type of the patch const word& physicalType() const { return physicalType_; } - //- Modifiable optional physical type of the patch + //- Modifiable (optional) physical type of the patch word& physicalType() { return physicalType_; @@ -136,37 +147,43 @@ public: return index_; } - //- Modifiable the index of this patch in the boundaryMesh + //- Modifiable index of this patch in the boundaryMesh label& index() { return index_; } - //- The optional groups that the patch belongs to + //- The (optional) groups that the patch belongs to const wordList& inGroups() const { return inGroups_; } - //- Modifiable optional groups that the patch belongs to + //- Modifiable (optional) groups that the patch belongs to wordList& inGroups() { return inGroups_; } - //- Check if the patch is in named group - bool inGroup(const word& name) const; + //- True if the patch is in named group + bool inGroup(const word& name) const + { + return inGroups_.found(name); + } - //- Write patchIdentifier as a dictionary + //- Write (physicalType, inGroups) dictionary entries + //- (without surrounding braces) void write(Ostream& os) const; - - - // Ostream Operator - - friend Ostream& operator<<(Ostream& os, const patchIdentifier& p); }; +// Global Operators + +//- Write (physicalType, inGroups) dictionary entries +//- (without surrounding braces) +Ostream& operator<<(Ostream& os, const patchIdentifier& p); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.C b/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.C index bcd02be2f6..8cfbd6934e 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.C +++ b/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,31 +29,54 @@ License #include "geometricSurfacePatch.H" #include "dictionary.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(geometricSurfacePatch, 0); + +static inline word readOptionalWord(Istream& is) +{ + token tok(is); + + if (tok.isWord()) + { + return tok.wordToken(); + } + else + { + // Allow empty words + return word::validate(tok.stringToken()); + } } -const Foam::word Foam::geometricSurfacePatch::emptyType = "empty"; +} // End namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::geometricSurfacePatch::geometricSurfacePatch() : - geometricType_(emptyType), - name_("patch"), - index_(0) + geometricSurfacePatch(0) {} Foam::geometricSurfacePatch::geometricSurfacePatch(const label index) : - geometricType_(emptyType), name_("patch"), - index_(index) + index_(index), + geometricType_(emptyType) +{} + + +Foam::geometricSurfacePatch::geometricSurfacePatch +( + const word& name, + const label index +) +: + name_(name), + index_(index), + geometricType_() {} @@ -64,66 +87,10 @@ Foam::geometricSurfacePatch::geometricSurfacePatch const word& geometricType ) : - geometricType_(geometricType), name_(name), - index_(index) -{ - if (geometricType_.empty()) - { - geometricType_ = emptyType; - } -} - - -Foam::geometricSurfacePatch::geometricSurfacePatch -( - const word& geometricType, - const word& name, - const label index -) -: - geometricType_(geometricType), - name_(name), - index_(index) -{ - if (geometricType_.empty()) - { - geometricType_ = emptyType; - } -} - - -Foam::geometricSurfacePatch::geometricSurfacePatch -( - const surfZoneIdentifier& ident -) -: - geometricType_(ident.geometricType()), - name_(ident.name()), - index_(ident.index()) -{ - if (geometricType_.empty()) - { - geometricType_ = emptyType; - } -} - - -Foam::geometricSurfacePatch::geometricSurfacePatch -( - Istream& is, - const label index -) -: - geometricType_(is), - name_(is), - index_(index) -{ - if (geometricType_.empty()) - { - geometricType_ = emptyType; - } -} + index_(index), + geometricType_(geometricType) +{} Foam::geometricSurfacePatch::geometricSurfacePatch @@ -133,26 +100,31 @@ Foam::geometricSurfacePatch::geometricSurfacePatch const label index ) : - geometricType_(emptyType), name_(name), - index_(index) + index_(index), + geometricType_() { dict.readIfPresent("geometricType", geometricType_); } +Foam::geometricSurfacePatch::geometricSurfacePatch +( + const surfZoneIdentifier& ident +) +: + geometricSurfacePatch(ident.name(), ident.index(), ident.geometricType()) +{} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::geometricSurfacePatch::write(Ostream& os) const { - os << nl << name_ - << nl << geometricType_; -} - - -void Foam::geometricSurfacePatch::writeDict(Ostream& os) const -{ - os.writeEntry("geometricType", geometricType_); + if (geometricType_.size()) + { + os.writeEntry("geometricType", geometricType_); + } } @@ -182,21 +154,54 @@ bool Foam::operator!= } -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // -Foam::Istream& Foam::operator>>(Istream& is, geometricSurfacePatch& p) +Foam::Istream& Foam::operator>>(Istream& is, geometricSurfacePatch& obj) { - is >> p.name_ >> p.geometricType_; + obj.name() = readOptionalWord(is); + obj.geometricType() = readOptionalWord(is); + return is; } -Foam::Ostream& Foam::operator<<(Ostream& os, const geometricSurfacePatch& p) +Foam::Ostream& Foam::operator<<(Ostream& os, const geometricSurfacePatch& obj) { - p.write(os); + // Force unconditional line-breaks on list output. + // We otherwise risk extremely unreadable entries + os << nl; + + // Empty words are double-quoted so they are treated as 'string' + + os.writeQuoted(obj.name(), obj.name().empty()) << token::SPACE; + os.writeQuoted(obj.geometricType(), obj.geometricType().empty()); + + // Equivalent for OpenFOAM-1912 and earlier: + // if (obj.geometricType().empty()) + // { + // os << emptyType; + // } + // else + // { + // os << obj.geometricType(); + // } + os.check(FUNCTION_NAME); return os; } +// * * * * * * * * * * * * * * * Housekeeping * * * * * * * * * * * * * * * // + +Foam::geometricSurfacePatch::geometricSurfacePatch +( + const word& geometricType, + const word& name, + const label index +) +: + geometricSurfacePatch(name, index, geometricType) +{} + + // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.H b/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.H index 80f1334d8a..9d466c3e3c 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.H +++ b/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatch.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,7 +39,6 @@ SourceFiles #ifndef geometricSurfacePatch_H #define geometricSurfacePatch_H -#include "typeInfo.H" #include "surfZoneIdentifier.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,13 +46,6 @@ SourceFiles namespace Foam { -// Forward declarations -class dictionary; -class geometricSurfacePatch; - -Istream& operator>>(Istream& is, geometricSurfacePatch& p); -Ostream& operator<<(Ostream& os, const geometricSurfacePatch& p); - /*---------------------------------------------------------------------------*\ Class geometricSurfacePatch Declaration \*---------------------------------------------------------------------------*/ @@ -62,65 +54,65 @@ class geometricSurfacePatch { // Private Data - //- Type name of patch - word geometricType_; - //- Name of patch word name_; //- Index of patch in boundary label index_; + //- Type name of patch + word geometricType_; + public: // Public Data //- The name for an 'empty' type - static const word emptyType; + static constexpr const char* const emptyType = "empty"; + + + // Public Classes //- Helper to convert identifier types as an operation struct fromIdentifier { - geometricSurfacePatch operator()(const surfZoneIdentifier& ident) - const + geometricSurfacePatch + operator()(const surfZoneIdentifier& ident) const { return geometricSurfacePatch(ident); } }; - //- Runtime type information - ClassName("geometricSurfacePatch"); + // Generated Methods + + //- Copy construct + geometricSurfacePatch(const geometricSurfacePatch&) = default; + + //- Copy assignment + geometricSurfacePatch& + operator=(const geometricSurfacePatch&) = default; // Constructors - //- Construct null + //- Default construct, use index=0, name="patch" geometricSurfacePatch(); //- Construct null with specified index explicit geometricSurfacePatch(const label index); + //- Construct from mandatory components + geometricSurfacePatch(const word& name, const label index); + //- Construct from components geometricSurfacePatch ( const word& name, const label index, - const word& geometricType = word::null + const word& geometricType ); - //- Construct from components - geometricSurfacePatch - ( - const word& geometricType, - const word& name, - const label index - ); - - //- Implicit conversion from surfZoneIdentifier, which has similar - //- information but in a different order - geometricSurfacePatch(const surfZoneIdentifier& ident); - //- Construct from dictionary geometricSurfacePatch ( @@ -129,59 +121,76 @@ public: const label index ); - //- Construct from Istream - geometricSurfacePatch(Istream& is, const label index); + //- Implicit conversion from surfZoneIdentifier + geometricSurfacePatch(const surfZoneIdentifier& ident); // Member Functions - //- Return name + //- The patch/zone name const word& name() const { return name_; } - //- Return name + //- Modifiable patch/zone name word& name() { return name_; } - //- Return the geometric type of the patch + //- The geometric type of the patch/zone const word& geometricType() const { return geometricType_; } - //- Return the geometric type of the patch for modification + //- Modifiable geometric type of the patch/zone word& geometricType() { return geometricType_; } - //- Return the index of this patch in the surface mesh + //- The index of this patch/zone in the surface mesh label index() const { return index_; } - //- Return the index of this patch in the surface mesh for modification + //- Modifiable index of this patch/zone in the surface mesh label& index() { return index_; } - //- Write + //- Write (geometricType) dictionary entry + //- (without surrounding braces) + // \warning Prior to 2020-01 was identical to operator<< output void write(Ostream& os) const; - //- Write dictionary - void writeDict(Ostream& os) const; + // Housekeeping - // Ostream Operator + //- Removed(2020-01) Construct from Istream + // \deprecated(2020-01) - unused, inconsistent + geometricSurfacePatch(Istream& is, const label index) = delete; - friend Istream& operator>>(Istream& is, geometricSurfacePatch& p); - friend Ostream& operator<<(Ostream& os, const geometricSurfacePatch& p); + //- Deprecated(2020-01) Construct from components + // \deprecated(2020-01) - order inconsistent with other identifiers + geometricSurfacePatch + ( + const word& geometricType, + const word& name, + const label index + ) FOAM_DEPRECATED(2020-01); + + //- Deprecated(2020-01) Write dictionary + // \deprecated(2020-01) - Write dictionary + void FOAM_DEPRECATED_FOR(2020-01, "write() or operator<<") + writeDict(Ostream& os) const + { + write(os); + } }; @@ -194,6 +203,13 @@ bool operator==(const geometricSurfacePatch& a, const geometricSurfacePatch& b); bool operator!=(const geometricSurfacePatch& a, const geometricSurfacePatch& b); +//- Read name, geometricType +Istream& operator>>(Istream& is, geometricSurfacePatch& obj); + +//- Write name, geometricType. Entries are quoted to support empty words. +Ostream& operator<<(Ostream& os, const geometricSurfacePatch& obj); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatchList.H b/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatchList.H index 278fc66297..c49c03a2ef 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatchList.H +++ b/src/OpenFOAM/meshes/Identifiers/surface/geometricSurfacePatchList.H @@ -27,6 +27,7 @@ Typedef Foam::geometricSurfacePatchList Description + A List of geometricSurfacePatch. \*---------------------------------------------------------------------------*/ @@ -43,7 +44,7 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -typedef List geometricSurfacePatchList; +typedef List geometricSurfacePatchList; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C index e962e4c4ba..a34658d289 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C +++ b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,9 +29,27 @@ License #include "surfZoneIdentifier.H" #include "dictionary.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * // -const Foam::word Foam::surfZoneIdentifier::emptyType = "empty"; +namespace Foam +{ + +static inline word readOptionalWord(Istream& is) +{ + token tok(is); + + if (tok.isWord()) + { + return tok.wordToken(); + } + else + { + // Allow empty words + return word::validate(tok.stringToken()); + } +} + +} // End namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -52,6 +70,18 @@ Foam::surfZoneIdentifier::surfZoneIdentifier(const label index) {} +Foam::surfZoneIdentifier::surfZoneIdentifier +( + const word& name, + const label index +) +: + name_(name), + index_(index), + geometricType_() +{} + + Foam::surfZoneIdentifier::surfZoneIdentifier ( const word& name, @@ -105,7 +135,11 @@ void Foam::surfZoneIdentifier::write(Ostream& os) const // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // -bool Foam::operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b) +bool Foam::operator== +( + const surfZoneIdentifier& a, + const surfZoneIdentifier& b +) { return ( @@ -116,7 +150,11 @@ bool Foam::operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b) } -bool Foam::operator!=(const surfZoneIdentifier& a, const surfZoneIdentifier& b) +bool Foam::operator!= +( + const surfZoneIdentifier& a, + const surfZoneIdentifier& b +) { return !(a == b); } @@ -126,15 +164,24 @@ bool Foam::operator!=(const surfZoneIdentifier& a, const surfZoneIdentifier& b) Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj) { - is >> obj.name() >> obj.geometricType(); + obj.name() = readOptionalWord(is); + obj.geometricType() = readOptionalWord(is); + return is; } 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(); + // Force unconditional line-breaks on list output. + // We otherwise risk extremely unreadable entries + os << nl; + + // Empty words are double-quoted so they are treated as 'string' + + os.writeQuoted(obj.name(), obj.name().empty()) << token::SPACE; + os.writeQuoted(obj.geometricType(), obj.geometricType().empty()); + os.check(FUNCTION_NAME); return os; } diff --git a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H index aec04a0c18..f28a6290b1 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H +++ b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifier.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,13 +43,14 @@ SourceFiles #include "word.H" #include "label.H" +#include "stdFoam.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// Forward declarations +// Forward Declarations class dictionary; /*---------------------------------------------------------------------------*\ @@ -58,7 +59,7 @@ class dictionary; class surfZoneIdentifier { - // Private data + // Private Data //- Name of zone word name_; @@ -69,29 +70,40 @@ class surfZoneIdentifier //- Type name of zone mutable word geometricType_; - public: - // Public data + // Public Data //- The name for an 'empty' type - static const word emptyType; + static constexpr const char* const emptyType = "empty"; + + + // Generated Methods + + //- Copy construct + surfZoneIdentifier(const surfZoneIdentifier&) = default; + + //- Copy assignment + surfZoneIdentifier& operator=(const surfZoneIdentifier&) = default; // Constructors - //- Construct null, with index zero + //- Default construct, with index zero surfZoneIdentifier(); //- Construct null with specified index explicit surfZoneIdentifier(const label index); + //- Construct from mandatory components + surfZoneIdentifier(const word& name, const label index); + //- Construct from components surfZoneIdentifier ( const word& name, const label index, - const word& geometricType = word::null + const word& geometricType ); //- Construct from dictionary @@ -102,7 +114,7 @@ public: const label index ); - //- Copy construct from another zone identifier, resetting the index + //- Copy construct, resetting the index surfZoneIdentifier ( const surfZoneIdentifier& p, @@ -110,64 +122,52 @@ public: ); - //- Destructor - virtual ~surfZoneIdentifier() = default; - - // Member Functions - //- Return name + //- The patch/zone name const word& name() const { return name_; } - //- Return name for modification + //- Modifiable patch/zone name word& name() { return name_; } - //- Return the geometric type of the patch/zone + //- The geometric type of the patch/zone const word& geometricType() const { return geometricType_; } - //- Return the geometric type of the patch/zone for modification + //- Modifiable geometric type of the patch/zone word& geometricType() { return geometricType_; } - //- Return the index of this patch/zone in the surface mesh + //- The index of this patch/zone in the surface mesh label index() const { return index_; } - //- Return the index of this patch/zone for modification + //- Modifiable index of this patch/zone in the surface mesh label& index() { return index_; } - - //- Write identifier as a dictionary + //- Write (geometricType) dictionary entry + //- (without surrounding braces) void write(Ostream& os) const; }; // 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); @@ -175,6 +175,13 @@ bool operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b); bool operator!=(const surfZoneIdentifier& a, const surfZoneIdentifier& b); +//- Read name, geometricType +Istream& operator>>(Istream& is, surfZoneIdentifier& obj); + +//- Write name, geometricType. Entries are quoted to support empty words. +Ostream& operator<<(Ostream& os, const surfZoneIdentifier& obj); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifierList.H b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifierList.H index 88ebfcfbfe..a7da0c83a6 100644 --- a/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifierList.H +++ b/src/OpenFOAM/meshes/Identifiers/surface/surfZoneIdentifierList.H @@ -27,6 +27,7 @@ Typedef Foam::surfZoneIdentifierList Description + A List of surfZoneIdentifier. \*---------------------------------------------------------------------------*/ @@ -43,7 +44,7 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -typedef List surfZoneIdentifierList; +typedef List surfZoneIdentifierList; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/dynamicMesh/boundaryMesh/boundaryMesh.C b/src/dynamicMesh/boundaryMesh/boundaryMesh.C index c34cf7dcba..7439f40732 100644 --- a/src/dynamicMesh/boundaryMesh/boundaryMesh.C +++ b/src/dynamicMesh/boundaryMesh/boundaryMesh.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -781,9 +782,9 @@ void Foam::boundaryMesh::writeTriSurface(const fileName& fName) const surfPatches[patchi] = geometricSurfacePatch ( - bp.physicalType(), bp.name(), - patchi + patchi, + bp.physicalType() ); } diff --git a/src/dynamicMesh/boundaryPatch/boundaryPatch.C b/src/dynamicMesh/boundaryPatch/boundaryPatch.C index 8164e34709..c1caf69392 100644 --- a/src/dynamicMesh/boundaryPatch/boundaryPatch.C +++ b/src/dynamicMesh/boundaryPatch/boundaryPatch.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,34 +60,14 @@ Foam::boundaryPatch::boundaryPatch {} -Foam::boundaryPatch::boundaryPatch(const boundaryPatch& p) -: - patchIdentifier(p.name(), p.index(), p.physicalType()), - size_(p.size()), - start_(p.start()) -{} - - Foam::boundaryPatch::boundaryPatch(const boundaryPatch& p, const label index) : - patchIdentifier(p.name(), index, p.physicalType()), - size_(p.size()), - start_(p.start()) -{} - - -Foam::autoPtr Foam::boundaryPatch::clone() const + boundaryPatch(p) { - return autoPtr::New(*this); + patchIdentifier::index() = index; } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::boundaryPatch::~boundaryPatch() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::boundaryPatch::write(Ostream& os) const @@ -97,7 +78,7 @@ void Foam::boundaryPatch::write(Ostream& os) const } -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // Foam::Ostream& Foam::operator<<(Ostream& os, const boundaryPatch& p) { diff --git a/src/dynamicMesh/boundaryPatch/boundaryPatch.H b/src/dynamicMesh/boundaryPatch/boundaryPatch.H index de01b05e3b..ec7d66a081 100644 --- a/src/dynamicMesh/boundaryPatch/boundaryPatch.H +++ b/src/dynamicMesh/boundaryPatch/boundaryPatch.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,8 +28,9 @@ Class Foam::boundaryPatch Description - Like polyPatch but without reference to mesh. patchIdentifier::index - is not used. Used in boundaryMesh to hold data on patches. + Like polyPatch but without reference to mesh. + Used in boundaryMesh to hold data on patches. + The patchIdentifier::index is set, but not used. SourceFiles boundaryPatch.C @@ -46,28 +48,25 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators - -class boundaryPatch; - -Ostream& operator<<(Ostream&, const boundaryPatch&); - - /*---------------------------------------------------------------------------*\ - Class boundaryPatch Declaration + Class boundaryPatch Declaration \*---------------------------------------------------------------------------*/ class boundaryPatch : public patchIdentifier { - // Private data + // Private Data label size_; + label start_; public: + // Generated Methods: copy construct, copy assignment + + // Constructors //- Construct from components @@ -88,18 +87,15 @@ public: const label index ); - //- Construct as copy - boundaryPatch(const boundaryPatch&); + //- Copy construct, resetting the index + boundaryPatch(const boundaryPatch& p, const label index); - //- Construct as copy, resetting the index - boundaryPatch(const boundaryPatch&, const label index); //- Clone - autoPtr clone() const; - - - //- Destructor - ~boundaryPatch(); + autoPtr clone() const + { + return autoPtr::New(*this); + } // Member Functions @@ -125,16 +121,17 @@ public: } - //- Write dictionary - virtual void write(Ostream&) const; - - - // Ostream Operator - - friend Ostream& operator<<(Ostream&, const boundaryPatch&); + //- Write dictionary entries (without surrounding braces) + virtual void write(Ostream& os) const; }; +// Global Operators + +//- Write boundaryPatch as dictionary entries (without surrounding braces) +Ostream& operator<<(Ostream&, const boundaryPatch& p); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/sampling/surface/isoSurface/isoSurface.C b/src/sampling/surface/isoSurface/isoSurface.C index 1434822884..00848f0ec7 100644 --- a/src/sampling/surface/isoSurface/isoSurface.C +++ b/src/sampling/surface/isoSurface/isoSurface.C @@ -1019,7 +1019,7 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints if (debug) { - triSurface surf(tris, geometricSurfacePatchList(0), newPoints); + triSurface surf(tris, geometricSurfacePatchList(), newPoints); forAll(surf, facei) { @@ -1054,7 +1054,7 @@ Foam::triSurface Foam::isoSurface::stitchTriPoints } } - return triSurface(tris, geometricSurfacePatchList(0), newPoints, true); + return triSurface(tris, geometricSurfacePatchList(), newPoints, true); } diff --git a/src/sampling/surface/isoSurface/isoSurfaceCell.C b/src/sampling/surface/isoSurface/isoSurfaceCell.C index 5c4338d75f..d1ddb13830 100644 --- a/src/sampling/surface/isoSurface/isoSurfaceCell.C +++ b/src/sampling/surface/isoSurface/isoSurfaceCell.C @@ -340,7 +340,7 @@ Foam::pointIndexHit Foam::isoSurfaceCell::collapseSurface triSurface surf ( localTris, - geometricSurfacePatchList(0), + geometricSurfacePatchList(), localPoints, true ); @@ -1053,7 +1053,7 @@ Foam::triSurface Foam::isoSurfaceCell::stitchTriPoints } } - return triSurface(tris, geometricSurfacePatchList(0), newPoints, true); + return triSurface(tris, geometricSurfacePatchList(), newPoints, true); } diff --git a/src/surfMesh/surfZone/surfZone.C b/src/surfMesh/surfZone/surfZone.C index 7abb405e16..0b696a71b8 100644 --- a/src/surfMesh/surfZone/surfZone.C +++ b/src/surfMesh/surfZone/surfZone.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2012 OpenFOAM Foundation - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,15 +28,6 @@ License #include "surfZone.H" #include "dictionary.H" -#include "word.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(surfZone, 0); -} - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -71,19 +62,6 @@ Foam::surfZone::surfZone {} -Foam::surfZone::surfZone(Istream& is, const label index) -: - surfZoneIdentifier(), - size_(0), - start_(0) -{ - word name(is); - dictionary dict(is); - - operator=(surfZone(name, dict, index)); -} - - Foam::surfZone::surfZone ( const word& name, @@ -97,31 +75,17 @@ Foam::surfZone::surfZone {} -Foam::surfZone::surfZone(const surfZone& zone) -: - surfZoneIdentifier(zone, zone.index()), - size_(zone.size()), - start_(zone.start()) -{} - - Foam::surfZone::surfZone(const surfZone& zone, const label index) : - surfZoneIdentifier(zone, index), - size_(zone.size()), - start_(zone.start()) -{} + surfZone(zone) +{ + surfZoneIdentifier::index() = index; +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // void Foam::surfZone::write(Ostream& os) const -{ - writeDict(os); -} - - -void Foam::surfZone::writeDict(Ostream& os) const { os.beginBlock(name()); @@ -133,39 +97,44 @@ void Foam::surfZone::writeDict(Ostream& os) const } -// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // -bool Foam::surfZone::operator!=(const surfZone& rhs) const -{ - return !(*this == rhs); -} - - -bool Foam::surfZone::operator==(const surfZone& rhs) const +bool Foam::operator==(const surfZone& a, const surfZone& b) { return ( - size() == rhs.size() - && start() == rhs.start() - && geometricType() == rhs.geometricType() + a.size() == b.size() + && a.start() == b.start() + && a.geometricType() == b.geometricType() ); } -// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // - -Foam::Istream& Foam::operator>>(Istream& is, surfZone& zone) +bool Foam::operator!=(const surfZone& a, const surfZone& b) { - zone = surfZone(is, 0); + return !(a == b); +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Istream& Foam::operator>>(Istream& is, surfZone& obj) +{ + const word name(is); + const dictionary dict(is); + + // Could also leave index untouched? + obj = surfZone(name, dict, 0); is.check(FUNCTION_NAME); return is; } -Foam::Ostream& Foam::operator<<(Ostream& os, const surfZone& zone) +Foam::Ostream& Foam::operator<<(Ostream& os, const surfZone& obj) { - zone.write(os); + obj.write(os); + os.check(FUNCTION_NAME); return os; } diff --git a/src/surfMesh/surfZone/surfZone.H b/src/surfMesh/surfZone/surfZone.H index 93d55d6807..7582556287 100644 --- a/src/surfMesh/surfZone/surfZone.H +++ b/src/surfMesh/surfZone/surfZone.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,9 +40,6 @@ SourceFiles #ifndef surfZone_H #define surfZone_H -#include "word.H" -#include "label.H" -#include "className.H" #include "surfZoneIdentifier.H" #include "labelRange.H" #include "autoPtr.H" @@ -53,12 +50,6 @@ SourceFiles namespace Foam { -// Forward declarations -class surfZone; - -Istream& operator>>(Istream&, surfZone&); -Ostream& operator<<(Ostream&, const surfZone&); - /*---------------------------------------------------------------------------*\ Class surfZone Declaration \*---------------------------------------------------------------------------*/ @@ -67,7 +58,7 @@ class surfZone : public surfZoneIdentifier { - // Private data + // Private Data //- Size of this group in the face list label size_; @@ -78,13 +69,18 @@ class surfZone public: - //- Runtime type information - ClassName("surfZone"); + // Generated Methods + + //- Copy construct + surfZone(const surfZone&) = default; + + //- Copy assignment + surfZone& operator=(const surfZone&) = default; // Constructors - //- Construct null with zero start, size, index + //- Default construct, with zero start, size, index surfZone(); //- Construct with name, size. With zero start, index @@ -100,9 +96,6 @@ public: const word& geometricType = word::null ); - //- Construct from Istream - surfZone(Istream& is, const label index); - //- Construct from dictionary surfZone ( @@ -111,10 +104,7 @@ public: const label index ); - //- Construct as copy - surfZone(const surfZone&); - - //- Construct from another zone, resetting the index + //- Copy construct, resetting the index surfZone(const surfZone&, const label index); //- Return clone @@ -126,8 +116,8 @@ public: static autoPtr New(Istream& is) { - word name(is); - dictionary dict(is); + const word name(is); + const dictionary dict(is); return autoPtr::New(name, dict, 0); } @@ -135,58 +125,73 @@ public: // Member Functions - //- Return start label of this zone in the face list + //- The start label of this zone in the face list label start() const { return start_; } - //- Return start label of this zone in the face list + //- Modifiable start label of this zone in the face list label& start() { return start_; } - //- Return size of this zone in the face list + //- The size of this zone in the face list label size() const { return size_; } - //- Return size of this zone in the face list + //- Modifiable size of this zone in the face list label& size() { return size_; } - //- Return start/size range of this zone + //- The start/size range of this zone labelRange range() const { return labelRange(start_, size_); } - //- Write - void write(Ostream&) const; - - //- Write dictionary - void writeDict(Ostream&) const; + //- Write dictionary, includes surrounding braces + // \warning Prior to 2020-01 was identical to operator<< output + void write(Ostream& os) const; - // Member Operators + // Housekeeping - bool operator!=(const surfZone&) const; + //- Removed(2020-01) Construct from Istream + // \deprecated(2020-01) - unused, inconsistent + surfZone(Istream& is, const label index) = delete; - //- compare. - bool operator==(const surfZone&) const; - - - // IOstream Operators - - friend Istream& operator>>(Istream&, surfZone&); - friend Ostream& operator<<(Ostream&, const surfZone&); + //- Deprecated(2020-01) Write dictionary + // \deprecated(2020-01) - Write dictionary + void FOAM_DEPRECATED_FOR(2020-01, "write() or operator<<") + writeDict(Ostream& os) const + { + write(os); + } }; +// Global Operators + +//- Compare surfZones for equality +bool operator==(const surfZone& a, const surfZone& b); + +//- Compare surfZones for inequality +bool operator!=(const surfZone& a, const surfZone& b); + + +//- Read as dictionary +Istream& operator>>(Istream& is, surfZone& obj); + +//- Write as dictionary +Ostream& operator<<(Ostream&, const surfZone& obj); + + // Global Functions //- The labelRange of a surfZone diff --git a/src/surfMesh/surfZone/surfZoneIOList.C b/src/surfMesh/surfZone/surfZoneIOList.C index 569f4be4e8..2cd1186147 100644 --- a/src/surfMesh/surfZone/surfZoneIOList.C +++ b/src/surfMesh/surfZone/surfZoneIOList.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. @@ -32,7 +32,7 @@ License namespace Foam { - defineTypeNameAndDebug(surfZoneIOList, 0); + defineTypeName(surfZoneIOList); } @@ -57,40 +57,28 @@ Foam::surfZoneIOList::surfZoneIOList Istream& is = readStream(typeName); PtrList dictEntries(is); - zones.setSize(dictEntries.size()); + zones.resize(dictEntries.size()); label facei = 0; - forAll(zones, zoneI) + forAll(zones, zonei) { - const dictionary& dict = dictEntries[zoneI].dict(); - - const label zoneSize = dict.get