diff --git a/src/surfMesh/surfZone/surfZone/surfZone.C b/src/surfMesh/surfZone/surfZone/surfZone.C index faab2394569cb012e42f8a59fb8e774466a9f33f..2620f2b4fbf171e78d3908bc2aff5678e48bfe90 100644 --- a/src/surfMesh/surfZone/surfZone/surfZone.C +++ b/src/surfMesh/surfZone/surfZone/surfZone.C @@ -116,7 +116,7 @@ void Foam::surfZone::writeDict(Ostream& os) const << indent << token::BEGIN_BLOCK << incrIndent << nl; surfZoneIdentifier::write(os); - os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl; + os.writeKeyword("nFaces") << size() << token::END_STATEMENT << nl; os.writeKeyword("startFace") << start() << token::END_STATEMENT << nl; os << decrIndent << indent << token::END_BLOCK << endl; @@ -135,7 +135,7 @@ bool Foam::surfZone::operator==(const surfZone& rhs) const { return ( - size() == rhs.size() + size() == rhs.size() && start() == rhs.start() && geometricType() == rhs.geometricType() ); diff --git a/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.C b/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.C index bf9322aac38a330b62963a90377941b576e4b6fa..049559865785f811a81f6c66ea1909fe0543f272 100644 --- a/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.C +++ b/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,13 +26,26 @@ License #include "surfZoneIdentifier.H" #include "dictionary.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +const Foam::word Foam::surfZoneIdentifier::emptyType = "empty"; + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::surfZoneIdentifier::surfZoneIdentifier() : - name_(word::null), + name_(), index_(0), - geometricType_(word::null) + geometricType_() +{} + + +Foam::surfZoneIdentifier::surfZoneIdentifier(label index) +: + name_(), + index_(index), + geometricType_() {} @@ -57,7 +70,8 @@ Foam::surfZoneIdentifier::surfZoneIdentifier ) : name_(name), - index_(index) + index_(index), + geometricType_() { dict.readIfPresent("geometricType", geometricType_); } @@ -88,7 +102,8 @@ void Foam::surfZoneIdentifier::write(Ostream& os) const { if (geometricType_.size()) { - os.writeKeyword("geometricType") << geometricType_ + os.writeKeyword("geometricType") + << geometricType_ << token::END_STATEMENT << nl; } } @@ -96,41 +111,46 @@ void Foam::surfZoneIdentifier::write(Ostream& os) const // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -// bool Foam::surfZoneIdentifier::operator!= -// ( -// const surfZoneIdentifier& p -// ) const -// { -// return !(*this == p); -// } -// -// -// bool Foam::surfZoneIdentifier::operator== -// ( -// const surfZoneIdentifier& p -// ) const -// { -// return geometricType() == p.geometricType() && name() == p.name(); -// } +// needed for list output + +bool Foam::surfZoneIdentifier::operator!= +( + const surfZoneIdentifier& rhs +) const +{ + return !(*this == rhs); +} + + +bool Foam::surfZoneIdentifier::operator== +( + const surfZoneIdentifier& rhs +) const +{ + return + ( + name() == rhs.name() + && geometricType() == rhs.geometricType() + ); +} // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // -// Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& p) -// { -// is >> p.name_ >> p.geometricType_; -// -// return is; -// } +Foam::Istream& Foam::operator>>(Istream& is, surfZoneIdentifier& obj) +{ + is >> obj.name_ + >> obj.geometricType_; + + return is; +} -Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& p) +Foam::Ostream& Foam::operator<<(Ostream& os, const surfZoneIdentifier& obj) { - p.write(os); - os.check - ( - "Ostream& operator<<(Ostream&, const surfZoneIdentifier&)" - ); + os << obj.name_ << ' ' << obj.geometricType_; + + os.check("Ostream& operator<<(Ostream&, const surfZoneIdentifier&)"); return os; } diff --git a/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.H b/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.H index c0687c157c3306b280965d1a3491bd7a56d1984f..3f6a1b9a7790a19dba9126616c744eae92e05b2c 100644 --- a/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.H +++ b/src/surfMesh/surfZone/surfZoneIdentifier/surfZoneIdentifier.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,10 +25,10 @@ Class Foam::surfZoneIdentifier Description - An identifier for a surface zone on a meshed surface. + Identifies a surface patch/zone by name, patch index and geometricType. - Similar in concept to a faceZone on the surface, but can also have a - "geometricType" as well. +SeeAlso + patchIdentifier SourceFiles surfZoneIdentifier.C @@ -52,6 +52,7 @@ class dictionary; // Forward declaration of friend functions and operators class surfZoneIdentifier; +Istream& operator>>(Istream&, surfZoneIdentifier&); Ostream& operator<<(Ostream&, const surfZoneIdentifier&); /*---------------------------------------------------------------------------*\ @@ -74,11 +75,23 @@ class surfZoneIdentifier public: + // Public data + + //- The name for an 'empty' type + static const word emptyType; + + // Constructors //- Construct null surfZoneIdentifier(); + //- Construct null with specified index + explicit surfZoneIdentifier + ( + const label index + ); + //- Construct from components surfZoneIdentifier ( @@ -122,42 +135,57 @@ public: return name_; } - //- Return the geometric type of the zone + //- Return the geometric type of the patch/zone const word& geometricType() const { return geometricType_; } - //- Return the geometric type of the zone for modification + //- Return the geometric type of the patch/zone for modification word& geometricType() { return geometricType_; } - //- Return the index of this zone in the surface mesh + //- Return the index of this patch/zone in the surface mesh label index() const { return index_; } - //- Write surfZoneIdentifier as a dictionary - void write(Ostream&) const; + //- Return the index of this patch/zone for modification + label& index() + { + return index_; + } + //- Write surfZoneIdentifier as a dictionary -// void writeDict(Ostream&) const; + void write(Ostream&) const; // Member Operators -// bool operator!=(const surfZoneIdentifier&) const; -// -// //- compare. -// bool operator==(const surfZoneIdentifier&) const; + bool operator!=(const surfZoneIdentifier&) const; + bool operator==(const surfZoneIdentifier&) const; + // Ostream Operator - friend Ostream& operator<<(Ostream&, const surfZoneIdentifier&); -// friend Istream& operator>>(Istream&, surfZoneIdentifier&); + //- Read name/type. + friend Istream& operator>> + ( + Istream&, + surfZoneIdentifier& + ); + + //- Write name/type. + friend Ostream& operator<< + ( + Ostream&, + const surfZoneIdentifier& + ); + };