diff --git a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C index 6a081fd49f..da17d2be68 100644 --- a/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C +++ b/src/postProcessing/functionObjects/field/regionSizeDistribution/regionSizeDistribution.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,8 +72,11 @@ void Foam::regionSizeDistribution::writeGraph OFstream str(outputPath/formatterPtr_().getFileName(coords, valNames)); - Info<< "Writing distribution of " << valueName << " to " << str.name() - << endl; + if (log_) + { + Info<< "Writing distribution of " << valueName << " to " << str.name() + << endl; + } List valPtrs(1); valPtrs[0] = &values; @@ -149,16 +152,26 @@ void Foam::regionSizeDistribution::writeAlphaFields liquidCore.correctBoundaryConditions(); backgroundAlpha.correctBoundaryConditions(); - Info<< " Volume of liquid-core = " - << fvc::domainIntegrate(liquidCore).value() - << endl; - Info<< " Volume of background = " - << fvc::domainIntegrate(backgroundAlpha).value() - << endl; + if (log_) + { + Info<< " Volume of liquid-core = " + << fvc::domainIntegrate(liquidCore).value() + << endl; + Info<< " Volume of background = " + << fvc::domainIntegrate(backgroundAlpha).value() + << endl; + } - Info<< "Writing liquid-core field to " << liquidCore.name() << endl; + if (log_) + { + Info<< "Writing liquid-core field to " << liquidCore.name() << endl; + } liquidCore.write(); - Info<< "Writing background field to " << backgroundAlpha.name() << endl; + + if (log_) + { + Info<< "Writing background field to " << backgroundAlpha.name() << endl; + } backgroundAlpha.write(); } @@ -322,12 +335,13 @@ Foam::regionSizeDistribution::regionSizeDistribution const bool loadFromFiles ) : - functionObjectFile(obr, name, typeName), + functionObjectFile(obr, name), name_(name), obr_(obr), active_(true), alphaName_(dict.lookup("field")), - patchNames_(dict.lookup("patches")) + patchNames_(dict.lookup("patches")), + log_(true) { // Check if the available mesh is an fvMesh, otherwise deactivate if (isA(obr_)) @@ -364,6 +378,10 @@ void Foam::regionSizeDistribution::read(const dictionary& dict) { if (active_) { + functionObjectFile::read(dict); + + log_.readIfPresent("log", dict); + dict.lookup("field") >> alphaName_; dict.lookup("patches") >> patchNames_; dict.lookup("threshold") >> threshold_; @@ -380,8 +398,11 @@ void Foam::regionSizeDistribution::read(const dictionary& dict) { coordSysPtr_.reset(new coordinateSystem(obr_, dict)); - Info<< "Transforming all vectorFields with coordinate system " - << coordSysPtr_().name() << endl; + if (log_) + { + Info<< "Transforming all vectorFields with coordinate system " + << coordSysPtr_().name() << endl; + } } } } @@ -409,18 +430,18 @@ void Foam::regionSizeDistribution::write() { if (active_) { - Info<< type() << " " << name_ << " output:" << nl; + if (log_) Info << type() << " " << name_ << " output:" << nl; const fvMesh& mesh = refCast(obr_); autoPtr alphaPtr; if (obr_.foundObject(alphaName_)) { - Info<< " Looking up field " << alphaName_ << endl; + if (log_) Info << " Looking up field " << alphaName_ << endl; } else { - Info<< " Reading field " << alphaName_ << endl; + if (log_) Info << " Reading field " << alphaName_ << endl; alphaPtr.reset ( new volScalarField @@ -446,17 +467,24 @@ void Foam::regionSizeDistribution::write() : obr_.lookupObject(alphaName_) ); - Info<< " Volume of alpha = " - << fvc::domainIntegrate(alpha).value() - << endl; + if (log_) + { + Info<< " Volume of alpha = " + << fvc::domainIntegrate(alpha).value() + << endl; + } const scalar meshVol = gSum(mesh.V()); const scalar maxDropletVol = 1.0/6.0*pow(maxDiam_, 3); const scalar delta = (maxDiam_-minDiam_)/nBins_; - Info<< " Mesh volume = " << meshVol << endl; - Info<< " Maximum droplet diameter = " << maxDiam_ << endl; - Info<< " Maximum droplet volume = " << maxDropletVol << endl; + if (log_) + { + Info<< " Mesh volume = " << meshVol << nl + << " Maximum droplet diameter = " << maxDiam_ << nl + << " Maximum droplet volume = " << maxDropletVol + << endl; + } // Determine blocked faces @@ -515,8 +543,11 @@ void Foam::regionSizeDistribution::write() regionSplit regions(mesh, blockedFace); - Info<< " Determined " << regions.nRegions() - << " disconnected regions" << endl; + if (log_) + { + Info<< " Determined " << regions.nRegions() + << " disconnected regions" << endl; + } if (debug) @@ -534,8 +565,13 @@ void Foam::regionSizeDistribution::write() mesh, dimensionedScalar("zero", dimless, 0) ); - Info<< " Dumping region as volScalarField to " << region.name() - << endl; + + if (log_) + { + Info<< " Dumping region as " << volScalarField::typeName + << " to " << region.name() + << endl; + } forAll(regions, cellI) { @@ -566,11 +602,15 @@ void Foam::regionSizeDistribution::write() if (debug) { - Info<< " " << token::TAB << "Region" - << token::TAB << "Volume(mesh)" - << token::TAB << "Volume(" << alpha.name() << "):" - << token::TAB << "nCells" - << endl; + if (log_) + { + Info<< " " << token::TAB << "Region" + << token::TAB << "Volume(mesh)" + << token::TAB << "Volume(" << alpha.name() << "):" + << token::TAB << "nCells" + << endl; + } + scalar meshSumVol = 0.0; scalar alphaSumVol = 0.0; label nCells = 0; @@ -586,50 +626,61 @@ void Foam::regionSizeDistribution::write() ++vIter, ++aIter, ++numIter ) { - Info<< " " << token::TAB << vIter.key() - << token::TAB << vIter() - << token::TAB << aIter() - << token::TAB << numIter() - << endl; + if (log_) + { + Info<< " " << token::TAB << vIter.key() + << token::TAB << vIter() + << token::TAB << aIter() + << token::TAB << numIter() + << endl; + } meshSumVol += vIter(); alphaSumVol += aIter(); nCells += numIter(); } - Info<< " " << token::TAB << "Total:" - << token::TAB << meshSumVol - << token::TAB << alphaSumVol - << token::TAB << nCells - << endl; - Info<< endl; + + if (log_) + { + Info<< " " << token::TAB << "Total:" + << token::TAB << meshSumVol + << token::TAB << alphaSumVol + << token::TAB << nCells + << nl << endl; + } } - + if (log_) { - Info<< " Patch connected regions (liquid core):" << endl; - Info<< token::TAB << " Region" + Info<< " Patch connected regions (liquid core):" << nl + << token::TAB << " Region" << token::TAB << "Volume(mesh)" << token::TAB << "Volume(" << alpha.name() << "):" << endl; + forAllConstIter(Map