Skip to content
Snippets Groups Projects

Updates to reduce unnecessary registration of tmp fields

Merged Mark OLESEN requested to merge md23-update-registry-handling into develop
All threads resolved!

As outlined in #2723 (closed) the registration/deregistration of tmp fields adds unnecessary hashing operations. These changes remove most of these cases and make more extensive use of various factory methods to simplify future changes. The largest contributor to tmp items is GeometricField (eg, volScalarField).

In general, the preference is to use more compact factory methods when dealing with tmp/autoPtr/refPtr. For example,

auto tfld = tmp<scalarField>::New(patch.size());
auto& fld = tfld.ref();

instead of

tmp<scalarField> tfld(new scalarField(patch.size()));
auto& fld = tfld.ref();

When dealing with regIOobject types (which can be registered in an objectRegistry), the syntax with the IOobject becomes messier. Thus for tmp GeometricFields etc there is are dedicated factory methods that use the current timeName and the relevant mesh for the registry. For example,

auto tfld = volScalarField::New("foo", mesh, dimensionedScalar(dimless, Zero));
auto& fld = tfld.ref();

instead of

auto tfld = tmp<volScalarField>::New
(
    IOobject
    (
        "foo",
        mesh.time().timeName(),
        mesh,
        IOobject::NO_READ,
        IOobject::NO_WRITE,
        IOobject::NO_REGISTER
    ),
    mesh,
    dimensionedScalar(dimless, Zero)
);
auto& fld = tfld.ref();

There are however instances when the tmp field must registered (eg, used for boundary conditions). In those cases it is also possible to explicitly specify the preferred registration handling:

auto tfld = volScalarField::New("foo", IOobject::REGISTER, mesh, dimensionedScalar(dimless, Zero));
auto& fld = tfld.ref();

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Mark OLESEN marked this merge request as ready

    marked this merge request as ready

  • Mark OLESEN added 49 commits

    added 49 commits

    Compare with previous version

  • Mark OLESEN added 12 commits

    added 12 commits

    Compare with previous version

  • Andrew Heather approved this merge request

    approved this merge request

  • Andrew Heather resolved all threads

    resolved all threads

  • Andrew Heather mentioned in commit 73b6ddd7

    mentioned in commit 73b6ddd7

  • merged

  • Please register or sign in to reply
    Loading