volRegion.H 5.41 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) 2016 OpenFOAM Foundation
    Copyright (C) 2016-2019 OpenCFD Ltd.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
-------------------------------------------------------------------------------
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.

    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/>.

Class
    Foam::functionObjects::volRegion

Group
    grpFieldFunctionObjects

Description
    Volume (cell) region selection class.

36 37 38 39 40
    The adjustments for mesh changes have been implemented with a lazy
    evaluation, to avoid unnecessary recalculation until the values are
    actually required. The update() method is used to ensure the cache
    values are up-to-date.

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    Examples of function object specification:
    \verbatim
    volRegion0
    {
        .
        .
        regionType      cellZone;
        name            c0;
        .
        .
    }

    volRegionAll
    {
        .
        .
        regionType      all;
        .
        .
    }
    \endverbatim

Usage
    \table
65 66 67
        Property     | Description                          | Required | Default
        regionType   | Selection type: all/cellSet/cellZone | no | all
        name         | Name of cellSet/cellZone if required | no |
68 69 70 71 72 73 74 75 76 77 78 79 80 81
    \endtable

See also
    Foam::functionObject

SourceFiles
    volRegion.C

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

#ifndef functionObjects_volRegion_H
#define functionObjects_volRegion_H

#include "writeFile.H"
82
#include "Enum.H"
83 84 85 86 87 88

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

namespace Foam
{

89
// Forward declarations
90
class fvMesh;
91 92
class polyMesh;
class mapPolyMesh;
93 94 95 96 97

namespace functionObjects
{

/*---------------------------------------------------------------------------*\
98
                          Class volRegion Declaration
99 100 101 102
\*---------------------------------------------------------------------------*/

class volRegion
{
103
    // Private Member Data
104

105 106
        const fvMesh& volMesh_;

107 108 109
        //- Flag to indicate whether the volRegion requires updating
        bool requireUpdate_;

110 111
        //- The cell ids, from cellSet
        labelList cellIds_;
112

113
        //- Cached total number of cells selected
114
        label nCells_;
115

116
        //- Cached total selection volume
117 118
        scalar V_;

119

120 121 122 123 124 125
    // Private Member Functions

        //- Update cellIds, nCells, volume
        void calculateCache();


126 127 128 129 130 131 132
public:

    // Public data types

        //- Region type enumeration
        enum regionTypes
        {
133 134 135
            vrtAll,             //!< All cells
            vrtCellSet,         //!< A cellSet
            vrtCellZone         //!< A cellZone
136 137 138
        };

        //- Region type names
139
        static const Enum<regionTypes> regionTypeNames_;
140 141 142 143


protected:

144
    // Protected Data
145 146 147 148

        //- Region type
        regionTypes regionType_;

149
        //- Region name (cellSet, cellZone, ...)
150 151
        word regionName_;

152
        //- Region ID (zone ID, ...)
153 154 155 156 157 158
        label regionID_;


    // Protected Member Functions

        //- Output file header information
159
        void writeFileHeader(const writeFile& wf, Ostream& file) const;
160 161 162 163 164 165 166 167 168 169 170


public:

    //- Run-time type information
    TypeName("volRegion");


    // Constructors

        //- Construct from fvMesh and dictionary
171
        volRegion(const fvMesh& mesh, const dictionary& dict);
172 173 174


    //- Destructor
175
    virtual ~volRegion() = default;
176 177


178
    // Member Functions
179 180 181 182 183 184 185

        //- Return the region type
        inline const regionTypes& regionType() const;

        //- Return the local list of cell IDs
        const labelList& cellIDs() const;

186
        //- Return the number of cells selected in the region
187 188 189 190 191
        inline label nCells() const;

        //- Return total volume of the selected region
        inline scalar V() const;

192 193 194 195
        //- Update the cached values as required
        //  \return False if the values were already up to date
        bool update();

196 197 198 199 200 201

        //- Read from dictionary
        virtual bool read(const dictionary& dict);

        //- Update for changes of mesh
        virtual void updateMesh(const mapPolyMesh&);
202

203 204
        //- Update for mesh point-motion
        virtual void movePoints(const polyMesh&);
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
};


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

} // End namespace functionObjects
} // End namespace Foam

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

#include "volRegionI.H"

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

#endif

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