functionObjects: Generating and storing fields on demand rather than on construction

Resolves bug report https://bugs.openfoam.org/view.php?id=3019
This commit is contained in:
Will Bainbridge
2018-08-03 15:51:41 +01:00
parent 1a0c91b3ba
commit 0f14683c11
11 changed files with 166 additions and 229 deletions

View File

@ -51,25 +51,6 @@ Foam::functionObjects::processorField::processorField
fvMeshFunctionObject(name, runTime, dict)
{
read(dict);
volScalarField* procFieldPtr
(
new volScalarField
(
IOobject
(
"processorID",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
dimensionedScalar("0", dimless, 0.0)
)
);
mesh_.objectRegistry::store(procFieldPtr);
}
@ -91,10 +72,24 @@ bool Foam::functionObjects::processorField::read(const dictionary& dict)
bool Foam::functionObjects::processorField::execute()
{
mesh_.lookupObjectRef<volScalarField>("processorID") ==
dimensionedScalar("proci", dimless, Pstream::myProcNo());
word name("processorID");
return true;
tmp<volScalarField> tprocField
(
new volScalarField
(
IOobject
(
name,
mesh_.time().timeName(),
mesh_
),
mesh_,
dimensionedScalar(name, dimless, Pstream::myProcNo())
)
);
return store(name, tprocField);
}