From c4c57690c659a15056ebb112af61fb938e6988b2 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Thu, 3 Nov 2016 12:11:20 +0000 Subject: [PATCH] ENH: function objects - use Info on construction/read, and Log for all other messages --- .../field/blendingFactor/blendingFactor.C | 1 + .../field/externalCoupled/externalCoupled.C | 48 +++++++++---------- .../field/fieldAverage/fieldAverage.C | 26 ++++------ .../fieldCoordinateSystemTransform.C | 2 +- .../field/fieldMinMax/fieldMinMax.C | 1 + .../fieldValueDelta/fieldValueDelta.C | 5 +- .../surfaceFieldValue/surfaceFieldValue.C | 2 +- src/functionObjects/field/flowType/flowType.C | 22 --------- .../field/fluxSummary/fluxSummary.C | 20 ++++---- .../field/histogram/histogram.C | 1 + .../field/mapFields/mapFields.C | 6 +-- .../field/nearWallFields/nearWallFields.C | 2 +- .../reactionsSensitivityAnalysis.C | 12 ++--- .../regionSizeDistribution.C | 3 +- .../field/streamLine/streamLine.C | 2 +- .../field/turbulenceFields/turbulenceFields.C | 10 ++-- .../field/wallShearStress/wallShearStress.C | 6 +-- src/functionObjects/forces/forces/forces.C | 8 ++-- .../icoUncoupledKinematicCloud.C | 4 +- .../timeActivatedFileUpdate.C | 4 +- 20 files changed, 75 insertions(+), 110 deletions(-) diff --git a/src/functionObjects/field/blendingFactor/blendingFactor.C b/src/functionObjects/field/blendingFactor/blendingFactor.C index f631b7e851..3861e809a2 100644 --- a/src/functionObjects/field/blendingFactor/blendingFactor.C +++ b/src/functionObjects/field/blendingFactor/blendingFactor.C @@ -114,6 +114,7 @@ Foam::functionObjects::blendingFactor::~blendingFactor() bool Foam::functionObjects::blendingFactor::read(const dictionary& dict) { fieldExpression::read(dict); + writeFile::read(dict); phiName_ = dict.lookupOrDefault("phi", "phi"); dict.readIfPresent("tolerance", tolerance_); diff --git a/src/functionObjects/field/externalCoupled/externalCoupled.C b/src/functionObjects/field/externalCoupled/externalCoupled.C index 727aa595f5..999e311f20 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupled.C +++ b/src/functionObjects/field/externalCoupled/externalCoupled.C @@ -936,37 +936,33 @@ bool Foam::functionObjects::externalCoupled::read(const dictionary& dict) } - // Print a bit - if (log) + Info<< type() << ": Communicating with regions:" << endl; + forAll(regionGroupNames_, rgi) { - Info<< type() << ": Communicating with regions:" << endl; - forAll(regionGroupNames_, rgi) + //const wordList& regionNames = regionGroupRegions_[rgi]; + const word& compName = regionGroupNames_[rgi]; + + Info<< "Region: " << compName << endl << incrIndent; + const labelList& groups = regionToGroups_[compName]; + forAll(groups, i) { - //const wordList& regionNames = regionGroupRegions_[rgi]; - const word& compName = regionGroupNames_[rgi]; + label groupi = groups[i]; + const wordRe& groupName = groupNames_[groupi]; - Info<< "Region: " << compName << endl << incrIndent; - const labelList& groups = regionToGroups_[compName]; - forAll(groups, i) - { - label groupi = groups[i]; - const wordRe& groupName = groupNames_[groupi]; - - Info<< indent << "patchGroup: " << groupName << "\t" - << endl - << incrIndent - << indent << "Reading fields: " - << groupReadFields_[groupi] - << endl - << indent << "Writing fields: " - << groupWriteFields_[groupi] - << endl - << decrIndent; - } - Info<< decrIndent; + Info<< indent << "patchGroup: " << groupName << "\t" + << endl + << incrIndent + << indent << "Reading fields: " + << groupReadFields_[groupi] + << endl + << indent << "Writing fields: " + << groupWriteFields_[groupi] + << endl + << decrIndent; } - Info<< endl; + Info<< decrIndent; } + Info<< endl; // Note: we should not have to make directories since the geometry diff --git a/src/functionObjects/field/fieldAverage/fieldAverage.C b/src/functionObjects/field/fieldAverage/fieldAverage.C index d7cd691bf2..46c30fbc97 100644 --- a/src/functionObjects/field/fieldAverage/fieldAverage.C +++ b/src/functionObjects/field/fieldAverage/fieldAverage.C @@ -108,8 +108,7 @@ void Foam::functionObjects::fieldAverage::initialize() void Foam::functionObjects::fieldAverage::restart() { - Log - << " Restarting averaging at time " << obr_.time().timeName() + Log << " Restarting averaging at time " << obr_.time().timeName() << nl << endl; totalIter_.clear(); @@ -159,8 +158,7 @@ void Foam::functionObjects::fieldAverage::calcAverages() restart(); } - Log - << type() << " " << name() << " write:" << nl + Log << type() << " " << name() << " write:" << nl << " Calculating averages" << nl; addMeanSqrToPrime2Mean(); @@ -221,14 +219,14 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties() totalTime_.clear(); totalTime_.setSize(faItems_.size(), obr_.time().deltaTValue()); - if ((restartOnRestart_ || restartOnOutput_) && log) + if (restartOnRestart_ || restartOnOutput_) { Info<< " Starting averaging at time " << obr_.time().timeName() << nl; } else { - Log << " Restarting averaging for fields:" << nl; + Info<< " Restarting averaging for fields:" << nl; forAll(faItems_, fieldi) @@ -242,15 +240,13 @@ void Foam::functionObjects::fieldAverage::readAveragingProperties() totalIter_[fieldi] = readLabel(fieldDict.lookup("totalIter")); totalTime_[fieldi] = readScalar(fieldDict.lookup("totalTime")); - Log - << " " << fieldName + Info<< " " << fieldName << " iters = " << totalIter_[fieldi] << " time = " << totalTime_[fieldi] << nl; } else { - Log - << " " << fieldName + Info<< " " << fieldName << ": starting averaging at time " << obr_.time().timeName() << endl; } @@ -299,7 +295,7 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict) initialised_ = false; - Log << type() << " " << name() << ":" << nl; + Info<< type() << " " << name() << ":" << nl; dict.readIfPresent("restartOnRestart", restartOnRestart_); dict.readIfPresent("restartOnOutput", restartOnOutput_); @@ -309,8 +305,7 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict) if (periodicRestart_) { dict.lookup("restartPeriod") >> restartPeriod_; - Log - << " Restart period " << restartPeriod_ + Info<< " Restart period " << restartPeriod_ << nl << endl; } @@ -324,15 +319,14 @@ bool Foam::functionObjects::fieldAverage::read(const dictionary& dict) } else { - Log - << " Restart scheduled at time " << restartTime_ + Info<< " Restart scheduled at time " << restartTime_ << nl << endl; } } readAveragingProperties(); - Log << endl; + Info<< endl; return true; } diff --git a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C index 4d16100f92..c9aabb275c 100644 --- a/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C +++ b/src/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransform.C @@ -60,7 +60,7 @@ fieldCoordinateSystemTransform { read(dict); - Log << type() << " " << name << ":" << nl + Info<< type() << " " << name << ":" << nl << " Applying transformation from global Cartesian to local " << coordSys_ << nl << endl; } diff --git a/src/functionObjects/field/fieldMinMax/fieldMinMax.C b/src/functionObjects/field/fieldMinMax/fieldMinMax.C index 5c6f4f4d6a..c2f6b643a6 100644 --- a/src/functionObjects/field/fieldMinMax/fieldMinMax.C +++ b/src/functionObjects/field/fieldMinMax/fieldMinMax.C @@ -122,6 +122,7 @@ Foam::functionObjects::fieldMinMax::~fieldMinMax() bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict) { fvMeshFunctionObject::read(dict); + writeFile::read(dict); location_ = dict.lookupOrDefault("location", true); diff --git a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C index 90010c4669..ca24bdad36 100644 --- a/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C +++ b/src/functionObjects/field/fieldValues/fieldValueDelta/fieldValueDelta.C @@ -128,7 +128,6 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::read ) { fvMeshFunctionObject::read(dict); - writeFile::read(dict); region1Ptr_.reset @@ -210,9 +209,9 @@ bool Foam::functionObjects::fieldValues::fieldValueDelta::write() applyOperation(type1, name1, name2, entry1, entry2, found); applyOperation(type1, name1, name2, entry1, entry2, found); - if (log && !found) + if (!found) { - Info<< "Operation between " + Log << "Operation between " << name1 << " with result " << entry1 << " and " << name2 << " with result " << entry2 << " not applied" << endl; diff --git a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C index 907d365d5c..578cf6884b 100644 --- a/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C +++ b/src/functionObjects/field/fieldValues/surfaceFieldValue/surfaceFieldValue.C @@ -488,7 +488,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise if (weightFieldName_ == "none") { dict.lookup("orientedWeightField") >> weightFieldName_; - Log << " weight field = " << weightFieldName_ << nl; + Info<< " weight field = " << weightFieldName_ << nl; orientWeightField_ = true; } else diff --git a/src/functionObjects/field/flowType/flowType.C b/src/functionObjects/field/flowType/flowType.C index 1451154bb0..b74616a7f3 100644 --- a/src/functionObjects/field/flowType/flowType.C +++ b/src/functionObjects/field/flowType/flowType.C @@ -21,28 +21,6 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Class - flowType - -Group - grpPostProcessingUtilities - -Description - Calculates and writes the flowType of velocity field U. - - The -noWrite option has no meaning. - - The flow type parameter is obtained according to the following equation: - \verbatim - |D| - |Omega| - lambda = ------------- - |D| + |Omega| - - -1 = rotational flow - 0 = simple shear flow - 1 = planar extensional flow - \endverbatim - \*---------------------------------------------------------------------------*/ #include "flowType.H" diff --git a/src/functionObjects/field/fluxSummary/fluxSummary.C b/src/functionObjects/field/fluxSummary/fluxSummary.C index deb45d77f1..7a27f18527 100644 --- a/src/functionObjects/field/fluxSummary/fluxSummary.C +++ b/src/functionObjects/field/fluxSummary/fluxSummary.C @@ -727,22 +727,18 @@ bool Foam::functionObjects::fluxSummary::read(const dictionary& dict) } } - // Provide some output - if (log) + Info<< type() << " " << name() << " output:" << nl; + + forAll(faceZoneName_, zonei) { - Info<< type() << " " << name() << " output:" << nl; + const word& zoneName = faceZoneName_[zonei]; + scalar zoneArea = faceArea_[zonei]; - forAll(faceZoneName_, zonei) - { - const word& zoneName = faceZoneName_[zonei]; - scalar zoneArea = faceArea_[zonei]; - - Info<< " Zone: " << zoneName << ", area: " << zoneArea << nl; - } - - Info<< endl; + Info<< " Zone: " << zoneName << ", area: " << zoneArea << nl; } + Info<< endl; + return true; } diff --git a/src/functionObjects/field/histogram/histogram.C b/src/functionObjects/field/histogram/histogram.C index 63e2abcf0a..064fb9dded 100644 --- a/src/functionObjects/field/histogram/histogram.C +++ b/src/functionObjects/field/histogram/histogram.C @@ -93,6 +93,7 @@ Foam::functionObjects::histogram::~histogram() bool Foam::functionObjects::histogram::read(const dictionary& dict) { fvMeshFunctionObject::read(dict); + writeFile::read(dict); dict.lookup("field") >> fieldName_; dict.lookup("max") >> max_; diff --git a/src/functionObjects/field/mapFields/mapFields.C b/src/functionObjects/field/mapFields/mapFields.C index 3f3ff47ab5..00a387ad6e 100644 --- a/src/functionObjects/field/mapFields/mapFields.C +++ b/src/functionObjects/field/mapFields/mapFields.C @@ -55,7 +55,7 @@ void Foam::functionObjects::mapFields::createInterpolation const fvMesh& meshTarget = mesh_; const word mapRegionName(dict.lookup("mapRegion")); - Log << name() << ':' << nl + Info<< name() << ':' << nl << " Reading mesh " << mapRegionName << endl; mapRegionPtr_.reset @@ -97,12 +97,12 @@ void Foam::functionObjects::mapFields::createInterpolation // Optionally override if (dict.readIfPresent("patchMapMethod", patchMapMethodName)) { - Log << " Patch mapping method: " << patchMapMethodName << endl; + Info<< " Patch mapping method: " << patchMapMethodName << endl; } bool consistent = readBool(dict.lookup("consistent")); - Log << " Creating mesh to mesh interpolation" << endl; + Info<< " Creating mesh to mesh interpolation" << endl; if (consistent) { diff --git a/src/functionObjects/field/nearWallFields/nearWallFields.C b/src/functionObjects/field/nearWallFields/nearWallFields.C index 1cb3f0684e..061aca85e9 100644 --- a/src/functionObjects/field/nearWallFields/nearWallFields.C +++ b/src/functionObjects/field/nearWallFields/nearWallFields.C @@ -281,7 +281,7 @@ bool Foam::functionObjects::nearWallFields::read(const dictionary& dict) reverseFieldMap_.insert(sampleFldName, fldName); } - Log << type() << " " << name() + Info<< type() << " " << name() << ": Sampling " << fieldMap_.size() << " fields" << endl; // Do analysis diff --git a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C index 8664497061..939de3548f 100644 --- a/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C +++ b/src/functionObjects/field/reactionSensitivityAnalysis/reactionsSensitivityAnalysis.C @@ -138,10 +138,10 @@ writeSpeciesRR() prodFilePtr_() << "delta T : "<< mesh_.time().deltaT().value() << nl << nl; consIntFilePtr_() << "start time : " << startTime_ << tab - << "end time :" << endTime_ << nl; + << "end time :" << endTime_ << nl; prodIntFilePtr_() << "start time : " << startTime_ << tab - << "end time :" << endTime_ << nl; + << "end time :" << endTime_ << nl; for (label reactioni = 0; reactioni < nReactions_; ++reactioni) { @@ -202,7 +202,7 @@ reactionsSensitivityAnalysis if (mesh_.nCells() != 1) { FatalErrorInFunction - << "Function object only applicable to single cell cases " + << "Function object only applicable to single cell cases" << abort(FatalError); } @@ -243,9 +243,9 @@ reactionsSensitivityAnalysis } else { - FatalErrorInFunction - << " Not chemistry model found. " - << " Object available are : " << mesh_.names() + FatalErrorInFunction + << " No chemistry model found. " + << " Objects available are : " << mesh_.names() << exit(FatalError); } } diff --git a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index fccc1b9cd1..48504de23d 100644 --- a/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -354,6 +354,7 @@ Foam::functionObjects::regionSizeDistribution::~regionSizeDistribution() bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict) { fvMeshFunctionObject::read(dict); + writeFile::read(dict); dict.lookup("field") >> alphaName_; dict.lookup("patches") >> patchNames_; @@ -371,7 +372,7 @@ bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict) { coordSysPtr_.reset(new coordinateSystem(obr_, dict)); - Log << "Transforming all vectorFields with coordinate system " + Info<< "Transforming all vectorFields with coordinate system " << coordSysPtr_().name() << endl; } diff --git a/src/functionObjects/field/streamLine/streamLine.C b/src/functionObjects/field/streamLine/streamLine.C index 1edbba13e6..8f0bd5cc9a 100644 --- a/src/functionObjects/field/streamLine/streamLine.C +++ b/src/functionObjects/field/streamLine/streamLine.C @@ -162,7 +162,7 @@ bool Foam::functionObjects::streamLine::read(const dictionary& dict) nSubCycle_ = max(nSubCycle_, 1); - Log << " automatic track length specified through" + Info<< " automatic track length specified through" << " number of sub cycles : " << nSubCycle_ << nl << endl; } diff --git a/src/functionObjects/field/turbulenceFields/turbulenceFields.C b/src/functionObjects/field/turbulenceFields/turbulenceFields.C index 29c1facb0e..b09c20ad5f 100644 --- a/src/functionObjects/field/turbulenceFields/turbulenceFields.C +++ b/src/functionObjects/field/turbulenceFields/turbulenceFields.C @@ -157,19 +157,19 @@ bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict) fieldSet_.insert(wordList(dict.lookup("fields"))); } - Log << type() << " " << name() << ": "; + Info<< type() << " " << name() << ": "; if (fieldSet_.size()) { - Log << "storing fields:" << nl; + Info<< "storing fields:" << nl; forAllConstIter(wordHashSet, fieldSet_, iter) { - Log << " " << modelName << ':' << iter.key() << nl; + Info<< " " << modelName << ':' << iter.key() << nl; } - Log << endl; + Info<< endl; } else { - Log << "no fields requested to be stored" << nl << endl; + Info<< "no fields requested to be stored" << nl << endl; } return true; diff --git a/src/functionObjects/field/wallShearStress/wallShearStress.C b/src/functionObjects/field/wallShearStress/wallShearStress.C index 39b4a5ed3d..1391123441 100644 --- a/src/functionObjects/field/wallShearStress/wallShearStress.C +++ b/src/functionObjects/field/wallShearStress/wallShearStress.C @@ -143,7 +143,7 @@ bool Foam::functionObjects::wallShearStress::read(const dictionary& dict) wordReList(dict.lookupOrDefault("patches", wordReList())) ); - Log << type() << " " << name() << ":" << nl; + Info<< type() << " " << name() << ":" << nl; if (patchSet_.empty()) { @@ -155,7 +155,7 @@ bool Foam::functionObjects::wallShearStress::read(const dictionary& dict) } } - Log << " processing all wall patches" << nl << endl; + Info<< " processing all wall patches" << nl << endl; } else { @@ -177,7 +177,7 @@ bool Foam::functionObjects::wallShearStress::read(const dictionary& dict) } } - Log << endl; + Info<< endl; patchSet_ = filteredPatchSet; } diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index 573c25671f..97de38581f 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -846,7 +846,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict) initialised_ = false; - Info << type() << " " << name() << ":" << nl; + Info<< type() << " " << name() << ":" << nl; directForceDensity_ = dict.lookupOrDefault("directForceDensity", false); @@ -889,11 +889,11 @@ bool Foam::functionObjects::forces::read(const dictionary& dict) dict.readIfPresent("porosity", porosity_); if (porosity_) { - Info << " Including porosity effects" << endl; + Info<< " Including porosity effects" << endl; } else { - Info << " Not including porosity effects" << endl; + Info<< " Not including porosity effects" << endl; } if (dict.found("binData")) @@ -924,7 +924,7 @@ bool Foam::functionObjects::forces::read(const dictionary& dict) if (writeFields_) { - Info << " Fields will be written" << endl; + Info<< " Fields will be written" << endl; volVectorField* forcePtr ( diff --git a/src/functionObjects/lagrangian/icoUncoupledKinematicCloud/icoUncoupledKinematicCloud.C b/src/functionObjects/lagrangian/icoUncoupledKinematicCloud/icoUncoupledKinematicCloud.C index c37307c377..4cce300a4d 100644 --- a/src/functionObjects/lagrangian/icoUncoupledKinematicCloud/icoUncoupledKinematicCloud.C +++ b/src/functionObjects/lagrangian/icoUncoupledKinematicCloud/icoUncoupledKinematicCloud.C @@ -120,9 +120,7 @@ bool Foam::functionObjects::icoUncoupledKinematicCloud::read const dictionary& dict ) { - fvMeshFunctionObject::read(dict); - - return true; + return fvMeshFunctionObject::read(dict); } diff --git a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C index d6dc1d1040..640fb58d10 100644 --- a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C +++ b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C @@ -111,7 +111,7 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read lastIndex_ = -1; fileToUpdate_.expand(); - Log << type() << " " << name() << " output:" << nl + Info<< type() << " " << name() << " output:" << nl << " time vs file list:" << endl; forAll(timeVsFile_, i) @@ -124,7 +124,7 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read << nl << exit(FatalError); } - Log << " " << timeVsFile_[i].first() << tab + Info<< " " << timeVsFile_[i].first() << tab << timeVsFile_[i].second() << endl; }