cellZone.H 6.63 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
OpenFOAM bot's avatar
OpenFOAM bot committed
6 7
     \\/     M anipulation  |
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8 9
    Copyright (C) 2011-2016 OpenFOAM Foundation
    Copyright (C) 2017-2018 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 31 32 33 34 35 36 37 38 39

Class
    Foam::cellZone

Description
    A subset of mesh cells.

    Currently set up as an indirect list but will be extended to use a
    primitive mesh.  For quick check whether a cell belongs to the zone use
    the lookup mechanism in cellZoneMesh, where all the zoned cells are
    registered with their zone number.

SourceFiles
    cellZone.C
40
    cellZoneNew.C
41 42 43 44 45 46

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

#ifndef cellZone_H
#define cellZone_H

47
#include "zone.H"
48 49 50 51 52 53 54
#include "cellZoneMeshFwd.H"

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

namespace Foam
{

55
// Forward declarations
56
class cellZone;
57
Ostream& operator<<(Ostream& os, const cellZone& zn);
58 59 60 61 62 63 64

/*---------------------------------------------------------------------------*\
                           Class cellZone Declaration
\*---------------------------------------------------------------------------*/

class cellZone
:
65
    public zone
66
{
67
protected:
68

69
    // Protected data
70 71 72 73 74

        //- Reference to zone list
        const cellZoneMesh& zoneMesh_;


75 76 77 78 79 80
    // Protected Member Functions

        //- No copy construct
        cellZone(const cellZone&) = delete;


81 82
public:

83
    // Static Data Members
84 85 86 87 88

        //- The name associated with the zone-labels dictionary entry
        static const char * const labelsName;


89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
    //- Runtime type information
    TypeName("cellZone");


    // Declare run-time constructor selection tables

        declareRunTimeSelectionTable
        (
            autoPtr,
            cellZone,
            dictionary,
            (
                const word& name,
                const dictionary& dict,
                const label index,
                const cellZoneMesh& zm
            ),
            (name, dict, index, zm)
        );


    // Constructors

Mark Olesen's avatar
Mark Olesen committed
112 113 114
        //- Construct an empty zone
        cellZone(const word& name, const label index, const cellZoneMesh& zm);

115 116 117 118
        //- Construct from components
        cellZone
        (
            const word& name,
119
            const labelUList& addr,
120
            const label index,
121
            const cellZoneMesh& zm
122 123
        );

Mark Olesen's avatar
Mark Olesen committed
124 125 126 127 128 129 130 131 132
        //- Construct from components, transferring addressing
        cellZone
        (
            const word& name,
            labelList&& addr,
            const label index,
            const cellZoneMesh& zm
        );

133 134 135 136
        //- Construct from dictionary
        cellZone
        (
            const word& name,
137
            const dictionary& dict,
138
            const label index,
139
            const cellZoneMesh& zm
140 141
        );

Mark Olesen's avatar
Mark Olesen committed
142 143
        //- Construct given the original zone (name is used),
        //- and resetting the cell list and zone mesh information
144 145
        cellZone
        (
Mark Olesen's avatar
Mark Olesen committed
146
            const cellZone& origZone,
147
            const labelUList& addr,
148
            const label index,
149
            const cellZoneMesh& zm
150 151
        );

Mark Olesen's avatar
Mark Olesen committed
152 153
        //- Construct with a new index and zone mesh information, the name
        //- of the original zone, resetting the cell addressing.
154 155
        cellZone
        (
Mark Olesen's avatar
Mark Olesen committed
156 157 158 159 160 161 162
            const cellZone& origZone,
            labelList&& addr,
            const label index,
            const cellZoneMesh& zm
        );


163 164 165
        //- Construct and return a clone, resetting the zone mesh
        virtual autoPtr<cellZone> clone(const cellZoneMesh& zm) const
        {
166
            return autoPtr<cellZone>::New(*this, *this, index(), zm);
167 168
        }

Mark Olesen's avatar
Mark Olesen committed
169 170
        //- Construct and return a clone,
        //- resetting the cell list and zone mesh
171 172
        virtual autoPtr<cellZone> clone
        (
173
            const labelUList& addr,
174 175 176 177
            const label index,
            const cellZoneMesh& zm
        ) const
        {
178
            return autoPtr<cellZone>::New(*this, addr, index, zm);
179 180 181 182 183 184
        }


    // Selectors

        //- Return a pointer to a new cell zone
Mark Olesen's avatar
Mark Olesen committed
185
        //- created on freestore from dictionary
186 187 188
        static autoPtr<cellZone> New
        (
            const word& name,
189
            const dictionary& dict,
190
            const label index,
191
            const cellZoneMesh& zm
192 193 194 195
        );


    //- Destructor
196
    virtual ~cellZone() = default;
197 198 199 200


    // Member Functions

201
        //- Helper function to re-direct to zone::localID(...)
202 203 204 205 206 207
        label whichCell(const label globalCellID) const;

        //- Return zoneMesh reference
        const cellZoneMesh& zoneMesh() const;

        //- Check zone definition. Return true if in error.
208
        virtual bool checkDefinition(const bool report = false) const;
209

210 211
        //- Check whether zone is synchronised across coupled boundaries.
        //  \return True if any errors.
212 213 214 215 216
        virtual bool checkParallelSync(const bool report = false) const
        {
            return false;
        }

217
        //- Write dictionary
218
        virtual void writeDict(Ostream& os) const;
219 220 221 222


    // Member Operators

223
        //- Assign to zone, clearing demand-driven data
224
        void operator=(const cellZone& zn);
225

226
        //- Assign addressing, clearing demand-driven data
227
        void operator=(const labelUList& addr);
228

Mark Olesen's avatar
Mark Olesen committed
229
        //- Move assign addressing, clearing demand-driven data
230
        void operator=(labelList&& addr);
231 232


233
    // I-O
234

235
        //- Ostream Operator
236
        friend Ostream& operator<<(Ostream& os, const cellZone& zn);
237 238 239 240 241 242 243 244 245 246 247 248
};


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

} // End namespace Foam

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

#endif

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