cellSource: Writing the volume of the cellSource (sum(V)) for each time is now optional
Previous behavior which may be useful for moving-mesh cases can be selected using the optional entry: writeVolume yes; The initial volume is written in the log and data file header e.g.: # Source : all # Cells : 3829 # Volume : 9.943164e-01 Also added sumMag | sum of component magnitudes
This commit is contained in:
parent
e393bbbaca
commit
ef3ba43cf4
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -41,10 +41,11 @@ namespace Foam
|
||||
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<fieldValues::cellSource::operationType, 9>::names[] =
|
||||
const char* NamedEnum<fieldValues::cellSource::operationType, 10>::names[] =
|
||||
{
|
||||
"none",
|
||||
"sum",
|
||||
"sumMag",
|
||||
"average",
|
||||
"weightedAverage",
|
||||
"volAverage",
|
||||
@ -65,7 +66,7 @@ namespace Foam
|
||||
const Foam::NamedEnum<Foam::fieldValues::cellSource::sourceType, 2>
|
||||
Foam::fieldValues::cellSource::sourceTypeNames_;
|
||||
|
||||
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 9>
|
||||
const Foam::NamedEnum<Foam::fieldValues::cellSource::operationType, 10>
|
||||
Foam::fieldValues::cellSource::operationTypeNames_;
|
||||
|
||||
|
||||
@ -77,6 +78,8 @@ void Foam::fieldValues::cellSource::setCellZoneCells()
|
||||
{
|
||||
case stCellZone:
|
||||
{
|
||||
dict().lookup("sourceName") >> sourceName_;
|
||||
|
||||
label zoneId = mesh().cellZones().findZoneID(sourceName_);
|
||||
|
||||
if (zoneId < 0)
|
||||
@ -114,6 +117,12 @@ void Foam::fieldValues::cellSource::setCellZoneCells()
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::fieldValues::cellSource::volume() const
|
||||
{
|
||||
return gSum(filterField(mesh().V()));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
|
||||
@ -125,8 +134,7 @@ void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
|
||||
WarningIn
|
||||
(
|
||||
"Foam::fieldValues::cellSource::initialise(const dictionary&)"
|
||||
)
|
||||
<< type() << " " << name_ << ": "
|
||||
) << type() << " " << name_ << ": "
|
||||
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl
|
||||
<< " Source has no cells - deactivating" << endl;
|
||||
|
||||
@ -151,10 +159,18 @@ void Foam::fieldValues::cellSource::initialise(const dictionary& dict)
|
||||
|
||||
void Foam::fieldValues::cellSource::writeFileHeader(const label i)
|
||||
{
|
||||
file()
|
||||
<< "# Source : " << sourceTypeNames_[source_] << " "
|
||||
<< sourceName_ << nl << "# Cells : " << nCells_ << nl
|
||||
<< "# Time" << tab << "sum(V)";
|
||||
writeCommented(file(), "Source : ");
|
||||
file() << sourceTypeNames_[source_] << " " << sourceName_ << endl;
|
||||
writeCommented(file(), "Cells : ");
|
||||
file() << nCells_ << endl;
|
||||
writeCommented(file(), "Volume : ");
|
||||
file() << volume() << endl;
|
||||
|
||||
writeCommented(file(), "Time");
|
||||
if (writeVolume_)
|
||||
{
|
||||
file() << tab << "Volume";
|
||||
}
|
||||
|
||||
forAll(fields_, i)
|
||||
{
|
||||
@ -182,7 +198,8 @@ Foam::fieldValues::cellSource::cellSource
|
||||
operation_(operationTypeNames_.read(dict.lookup("operation"))),
|
||||
nCells_(0),
|
||||
cellId_(),
|
||||
weightFieldName_("none")
|
||||
weightFieldName_("none"),
|
||||
writeVolume_(dict.lookupOrDefault("writeVolume", false))
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -214,10 +231,17 @@ void Foam::fieldValues::cellSource::write()
|
||||
|
||||
if (active_)
|
||||
{
|
||||
scalar totalVolume = gSum(filterField(mesh().V()));
|
||||
if (Pstream::master())
|
||||
{
|
||||
file() << obr_.time().value() << tab << totalVolume;
|
||||
file() << obr_.time().value();
|
||||
}
|
||||
|
||||
if (writeVolume_)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
file() << tab << volume();
|
||||
}
|
||||
}
|
||||
|
||||
forAll(fields_, i)
|
||||
|
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,9 +58,10 @@ Description
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: cellSource | yes |
|
||||
log | write data to standard output | no | no
|
||||
valueOutput | write the raw output values | yes |
|
||||
type | Type name: cellSource | yes |
|
||||
log | Write data to standard output | no | no
|
||||
valueOutput | Write the raw output values | yes |
|
||||
writeVolume | Write the volume of the cellSource | no |
|
||||
source | cell source: see below | yes |
|
||||
sourceName | name of cell source if required | no |
|
||||
operation | operation to perform | yes |
|
||||
@ -80,6 +81,7 @@ Description
|
||||
\plaintable
|
||||
none | no operation
|
||||
sum | sum
|
||||
sumMag | sum of component magnitudes
|
||||
average | ensemble average
|
||||
weightedAverage | weighted average
|
||||
volAverage | volume weighted average
|
||||
@ -143,6 +145,7 @@ public:
|
||||
{
|
||||
opNone,
|
||||
opSum,
|
||||
opSumMag,
|
||||
opAverage,
|
||||
opWeightedAverage,
|
||||
opVolAverage,
|
||||
@ -153,7 +156,7 @@ public:
|
||||
};
|
||||
|
||||
//- Operation type names
|
||||
static const NamedEnum<operationType, 9> operationTypeNames_;
|
||||
static const NamedEnum<operationType, 10> operationTypeNames_;
|
||||
|
||||
|
||||
private:
|
||||
@ -166,6 +169,9 @@ private:
|
||||
//- Set cells to evaluate based on a patch
|
||||
void setPatchCells();
|
||||
|
||||
//- Calculate and return volume of the cellSource: sum(V)
|
||||
scalar volume() const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -186,6 +192,9 @@ protected:
|
||||
//- Weight field name - only used for opWeightedAverage mode
|
||||
word weightFieldName_;
|
||||
|
||||
//- Optionally write the volume of the cellSource
|
||||
bool writeVolume_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -90,6 +90,11 @@ Type Foam::fieldValues::cellSource::processValues
|
||||
result = sum(values);
|
||||
break;
|
||||
}
|
||||
case opSumMag:
|
||||
{
|
||||
result = sum(cmptMag(values));
|
||||
break;
|
||||
}
|
||||
case opAverage:
|
||||
{
|
||||
result = sum(values)/values.size();
|
||||
@ -201,7 +206,7 @@ bool Foam::fieldValues::cellSource::writeValues(const word& fieldName)
|
||||
file()<< tab << result;
|
||||
|
||||
Info(log_)<< " " << operationTypeNames_[operation_]
|
||||
<< "(" << sourceName_ << ") for " << fieldName
|
||||
<< "(" << sourceName_ << ") of " << fieldName
|
||||
<< " = " << result << endl;
|
||||
}
|
||||
}
|
||||
@ -221,4 +226,3 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValues::cellSource::filterField
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
|
@ -80,7 +80,7 @@ Foam::fieldValue::fieldValue
|
||||
dict_(dict),
|
||||
active_(true),
|
||||
log_(true),
|
||||
sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")),
|
||||
sourceName_(word::null),
|
||||
fields_(dict.lookup("fields")),
|
||||
valueOutput_(dict.lookup("valueOutput")),
|
||||
resultDict_(fileName("name"), dictionary::null)
|
||||
|
Loading…
Reference in New Issue
Block a user