functionObject: Added executeAtStart

By default most functionObjects now execute and write at the start-time except
those that perform averaging (fieldAverage, dsmcFields) which cannot be executed
until the end of the first time-step.  There is also a new optional
functionObject dictionary entry "executeAtStart" which defaults to true but can
be set false if the execution and results of the functionObject are not required
or appropriate at the start-time.

A result of this change is that time logs of forces, sampling etc. now include a
values for time 0.
This commit is contained in:
Henry Weller
2019-09-30 11:03:20 +01:00
parent 6f1c3362a6
commit 2ebed5ec71
8 changed files with 97 additions and 31 deletions

View File

@ -565,11 +565,11 @@ void Foam::functionObjectList::clear()
Foam::label Foam::functionObjectList::findObjectID(const word& name) const
{
forAll(*this, objectI)
forAll(*this, oi)
{
if (operator[](objectI).name() == name)
if (operator[](oi).name() == name)
{
return objectI;
return oi;
}
}
@ -598,7 +598,21 @@ bool Foam::functionObjectList::status() const
bool Foam::functionObjectList::start()
{
return read();
bool ok = read();
if (execution_)
{
forAll(*this, oi)
{
if (operator[](oi).executeAtStart())
{
ok = operator[](oi).execute() && ok;
ok = operator[](oi).write() && ok;
}
}
}
return ok;
}
@ -613,10 +627,10 @@ bool Foam::functionObjectList::execute()
read();
}
forAll(*this, objectI)
forAll(*this, oi)
{
ok = operator[](objectI).execute() && ok;
ok = operator[](objectI).write() && ok;
ok = operator[](oi).execute() && ok;
ok = operator[](oi).write() && ok;
}
}
@ -635,9 +649,9 @@ bool Foam::functionObjectList::end()
read();
}
forAll(*this, objectI)
forAll(*this, oi)
{
ok = operator[](objectI).end() && ok;
ok = operator[](oi).end() && ok;
}
}
@ -658,11 +672,11 @@ bool Foam::functionObjectList::setTimeStep()
wordList names;
forAll(*this, objectI)
forAll(*this, oi)
{
if (operator[](objectI).setTimeStep())
if (operator[](oi).setTimeStep())
{
names.append(operator[](objectI).name());
names.append(operator[](oi).name());
set = true;
}
}
@ -693,9 +707,9 @@ Foam::scalar Foam::functionObjectList::timeToNextWrite()
read();
}
forAll(*this, objectI)
forAll(*this, oi)
{
result = min(result, operator[](objectI).timeToNextWrite());
result = min(result, operator[](oi).timeToNextWrite());
}
}
@ -870,9 +884,9 @@ void Foam::functionObjectList::updateMesh(const mapPolyMesh& mpm)
{
if (execution_)
{
forAll(*this, objectI)
forAll(*this, oi)
{
operator[](objectI).updateMesh(mpm);
operator[](oi).updateMesh(mpm);
}
}
}
@ -882,9 +896,9 @@ void Foam::functionObjectList::movePoints(const polyMesh& mesh)
{
if (execution_)
{
forAll(*this, objectI)
forAll(*this, oi)
{
operator[](objectI).movePoints(mesh);
operator[](oi).movePoints(mesh);
}
}
}