diff --git a/etc/caseDicts/postProcessing/minMax/cellMinMax.cfg b/etc/caseDicts/postProcessing/minMax/cellMinMax.cfg index 383fe224d3..881093ef31 100644 --- a/etc/caseDicts/postProcessing/minMax/cellMinMax.cfg +++ b/etc/caseDicts/postProcessing/minMax/cellMinMax.cfg @@ -6,7 +6,7 @@ | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ -type volRegion; +type volFieldValue; libs ("libfieldFunctionObjects.so"); writeControl timeStep; diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 2f4ed7e376..20ef3e4f13 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -91,7 +91,8 @@ $(faceToCell)/extendedFaceToCellStencil.C $(faceToCell)/extendedCentredFaceToCellStencil.C $(faceToCell)/MeshObjects/centredCFCFaceToCellStencilObject.C -fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C +functionObjects/fvMeshFunctionObject/fvMeshFunctionObject.C +functionObjects/volRegion/volRegion.C fvPatchFields = fields/fvPatchFields $(fvPatchFields)/fvPatchField/fvPatchFields.C diff --git a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C b/src/finiteVolume/functionObjects/fvMeshFunctionObject/fvMeshFunctionObject.C similarity index 100% rename from src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.C rename to src/finiteVolume/functionObjects/fvMeshFunctionObject/fvMeshFunctionObject.C diff --git a/src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H b/src/finiteVolume/functionObjects/fvMeshFunctionObject/fvMeshFunctionObject.H similarity index 100% rename from src/finiteVolume/fvMesh/fvMeshFunctionObject/fvMeshFunctionObject.H rename to src/finiteVolume/functionObjects/fvMeshFunctionObject/fvMeshFunctionObject.H diff --git a/src/finiteVolume/functionObjects/volRegion/volRegion.C b/src/finiteVolume/functionObjects/volRegion/volRegion.C new file mode 100644 index 0000000000..be2bca5e83 --- /dev/null +++ b/src/finiteVolume/functionObjects/volRegion/volRegion.C @@ -0,0 +1,189 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +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 . + +\*---------------------------------------------------------------------------*/ + +#include "volRegion.H" +#include "volMesh.H" +#include "globalMeshData.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(volRegion, 0); +} +} + +template<> +const char* +Foam::NamedEnum +< + Foam::functionObjects::volRegion::regionTypes, + 2 +>::names[] = {"cellZone", "all"}; + +const Foam::NamedEnum +< + Foam::functionObjects::volRegion::regionTypes, + 2 +> Foam::functionObjects::volRegion::regionTypeNames_; + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::functionObjects::volRegion::writeFileHeader +( + const writeFile& wf, + Ostream& file +) +{ + wf.writeCommented(file, "Region : "); + file << regionTypeNames_[regionType_] << " " << regionName_ << endl; + wf.writeHeaderValue(file, "Cells", nCells()); + wf.writeHeaderValue(file, "Volume", V()); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::volRegion::volRegion +( + const fvMesh& mesh, + const dictionary& dict +) +: + mesh_(mesh), + regionType_ + ( + dict.found("regionType") + ? regionTypeNames_.read(dict.lookup("regionType")) + : vrtAll + ), + regionID_(-1) +{ + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::volRegion::~volRegion() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::volRegion::read +( + const dictionary& dict +) +{ + switch (regionType_) + { + case vrtCellZone: + { + dict.lookup("name") >> regionName_; + + regionID_ = mesh_.cellZones().findZoneID(regionName_); + + if (regionID_ < 0) + { + FatalIOErrorInFunction(dict) + << "Unknown cell zone name: " << regionName_ + << ". Valid cell zones are: " << mesh_.cellZones().names() + << exit(FatalIOError); + } + + if (nCells() == 0) + { + FatalIOErrorInFunction(dict) + << regionTypeNames_[regionType_] + << "(" << regionName_ << "):" << nl + << " Region has no cells" + << exit(FatalIOError); + } + + break; + } + + case vrtAll: + { + break; + } + + default: + { + FatalIOErrorInFunction(dict) + << "Unknown region type. Valid region types are:" + << regionTypeNames_ + << exit(FatalIOError); + } + } + + return true; +} + + +const Foam::labelList& Foam::functionObjects::volRegion::cellIDs() const +{ + if (regionType_ == vrtAll) + { + return labelList::null(); + } + else + { + return mesh_.cellZones()[regionID_]; + } +} + + +Foam::label Foam::functionObjects::volRegion::nCells() const +{ + if (regionType_ == vrtAll) + { + return mesh_.globalData().nTotalCells(); + } + else + { + return returnReduce(cellIDs().size(), sumOp