diff --git a/src/finiteVolume/functionObjects/volRegion/volRegion.C b/src/finiteVolume/functionObjects/volRegion/volRegion.C index c39c9cf8c5..ceb7cdb801 100644 --- a/src/finiteVolume/functionObjects/volRegion/volRegion.C +++ b/src/finiteVolume/functionObjects/volRegion/volRegion.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,6 +51,67 @@ Foam::functionObjects::volRegion::regionTypeNames_ }); +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::functionObjects::volRegion::calculateCache() +{ + regionID_ = -1; + cellIds_.clear(); + + switch (regionType_) + { + case vrtAll: + { + nCells_ = volMesh_.globalData().nTotalCells(); + V_ = gSum(volMesh_.V()); + return; + break; + } + + case vrtCellSet: + { + cellIds_ = cellSet(volMesh_, regionName_).sortedToc(); + break; + } + + case vrtCellZone: + { + regionID_ = volMesh_.cellZones().findZoneID(regionName_); + + if (regionID_ < 0) + { + FatalErrorInFunction + << "Unknown cell zone name: " << regionName_ + << ". Valid cell zones : " + << flatOutput(volMesh_.cellZones().names()) + << exit(FatalError); + } + break; + } + } + + // Cached value for nCells() + nCells_ = returnReduce(cellIDs().size(), sumOp