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
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -72,8 +72,11 @@ void Foam::regionSizeDistribution::writeGraph
|
|||||||
|
|
||||||
OFstream str(outputPath/formatterPtr_().getFileName(coords, valNames));
|
OFstream str(outputPath/formatterPtr_().getFileName(coords, valNames));
|
||||||
|
|
||||||
Info<< "Writing distribution of " << valueName << " to " << str.name()
|
if (log_)
|
||||||
<< endl;
|
{
|
||||||
|
Info<< "Writing distribution of " << valueName << " to " << str.name()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
List<const scalarField*> valPtrs(1);
|
List<const scalarField*> valPtrs(1);
|
||||||
valPtrs[0] = &values;
|
valPtrs[0] = &values;
|
||||||
@ -149,16 +152,26 @@ void Foam::regionSizeDistribution::writeAlphaFields
|
|||||||
liquidCore.correctBoundaryConditions();
|
liquidCore.correctBoundaryConditions();
|
||||||
backgroundAlpha.correctBoundaryConditions();
|
backgroundAlpha.correctBoundaryConditions();
|
||||||
|
|
||||||
Info<< " Volume of liquid-core = "
|
if (log_)
|
||||||
<< fvc::domainIntegrate(liquidCore).value()
|
{
|
||||||
<< endl;
|
Info<< " Volume of liquid-core = "
|
||||||
Info<< " Volume of background = "
|
<< fvc::domainIntegrate(liquidCore).value()
|
||||||
<< fvc::domainIntegrate(backgroundAlpha).value()
|
<< endl;
|
||||||
<< 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();
|
liquidCore.write();
|
||||||
Info<< "Writing background field to " << backgroundAlpha.name() << endl;
|
|
||||||
|
if (log_)
|
||||||
|
{
|
||||||
|
Info<< "Writing background field to " << backgroundAlpha.name() << endl;
|
||||||
|
}
|
||||||
backgroundAlpha.write();
|
backgroundAlpha.write();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,12 +335,13 @@ Foam::regionSizeDistribution::regionSizeDistribution
|
|||||||
const bool loadFromFiles
|
const bool loadFromFiles
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
functionObjectFile(obr, name, typeName),
|
functionObjectFile(obr, name),
|
||||||
name_(name),
|
name_(name),
|
||||||
obr_(obr),
|
obr_(obr),
|
||||||
active_(true),
|
active_(true),
|
||||||
alphaName_(dict.lookup("field")),
|
alphaName_(dict.lookup("field")),
|
||||||
patchNames_(dict.lookup("patches"))
|
patchNames_(dict.lookup("patches")),
|
||||||
|
log_(true)
|
||||||
{
|
{
|
||||||
// Check if the available mesh is an fvMesh, otherwise deactivate
|
// Check if the available mesh is an fvMesh, otherwise deactivate
|
||||||
if (isA<fvMesh>(obr_))
|
if (isA<fvMesh>(obr_))
|
||||||
@ -364,6 +378,10 @@ void Foam::regionSizeDistribution::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
|
functionObjectFile::read(dict);
|
||||||
|
|
||||||
|
log_.readIfPresent("log", dict);
|
||||||
|
|
||||||
dict.lookup("field") >> alphaName_;
|
dict.lookup("field") >> alphaName_;
|
||||||
dict.lookup("patches") >> patchNames_;
|
dict.lookup("patches") >> patchNames_;
|
||||||
dict.lookup("threshold") >> threshold_;
|
dict.lookup("threshold") >> threshold_;
|
||||||
@ -380,8 +398,11 @@ void Foam::regionSizeDistribution::read(const dictionary& dict)
|
|||||||
{
|
{
|
||||||
coordSysPtr_.reset(new coordinateSystem(obr_, dict));
|
coordSysPtr_.reset(new coordinateSystem(obr_, dict));
|
||||||
|
|
||||||
Info<< "Transforming all vectorFields with coordinate system "
|
if (log_)
|
||||||
<< coordSysPtr_().name() << endl;
|
{
|
||||||
|
Info<< "Transforming all vectorFields with coordinate system "
|
||||||
|
<< coordSysPtr_().name() << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -409,18 +430,18 @@ void Foam::regionSizeDistribution::write()
|
|||||||
{
|
{
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
Info<< type() << " " << name_ << " output:" << nl;
|
if (log_) Info << type() << " " << name_ << " output:" << nl;
|
||||||
|
|
||||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||||
|
|
||||||
autoPtr<volScalarField> alphaPtr;
|
autoPtr<volScalarField> alphaPtr;
|
||||||
if (obr_.foundObject<volScalarField>(alphaName_))
|
if (obr_.foundObject<volScalarField>(alphaName_))
|
||||||
{
|
{
|
||||||
Info<< " Looking up field " << alphaName_ << endl;
|
if (log_) Info << " Looking up field " << alphaName_ << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info<< " Reading field " << alphaName_ << endl;
|
if (log_) Info << " Reading field " << alphaName_ << endl;
|
||||||
alphaPtr.reset
|
alphaPtr.reset
|
||||||
(
|
(
|
||||||
new volScalarField
|
new volScalarField
|
||||||
@ -446,17 +467,24 @@ void Foam::regionSizeDistribution::write()
|
|||||||
: obr_.lookupObject<volScalarField>(alphaName_)
|
: obr_.lookupObject<volScalarField>(alphaName_)
|
||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Volume of alpha = "
|
if (log_)
|
||||||
<< fvc::domainIntegrate(alpha).value()
|
{
|
||||||
<< endl;
|
Info<< " Volume of alpha = "
|
||||||
|
<< fvc::domainIntegrate(alpha).value()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
const scalar meshVol = gSum(mesh.V());
|
const scalar meshVol = gSum(mesh.V());
|
||||||
const scalar maxDropletVol = 1.0/6.0*pow(maxDiam_, 3);
|
const scalar maxDropletVol = 1.0/6.0*pow(maxDiam_, 3);
|
||||||
const scalar delta = (maxDiam_-minDiam_)/nBins_;
|
const scalar delta = (maxDiam_-minDiam_)/nBins_;
|
||||||
|
|
||||||
Info<< " Mesh volume = " << meshVol << endl;
|
if (log_)
|
||||||
Info<< " Maximum droplet diameter = " << maxDiam_ << endl;
|
{
|
||||||
Info<< " Maximum droplet volume = " << maxDropletVol << endl;
|
Info<< " Mesh volume = " << meshVol << nl
|
||||||
|
<< " Maximum droplet diameter = " << maxDiam_ << nl
|
||||||
|
<< " Maximum droplet volume = " << maxDropletVol
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Determine blocked faces
|
// Determine blocked faces
|
||||||
@ -515,8 +543,11 @@ void Foam::regionSizeDistribution::write()
|
|||||||
|
|
||||||
regionSplit regions(mesh, blockedFace);
|
regionSplit regions(mesh, blockedFace);
|
||||||
|
|
||||||
Info<< " Determined " << regions.nRegions()
|
if (log_)
|
||||||
<< " disconnected regions" << endl;
|
{
|
||||||
|
Info<< " Determined " << regions.nRegions()
|
||||||
|
<< " disconnected regions" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
@ -534,8 +565,13 @@ void Foam::regionSizeDistribution::write()
|
|||||||
mesh,
|
mesh,
|
||||||
dimensionedScalar("zero", dimless, 0)
|
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)
|
forAll(regions, cellI)
|
||||||
{
|
{
|
||||||
@ -566,11 +602,15 @@ void Foam::regionSizeDistribution::write()
|
|||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< " " << token::TAB << "Region"
|
if (log_)
|
||||||
<< token::TAB << "Volume(mesh)"
|
{
|
||||||
<< token::TAB << "Volume(" << alpha.name() << "):"
|
Info<< " " << token::TAB << "Region"
|
||||||
<< token::TAB << "nCells"
|
<< token::TAB << "Volume(mesh)"
|
||||||
<< endl;
|
<< token::TAB << "Volume(" << alpha.name() << "):"
|
||||||
|
<< token::TAB << "nCells"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
scalar meshSumVol = 0.0;
|
scalar meshSumVol = 0.0;
|
||||||
scalar alphaSumVol = 0.0;
|
scalar alphaSumVol = 0.0;
|
||||||
label nCells = 0;
|
label nCells = 0;
|
||||||
@ -586,50 +626,61 @@ void Foam::regionSizeDistribution::write()
|
|||||||
++vIter, ++aIter, ++numIter
|
++vIter, ++aIter, ++numIter
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Info<< " " << token::TAB << vIter.key()
|
if (log_)
|
||||||
<< token::TAB << vIter()
|
{
|
||||||
<< token::TAB << aIter()
|
Info<< " " << token::TAB << vIter.key()
|
||||||
<< token::TAB << numIter()
|
<< token::TAB << vIter()
|
||||||
<< endl;
|
<< token::TAB << aIter()
|
||||||
|
<< token::TAB << numIter()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
meshSumVol += vIter();
|
meshSumVol += vIter();
|
||||||
alphaSumVol += aIter();
|
alphaSumVol += aIter();
|
||||||
nCells += numIter();
|
nCells += numIter();
|
||||||
}
|
}
|
||||||
Info<< " " << token::TAB << "Total:"
|
|
||||||
<< token::TAB << meshSumVol
|
if (log_)
|
||||||
<< token::TAB << alphaSumVol
|
{
|
||||||
<< token::TAB << nCells
|
Info<< " " << token::TAB << "Total:"
|
||||||
<< endl;
|
<< token::TAB << meshSumVol
|
||||||
Info<< endl;
|
<< token::TAB << alphaSumVol
|
||||||
|
<< token::TAB << nCells
|
||||||
|
<< nl << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (log_)
|
||||||
{
|
{
|
||||||
Info<< " Patch connected regions (liquid core):" << endl;
|
Info<< " Patch connected regions (liquid core):" << nl
|
||||||
Info<< token::TAB << " Region"
|
<< token::TAB << " Region"
|
||||||
<< token::TAB << "Volume(mesh)"
|
<< token::TAB << "Volume(mesh)"
|
||||||
<< token::TAB << "Volume(" << alpha.name() << "):"
|
<< token::TAB << "Volume(" << alpha.name() << "):"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
forAllConstIter(Map<label>, patchRegions, iter)
|
forAllConstIter(Map<label>, patchRegions, iter)
|
||||||
{
|
{
|
||||||
label regionI = iter.key();
|
label regionI = iter.key();
|
||||||
|
|
||||||
Info<< " " << token::TAB << iter.key()
|
Info<< " " << token::TAB << iter.key()
|
||||||
<< token::TAB << allRegionVolume[regionI]
|
<< token::TAB << allRegionVolume[regionI]
|
||||||
<< token::TAB << allRegionAlphaVolume[regionI] << endl;
|
<< token::TAB << allRegionAlphaVolume[regionI] << endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (log_)
|
||||||
{
|
{
|
||||||
Info<< " Background regions:" << endl;
|
Info<< " Background regions:" << nl
|
||||||
Info<< " " << token::TAB << "Region"
|
<< " " << token::TAB << "Region"
|
||||||
<< token::TAB << "Volume(mesh)"
|
<< token::TAB << "Volume(mesh)"
|
||||||
<< token::TAB << "Volume(" << alpha.name() << "):"
|
<< token::TAB << "Volume(" << alpha.name() << "):"
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
Map<scalar>::const_iterator vIter = allRegionVolume.begin();
|
Map<scalar>::const_iterator vIter = allRegionVolume.begin();
|
||||||
Map<scalar>::const_iterator aIter = allRegionAlphaVolume.begin();
|
Map<scalar>::const_iterator aIter = allRegionAlphaVolume.begin();
|
||||||
|
|
||||||
@ -652,6 +703,7 @@ void Foam::regionSizeDistribution::write()
|
|||||||
<< token::TAB << aIter() << endl;
|
<< token::TAB << aIter() << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,9 +798,10 @@ void Foam::regionSizeDistribution::write()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write to screen
|
// Write to screen
|
||||||
|
if (log_)
|
||||||
{
|
{
|
||||||
Info<< " Bins:" << endl;
|
Info<< " Bins:" << nl
|
||||||
Info<< " " << token::TAB << "Bin"
|
<< " " << token::TAB << "Bin"
|
||||||
<< token::TAB << "Min diameter"
|
<< token::TAB << "Min diameter"
|
||||||
<< token::TAB << "Count:"
|
<< token::TAB << "Count:"
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -759,8 +812,10 @@ void Foam::regionSizeDistribution::write()
|
|||||||
Info<< " " << token::TAB << binI
|
Info<< " " << token::TAB << binI
|
||||||
<< token::TAB << diam
|
<< token::TAB << diam
|
||||||
<< token::TAB << binCount[binI] << endl;
|
<< token::TAB << binCount[binI] << endl;
|
||||||
|
|
||||||
diam += delta;
|
diam += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< endl;
|
Info<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -783,7 +838,7 @@ void Foam::regionSizeDistribution::write()
|
|||||||
forAll(selected, i)
|
forAll(selected, i)
|
||||||
{
|
{
|
||||||
const word& fldName = scalarNames[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
|
const scalarField& fld = obr_.lookupObject
|
||||||
<
|
<
|
||||||
@ -812,7 +867,7 @@ void Foam::regionSizeDistribution::write()
|
|||||||
forAll(selected, i)
|
forAll(selected, i)
|
||||||
{
|
{
|
||||||
const word& fldName = vectorNames[selected[i]];
|
const word& fldName = vectorNames[selected[i]];
|
||||||
Info<< " Vector field " << fldName << endl;
|
if (log_) Info << " Vector field " << fldName << endl;
|
||||||
|
|
||||||
vectorField fld = obr_.lookupObject
|
vectorField fld = obr_.lookupObject
|
||||||
<
|
<
|
||||||
@ -821,10 +876,13 @@ void Foam::regionSizeDistribution::write()
|
|||||||
|
|
||||||
if (coordSysPtr_.valid())
|
if (coordSysPtr_.valid())
|
||||||
{
|
{
|
||||||
Info<< "Transforming vector field " << fldName
|
if (log_)
|
||||||
<< " with coordinate system "
|
{
|
||||||
<< coordSysPtr_().name()
|
Info<< "Transforming vector field " << fldName
|
||||||
<< endl;
|
<< " with coordinate system "
|
||||||
|
<< coordSysPtr_().name()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
fld = coordSysPtr_().localVector(fld);
|
fld = coordSysPtr_().localVector(fld);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -92,6 +92,7 @@ Description
|
|||||||
minDiameter | minimum region equivalent diameter | no | 0
|
minDiameter | minimum region equivalent diameter | no | 0
|
||||||
setFormat | writing format | yes |
|
setFormat | writing format | yes |
|
||||||
coordinateSystem | transformation for vector fields | no |
|
coordinateSystem | transformation for vector fields | no |
|
||||||
|
log | Log to standard output | no | yes
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
SeeAlso
|
SeeAlso
|
||||||
@ -113,6 +114,7 @@ SourceFiles
|
|||||||
#include "volFieldsFwd.H"
|
#include "volFieldsFwd.H"
|
||||||
#include "wordReList.H"
|
#include "wordReList.H"
|
||||||
#include "coordinateSystem.H"
|
#include "coordinateSystem.H"
|
||||||
|
#include "Switch.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -150,6 +152,9 @@ class regionSizeDistribution
|
|||||||
//- Patches to walk from
|
//- Patches to walk from
|
||||||
wordReList patchNames_;
|
wordReList patchNames_;
|
||||||
|
|
||||||
|
//- Switch to send output to Info as well as to file
|
||||||
|
Switch log_;
|
||||||
|
|
||||||
//- Clip value
|
//- Clip value
|
||||||
scalar threshold_;
|
scalar threshold_;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user