Updates to reduce unnecessary registration of tmp fields
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
Activity
assigned to @andy
- Resolved by Mark OLESEN
- compilation with linux64 (clang15 int32 DP) (gcc-7.5.0 int32 DP)
- Alltest looks OK.
- @Prashant : please take it for an extra spin, when you get a chance
- @kuti : see commit related to src/regionModels src/regionFaModels for possible merge conflicts with your !663 (merged) and cherry-pick or something.
- Resolved by Andrew Heather
added 49 commits
-
9a7dca8c...87eed74e - 36 commits from branch
develop
- 87eed74e...052b78e8 - 3 earlier commits
- 1ebb116d - ENH: use tmp field factory methods [3] (#2723 (closed))
- 34c1dc6c - ENH: use tmp field factory methods [4] (#2723 (closed))
- 75765764 - ENH: use tmp field factory methods [5] (#2723 (closed))
- 52e5871d - ENH: use tmp field factory methods [6] (#2723 (closed))
- b5bc8c07 - ENH: use tmp field factory methods [7] (#2723 (closed))
- e16c133d - ENH: use tmp field factory methods [8] (#2723 (closed))
- aedfb0b8 - ENH: use tmp field factory methods [9] (#2723 (closed))
- d7cb3ee3 - ENH: use tmp field factory methods [10] (#2723 (closed))
- fefe2b31 - ENH: use tmp field factory methods [11] (#2723 (closed))
- fff30105 - ENH: use tmp field factory methods [12] (#2723 (closed))
Toggle commit list-
9a7dca8c...87eed74e - 36 commits from branch
added 12 commits
- fff30105...092db087 - 2 earlier commits
- 710eb5c1 - ENH: use tmp field factory methods [3] (#2723 (closed))
- 33f20edb - ENH: use tmp field factory methods [4] (#2723 (closed))
- 995a9705 - ENH: use tmp field factory methods [5] (#2723 (closed))
- 71d4a23e - ENH: use tmp field factory methods [6] (#2723 (closed))
- 51f150d8 - ENH: use tmp field factory methods [7] (#2723 (closed))
- 7bf0aaf9 - ENH: use tmp field factory methods [8] (#2723 (closed))
- d9483f50 - ENH: use tmp field factory methods [9] (#2723 (closed))
- c138f89c - ENH: use tmp field factory methods [10] (#2723 (closed))
- ec2b1be8 - ENH: use tmp field factory methods [11] (#2723 (closed))
- 8b73d068 - ENH: use tmp field factory methods [12] (#2723 (closed))
Toggle commit listmentioned in commit 73b6ddd7