From bd737621a0897c45d0918502fb4f6d408400ddbd Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 1 Dec 2015 15:34:25 +0000 Subject: [PATCH] ENH: fluxSummary function object - added faceZone area output on construction --- .../utilities/fluxSummary/fluxSummary.C | 222 ++++++++++-------- 1 file changed, 120 insertions(+), 102 deletions(-) diff --git a/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C b/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C index 7ec070bef0..e1b078a417 100644 --- a/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C +++ b/src/postProcessing/functionObjects/utilities/fluxSummary/fluxSummary.C @@ -677,120 +677,138 @@ Foam::fluxSummary::~fluxSummary() void Foam::fluxSummary::read(const dictionary& dict) { - if (active_) + if (!active_) { - functionObjectFile::read(dict); + return; + } - log_ = dict.lookupOrDefault("log", true); + functionObjectFile::read(dict); - mode_ = modeTypeNames_.read(dict.lookup("mode")); - phiName_= dict.lookupOrDefault("phiName", "phi"); - dict.readIfPresent("scaleFactor", scaleFactor_); - dict.readIfPresent("tolerance", tolerance_); + log_ = dict.lookupOrDefault("log", true); - // initialise with capacity of 10 faceZones - DynamicList refDir(10); - DynamicList faceZoneName(refDir.size()); - DynamicList > faceID(refDir.size()); - DynamicList > facePatchID(refDir.size()); - DynamicList > faceSign(refDir.size()); + mode_ = modeTypeNames_.read(dict.lookup("mode")); + phiName_= dict.lookupOrDefault("phiName", "phi"); + dict.readIfPresent("scaleFactor", scaleFactor_); + dict.readIfPresent("tolerance", tolerance_); - switch (mode_) + // initialise with capacity of 10 faceZones + DynamicList refDir(10); + DynamicList faceZoneName(refDir.size()); + DynamicList > faceID(refDir.size()); + DynamicList > facePatchID(refDir.size()); + DynamicList > faceSign(refDir.size()); + + switch (mode_) + { + case mdFaceZone: { - case mdFaceZone: - { - List zones(dict.lookup("faceZones")); + List zones(dict.lookup("faceZones")); - forAll(zones, i) - { - initialiseFaceZone - ( - zones[i], - faceZoneName, - faceID, - facePatchID, - faceSign - ); - } - break; - } - case mdFaceZoneAndDirection: + forAll(zones, i) { - List > - zoneAndDirection(dict.lookup("faceZoneAndDirection")); - - forAll(zoneAndDirection, i) - { - initialiseFaceZoneAndDirection - ( - zoneAndDirection[i].first(), - zoneAndDirection[i].second(), - refDir, - faceZoneName, - faceID, - facePatchID, - faceSign - ); - } - break; - } - case mdCellZoneAndDirection: - { - List > - zoneAndDirection(dict.lookup("cellZoneAndDirection")); - - forAll(zoneAndDirection, i) - { - initialiseCellZoneAndDirection - ( - zoneAndDirection[i].first(), - zoneAndDirection[i].second(), - refDir, - faceZoneName, - faceID, - facePatchID, - faceSign - ); - } - break; - } - default: - { - FatalIOErrorIn + initialiseFaceZone ( - "void Foam::fluxSummary::read(const dictionary&)", - dict - ) - << "unhandled enumeration " << modeTypeNames_[mode_] - << abort(FatalIOError); - } - } - - faceZoneName_.transfer(faceZoneName); - refDir_.transfer(refDir); - faceID_.transfer(faceID); - facePatchID_.transfer(facePatchID); - faceSign_.transfer(faceSign); - - initialiseFaceArea(); - - if (writeToFile()) - { - filePtrs_.setSize(faceZoneName_.size()); - - forAll(filePtrs_, fileI) - { - const word& fzName = faceZoneName_[fileI]; - filePtrs_.set(fileI, createFile(fzName)); - writeFileHeader - ( - fzName, - faceArea_[fileI], - refDir_[fileI], - filePtrs_[fileI] + zones[i], + faceZoneName, + faceID, + facePatchID, + faceSign ); } + break; } + case mdFaceZoneAndDirection: + { + List > + zoneAndDirection(dict.lookup("faceZoneAndDirection")); + + forAll(zoneAndDirection, i) + { + initialiseFaceZoneAndDirection + ( + zoneAndDirection[i].first(), + zoneAndDirection[i].second(), + refDir, + faceZoneName, + faceID, + facePatchID, + faceSign + ); + } + break; + } + case mdCellZoneAndDirection: + { + List > + zoneAndDirection(dict.lookup("cellZoneAndDirection")); + + forAll(zoneAndDirection, i) + { + initialiseCellZoneAndDirection + ( + zoneAndDirection[i].first(), + zoneAndDirection[i].second(), + refDir, + faceZoneName, + faceID, + facePatchID, + faceSign + ); + } + break; + } + default: + { + FatalIOErrorIn + ( + "void Foam::fluxSummary::read(const dictionary&)", + dict + ) + << "unhandled enumeration " << modeTypeNames_[mode_] + << abort(FatalIOError); + } + } + + faceZoneName_.transfer(faceZoneName); + refDir_.transfer(refDir); + faceID_.transfer(faceID); + facePatchID_.transfer(facePatchID); + faceSign_.transfer(faceSign); + + initialiseFaceArea(); + + if (writeToFile()) + { + filePtrs_.setSize(faceZoneName_.size()); + + forAll(filePtrs_, fileI) + { + const word& fzName = faceZoneName_[fileI]; + filePtrs_.set(fileI, createFile(fzName)); + writeFileHeader + ( + fzName, + faceArea_[fileI], + refDir_[fileI], + filePtrs_[fileI] + ); + } + } + + // Provide some output + if (log_) + { + Info<< type() << " " << name_ << " output:" << nl; + + forAll(faceZoneName_, zoneI) + { + const word& zoneName = faceZoneName_[zoneI]; + scalar zoneArea = faceArea_[zoneI]; + + Info<< " Zone: " << zoneName << ", area: " << zoneArea << nl; + } + + Info<< endl; } }