Function1: made the clone function pure virtual
Avoids potential problems with derived classes which do not define a clone function.
This commit is contained in:
parent
dee9b200eb
commit
11e4a71463
11 changed files with 75 additions and 18 deletions
|
|
@ -714,6 +714,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>
|
||||
|
|
|
|||
|
|
@ -437,6 +437,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
|
||||
|
|
@ -78,7 +78,7 @@ uniformFixedValuePointPatchField
|
|||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(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<Type>(ptf),
|
||||
uniformValue_(ptf.uniformValue_().clone().ptr())
|
||||
uniformValue_(ptf.uniformValue_, false)
|
||||
{}
|
||||
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ uniformFixedValuePointPatchField
|
|||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf, iF),
|
||||
uniformValue_(ptf.uniformValue_().clone().ptr())
|
||||
uniformValue_(ptf.uniformValue_, false)
|
||||
{
|
||||
// For safety re-evaluate
|
||||
const scalar t = this->db().time().timeOutputValue();
|
||||
|
|
|
|||
|
|
@ -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 |
|
||||
-------------------------------------------------------------------------------
|
||||
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 |
|
||||
-------------------------------------------------------------------------------
|
||||
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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue