Commit 2f431ffd authored by Henry Weller's avatar Henry Weller Committed by Andrew Heather
Browse files

made the clone function pure virtual

Avoids potential problems with derived classes which do not define a clone function.
parent 5157be4b
......@@ -721,6 +721,17 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField
#endif
template<class Type, template<class> class PatchField, class GeoMesh>
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
Foam::GeometricField<Type, PatchField, GeoMesh>::clone() const
{
return tmp<GeometricField<Type, PatchField, GeoMesh>>
(
new GeometricField<Type, PatchField, GeoMesh>(*this)
);
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * //
template<class Type, template<class> class PatchField, class GeoMesh>
......
......@@ -441,6 +441,9 @@ public:
);
#endif
//- Clone
tmp<GeometricField<Type, PatchField, GeoMesh>> clone() const;
//- Destructor
virtual ~GeometricField();
......
......@@ -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> class PatchField,
template<class> class SlicedPatchField,
class GeoMesh
>
Foam::tmp
<
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>
>
Foam::SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>::
clone() const
{
return tmp
<
SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>
>
(
new SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>
(
*this
)
);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template
......
......@@ -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<SlicedGeometricField<Type, PatchField, SlicedPatchField, GeoMesh>>
clone() const;
//- Destructor
~SlicedGeometricField();
......
......@@ -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
......
......@@ -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<T>::ptr() const
}
else
{
return new T(*ptr_);
return ptr_->clone().ptr();
}
}
......
......@@ -105,10 +105,7 @@ public:
Function1(const Function1<Type>& de);
//- Construct and return a clone
virtual tmp<Function1<Type>> clone() const
{
return tmp<Function1<Type>>(new Function1<Type>(*this));
}
virtual tmp<Function1<Type>> clone() const = 0;
//- Selector
......
......@@ -35,7 +35,7 @@ Foam::uniformJumpFvPatchField<Type>::uniformJumpFvPatchField
)
:
fixedJumpFvPatchField<Type>(p, iF),
jumpTable_(new Function1<Type>("jumpTable"))
jumpTable_()
{}
......@@ -62,7 +62,7 @@ Foam::uniformJumpFvPatchField<Type>::uniformJumpFvPatchField
)
:
fixedJumpFvPatchField<Type>(p, iF),
jumpTable_(new Function1<Type>("jumpTable"))
jumpTable_()
{
if (this->cyclicPatch().owner())
{
......
......@@ -35,7 +35,7 @@ Foam::uniformJumpAMIFvPatchField<Type>::uniformJumpAMIFvPatchField
)
:
fixedJumpAMIFvPatchField<Type>(p, iF),
jumpTable_(0)
jumpTable_()
{}
......@@ -62,7 +62,7 @@ Foam::uniformJumpAMIFvPatchField<Type>::uniformJumpAMIFvPatchField
)
:
fixedJumpAMIFvPatchField<Type>(p, iF),
jumpTable_(new Function1<Type>("jumpTable"))
jumpTable_()
{
if (this->cyclicAMIPatch().owner())
{
......
......@@ -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 | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
......@@ -451,6 +451,18 @@ Foam::fvMatrix<Type>::fvMatrix
}
template<class Type>
Foam::tmp<Foam::fvMatrix<Type>> Foam::fvMatrix<Type>::clone() const
{
return tmp<fvMatrix<Type>>
(
new fvMatrix<Type>(*this)
);
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * //
template<class Type>
Foam::fvMatrix<Type>::~fvMatrix()
{
......
......@@ -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 | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
......@@ -270,6 +270,9 @@ public:
//- Construct from Istream given field to solve for
fvMatrix(const GeometricField<Type, fvPatchField, volMesh>&, Istream&);
//- Clone
tmp<fvMatrix<Type>> clone() const;
//- Destructor
virtual ~fvMatrix();
......
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