Commit 083d7059 authored by Henry's avatar Henry
Browse files

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
parent 5b1edc73
......@@ -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
......@@ -38,7 +38,7 @@ Foam::label Foam::functionObjectFile::addChars = 7;
void Foam::functionObjectFile::initStream(Ostream& os) const
{
os.setf(ios_base::scientific, ios_base::floatfield);
// os.precision(IOstream::defaultPrecision());
// os.precision(IOstream::defaultPrecision());
os.width(charWidth());
}
......
......@@ -107,13 +107,13 @@ 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 ++;
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 * * * * * * * * * * * //
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
if (Pstream::master())
{
totalArea = gSum(filterField(mesh().magSf(), false));
file() << obr_.time().value();
}
if (Pstream::master())
if (writeTotalArea_)
{
file() << obr_.time().value() << tab << totalArea;
if (Pstream::master())
{
file() << tab << totalArea();
}
}
// construct weight field. Note: zero size means weight = 1
......
......@@ -214,20 +214,23 @@ private:
//- Set faces according to sampledSurface
void sampledSurfaceFaces(const dictionary&);
//- Combine mesh faces and points from multiple processors
//- Combine mesh faces and points from multiple processors
void combineMeshGeometry
(
faceList& faces,
pointField& points
) const;
//- Combine surface faces and points from multiple processors
//- Combine surface faces and points from multiple processors
void combineSurfaceGeometry
(
faceList& faces,
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_;
......
#!/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;
outputInterval 1;
log yes;
writeTotalArea no;
valueOutput no;
source faceZone;
sourceName f0;
......
#!/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;
outputInterval 1;
log yes;
writeTotalArea no;
valueOutput no;
source faceZone;
sourceName f0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment