mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: regionSizeDistribution FO updated follwing changes to functionObjectFile
This commit is contained in:
@ -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<const scalarField*> 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<fvMesh>(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<const fvMesh>(obr_);
|
||||
|
||||
autoPtr<volScalarField> alphaPtr;
|
||||
if (obr_.foundObject<volScalarField>(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<volScalarField>(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<label>, patchRegions, iter)
|
||||
{
|
||||
label regionI = iter.key();
|
||||
|
||||
Info<< " " << token::TAB << iter.key()
|
||||
<< token::TAB << allRegionVolume[regionI]
|
||||
<< token::TAB << allRegionAlphaVolume[regionI] << endl;
|
||||
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Background regions:" << endl;
|
||||
Info<< " " << token::TAB << "Region"
|
||||
Info<< " Background regions:" << nl
|
||||
<< " " << token::TAB << "Region"
|
||||
<< token::TAB << "Volume(mesh)"
|
||||
<< token::TAB << "Volume(" << alpha.name() << "):"
|
||||
<< endl;
|
||||
|
||||
Map<scalar>::const_iterator vIter = allRegionVolume.begin();
|
||||
Map<scalar>::const_iterator aIter = allRegionAlphaVolume.begin();
|
||||
|
||||
@ -652,6 +703,7 @@ void Foam::regionSizeDistribution::write()
|
||||
<< token::TAB << aIter() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -746,9 +798,10 @@ void Foam::regionSizeDistribution::write()
|
||||
}
|
||||
|
||||
// Write to screen
|
||||
if (log_)
|
||||
{
|
||||
Info<< " Bins:" << endl;
|
||||
Info<< " " << token::TAB << "Bin"
|
||||
Info<< " Bins:" << nl
|
||||
<< " " << token::TAB << "Bin"
|
||||
<< token::TAB << "Min diameter"
|
||||
<< token::TAB << "Count:"
|
||||
<< endl;
|
||||
@ -759,8 +812,10 @@ void Foam::regionSizeDistribution::write()
|
||||
Info<< " " << token::TAB << binI
|
||||
<< token::TAB << diam
|
||||
<< token::TAB << binCount[binI] << endl;
|
||||
|
||||
diam += delta;
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
}
|
||||
|
||||
@ -783,7 +838,7 @@ void Foam::regionSizeDistribution::write()
|
||||
forAll(selected, i)
|
||||
{
|
||||
const word& fldName = scalarNames[selected[i]];
|
||||
Info<< " Scalar field " << fldName << endl;
|
||||
if (log_) Info << " Scalar field " << fldName << endl;
|
||||
|
||||
const scalarField& fld = obr_.lookupObject
|
||||
<
|
||||
@ -812,7 +867,7 @@ void Foam::regionSizeDistribution::write()
|
||||
forAll(selected, i)
|
||||
{
|
||||
const word& fldName = vectorNames[selected[i]];
|
||||
Info<< " Vector field " << fldName << endl;
|
||||
if (log_) Info << " Vector field " << fldName << endl;
|
||||
|
||||
vectorField fld = obr_.lookupObject
|
||||
<
|
||||
@ -821,10 +876,13 @@ void Foam::regionSizeDistribution::write()
|
||||
|
||||
if (coordSysPtr_.valid())
|
||||
{
|
||||
Info<< "Transforming vector field " << fldName
|
||||
<< " with coordinate system "
|
||||
<< coordSysPtr_().name()
|
||||
<< endl;
|
||||
if (log_)
|
||||
{
|
||||
Info<< "Transforming vector field " << fldName
|
||||
<< " with coordinate system "
|
||||
<< coordSysPtr_().name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
fld = coordSysPtr_().localVector(fld);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -92,6 +92,7 @@ Description
|
||||
minDiameter | minimum region equivalent diameter | no | 0
|
||||
setFormat | writing format | yes |
|
||||
coordinateSystem | transformation for vector fields | no |
|
||||
log | Log to standard output | no | yes
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
@ -113,6 +114,7 @@ SourceFiles
|
||||
#include "volFieldsFwd.H"
|
||||
#include "wordReList.H"
|
||||
#include "coordinateSystem.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -150,6 +152,9 @@ class regionSizeDistribution
|
||||
//- Patches to walk from
|
||||
wordReList patchNames_;
|
||||
|
||||
//- Switch to send output to Info as well as to file
|
||||
Switch log_;
|
||||
|
||||
//- Clip value
|
||||
scalar threshold_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user