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:
Henry
2015-04-26 16:32:19 +01:00
parent 5b1edc73b1
commit 083d7059fc
8 changed files with 56 additions and 28 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License

View File

@ -107,10 +107,10 @@ Foam::fv::optionList::optionList(const fvMesh& mesh)
void Foam::fv::optionList::reset(const dictionary& dict)
{
// Count number of active fvOptions
label count = 0;
forAllConstIter(dictionary, dict, iter)
{
// safety:
if (iter().isDict())
{
count++;

View File

@ -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 * * * * * * * * * * * //
void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
@ -423,22 +440,15 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
return;
}
scalar totalArea;
if (surfacePtr_.valid())
{
surfacePtr_().update();
totalArea = gSum(surfacePtr_().magSf());
}
else
{
totalArea = gSum(filterField(mesh().magSf(), false));
}
Info<< type() << " " << name_ << ":" << nl
<< " total faces = " << nFaces_
<< nl
<< " total area = " << totalArea
<< " total area = " << totalArea()
<< nl;
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)
{
file()
<< "# Source : " << sourceTypeNames_[source_] << " "
<< sourceName_ << nl << "# Faces : " << nFaces_ << nl
<< "# Time" << tab << "sum(magSf)";
writeCommented(file(), "Source : ");
file() << sourceTypeNames_[source_] << " " << sourceName_ << endl;
writeCommented(file(), "Faces : ");
file() << nFaces_ << endl;
writeCommented(file(), "Area : ");
file() << totalArea() << endl;
writeCommented(file(), "Time");
if (writeTotalArea_)
{
file() << tab << "Area";
}
forAll(fields_, i)
{
@ -621,6 +639,7 @@ Foam::fieldValues::faceSource::faceSource
:
fieldValue(name, obr, dict, typeName, loadFromFiles),
surfaceWriterPtr_(NULL),
writeTotalArea_(dict.lookupOrDefault("writeTotalArea", false)),
source_(sourceTypeNames_.read(dict.lookup("source"))),
operation_(operationTypeNames_.read(dict.lookup("operation"))),
weightFieldName_("none"),
@ -661,21 +680,22 @@ void Foam::fieldValues::faceSource::write()
if (active_)
{
scalar totalArea;
if (surfacePtr_.valid())
{
surfacePtr_().update();
totalArea = gSum(surfacePtr_().magSf());
}
else
{
totalArea = gSum(filterField(mesh().magSf(), false));
}
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

View File

@ -228,6 +228,9 @@ private:
pointField& points
) const;
//- Calculate and return total area of the faceSource: sum(magSf)
scalar totalArea() const;
protected:
@ -236,6 +239,9 @@ protected:
//- Surface writer
autoPtr<surfaceWriter> surfaceWriterPtr_;
//- Optionally write the totalArea
bool writeTotalArea_;
//- Source type
sourceType source_;

View File

@ -1,2 +1,2 @@
#!/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

View File

@ -75,6 +75,7 @@ functions
outputControl timeStep;
outputInterval 1;
log yes;
writeTotalArea no;
valueOutput no;
source faceZone;
sourceName f0;

View File

@ -1,2 +1,2 @@
#!/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

View File

@ -75,6 +75,7 @@ functions
outputControl timeStep;
outputInterval 1;
log yes;
writeTotalArea no;
valueOutput no;
source faceZone;
sourceName f0;