INT: objectRegistry: optionally caching temporary objects (#2723)

- functionality introduced by openfoam.org to support selective
  caching of temporary fields. The purpose is two-fold: to enable
  diagnostics and to allow more places to use unregistered fields by
  default.

  For example to cache the grad(k) field in

    cacheTemporaryObjects
    (
        grad(k)
    );

  If the name of a field which in never constructed is added to the
  cacheTemporaryObjects list a waning message is generated which
  includes a useful list of ALL the temporary fields constructed
  during the time step

  Multiple regions are also supported by specifying individual region
  names in a cacheTemporaryObjects dictionary.

    cacheTemporaryObjects
    {
        porous
        (
            porosityBlockage:UNbr
        );
    }

    functions
    {
        writePorousObjects
        {
            type        writeObjects;
            libs        (utilityFunctionObjects);

            region      porous;
            writeControl writeTime;
            writeOption anyWrite;

            objects     (porosityBlockage:UNbr);
        }
    }
This commit is contained in:
Mark Olesen
2023-03-16 15:25:07 +01:00
parent 2df90880d6
commit 1685e8e418
11 changed files with 441 additions and 47 deletions

View File

@ -219,9 +219,22 @@ bool Foam::functionObjects::writeObjects::write()
}
else
{
Log << " writing object " << obj.name() << endl;
// TBD:
// If the object is a temporary field expression wrap with tmp<...>
obj.write();
// if (obj.db().cacheTemporaryObject(objName))
// {
// obj.IOobject::rename("tmp<" + objName + ">");
//
// Log << " writing object " << obj.name() << endl;
// obj.write();
// obj.IOobject::rename(objName);
// }
// else
{
Log << " writing object " << obj.name() << endl;
obj.write();
}
}
}