Skip to content
Snippets Groups Projects
surfZoneIdentifier.H 5.32 KiB
Newer Older
  • Learn to ignore specific revisions
  • Mark Olesen's avatar
    Mark Olesen committed
    /*---------------------------------------------------------------------------*\
      =========                 |
      \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
       \\    /   O peration     |
    
    OpenFOAM bot's avatar
    OpenFOAM bot committed
        \\  /    A nd           | www.openfoam.com
    
         \\/     M anipulation  |
    -------------------------------------------------------------------------------
    
    OpenFOAM bot's avatar
    OpenFOAM bot committed
        Copyright (C) 2011 OpenFOAM Foundation
    
        Copyright (C) 2016-2021 OpenCFD Ltd.
    
    Mark Olesen's avatar
    Mark Olesen committed
    -------------------------------------------------------------------------------
    License
        This file is part of OpenFOAM.
    
    
        OpenFOAM is free software: you can redistribute it and/or modify it
        under the terms of the GNU General Public License as published by
        the Free Software Foundation, either version 3 of the License, or
        (at your option) any later version.
    
    Mark Olesen's avatar
    Mark Olesen committed
    
        OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
        ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
        FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
        for more details.
    
        You should have received a copy of the GNU General Public License
    
        along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    Class
    
        Foam::surfZoneIdentifier
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    Description
    
        Identifies a surface patch/zone by name and index,
        with optional geometric type.
    
    SeeAlso
        patchIdentifier
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    SourceFiles
    
        surfZoneIdentifier.C
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    \*---------------------------------------------------------------------------*/
    
    
    #ifndef surfZoneIdentifier_H
    #define surfZoneIdentifier_H
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    #include "word.H"
    #include "label.H"
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    namespace Foam
    {
    
    
    Mark Olesen's avatar
    Mark Olesen committed
    class dictionary;
    
    /*---------------------------------------------------------------------------*\
    
    Mark Olesen's avatar
    Mark Olesen committed
    \*---------------------------------------------------------------------------*/
    
    
    class surfZoneIdentifier
    
    Mark Olesen's avatar
    Mark Olesen committed
    {
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    
            //- Patch/zone name
    
    Mark Olesen's avatar
    Mark Olesen committed
            word name_;
    
    
            //- Patch/zone index in meshed surface
    
            label index_;
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    
            //- Patch/zone type (optional)
            word geometricType_;
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    public:
    
    
    
            //- The name for an 'empty' type
    
            static constexpr const char* const emptyType = "empty";
    
    
    
        // Static Member Functions
    
            //- Default zone name: "zone" or "zoneN"
            static word defaultName(const label n = -1)
            {
                return
                (
                    n < 0
                  ? word("zone", false)
                  : word("zone" + std::to_string(n), false)
                );
            }
    
    
    
        // Generated Methods
    
            //- Copy construct
            surfZoneIdentifier(const surfZoneIdentifier&) = default;
    
            //- Copy assignment
            surfZoneIdentifier& operator=(const surfZoneIdentifier&) = default;
    
    Mark Olesen's avatar
    Mark Olesen committed
        // Constructors
    
    
            //- Default construct. Uses name="", index=0
    
            surfZoneIdentifier();
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    
            //- Construct null with specified index
    
            explicit surfZoneIdentifier(const label index);
    
            //- Construct from mandatory components
            surfZoneIdentifier(const word& name, const label index);
    
    
    Mark Olesen's avatar
    Mark Olesen committed
            //- Construct from components
    
            surfZoneIdentifier
    
    Mark Olesen's avatar
    Mark Olesen committed
            (
                const word& name,
                const label index,
    
    Mark Olesen's avatar
    Mark Olesen committed
            );
    
            //- Construct from dictionary
    
            surfZoneIdentifier
    
    Mark Olesen's avatar
    Mark Olesen committed
            (
                const word& name,
    
    Mark Olesen's avatar
    Mark Olesen committed
                const label index
            );
    
    
            //- Copy construct, resetting the index
    
            surfZoneIdentifier
    
    Mark Olesen's avatar
    Mark Olesen committed
            (
    
                const surfZoneIdentifier& ident,
    
    Mark Olesen's avatar
    Mark Olesen committed
                const label index
            );
    
    
        // Member Functions
    
    
    Mark Olesen's avatar
    Mark Olesen committed
            const word& name() const
            {
                return name_;
            }
    
    
    Mark Olesen's avatar
    Mark Olesen committed
            word& name()
            {
                return name_;
            }
    
    
            //- The geometric type of the patch/zone
    
    Mark Olesen's avatar
    Mark Olesen committed
            const word& geometricType() const
            {
                return geometricType_;
            }
    
    
            //- Modifiable geometric type of the patch/zone
    
    Mark Olesen's avatar
    Mark Olesen committed
            word& geometricType()
            {
                return geometricType_;
            }
    
    
            //- The index of this patch/zone in the surface mesh
    
    Mark Olesen's avatar
    Mark Olesen committed
            label index() const
            {
    
                return index_;
    
    Mark Olesen's avatar
    Mark Olesen committed
            }
    
    
            //- Modifiable index of this patch/zone in the surface mesh
    
            label& index()
            {
                return index_;
            }
    
    
            //- Write (geometricType) dictionary entry
            //- (without surrounding braces)
    
    Mark Olesen's avatar
    Mark Olesen committed
    
    
    // Global Operators
    
    //- Compare zone indentifiers for equality
    bool operator==(const surfZoneIdentifier& a, const surfZoneIdentifier& b);
    
    //- Compare zone indentifiers for inequality
    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);
    
    
    
    Mark Olesen's avatar
    Mark Olesen committed
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    } // End namespace Foam
    
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    
    #endif
    
    // ************************************************************************* //