Commit 12b30732 authored by Henry Weller's avatar Henry Weller
Browse files

GeometricField: Added another constructor from tmp<GeometricField>

which supports re-using the internalField storage
parent 6fde55cb
......@@ -422,7 +422,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
if (debug)
{
InfoInFunction
<< "Constructing as copy" << endl << this->info() << endl;
<< "Constructing from tmp" << endl << this->info() << endl;
}
this->writeOpt() = IOobject::NO_WRITE;
......@@ -634,6 +634,47 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
}
#ifndef NoConstructFromTmp
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
(
const IOobject& io,
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf,
const wordList& patchFieldTypes,
const wordList& actualPatchTypes
)
:
DimensionedField<Type, GeoMesh>
(
io,
const_cast<GeometricField<Type, PatchField, GeoMesh>&>(tgf()),
tgf.isTmp()
),
timeIndex_(tgf().timeIndex()),
field0Ptr_(NULL),
fieldPrevIterPtr_(NULL),
boundaryField_
(
this->mesh().boundary(),
*this,
patchFieldTypes,
actualPatchTypes
)
{
if (debug)
{
InfoInFunction
<< "Constructing from tmp resetting IO params and patch types"
<< endl << this->info() << endl;
}
boundaryField_ == tgf().boundaryField_;
tgf.clear();
}
#endif
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * //
template<class Type, template<class> class PatchField, class GeoMesh>
......
......@@ -411,6 +411,17 @@ public:
const wordList& actualPatchTypes = wordList()
);
//- Construct as copy resetting IO parameters and boundary types
#ifndef NoConstructFromTmp
GeometricField
(
const IOobject&,
const tmp<GeometricField<Type, PatchField, GeoMesh>>&,
const wordList& patchFieldTypes,
const wordList& actualPatchTypes = wordList()
);
#endif
//- Destructor
virtual ~GeometricField();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment