Skip to content

Confusing/misleading GeometricField constructor

As raised as cfd-online issue, the following field constructor can be misleading:

//- Construct and read given IOobject
GeometricField
(
    const IOobject& io,
    const Mesh& mesh,
    const bool readOldTime = true
);

One could suppose that the constructor respects the readOption of the IOobject but it does not. It always reads!

For a non-read constructor, the preferred form would be

GeometricField
(
    const IOobject& io,
    const Mesh& mesh,
    const dimensionSet& ds,
    const word& patchFieldType = PatchField<Type>::calculatedType()
);

but this may be non-obvious.

  • Minimum fix: more explicit documentation, add a warning message when using with incorrect readOption so that it emits something before possibly failing.
  • TBD: have the constructor switch to readIfPresent behaviour or even no-read. In these cases, not really sure if the implied boundaries are also "calculated" etc. Could potentially change some existing code?
Edited by Mark OLESEN