mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
faceSource: Writing the total area of the faceSource (sum(magSf)) for each time is now optional
Previous behavior which may be useful for moving-mesh cases can be
selected using the optional entry:
writeTotalArea yes;
The initial total area is written in the log and data file header e.g.:
# Source : faceZone f0
# Faces : 8
# Area : 1.063860e-02
This commit is contained in:
@ -2,7 +2,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) 2012-2014 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
|
|||||||
@ -107,10 +107,10 @@ Foam::fv::optionList::optionList(const fvMesh& mesh)
|
|||||||
|
|
||||||
void Foam::fv::optionList::reset(const dictionary& dict)
|
void Foam::fv::optionList::reset(const dictionary& dict)
|
||||||
{
|
{
|
||||||
|
// Count number of active fvOptions
|
||||||
label count = 0;
|
label count = 0;
|
||||||
forAllConstIter(dictionary, dict, iter)
|
forAllConstIter(dictionary, dict, iter)
|
||||||
{
|
{
|
||||||
// safety:
|
|
||||||
if (iter().isDict())
|
if (iter().isDict())
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
|||||||
@ -378,6 +378,23 @@ void Foam::fieldValues::faceSource::combineSurfaceGeometry
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::scalar Foam::fieldValues::faceSource::totalArea() const
|
||||||
|
{
|
||||||
|
scalar totalArea;
|
||||||
|
|
||||||
|
if (surfacePtr_.valid())
|
||||||
|
{
|
||||||
|
totalArea = gSum(surfacePtr_().magSf());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
totalArea = gSum(filterField(mesh().magSf(), false));
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
||||||
@ -423,22 +440,15 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
scalar totalArea;
|
|
||||||
|
|
||||||
if (surfacePtr_.valid())
|
if (surfacePtr_.valid())
|
||||||
{
|
{
|
||||||
surfacePtr_().update();
|
surfacePtr_().update();
|
||||||
totalArea = gSum(surfacePtr_().magSf());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
totalArea = gSum(filterField(mesh().magSf(), false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Info<< type() << " " << name_ << ":" << nl
|
Info<< type() << " " << name_ << ":" << nl
|
||||||
<< " total faces = " << nFaces_
|
<< " total faces = " << nFaces_
|
||||||
<< nl
|
<< nl
|
||||||
<< " total area = " << totalArea
|
<< " total area = " << totalArea()
|
||||||
<< nl;
|
<< nl;
|
||||||
|
|
||||||
if (dict.readIfPresent("weightField", weightFieldName_))
|
if (dict.readIfPresent("weightField", weightFieldName_))
|
||||||
@ -517,10 +527,18 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
|
|||||||
|
|
||||||
void Foam::fieldValues::faceSource::writeFileHeader(const label i)
|
void Foam::fieldValues::faceSource::writeFileHeader(const label i)
|
||||||
{
|
{
|
||||||
file()
|
writeCommented(file(), "Source : ");
|
||||||
<< "# Source : " << sourceTypeNames_[source_] << " "
|
file() << sourceTypeNames_[source_] << " " << sourceName_ << endl;
|
||||||
<< sourceName_ << nl << "# Faces : " << nFaces_ << nl
|
writeCommented(file(), "Faces : ");
|
||||||
<< "# Time" << tab << "sum(magSf)";
|
file() << nFaces_ << endl;
|
||||||
|
writeCommented(file(), "Area : ");
|
||||||
|
file() << totalArea() << endl;
|
||||||
|
writeCommented(file(), "Time");
|
||||||
|
|
||||||
|
if (writeTotalArea_)
|
||||||
|
{
|
||||||
|
file() << tab << "Area";
|
||||||
|
}
|
||||||
|
|
||||||
forAll(fields_, i)
|
forAll(fields_, i)
|
||||||
{
|
{
|
||||||
@ -621,6 +639,7 @@ Foam::fieldValues::faceSource::faceSource
|
|||||||
:
|
:
|
||||||
fieldValue(name, obr, dict, typeName, loadFromFiles),
|
fieldValue(name, obr, dict, typeName, loadFromFiles),
|
||||||
surfaceWriterPtr_(NULL),
|
surfaceWriterPtr_(NULL),
|
||||||
|
writeTotalArea_(dict.lookupOrDefault("writeTotalArea", false)),
|
||||||
source_(sourceTypeNames_.read(dict.lookup("source"))),
|
source_(sourceTypeNames_.read(dict.lookup("source"))),
|
||||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||||
weightFieldName_("none"),
|
weightFieldName_("none"),
|
||||||
@ -661,21 +680,22 @@ void Foam::fieldValues::faceSource::write()
|
|||||||
|
|
||||||
if (active_)
|
if (active_)
|
||||||
{
|
{
|
||||||
scalar totalArea;
|
|
||||||
|
|
||||||
if (surfacePtr_.valid())
|
if (surfacePtr_.valid())
|
||||||
{
|
{
|
||||||
surfacePtr_().update();
|
surfacePtr_().update();
|
||||||
totalArea = gSum(surfacePtr_().magSf());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
totalArea = gSum(filterField(mesh().magSf(), false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
file() << obr_.time().value() << tab << totalArea;
|
file() << obr_.time().value();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (writeTotalArea_)
|
||||||
|
{
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
file() << tab << totalArea();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// construct weight field. Note: zero size means weight = 1
|
// construct weight field. Note: zero size means weight = 1
|
||||||
|
|||||||
@ -228,6 +228,9 @@ private:
|
|||||||
pointField& points
|
pointField& points
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
//- Calculate and return total area of the faceSource: sum(magSf)
|
||||||
|
scalar totalArea() const;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -236,6 +239,9 @@ protected:
|
|||||||
//- Surface writer
|
//- Surface writer
|
||||||
autoPtr<surfaceWriter> surfaceWriterPtr_;
|
autoPtr<surfaceWriter> surfaceWriterPtr_;
|
||||||
|
|
||||||
|
//- Optionally write the totalArea
|
||||||
|
bool writeTotalArea_;
|
||||||
|
|
||||||
//- Source type
|
//- Source type
|
||||||
sourceType source_;
|
sourceType source_;
|
||||||
|
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
awk '{print $1 " " $4}' postProcessing/poolHeight/0/faceSource.dat > poolHeight_vs_time
|
awk '{print $1 " " $3}' postProcessing/poolHeight/0/faceSource.dat > poolHeight_vs_time
|
||||||
|
|||||||
@ -75,6 +75,7 @@ functions
|
|||||||
outputControl timeStep;
|
outputControl timeStep;
|
||||||
outputInterval 1;
|
outputInterval 1;
|
||||||
log yes;
|
log yes;
|
||||||
|
writeTotalArea no;
|
||||||
valueOutput no;
|
valueOutput no;
|
||||||
source faceZone;
|
source faceZone;
|
||||||
sourceName f0;
|
sourceName f0;
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
awk '{print $1 " " $4}' postProcessing/poolHeight/0/faceSource.dat > poolHeight_vs_time
|
awk '{print $1 " " $3}' postProcessing/poolHeight/0/faceSource.dat > poolHeight_vs_time
|
||||||
|
|||||||
@ -75,6 +75,7 @@ functions
|
|||||||
outputControl timeStep;
|
outputControl timeStep;
|
||||||
outputInterval 1;
|
outputInterval 1;
|
||||||
log yes;
|
log yes;
|
||||||
|
writeTotalArea no;
|
||||||
valueOutput no;
|
valueOutput no;
|
||||||
source faceZone;
|
source faceZone;
|
||||||
sourceName f0;
|
sourceName f0;
|
||||||
|
|||||||
Reference in New Issue
Block a user