Newer
Older
Henry Weller
committed
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Henry Weller
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.
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.
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.
Henry Weller
committed
Examples of function object specification:
\verbatim
volRegion0
{
.
.
regionType cellZone;
name c0;
.
.
}
volRegionAll
{
.
.
regionType all;
.
.
}
\endverbatim
Usage
\table
Property | Description | Required | Default
regionType | Selection type: all/cellSet/cellZone | no | all
name | Name of cellSet/cellZone if required | no |
Henry Weller
committed
\endtable
See also
Foam::functionObject
SourceFiles
volRegion.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_volRegion_H
#define functionObjects_volRegion_H
#include "writeFile.H"
Henry Weller
committed
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
Henry Weller
committed
class fvMesh;
class polyMesh;
class mapPolyMesh;
Henry Weller
committed
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class volRegion Declaration
Henry Weller
committed
\*---------------------------------------------------------------------------*/
class volRegion
{
Henry Weller
committed
const fvMesh& volMesh_;
//- Flag to indicate whether the volRegion requires updating
bool requireUpdate_;
//- The cell ids, from cellSet
labelList cellIds_;
Henry Weller
committed
//- Cached total number of cells selected
label nCells_;
//- Cached total selection volume
scalar V_;
Henry Weller
committed
// Private Member Functions
//- Update cellIds, nCells, volume
void calculateCache();
Henry Weller
committed
public:
// Public data types
//- Region type enumeration
enum regionTypes
{
vrtAll, //!< All cells
vrtCellSet, //!< A cellSet
vrtCellZone //!< A cellZone
Henry Weller
committed
};
//- Region type names
static const Enum<regionTypes> regionTypeNames_;
Henry Weller
committed
protected:
Henry Weller
committed
//- Region type
regionTypes regionType_;
//- Region name (cellSet, cellZone, ...)
Henry Weller
committed
word regionName_;
//- Region ID (zone ID, ...)
Henry Weller
committed
label regionID_;
// Protected Member Functions
//- Output file header information
void writeFileHeader(const writeFile& wf, Ostream& file) const;
Henry Weller
committed
public:
//- Run-time type information
TypeName("volRegion");
// Constructors
//- Construct from fvMesh and dictionary
volRegion(const fvMesh& mesh, const dictionary& dict);
Henry Weller
committed
//- Destructor
virtual ~volRegion() = default;
Henry Weller
committed
Henry Weller
committed
//- Return the region type
inline const regionTypes& regionType() const;
//- Return the local list of cell IDs
const labelList& cellIDs() const;
//- Return the number of cells selected in the region
inline label nCells() const;
//- Return total volume of the selected region
inline scalar V() const;
//- Update the cached values as required
// \return False if the values were already up to date
bool update();
//- Read from dictionary
virtual bool read(const dictionary& dict);
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&);
Henry Weller
committed
//- Update for mesh point-motion
virtual void movePoints(const polyMesh&);
Henry Weller
committed
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "volRegionI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //