patchIdentifier.H 5.3 KB
Newer Older
1 2 3 4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           | www.openfoam.com
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2013 OpenFOAM Foundation
9
    Copyright (C) 2020 OpenCFD Ltd.
10 11 12 13
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

14 15 16 17
    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.
18 19 20 21 22 23 24

    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
25
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
26 27 28 29 30

Class
    Foam::patchIdentifier

Description
31
    Identifies a patch by name, patch index and physical type
32 33 34 35 36 37 38 39 40

SourceFiles
    patchIdentifier.C

\*---------------------------------------------------------------------------*/

#ifndef patchIdentifier_H
#define patchIdentifier_H

41
#include "wordList.H"
42 43 44 45 46 47

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

48
// Forward Declarations
49 50 51
class dictionary;

/*---------------------------------------------------------------------------*\
52
                       Class patchIdentifier Declaration
53 54 55 56
\*---------------------------------------------------------------------------*/

class patchIdentifier
{
57
    // Private Data
58 59 60 61 62

        //- Name of patch
        word name_;

        //- Index of patch in boundary
Mark Olesen's avatar
Mark Olesen committed
63
        label index_;
64 65 66 67

        //- Optional physical type
        mutable word physicalType_;

68
        //- Optional groups to which the patch belongs
69
        wordList inGroups_;
70 71 72

public:

73 74 75 76 77 78 79 80 81 82 83 84 85 86
    // Static Member Functions

        //- Default patch name: "patch" or "patchN"
        static word defaultName(const label n = -1)
        {
            return
            (
                n < 0
              ? word("patch", false)
              : word("patch" + std::to_string(n), false)
            );
        }


87 88 89 90 91 92 93 94 95 96 97 98
    // Generated Methods

        //- Copy construct
        patchIdentifier(const patchIdentifier&) = default;

        //- Copy assignment
        patchIdentifier& operator=(const patchIdentifier&) = default;

        //- Destructor
        virtual ~patchIdentifier() = default;


99 100
    // Constructors

101 102 103 104 105 106
        //- Default construct, with index zero
        patchIdentifier();

        //- Construct from mandatory components
        patchIdentifier(const word& name, const label index);

107 108 109 110 111
        //- Construct from components
        patchIdentifier
        (
            const word& name,
            const label index,
112
            const word& physicalType,
113
            const wordList& inGroups = wordList()
114 115 116 117 118 119
        );

        //- Construct from dictionary
        patchIdentifier
        (
            const word& name,
120
            const dictionary& dict,
121 122 123
            const label index
        );

124
        //- Copy construct, resetting the index
125 126
        patchIdentifier
        (
127
            const patchIdentifier& p,
128 129 130 131 132 133
            const label index
        );


    // Member Functions

134
        //- The patch name
135 136 137 138 139
        const word& name() const
        {
            return name_;
        }

140
        //- Modifiable patch name
141 142 143 144 145
        word& name()
        {
            return name_;
        }

146
        //- The (optional) physical type of the patch
147 148 149 150 151
        const word& physicalType() const
        {
            return physicalType_;
        }

152
        //- Modifiable (optional) physical type of the patch
153 154 155 156 157
        word& physicalType()
        {
            return physicalType_;
        }

158
        //- The index of this patch in the boundaryMesh
159 160
        label index() const
        {
Mark Olesen's avatar
Mark Olesen committed
161
            return index_;
162 163
        }

164
        //- Modifiable index of this patch in the boundaryMesh
165 166
        label& index()
        {
Mark Olesen's avatar
Mark Olesen committed
167
            return index_;
168 169
        }

170
        //- The (optional) groups that the patch belongs to
171 172 173 174 175
        const wordList& inGroups() const
        {
            return inGroups_;
        }

176
        //- Modifiable (optional) groups that the patch belongs to
177 178 179 180 181
        wordList& inGroups()
        {
            return inGroups_;
        }

182 183 184 185 186
        //- True if the patch is in named group
        bool inGroup(const word& name) const
        {
            return inGroups_.found(name);
        }
187

188 189
        //- Write (physicalType, inGroups) dictionary entries
        //- (without surrounding braces)
190
        void write(Ostream& os) const;
191
};
192 193


194
// Global Operators
195

196 197 198
//- Write (physicalType, inGroups) dictionary entries
//- (without surrounding braces)
Ostream& operator<<(Ostream& os, const patchIdentifier& p);
199 200 201 202 203 204 205 206 207 208 209


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //