suspicious use internal field (temporary)
by code inspection, in adjoint/global/createZeroField.H : createZeroBoundaryPtr
autoPtr<Boundary> bPtr
(
new Boundary
(
mesh.boundary(),
mesh.V()*pTraits<Type>::zero, // Dummy internal field,
wordList(bm.size(), fvPatchFieldBase::calculatedType()),
actualPatchTypes
)
);
It looks to me that the dummy internal field is created as intermediate (ie, mesh.V()*pTraits<Type>::zero
) and its lifetime is extended as as a const-ref, which gets passed through into the various patch fields and held there. Not sure if how intentional this is (potentially a good amount of overhead since this function is called multiple times), or using DimensionedField<Type, volMesh>::null()
as a dummy would be a potential alternative.
If a concrete internal field is actually needed, I suppose could create a demand-driven hash of different types (or something) and re-use them, but this could also be messy.
Edited by Mark OLESEN