diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index 9005eb8b5e..e1e20674e1 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -714,6 +714,17 @@ Foam::GeometricField::GeometricField #endif +template class PatchField, class GeoMesh> +Foam::tmp> +Foam::GeometricField::clone() const +{ + return tmp> + ( + new GeometricField(*this) + ); +} + + // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * // template class PatchField, class GeoMesh> diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index a15a9c3c75..ee385efe1f 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -437,6 +437,9 @@ public: ); #endif + //- Clone + tmp> clone() const; + //- Destructor virtual ~GeometricField(); diff --git a/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.C b/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.C index f42c11ecdb..bfd24de2a0 100644 --- a/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -338,6 +338,33 @@ SlicedGeometricField } +template +< + class Type, + template class PatchField, + template class SlicedPatchField, + class GeoMesh +> +Foam::tmp +< + Foam::SlicedGeometricField +> +Foam::SlicedGeometricField:: +clone() const +{ + return tmp + < + SlicedGeometricField + > + ( + new SlicedGeometricField + ( + *this + ) + ); +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template diff --git a/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.H b/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.H index 13279bf737..66b15b65b8 100644 --- a/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/SlicedGeometricField/SlicedGeometricField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -159,6 +159,10 @@ public: >& ); + //- Clone + tmp> + clone() const; + //- Destructor ~SlicedGeometricField(); diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.C index ec9dfa6ea4..cd0b7ec418 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/derived/uniformFixedValue/uniformFixedValuePointPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -78,7 +78,7 @@ uniformFixedValuePointPatchField ) : fixedValuePointPatchField(ptf, p, iF, mapper), - uniformValue_(ptf.uniformValue_().clone().ptr()) + uniformValue_(ptf.uniformValue_, false) { // For safety re-evaluate const scalar t = this->db().time().timeOutputValue(); @@ -94,7 +94,7 @@ uniformFixedValuePointPatchField ) : fixedValuePointPatchField(ptf), - uniformValue_(ptf.uniformValue_().clone().ptr()) + uniformValue_(ptf.uniformValue_, false) {} @@ -107,7 +107,7 @@ uniformFixedValuePointPatchField ) : fixedValuePointPatchField(ptf, iF), - uniformValue_(ptf.uniformValue_().clone().ptr()) + uniformValue_(ptf.uniformValue_, false) { // For safety re-evaluate const scalar t = this->db().time().timeOutputValue(); diff --git a/src/OpenFOAM/memory/tmp/tmpI.H b/src/OpenFOAM/memory/tmp/tmpI.H index 7e5800dcbb..da49097991 100644 --- a/src/OpenFOAM/memory/tmp/tmpI.H +++ b/src/OpenFOAM/memory/tmp/tmpI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -221,7 +221,7 @@ inline T* Foam::tmp::ptr() const } else { - return new T(*ptr_); + return ptr_->clone().ptr(); } } diff --git a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H index a0492f66ee..3f364bdf6b 100644 --- a/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H +++ b/src/OpenFOAM/primitives/functions/Function1/Function1/Function1.H @@ -105,10 +105,7 @@ public: Function1(const Function1& de); //- Construct and return a clone - virtual tmp> clone() const - { - return tmp>(new Function1(*this)); - } + virtual tmp> clone() const = 0; //- Selector diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C index 265bbf3ec4..31350e6230 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformJump/uniformJumpFvPatchField.C @@ -35,7 +35,7 @@ Foam::uniformJumpFvPatchField::uniformJumpFvPatchField ) : fixedJumpFvPatchField(p, iF), - jumpTable_(new Function1("jumpTable")) + jumpTable_() {} @@ -62,7 +62,7 @@ Foam::uniformJumpFvPatchField::uniformJumpFvPatchField ) : fixedJumpFvPatchField(p, iF), - jumpTable_(new Function1("jumpTable")) + jumpTable_() { if (this->cyclicPatch().owner()) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C index 12857efacb..033afb572a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformJumpAMI/uniformJumpAMIFvPatchField.C @@ -35,7 +35,7 @@ Foam::uniformJumpAMIFvPatchField::uniformJumpAMIFvPatchField ) : fixedJumpAMIFvPatchField(p, iF), - jumpTable_(0) + jumpTable_() {} @@ -62,7 +62,7 @@ Foam::uniformJumpAMIFvPatchField::uniformJumpAMIFvPatchField ) : fixedJumpAMIFvPatchField(p, iF), - jumpTable_(new Function1("jumpTable")) + jumpTable_() { if (this->cyclicAMIPatch().owner()) { diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index 4c2ffb5a1f..111aecfb75 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -451,6 +451,18 @@ Foam::fvMatrix::fvMatrix } +template +Foam::tmp> Foam::fvMatrix::clone() const +{ + return tmp> + ( + new fvMatrix(*this) + ); +} + + +// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * // + template Foam::fvMatrix::~fvMatrix() { diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index 590c3e324e..6e619f0904 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -270,6 +270,9 @@ public: //- Construct from Istream given field to solve for fvMatrix(const GeometricField&, Istream&); + //- Clone + tmp> clone() const; + //- Destructor virtual ~fvMatrix();