ENH: Function objects - first pass at updating read functionality

Note: should be using the result of the parent::read(dict) when
deciding whether to read local entries...
This commit is contained in:
Andrew Heather
2016-09-30 13:24:58 +01:00
parent 839f14afcd
commit 54042b08df
36 changed files with 88 additions and 23 deletions

View File

@ -110,6 +110,7 @@ Foam::functionObjects::DESModelRegions::~DESModelRegions()
bool Foam::functionObjects::DESModelRegions::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
writeFile::read(dict);
dict.readIfPresent("resultName", resultName_);

View File

@ -144,6 +144,7 @@ Foam::functionObjects::PecletNo::PecletNo
rhoName_("rho")
{
setResultName("Pe", "phi");
read(dict);
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -63,6 +63,12 @@ Foam::functionObjects::XiReactionRate::~XiReactionRate()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::XiReactionRate::read(const dictionary& dict)
{
return fvMeshFunctionObject::read(dict);
}
bool Foam::functionObjects::XiReactionRate::execute()
{
return true;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -107,10 +107,13 @@ public:
// Member Functions
//- Read the reaction rate data
virtual bool read(const dictionary&);
//- Do nothing
virtual bool execute();
//- Write the cell-centre fields
//- Write the reaction rate fields
virtual bool write();
};

View File

@ -63,9 +63,7 @@ Foam::functionObjects::components::components
)
:
fieldExpression(name, runTime, dict)
{
read(dict);
}
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -196,6 +196,8 @@ Foam::functionObjects::ddt2::~ddt2()
bool Foam::functionObjects::ddt2::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
if (word(mesh_.ddtScheme("default")) == "steadyState")
{
WarningInFunction

View File

@ -854,6 +854,8 @@ bool Foam::functionObjects::externalCoupled::end()
bool Foam::functionObjects::externalCoupled::read(const dictionary& dict)
{
functionObject::read(dict);
dict.readIfPresent("enabled", enabled_);
if (!enabled_)

View File

@ -619,6 +619,7 @@ Foam::functionObjects::fluxSummary::~fluxSummary()
bool Foam::functionObjects::fluxSummary::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
writeFile::read(dict);
mode_ = modeTypeNames_.read(dict.lookup("mode"));

View File

@ -61,9 +61,7 @@ Foam::functionObjects::grad::grad
)
:
fieldExpression(name, runTime, dict)
{
read(dict);
}
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -92,6 +92,8 @@ Foam::functionObjects::histogram::~histogram()
bool Foam::functionObjects::histogram::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
dict.lookup("field") >> fieldName_;
dict.lookup("max") >> max_;
min_ = dict.lookupOrDefault<scalar>("min", 0);

View File

@ -64,9 +64,7 @@ Foam::functionObjects::mag::mag
)
:
fieldExpression(name, runTime, dict)
{
read(dict);
}
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -64,9 +64,7 @@ Foam::functionObjects::magSqr::magSqr
)
:
fieldExpression(name, runTime, dict)
{
read(dict);
}
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -166,6 +166,8 @@ Foam::functionObjects::mapFields::~mapFields()
bool Foam::functionObjects::mapFields::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
dict.lookup("fields") >> fieldNames_;
createInterpolation(dict);
return true;

View File

@ -230,6 +230,8 @@ Foam::functionObjects::pressure::~pressure()
bool Foam::functionObjects::pressure::read(const dictionary& dict)
{
fieldExpression::read(dict);
dict.readIfPresent("U", UName_);
dict.readIfPresent("rho", rhoName_);

View File

@ -267,6 +267,7 @@ bool Foam::functionObjects::reactionsSensitivityAnalysis<chemistryType>::read
const dictionary& dict
)
{
fvMeshFunctionObject::read(dict);
writeFile::read(dict);
return true;
}

View File

@ -353,6 +353,8 @@ Foam::functionObjects::regionSizeDistribution::~regionSizeDistribution()
bool Foam::functionObjects::regionSizeDistribution::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
dict.lookup("field") >> alphaName_;
dict.lookup("patches") >> patchNames_;
dict.lookup("threshold") >> threshold_;

View File

@ -507,6 +507,8 @@ Foam::functionObjects::streamLineBase::~streamLineBase()
bool Foam::functionObjects::streamLineBase::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
Info<< type() << " " << name() << ":" << nl;
dict.lookup("fields") >> fields_;

View File

@ -74,6 +74,8 @@ bool Foam::functionObjects::surfaceInterpolate::read
const dictionary& dict
)
{
fvMeshFunctionObject::read(dict);
dict.lookup("fields") >> fieldSet_;
return true;

View File

@ -146,6 +146,8 @@ Foam::functionObjects::turbulenceFields::~turbulenceFields()
bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
if (dict.found("field"))
{
fieldSet_.insert(word(dict.lookup("field")));

View File

@ -106,6 +106,7 @@ Foam::functionObjects::valueAverage::~valueAverage()
bool Foam::functionObjects::valueAverage::read(const dictionary& dict)
{
regionFunctionObject::read(dict);
writeFile::read(dict);
dict.lookup("functionObjectName") >> functionObjectName_;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -62,6 +62,12 @@ Foam::functionObjects::writeCellCentres::~writeCellCentres()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::writeCellCentres::read(const dictionary& dict)
{
return fvMeshFunctionObject::read(dict);
}
bool Foam::functionObjects::writeCellCentres::execute()
{
return true;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -107,6 +107,9 @@ public:
// Member Functions
//- Read the cell-centre rate data
virtual bool read(const dictionary&);
//- Do nothing
virtual bool execute();

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -62,6 +62,12 @@ Foam::functionObjects::writeCellVolumes::~writeCellVolumes()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::writeCellVolumes::read(const dictionary& dict)
{
return fvMeshFunctionObject::read(dict);
}
bool Foam::functionObjects::writeCellVolumes::execute()
{
return true;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -106,10 +106,13 @@ public:
// Member Functions
//- Read the cell-volume data
virtual bool read(const dictionary&);
//- Do nothing
virtual bool execute();
//- Write the cell-centre fields
//- Write the cell-volume fields
virtual bool write();
};

View File

@ -181,6 +181,8 @@ Foam::functionObjects::zeroGradient::~zeroGradient()
bool Foam::functionObjects::zeroGradient::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
dict.lookup("fields") >> selectFields_;
uniqWords(selectFields_);

View File

@ -90,6 +90,8 @@ Foam::functionObjects::runTimePostProcessing::~runTimePostProcessing()
bool Foam::functionObjects::runTimePostProcessing::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
Info<< type() << " " << name() << ": reading post-processing data" << endl;
scene_.read(dict);

View File

@ -75,6 +75,7 @@ Foam::functionObjects::dsmcFields::~dsmcFields()
bool Foam::functionObjects::dsmcFields::read(const dictionary& dict)
{
fvMeshFunctionObject::read(dict);
return true;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -114,6 +114,8 @@ Foam::functionObjects::abort::~abort()
bool Foam::functionObjects::abort::read(const dictionary& dict)
{
functionObject::read(dict);
if (dict.found("action"))
{
action_ = actionTypeNames_.read(dict.lookup("action"));

View File

@ -184,6 +184,8 @@ bool Foam::codedFunctionObject::end()
bool Foam::codedFunctionObject::read(const dictionary& dict)
{
functionObject::read(dict);
// Backward compatibility
if (dict.found("redirectType"))
{

View File

@ -72,6 +72,8 @@ Foam::functionObjects::removeRegisteredObject::~removeRegisteredObject()
bool Foam::functionObjects::removeRegisteredObject::read(const dictionary& dict)
{
regionFunctionObject::read(dict);
dict.lookup("objects") >> objectNames_;
return true;

View File

@ -77,6 +77,8 @@ bool Foam::functionObjects::runTimeControls::runTimeControl::read
const dictionary& dict
)
{
fvMeshFunctionObject::read(dict);
const dictionary& conditionsDict = dict.subDict("conditions");
const wordList conditionNames(conditionsDict.toc());
conditions_.setSize(conditionNames.size());

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -92,6 +92,8 @@ bool Foam::functionObjects::setTimeStepFunctionObject::read
const dictionary& dict
)
{
functionObject::read(dict);
timeStepPtr_ = Function1<scalar>::New("deltaT", dict);
// Check that adjustTimeStep is active

View File

@ -74,6 +74,8 @@ Foam::functionObjects::systemCall::~systemCall()
bool Foam::functionObjects::systemCall::read(const dictionary& dict)
{
functionObject::read(dict);
dict.readIfPresent("executeCalls", executeCalls_);
dict.readIfPresent("endCalls", endCalls_);
dict.readIfPresent("writeCalls", writeCalls_);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -103,6 +103,8 @@ bool Foam::functionObjects::timeActivatedFileUpdate::read
const dictionary& dict
)
{
functionObject::read(dict);
dict.lookup("fileToUpdate") >> fileToUpdate_;
dict.lookup("timeVsFile") >> timeVsFile_;

View File

@ -122,6 +122,8 @@ Foam::functionObjects::writeDictionary::~writeDictionary()
bool Foam::functionObjects::writeDictionary::read(const dictionary& dict)
{
regionFunctionObject::read(dict);
wordList dictNames(dict.lookup("dictNames"));
HashSet<word> uniqueNames(dictNames);
dictNames_ = uniqueNames.toc();

View File

@ -98,6 +98,8 @@ Foam::functionObjects::writeObjects::~writeObjects()
bool Foam::functionObjects::writeObjects::read(const dictionary& dict)
{
functionObject::read(dict);
if (dict.found("field"))
{
objectNames_.setSize(1);