Commit 6838df9c authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: Multiple updates to function objects

Updated objects
- corrected Peclet number for compressible cases
- propagated log flag and resultName across objects

New function objects
- new fluxSummary:
  - calculates positive, negative, absolute and net flux across face
    zones
- new runTimeControl
  - abort the calculation when a user-defined metric is achieved.
    Available options include:
    - average value remains unchanged wrt a given threshold
    - equation initial residual exceeds a threshold - useful to abort
      diverging cases
    - equation max iterations exceeds a threshold - useful to abort
      diverging cases
    - min/max of a function object value
    - min time step exceeds a threshold - useful to abort diverging
      cases
- new valueAverage:
  - average singular values from other function objects, e.g. Cd, Cl and
    Cm from the forceCoeffs function object
parent f4de5d17
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -31,7 +31,7 @@ License
namespace Foam
{
template<>
const char* NamedEnum<outputFilterOutputControl::outputControls, 7>::
const char* NamedEnum<outputFilterOutputControl::outputControls, 8>::
names[] =
{
"timeStep",
......@@ -40,11 +40,12 @@ namespace Foam
"runTime",
"clockTime",
"cpuTime",
"onEnd",
"none"
};
}
const Foam::NamedEnum<Foam::outputFilterOutputControl::outputControls, 7>
const Foam::NamedEnum<Foam::outputFilterOutputControl::outputControls, 8>
Foam::outputFilterOutputControl::outputControlNames_;
......@@ -113,6 +114,7 @@ void Foam::outputFilterOutputControl::read(const dictionary& dict)
break;
}
case ocOnEnd:
default:
{
// do nothing
......@@ -196,6 +198,13 @@ bool Foam::outputFilterOutputControl::output()
break;
}
case ocOnEnd:
{
scalar endTime = time_.endTime().value() - 0.5*time_.deltaTValue();
return time_.value() > endTime;
break;
}
case ocNone:
{
return false;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -62,6 +62,7 @@ public:
ocRunTime, /*!< run time for dumping */
ocClockTime, /*!< clock time for dumping */
ocCpuTime, /*!< cpu time for dumping */
ocOnEnd, /*!< on end of run*/
ocNone /*!< no output */
};
......@@ -77,7 +78,7 @@ private:
const word prefix_;
//- String representation of outputControls enums
static const NamedEnum<outputControls, 7> outputControlNames_;
static const NamedEnum<outputControls, 8> outputControlNames_;
//- Type of output
outputControls outputControl_;
......
......@@ -10,7 +10,6 @@ $(BCs)/totalFlowRateAdvectiveDiffusive/totalFlowRateAdvectiveDiffusiveFvPatchSca
$(BCs)/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C
$(BCs)/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C
$(BCs)/wallHeatTransfer/wallHeatTransferFvPatchScalarField.C
$(BCs)/externalCoupledTemperatureMixed/externalCoupledTemperatureMixedFvPatchScalarField.C
$(BCs)/convectiveHeatTransfer/convectiveHeatTransferFvPatchScalarField.C
turbulentFluidThermoModels/derivedFvPatchFields/wallFunctions/alphatWallFunctions/alphatWallFunction/alphatWallFunctionFvPatchScalarField.C
......
......@@ -133,7 +133,6 @@ $(derivedFvPatchFields)/advective/advectiveFvPatchFields.C
$(derivedFvPatchFields)/codedFixedValue/codedFixedValueFvPatchFields.C
$(derivedFvPatchFields)/codedMixed/codedMixedFvPatchFields.C
$(derivedFvPatchFields)/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C
$(derivedFvPatchFields)/externalCoupledMixed/externalCoupledMixedFvPatchFields.C
$(derivedFvPatchFields)/fan/fanFvPatchFields.C
$(derivedFvPatchFields)/fanPressure/fanPressureFvPatchScalarField.C
$(derivedFvPatchFields)/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -49,7 +49,8 @@ Foam::partialWrite::partialWrite
)
:
name_(name),
obr_(obr)
obr_(obr),
log_(true)
{
read(dict);
}
......@@ -65,16 +66,39 @@ Foam::partialWrite::~partialWrite()
void Foam::partialWrite::read(const dictionary& dict)
{
log_.readIfPresent("log", dict);
dict.lookup("objectNames") >> objectNames_;
dict.lookup("writeInterval") >> writeInterval_;
writeInstance_ = 0;
Info<< type() << " " << name() << ":" << nl
<< " dumping every " << writeInterval_
<< " th outputTime : " << nl << endl ;
forAllConstIter(HashSet<word>, objectNames_, iter)
if (log_)
{
Info<< ' ' << iter.key();
Info<< type() << " " << name() << ":" << nl
<< " dumping every outputTime :";
forAllConstIter(HashSet<word>, objectNames_, iter)
{
Info<< ' ' << iter.key();
}
word postStr = "";
if (writeInterval_ == 2)
{
postStr = "nd ";
}
else if (writeInterval_ == 3)
{
postStr = "rd ";
}
else
{
postStr = "th ";
}
Info<< nl
<< " dumping all other fields every "
<< writeInterval_ << postStr << " outputTime" << nl
<< endl;
}
if (writeInterval_ < 1)
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -50,6 +50,7 @@ Description
type | type name: partialWrite | yes |
objectNames | objects to write | yes |
writeInterval | write interval | yes |
log | Log to standard output | no | yes
\endtable
SeeAlso
......@@ -91,11 +92,15 @@ protected:
// Private data
//- Name of this set of partialWrite
//- Name of this set of partialWrite object
word name_;
//- Refefence to the database
const objectRegistry& obr_;
//- Switch to send output to Info as well as to file
Switch log_;
//- Loaded fields
UPtrList<volScalarField> vsf_;
UPtrList<volVectorField> vvf_;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -68,7 +68,7 @@ void Foam::partialWrite::loadField
<< " found in database" << endl;
}
sfType& sField =
sfType& sField =
const_cast<sfType&>
(
obr_.lookupObject<sfType>(fieldName)
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -31,7 +31,7 @@ License
namespace Foam
{
defineTypeNameAndDebug(removeRegisteredObject, 0);
defineTypeNameAndDebug(removeRegisteredObject, 0);
}
......@@ -47,7 +47,8 @@ Foam::removeRegisteredObject::removeRegisteredObject
:
name_(name),
obr_(obr),
objectNames_()
objectNames_(),
log_(true)
{
read(dict);
}
......@@ -78,7 +79,8 @@ void Foam::removeRegisteredObject::execute()
if (obj.ownedByRegistry())
{
Info<< type() << " " << name_ << " output:" << nl
if (log_) Info
<< type() << " " << name_ << " output:" << nl
<< " removing object " << obj.name() << nl
<< endl;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -46,6 +46,7 @@ Description
Property | Description | Required | Default value
type | type name: removeRegisteredObject | yes |
objectNames | objects to remove | yes |
log | Log to standard output | no | yes
\endtable
SeeAlso
......@@ -63,6 +64,7 @@ SourceFiles
#include "wordList.H"
#include "runTimeSelectionTables.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -85,9 +87,10 @@ protected:
// Private data
//- Name of this set of removeRegisteredObject
//- Name of this set of removeRegisteredObject object
word name_;
//- Refefence to the database
const objectRegistry& obr_;
// Read from dictionary
......@@ -95,6 +98,9 @@ protected:
//- Names of objects to control
wordList objectNames_;
//- Switch to send output to Info as well as to file
Switch log_;
// Private Member Functions
......
......@@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -48,7 +48,8 @@ Foam::writeRegisteredObject::writeRegisteredObject
name_(name),
exclusiveWriting_(false),
obr_(obr),
objectNames_()
objectNames_(),
log_(true)
{
read(dict);
}
......@@ -64,6 +65,8 @@ Foam::writeRegisteredObject::~writeRegisteredObject()
void Foam::writeRegisteredObject::read(const dictionary& dict)
{
log_.readIfPresent("log", dict);
dict.lookup("objectNames") >> objectNames_;
dict.readIfPresent("exclusiveWriting", exclusiveWriting_);
}
......@@ -89,7 +92,7 @@ void Foam::writeRegisteredObject::timeSet()
void Foam::writeRegisteredObject::write()
{
Info<< type() << " " << name_ << " output:" << nl;
if (log_) Info<< type() << " " << name_ << " output:" << nl;
DynamicList<word> allNames(obr_.toc().size());
forAll(objectNames_, i)
......@@ -123,7 +126,7 @@ void Foam::writeRegisteredObject::write()
obj.writeOpt() = IOobject::NO_WRITE;
}
Info<< " writing object " << obj.name() << nl << endl;
if (log_) Info<< " writing object " << obj.name() << nl << endl;
obj.write();
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -30,13 +30,13 @@ Group
Description
This function object allows specification of different writing frequency
of objects registered to the database. It has similar functionality
as the main time database through the outputControl setting:
timeStep
outputTime
adjustableTime
runTime
clockTime
cpuTime
as the main time database through the \c outputControl setting:
- timeStep
- outputTime
- adjustableTime
- runTime
- clockTime
- cpuTime
Example of function object specification:
\verbatim
......@@ -56,6 +56,7 @@ Description
type | type name: writeRegisteredObject | yes |
objectNames | objects to write | yes |
exclusiveWriting | Takes over object writing | no | yes
log | Log to standard output | no | yes
\endtable
exclusiveWriting disables automatic writing (i.e through database) of the
......@@ -76,6 +77,7 @@ SourceFiles
#include "wordReList.H"
#include "runTimeSelectionTables.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -104,7 +106,7 @@ protected:
//- Takes over the writing from Db
bool exclusiveWriting_;
//- Refererence to Db
//- Refererence to the database
const objectRegistry& obr_;
// Read from dictionary
......@@ -112,6 +114,9 @@ protected:
//- Names of objects to control
wordReList objectNames_;
//- Switch to send output to Info as well as to file
Switch log_;
// Private Member Functions
......
......@@ -172,16 +172,14 @@ void Foam::cloudInfo::write()
<< endl;
}
if (log_)
{
Info<< type() << " " << name_ << " output:" << nl
<< " number of parcels : " << nParcels << nl
<< " mass in system : " << massInSystem << nl
<< " maximum diameter : " << Dmax << nl
<< " D10 diameter : " << D10 << nl
<< " D32 diameter : " << D32 << nl
<< endl;
}
if (log_) Info
<< type() << " " << name_ << " output:" << nl
<< " number of parcels : " << nParcels << nl
<< " mass in system : " << massInSystem << nl
<< " maximum diameter : " << Dmax << nl
<< " D10 diameter : " << D10 << nl
<< " D32 diameter : " << D32 << nl
<< endl;
}
}
}
......
......@@ -40,6 +40,7 @@ The current range of features comprises of:
- \ref grpFieldFunctionObjects
- \ref grpForcesFunctionObjects
- \ref grpFVFunctionObjects
- \ref grpGraphicsFunctionObjects
- \ref grpIOFunctionObjects
- \ref grpJobControlFunctionObjects
- \ref grpUtilitiesFunctionObjects
......
......@@ -34,16 +34,19 @@ streamLine/streamLineParticle.C
streamLine/streamLineParticleCloud.C
streamLine/streamLineFunctionObject.C
wallBoundedStreamLine/wallBoundedStreamLine.C
wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C
wallBoundedStreamLine/wallBoundedStreamLineParticle.C
wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.C
wallBoundedStreamLine/wallBoundedParticle.C
surfaceInterpolateFields/surfaceInterpolateFields.C
surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C
regionSizeDistribution/regionSizeDistribution.C
regionSizeDistribution/regionSizeDistributionFunctionObject.C
valueAverage/valueAverage.C
valueAverage/valueAverageFunctionObject.C
wallBoundedStreamLine/wallBoundedStreamLine.C
wallBoundedStreamLine/wallBoundedStreamLineFunctionObject.C
wallBoundedStreamLine/wallBoundedStreamLineParticle.C
wallBoundedStreamLine/wallBoundedStreamLineParticleCloud.C
wallBoundedStreamLine/wallBoundedParticle.C
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects
......@@ -124,11 +124,9 @@ void Foam::fieldAverage::calcAverages()
prevTimeIndex_ = currentTimeIndex;
}
if (log_)
{
Info<< type() << " " << name_ << " output:" << nl
<< " Calculating averages" << nl;
}
if (log_) Info
<< type() << " " << name_ << " output:" << nl
<< " Calculating averages" << nl;
addMeanSqrToPrime2Mean<scalar, scalar>();
addMeanSqrToPrime2Mean<vector, symmTensor>();
......@@ -204,21 +202,17 @@ void Foam::fieldAverage::readAveragingProperties()
totalIter_[fieldI] = readLabel(fieldDict.lookup("totalIter"));
totalTime_[fieldI] = readScalar(fieldDict.lookup("totalTime"));
if (log_)
{
Info<< " " << fieldName
<< " iters = " << totalIter_[fieldI]
<< " time = " << totalTime_[fieldI] << nl;
}
if (log_) Info
<< " " << fieldName
<< " iters = " << totalIter_[fieldI]
<< " time = " << totalTime_[fieldI] << nl;
}
else
{
if (log_)
{
Info<< " " << fieldName
<< ": starting averaging at time "
<< obr_.time().timeName() << endl;
}
if (log_) Info
<< " " << fieldName
<< ": starting averaging at time "
<< obr_.time().timeName() << endl;
}
}
}
......@@ -315,11 +309,9 @@ void Foam::fieldAverage::write()
if (resetOnOutput_)
{
if (log_)
{
Info<< " Restarting averaging at time " << obr_.time().timeName()
<< nl << endl;
}
if (log_) Info
<< " Restarting averaging at time " << obr_.time().timeName()
<< nl << endl;
totalIter_.clear();
totalIter_.setSize(faItems_.size(), 1);
......
......@@ -46,12 +46,10 @@ void Foam::fieldAverage::addMeanFieldType(const label fieldI)
}
else if (obr_.found(meanFieldName))
{
if (log_)
{
Info<< " Cannot allocate average field " << meanFieldName
<< " since an object with that name already exists."
<< " Disabling averaging for field." << endl;
}
if (log_) Info
<< " Cannot allocate average field " << meanFieldName
<< " since an object with that name already exists."
<< " Disabling averaging for field." << endl;
faItems_[fieldI].mean() = false;
}
......@@ -110,10 +108,8 @@ void Foam::fieldAverage::addPrime2MeanFieldType(const label fieldI)
const word& meanFieldName = faItems_[fieldI].meanFieldName();
const word& prime2MeanFieldName = faItems_[fieldI].prime2MeanFieldName();
if (log_)
{
Info << " Reading/initialising field " << prime2MeanFieldName << nl;
}
if (log_) Info
<< " Reading/initialising field " << prime2MeanFieldName << endl;
if (obr_.foundObject<Type2>(prime2MeanFieldName))
{
......@@ -121,12 +117,10 @@ void Foam::fieldAverage::addPrime2MeanFieldType(const label fieldI)
}
else if (obr_.found(prime2MeanFieldName))
{
if (log_)
{
Info<< " Cannot allocate average field " << prime2MeanFieldName
<< " since an object with that name already exists."
<< " Disabling averaging for field." << nl;
}
if (log_) Info
<< " Cannot allocate average field " << prime2MeanFieldName