tmp: Updated to store and preserve the const-ness of the reference to a constant object

This change requires that the de-reference operator '()' returns a
const-reference to the object stored irrespective of the const-ness of
object stored and the new member function 'ref()' is provided to return
an non-const reference to stored object which throws a fatal error if the
stored object is const.

In order to smooth the transition to this new safer 'tmp' the now
deprecated and unsafe non-const de-reference operator '()' is still
provided by default but may be switched-off with the compilation switch
'CONST_TMP'.

The main OpenFOAM library has already been upgraded and '-DCONST_TMP'
option specified in the 'options' file to switch to the new 'tmp'
behavior.  The rest of OpenFOAM-dev will be upgraded over the following
few weeks.

Henry G. Weller
CFD Direct
This commit is contained in:
Henry Weller
2016-02-22 16:23:21 +00:00
parent 96b0f62d04
commit 15b7e87da7
34 changed files with 291 additions and 183 deletions

View File

@ -36,13 +36,13 @@ void Foam::BlendedInterfacialModel<ModelType>::correctFixedFluxBCs
GeometricField& field
) const
{
forAll(phase1_.phi()->boundaryField(), patchI)
forAll(phase1_.phi()().boundaryField(), patchI)
{
if
(
isA<fixedValueFvsPatchScalarField>
(
phase1_.phi()->boundaryField()[patchI]
phase1_.phi()().boundaryField()[patchI]
)
)
{

View File

@ -1,4 +1,4 @@
EXE_INC = -I$(OBJECTS_DIR)
EXE_INC = -DCONST_TMP -I$(OBJECTS_DIR)
LIB_LIBS = \
$(FOAM_LIBBIN)/libOSspecific.o \

View File

@ -564,7 +564,7 @@ Foam::Field<Type>::component
) const
{
tmp<Field<cmptType>> Component(new Field<cmptType>(this->size()));
::Foam::component(Component(), *this, d);
::Foam::component(Component.ref(), *this, d);
return Component;
}

View File

@ -87,7 +87,7 @@ pow
(
new Field<powProductType>(f.size())
);
pow<Type, r>(tRes(), f);
pow<Type, r>(tRes.ref(), f);
return tRes;
}
@ -101,7 +101,7 @@ pow
{
typedef typename powProduct<Type, r>::type powProductType;
tmp<Field<powProductType>> tRes = reuseTmp<powProductType, Type>::New(tf);
pow<Type, r>(tRes(), tf());
pow<Type, r>(tRes.ref(), tf());
reuseTmp<powProductType, Type>::clear(tf);
return tRes;
}
@ -127,7 +127,7 @@ sqr(const UList<Type>& f)
(
new Field<outerProductType>(f.size())
);
sqr(tRes(), f);
sqr(tRes.ref(), f);
return tRes;
}
@ -138,7 +138,7 @@ sqr(const tmp<Field<Type>>& tf)
typedef typename outerProduct<Type, Type>::type outerProductType;
tmp<Field<outerProductType>> tRes =
reuseTmp<outerProductType, Type>::New(tf);
sqr(tRes(), tf());
sqr(tRes.ref(), tf());
reuseTmp<outerProductType, Type>::clear(tf);
return tRes;
}
@ -154,7 +154,7 @@ template<class Type>
tmp<Field<scalar>> magSqr(const UList<Type>& f)
{
tmp<Field<scalar>> tRes(new Field<scalar>(f.size()));
magSqr(tRes(), f);
magSqr(tRes.ref(), f);
return tRes;
}
@ -162,7 +162,7 @@ template<class Type>
tmp<Field<scalar>> magSqr(const tmp<Field<Type>>& tf)
{
tmp<Field<scalar>> tRes = reuseTmp<scalar, Type>::New(tf);
magSqr(tRes(), tf());
magSqr(tRes.ref(), tf());
reuseTmp<scalar, Type>::clear(tf);
return tRes;
}
@ -178,7 +178,7 @@ template<class Type>
tmp<Field<scalar>> mag(const UList<Type>& f)
{
tmp<Field<scalar>> tRes(new Field<scalar>(f.size()));
mag(tRes(), f);
mag(tRes.ref(), f);
return tRes;
}
@ -186,7 +186,7 @@ template<class Type>
tmp<Field<scalar>> mag(const tmp<Field<Type>>& tf)
{
tmp<Field<scalar>> tRes = reuseTmp<scalar, Type>::New(tf);
mag(tRes(), tf());
mag(tRes.ref(), tf());
reuseTmp<scalar, Type>::clear(tf);
return tRes;
}
@ -204,7 +204,7 @@ tmp<Field<typename Field<Type>::cmptType>> cmptMax(const UList<Type>& f)
{
typedef typename Field<Type>::cmptType cmptType;
tmp<Field<cmptType>> tRes(new Field<cmptType>(f.size()));
cmptMax(tRes(), f);
cmptMax(tRes.ref(), f);
return tRes;
}
@ -213,7 +213,7 @@ tmp<Field<typename Field<Type>::cmptType>> cmptMax(const tmp<Field<Type>>& tf)
{
typedef typename Field<Type>::cmptType cmptType;
tmp<Field<cmptType>> tRes = reuseTmp<cmptType, Type>::New(tf);
cmptMax(tRes(), tf());
cmptMax(tRes.ref(), tf());
reuseTmp<cmptType, Type>::clear(tf);
return tRes;
}
@ -231,7 +231,7 @@ tmp<Field<typename Field<Type>::cmptType>> cmptMin(const UList<Type>& f)
{
typedef typename Field<Type>::cmptType cmptType;
tmp<Field<cmptType>> tRes(new Field<cmptType>(f.size()));
cmptMin(tRes(), f);
cmptMin(tRes.ref(), f);
return tRes;
}
@ -240,7 +240,7 @@ tmp<Field<typename Field<Type>::cmptType>> cmptMin(const tmp<Field<Type>>& tf)
{
typedef typename Field<Type>::cmptType cmptType;
tmp<Field<cmptType>> tRes = reuseTmp<cmptType, Type>::New(tf);
cmptMin(tRes(), tf());
cmptMin(tRes.ref(), tf());
reuseTmp<cmptType, Type>::clear(tf);
return tRes;
}
@ -258,7 +258,7 @@ tmp<Field<typename Field<Type>::cmptType>> cmptAv(const UList<Type>& f)
{
typedef typename Field<Type>::cmptType cmptType;
tmp<Field<cmptType>> tRes(new Field<cmptType>(f.size()));
cmptAv(tRes(), f);
cmptAv(tRes.ref(), f);
return tRes;
}
@ -267,7 +267,7 @@ tmp<Field<typename Field<Type>::cmptType>> cmptAv(const tmp<Field<Type>>& tf)
{
typedef typename Field<Type>::cmptType cmptType;
tmp<Field<cmptType>> tRes = reuseTmp<cmptType, Type>::New(tf);
cmptAv(tRes(), tf());
cmptAv(tRes.ref(), tf());
reuseTmp<cmptType, Type>::clear(tf);
return tRes;
}
@ -283,7 +283,7 @@ template<class Type>
tmp<Field<Type>> cmptMag(const UList<Type>& f)
{
tmp<Field<Type>> tRes(new Field<Type>(f.size()));
cmptMag(tRes(), f);
cmptMag(tRes.ref(), f);
return tRes;
}
@ -291,7 +291,7 @@ template<class Type>
tmp<Field<Type>> cmptMag(const tmp<Field<Type>>& tf)
{
tmp<Field<Type>> tRes = reuseTmp<Type, Type>::New(tf);
cmptMag(tRes(), tf());
cmptMag(tRes.ref(), tf());
reuseTmp<Type, Type>::clear(tf);
return tRes;
}
@ -653,7 +653,7 @@ operator Op(const UList<Type1>& f1, const UList<Type2>& f2) \
{ \
typedef typename product<Type1, Type2>::type productType; \
tmp<Field<productType>> tRes(new Field<productType>(f1.size())); \
OpFunc(tRes(), f1, f2); \
OpFunc(tRes.ref(), f1, f2); \
return tRes; \
} \
\
@ -663,7 +663,7 @@ operator Op(const UList<Type1>& f1, const tmp<Field<Type2>>& tf2) \
{ \
typedef typename product<Type1, Type2>::type productType; \
tmp<Field<productType>> tRes = reuseTmp<productType, Type2>::New(tf2); \
OpFunc(tRes(), f1, tf2()); \
OpFunc(tRes.ref(), f1, tf2()); \
reuseTmp<productType, Type2>::clear(tf2); \
return tRes; \
} \
@ -674,7 +674,7 @@ operator Op(const tmp<Field<Type1>>& tf1, const UList<Type2>& f2) \
{ \
typedef typename product<Type1, Type2>::type productType; \
tmp<Field<productType>> tRes = reuseTmp<productType, Type1>::New(tf1); \
OpFunc(tRes(), tf1(), f2); \
OpFunc(tRes.ref(), tf1(), f2); \
reuseTmp<productType, Type1>::clear(tf1); \
return tRes; \
} \
@ -686,7 +686,7 @@ operator Op(const tmp<Field<Type1>>& tf1, const tmp<Field<Type2>>& tf2) \
typedef typename product<Type1, Type2>::type productType; \
tmp<Field<productType>> tRes = \
reuseTmpTmp<productType, Type1, Type1, Type2>::New(tf1, tf2); \
OpFunc(tRes(), tf1(), tf2()); \
OpFunc(tRes.ref(), tf1(), tf2()); \
reuseTmpTmp<productType, Type1, Type1, Type2>::clear(tf1, tf2); \
return tRes; \
} \
@ -710,7 +710,7 @@ operator Op(const UList<Type>& f1, const VectorSpace<Form,Cmpt,nCmpt>& vs) \
{ \
typedef typename product<Type, Form>::type productType; \
tmp<Field<productType>> tRes(new Field<productType>(f1.size())); \
OpFunc(tRes(), f1, static_cast<const Form&>(vs)); \
OpFunc(tRes.ref(), f1, static_cast<const Form&>(vs)); \
return tRes; \
} \
\
@ -724,7 +724,7 @@ operator Op \
{ \
typedef typename product<Type, Form>::type productType; \
tmp<Field<productType>> tRes = reuseTmp<productType, Type>::New(tf1); \
OpFunc(tRes(), tf1(), static_cast<const Form&>(vs)); \
OpFunc(tRes.ref(), tf1(), static_cast<const Form&>(vs)); \
reuseTmp<productType, Type>::clear(tf1); \
return tRes; \
} \
@ -748,7 +748,7 @@ operator Op(const VectorSpace<Form,Cmpt,nCmpt>& vs, const UList<Type>& f1) \
{ \
typedef typename product<Form, Type>::type productType; \
tmp<Field<productType>> tRes(new Field<productType>(f1.size())); \
OpFunc(tRes(), static_cast<const Form&>(vs), f1); \
OpFunc(tRes.ref(), static_cast<const Form&>(vs), f1); \
return tRes; \
} \
\
@ -761,7 +761,7 @@ operator Op \
{ \
typedef typename product<Form, Type>::type productType; \
tmp<Field<productType>> tRes = reuseTmp<productType, Type>::New(tf1); \
OpFunc(tRes(), static_cast<const Form&>(vs), tf1()); \
OpFunc(tRes.ref(), static_cast<const Form&>(vs), tf1()); \
reuseTmp<productType, Type>::clear(tf1); \
return tRes; \
}

View File

@ -40,7 +40,7 @@ TEMPLATE \
tmp<Field<ReturnType>> Func(const UList<Type>& f) \
{ \
tmp<Field<ReturnType>> tRes(new Field<ReturnType>(f.size())); \
Func(tRes(), f); \
Func(tRes.ref(), f); \
return tRes; \
} \
\
@ -48,7 +48,7 @@ TEMPLATE \
tmp<Field<ReturnType>> Func(const tmp<Field<Type>>& tf) \
{ \
tmp<Field<ReturnType>> tRes = reuseTmp<ReturnType, Type>::New(tf); \
Func(tRes(), tf()); \
Func(tRes.ref(), tf()); \
reuseTmp<ReturnType, Type>::clear(tf); \
return tRes; \
}
@ -68,7 +68,7 @@ TEMPLATE \
tmp<Field<ReturnType>> operator Op(const UList<Type>& f) \
{ \
tmp<Field<ReturnType>> tRes(new Field<ReturnType>(f.size())); \
OpFunc(tRes(), f); \
OpFunc(tRes.ref(), f); \
return tRes; \
} \
\
@ -76,7 +76,7 @@ TEMPLATE \
tmp<Field<ReturnType>> operator Op(const tmp<Field<Type>>& tf) \
{ \
tmp<Field<ReturnType>> tRes = reuseTmp<ReturnType, Type>::New(tf); \
OpFunc(tRes(), tf()); \
OpFunc(tRes.ref(), tf()); \
reuseTmp<ReturnType, Type>::clear(tf); \
return tRes; \
}
@ -108,7 +108,7 @@ tmp<Field<ReturnType>> Func \
) \
{ \
tmp<Field<ReturnType>> tRes(new Field<ReturnType>(f1.size())); \
Func(tRes(), f1, f2); \
Func(tRes.ref(), f1, f2); \
return tRes; \
} \
\
@ -120,7 +120,7 @@ tmp<Field<ReturnType>> Func \
) \
{ \
tmp<Field<ReturnType>> tRes = reuseTmp<ReturnType, Type2>::New(tf2); \
Func(tRes(), f1, tf2()); \
Func(tRes.ref(), f1, tf2()); \
reuseTmp<ReturnType, Type2>::clear(tf2); \
return tRes; \
} \
@ -133,7 +133,7 @@ tmp<Field<ReturnType>> Func \
) \
{ \
tmp<Field<ReturnType>> tRes = reuseTmp<ReturnType, Type1>::New(tf1); \
Func(tRes(), tf1(), f2); \
Func(tRes.ref(), tf1(), f2); \
reuseTmp<ReturnType, Type1>::clear(tf1); \
return tRes; \
} \
@ -147,7 +147,7 @@ tmp<Field<ReturnType>> Func \
{ \
tmp<Field<ReturnType>> tRes = \
reuseTmpTmp<ReturnType, Type1, Type1, Type2>::New(tf1, tf2); \
Func(tRes(), tf1(), tf2()); \
Func(tRes.ref(), tf1(), tf2()); \
reuseTmpTmp<ReturnType, Type1, Type1, Type2>::clear(tf1, tf2); \
return tRes; \
}
@ -179,7 +179,7 @@ tmp<Field<ReturnType>> Func \
) \
{ \
tmp<Field<ReturnType>> tRes(new Field<ReturnType>(f2.size())); \
Func(tRes(), s1, f2); \
Func(tRes.ref(), s1, f2); \
return tRes; \
} \
\
@ -191,7 +191,7 @@ tmp<Field<ReturnType>> Func \
) \
{ \
tmp<Field<ReturnType>> tRes = reuseTmp<ReturnType, Type2>::New(tf2); \
Func(tRes(), s1, tf2()); \
Func(tRes.ref(), s1, tf2()); \
reuseTmp<ReturnType, Type2>::clear(tf2); \
return tRes; \
}
@ -221,7 +221,7 @@ tmp<Field<ReturnType>> Func \
) \
{ \
tmp<Field<ReturnType>> tRes(new Field<ReturnType>(f1.size())); \
Func(tRes(), f1, s2); \
Func(tRes.ref(), f1, s2); \
return tRes; \
} \
\
@ -233,7 +233,7 @@ tmp<Field<ReturnType>> Func \
) \
{ \
tmp<Field<ReturnType>> tRes = reuseTmp<ReturnType, Type1>::New(tf1); \
Func(tRes(), tf1(), s2); \
Func(tRes.ref(), tf1(), s2); \
reuseTmp<ReturnType, Type1>::clear(tf1); \
return tRes; \
}
@ -267,7 +267,7 @@ tmp<Field<ReturnType>> operator Op \
) \
{ \
tmp<Field<ReturnType>> tRes(new Field<ReturnType>(f1.size())); \
OpFunc(tRes(), f1, f2); \
OpFunc(tRes.ref(), f1, f2); \
return tRes; \
} \
\
@ -279,7 +279,7 @@ tmp<Field<ReturnType>> operator Op \
) \
{ \
tmp<Field<ReturnType>> tRes = reuseTmp<ReturnType, Type2>::New(tf2); \
OpFunc(tRes(), f1, tf2()); \
OpFunc(tRes.ref(), f1, tf2()); \
reuseTmp<ReturnType, Type2>::clear(tf2); \
return tRes; \
} \
@ -292,7 +292,7 @@ tmp<Field<ReturnType>> operator Op \
) \
{ \
tmp<Field<ReturnType>> tRes = reuseTmp<ReturnType, Type1>::New(tf1); \
OpFunc(tRes(), tf1(), f2); \
OpFunc(tRes.ref(), tf1(), f2); \
reuseTmp<ReturnType, Type1>::clear(tf1); \
return tRes; \
} \
@ -306,7 +306,7 @@ tmp<Field<ReturnType>> operator Op \
{ \
tmp<Field<ReturnType>> tRes = \
reuseTmpTmp<ReturnType, Type1, Type1, Type2>::New(tf1, tf2); \
OpFunc(tRes(), tf1(), tf2()); \
OpFunc(tRes.ref(), tf1(), tf2()); \
reuseTmpTmp<ReturnType, Type1, Type1, Type2>::clear(tf1, tf2); \
return tRes; \
}
@ -335,7 +335,7 @@ tmp<Field<ReturnType>> operator Op \
) \
{ \
tmp<Field<ReturnType>> tRes(new Field<ReturnType>(f2.size())); \
OpFunc(tRes(), s1, f2); \
OpFunc(tRes.ref(), s1, f2); \
return tRes; \
} \
\
@ -347,7 +347,7 @@ tmp<Field<ReturnType>> operator Op \
) \
{ \
tmp<Field<ReturnType>> tRes = reuseTmp<ReturnType, Type2>::New(tf2); \
OpFunc(tRes(), s1, tf2()); \
OpFunc(tRes.ref(), s1, tf2()); \
reuseTmp<ReturnType, Type2>::clear(tf2); \
return tRes; \
}
@ -374,7 +374,7 @@ tmp<Field<ReturnType>> operator Op \
) \
{ \
tmp<Field<ReturnType>> tRes(new Field<ReturnType>(f1.size())); \
OpFunc(tRes(), f1, s2); \
OpFunc(tRes.ref(), f1, s2); \
return tRes; \
} \
\
@ -386,7 +386,7 @@ tmp<Field<ReturnType>> operator Op \
) \
{ \
tmp<Field<ReturnType>> tRes = reuseTmp<ReturnType, Type1>::New(tf1); \
OpFunc(tRes(), tf1(), s2); \
OpFunc(tRes.ref(), tf1(), s2); \
reuseTmp<ReturnType, Type1>::clear(tf1); \
return tRes; \
}

View File

@ -71,7 +71,7 @@ public:
if (initRet)
{
rtf() = tf1();
rtf.ref() = tf1();
}
return rtf;

View File

@ -74,14 +74,14 @@ void stabilise(scalarField& res, const UList<scalar>& sf, const scalar s)
tmp<scalarField> stabilise(const UList<scalar>& sf, const scalar s)
{
tmp<scalarField> tRes(new scalarField(sf.size()));
stabilise(tRes(), sf, s);
stabilise(tRes.ref(), sf, s);
return tRes;
}
tmp<scalarField> stabilise(const tmp<scalarField>& tsf, const scalar s)
{
tmp<scalarField> tRes = reuseTmp<scalar, scalar>::New(tsf);
stabilise(tRes(), tsf(), s);
stabilise(tRes.ref(), tsf(), s);
reuseTmp<scalar, scalar>::clear(tsf);
return tRes;
}
@ -173,14 +173,14 @@ void func(scalarField& res, const int n, const UList<scalar>& sf) \
tmp<scalarField> func(const int n, const UList<scalar>& sf) \
{ \
tmp<scalarField> tRes(new scalarField(sf.size())); \
func(tRes(), n, sf); \
func(tRes.ref(), n, sf); \
return tRes; \
} \
\
tmp<scalarField> func(const int n, const tmp<scalarField>& tsf) \
{ \
tmp<scalarField> tRes = reuseTmp<scalar, scalar>::New(tsf); \
func(tRes(), n, tsf()); \
func(tRes.ref(), n, tsf()); \
reuseTmp<scalar, scalar>::clear(tsf); \
return tRes; \
}

View File

@ -108,14 +108,14 @@ void inv(Field<symmTensor>& tf, const UList<symmTensor>& tf1)
tmp<symmTensorField> inv(const UList<symmTensor>& tf)
{
tmp<symmTensorField> result(new symmTensorField(tf.size()));
inv(result(), tf);
inv(result.ref(), tf);
return result;
}
tmp<symmTensorField> inv(const tmp<symmTensorField>& tf)
{
tmp<symmTensorField> tRes = reuseTmp<symmTensor, symmTensor>::New(tf);
inv(tRes(), tf());
inv(tRes.ref(), tf());
reuseTmp<symmTensor, symmTensor>::clear(tf);
return tRes;
}

View File

@ -63,7 +63,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf(new Field<Type> (tf.size()));
transform(tranf(), trf, tf);
transform(tranf.ref(), trf, tf);
return tranf;
}
@ -76,7 +76,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf = reuseTmp<Type, Type>::New(ttf);
transform(tranf(), trf, ttf());
transform(tranf.ref(), trf, ttf());
reuseTmp<Type, Type>::clear(ttf);
return tranf;
}
@ -90,7 +90,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf(new Field<Type> (tf.size()));
transform(tranf(), ttrf(), tf);
transform(tranf.ref(), ttrf(), tf);
ttrf.clear();
return tranf;
}
@ -104,7 +104,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf = reuseTmp<Type, Type>::New(ttf);
transform(tranf(), ttrf(), ttf());
transform(tranf.ref(), ttrf(), ttf());
reuseTmp<Type, Type>::clear(ttf);
ttrf.clear();
return tranf;
@ -131,7 +131,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf(new Field<Type>(tf.size()));
transform(tranf(), t, tf);
transform(tranf.ref(), t, tf);
return tranf;
}
@ -144,7 +144,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf = reuseTmp<Type, Type>::New(ttf);
transform(tranf(), t, ttf());
transform(tranf.ref(), t, ttf());
reuseTmp<Type, Type>::clear(ttf);
return tranf;
}

View File

@ -106,14 +106,14 @@ void inv(Field<tensor>& tf, const UList<tensor>& tf1)
tmp<tensorField> inv(const UList<tensor>& tf)
{
tmp<tensorField> result(new tensorField(tf.size()));
inv(result(), tf);
inv(result.ref(), tf);
return result;
}
tmp<tensorField> inv(const tmp<tensorField>& tf)
{
tmp<tensorField> tRes = reuseTmp<tensor, tensor>::New(tf);
inv(tRes(), tf());
inv(tRes.ref(), tf());
reuseTmp<tensor, tensor>::clear(tf);
return tRes;
}
@ -132,7 +132,7 @@ tmp<Field<tensor>> transformFieldMask<tensor>
)
{
tmp<tensorField> tRes(new tensorField(stf.size()));
tensorField& res = tRes();
tensorField& res = tRes.ref();
TFOR_ALL_F_OP_F(tensor, res, =, symmTensor, stf)
return tRes;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,7 +48,7 @@ Foam::tmp<Foam::vectorField> Foam::transform
)
{
tmp<vectorField > tranf(new vectorField(tf.size()));
transform(tranf(), q, tf);
transform(tranf.ref(), q, tf);
return tranf;
}
@ -60,7 +60,7 @@ Foam::tmp<Foam::vectorField> Foam::transform
)
{
tmp<vectorField > tranf = reuseTmp<vector, vector>::New(ttf);
transform(tranf(), q, ttf());
transform(tranf.ref(), q, ttf());
reuseTmp<vector, vector>::clear(ttf);
return tranf;
}
@ -106,7 +106,7 @@ Foam::tmp<Foam::vectorField> Foam::transform
)
{
tmp<vectorField > tranf(new vectorField(tf.size()));
transform(tranf(), tr, tf);
transform(tranf.ref(), tr, tf);
return tranf;
}
@ -118,7 +118,7 @@ Foam::tmp<Foam::vectorField> Foam::transform
)
{
tmp<vectorField > tranf = reuseTmp<vector, vector>::New(ttf);
transform(tranf(), tr, ttf());
transform(tranf.ref(), tr, ttf());
reuseTmp<vector, vector>::clear(ttf);
return tranf;
}

View File

@ -63,7 +63,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf(new Field<Type> (tf.size()));
transform(tranf(), trf, tf);
transform(tranf.ref(), trf, tf);
return tranf;
}
@ -76,7 +76,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf = reuseTmp<Type, Type>::New(ttf);
transform(tranf(), trf, ttf());
transform(tranf.ref(), trf, ttf());
reuseTmp<Type, Type>::clear(ttf);
return tranf;
}
@ -90,7 +90,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf(new Field<Type> (tf.size()));
transform(tranf(), ttrf(), tf);
transform(tranf.ref(), ttrf(), tf);
ttrf.clear();
return tranf;
}
@ -104,7 +104,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf = reuseTmp<Type, Type>::New(ttf);
transform(tranf(), ttrf(), ttf());
transform(tranf.ref(), ttrf(), ttf());
reuseTmp<Type, Type>::clear(ttf);
ttrf.clear();
return tranf;
@ -131,7 +131,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf(new Field<Type>(tf.size()));
transform(tranf(), t, tf);
transform(tranf.ref(), t, tf);
return tranf;
}
@ -144,7 +144,7 @@ tmp<Field<Type>> transform
)
{
tmp<Field<Type>> tranf = reuseTmp<Type, Type>::New(ttf);
transform(tranf(), t, ttf());
transform(tranf.ref(), t, ttf());
reuseTmp<Type, Type>::clear(ttf);
return tranf;
}

View File

@ -286,7 +286,7 @@ Foam::tmp<Foam::Field<Type>> Foam::LduMatrix<Type, DType, LUType>::residual
) const
{
tmp<Field<Type>> trA(new Field<Type>(psi.size()));
residual(trA(), psi);
residual(trA.ref(), psi);
return trA;
}

View File

@ -126,7 +126,7 @@ Foam::tmp<Foam::Field<Type>> Foam::processorLduInterface::receive
) const
{
tmp<Field<Type>> tf(new Field<Type>(size));
receive(commsType, tf());
receive(commsType, tf.ref());
return tf;
}
@ -268,7 +268,7 @@ Foam::tmp<Foam::Field<Type>> Foam::processorLduInterface::compressedReceive
) const
{
tmp<Field<Type>> tf(new Field<Type>(size));
compressedReceive(commsType, tf());
compressedReceive(commsType, tf.ref());
return tf;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -290,7 +290,7 @@ Foam::tmp<Foam::scalarField> Foam::lduMatrix::residual
) const
{
tmp<scalarField> trA(new scalarField(psi.size()));
residual(trA(), psi, source, interfaceBouCoeffs, interfaces, cmpt);
residual(trA.ref(), psi, source, interfaceBouCoeffs, interfaces, cmpt);
return trA;
}
@ -304,7 +304,7 @@ Foam::tmp<Foam::scalarField > Foam::lduMatrix::H1() const
if (lowerPtr_ || upperPtr_)
{
scalarField& H1_ = tH1();
scalarField& H1_ = tH1.ref();
scalar* __restrict__ H1Ptr = H1_.begin();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -181,7 +181,7 @@ Foam::tmp<Foam::labelField> Foam::pairGAMGAgglomeration::agglomerate
// go through the faces and create clusters
tmp<labelField> tcoarseCellMap(new labelField(nFineCells, -1));
labelField& coarseCellMap = tcoarseCellMap();
labelField& coarseCellMap = tcoarseCellMap.ref();
nCoarseCells = 0;
label celli;

View File

@ -166,7 +166,7 @@ Foam::procFacesGAMGProcAgglomeration::processorAgglomeration
);
tmp<labelField> tfineToCoarse(new labelField(0));
labelField& fineToCoarse = tfineToCoarse();
labelField& fineToCoarse = tfineToCoarse.ref();
if (singleCellMeshPtr.valid())
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -81,7 +81,7 @@ Foam::tmp<Foam::scalarField> Foam::GAMGInterface::agglomerateCoeffs
) const
{
tmp<scalarField> tcoarseCoeffs(new scalarField(size(), 0.0));
scalarField& coarseCoeffs = tcoarseCoeffs();
scalarField& coarseCoeffs = tcoarseCoeffs.ref();
if (fineCoeffs.size() != faceRestrictAddressing_.size())
{

View File

@ -34,7 +34,7 @@ Foam::tmp<Foam::Field<Type>> Foam::GAMGInterface::interfaceInternalField
) const
{
tmp<Field<Type>> tresult(new Field<Type>(size()));
interfaceInternalField(iF, tresult());
interfaceInternalField(iF, tresult.ref());
return tresult;
}

View File

@ -182,7 +182,7 @@ Foam::tmp<Foam::labelField> Foam::cyclicGAMGInterface::internalFieldTransfer
const labelUList& nbrFaceCells = nbr.faceCells();
tmp<labelField> tpnf(new labelField(size()));
labelField& pnf = tpnf();
labelField& pnf = tpnf.ref();
forAll(pnf, facei)
{

View File

@ -52,15 +52,20 @@ class tmp
{
// Private data
//- Flag for whether object is a temporary or a constant object
bool isTmp_;
//- Object types
enum type
{
TMP,
REF,
CONST_REF
};
//- Pointer to temporary object
//- Type of object
type type_;
//- Pointer to object
mutable T* ptr_;
//- Const reference to constant object
const T& ref_;
public:
@ -69,9 +74,15 @@ public:
//- Store object pointer
inline explicit tmp(T* = 0);
//- Store object rvalue reference
inline tmp(T&&);
//- Store object const reference
inline tmp(const T&);
//- Construct copy and increment reference count
inline tmp(tmp<T>&&);
//- Construct copy and increment reference count
inline tmp(const tmp<T>&);
@ -100,6 +111,10 @@ public:
// Edit
//- Return non-const reference or generate a fatal error
// if the object is const.
inline T& ref();
//- Return tmp pointer for reuse.
// Returns a clone if the object is not a temporary
inline T* ptr() const;
@ -111,8 +126,11 @@ public:
// Member operators
//- Dereference operator
#ifndef CONST_TMP
//- Deprecated non-const dereference operator.
// Use ref() where non-const access is required
inline T& operator()();
#endif
//- Const dereference operator
inline const T& operator()() const;

View File

@ -31,29 +31,34 @@ License
template<class T>
inline Foam::tmp<T>::tmp(T* tPtr)
:
isTmp_(true),
ptr_(tPtr),
ref_(*tPtr)
type_(TMP),
ptr_(tPtr)
{}
template<class T>
inline Foam::tmp<T>::tmp(T&& tRef)
:
type_(REF),
ptr_(&tRef)
{}
template<class T>
inline Foam::tmp<T>::tmp(const T& tRef)
:
isTmp_(false),
ptr_(0),
ref_(tRef)
type_(CONST_REF),
ptr_(const_cast<T*>(&tRef))
{}
template<class T>
inline Foam::tmp<T>::tmp(const tmp<T>& t)
inline Foam::tmp<T>::tmp(tmp<T>&& t)
:
isTmp_(t.isTmp_),
ptr_(t.ptr_),
ref_(t.ref_)
type_(t.type_),
ptr_(t.ptr_)
{
if (isTmp_)
if (isTmp())
{
if (ptr_)
{
@ -62,7 +67,7 @@ inline Foam::tmp<T>::tmp(const tmp<T>& t)
else
{
FatalErrorInFunction
<< "attempted copy of a deallocated temporary"
<< "Attempted copy of a deallocated temporary"
<< " of type " << typeid(T).name()
<< abort(FatalError);
}
@ -70,14 +75,40 @@ inline Foam::tmp<T>::tmp(const tmp<T>& t)
}
template<class T>
inline Foam::tmp<T>::tmp(const tmp<T>& t)
:
type_(t.type_),
ptr_(t.ptr_)
{
if (isTmp())
{
if (ptr_)
{
ptr_->operator++();
}
else
{
FatalErrorInFunction
<< "Attempted copy of a deallocated temporary"
<< " of type " << typeid(T).name()
<< abort(FatalError);
}
}
else if (type_ == REF)
{
type_ = CONST_REF;
}
}
template<class T>
inline Foam::tmp<T>::tmp(const tmp<T>& t, bool allowTransfer)
:
isTmp_(t.isTmp_),
ptr_(t.ptr_),
ref_(t.ref_)
type_(t.type_),
ptr_(t.ptr_)
{
if (isTmp_)
if (isTmp())
{
if (allowTransfer)
{
@ -92,7 +123,7 @@ inline Foam::tmp<T>::tmp(const tmp<T>& t, bool allowTransfer)
else
{
FatalErrorInFunction
<< "attempted copy of a deallocated temporary"
<< "Attempted copy of a deallocated temporary"
<< " of type " << typeid(T).name()
<< abort(FatalError);
}
@ -104,7 +135,7 @@ inline Foam::tmp<T>::tmp(const tmp<T>& t, bool allowTransfer)
template<class T>
inline Foam::tmp<T>::~tmp()
{
if (isTmp_ && ptr_)
if (isTmp() && ptr_)
{
if (ptr_->okToDelete())
{
@ -124,33 +155,60 @@ inline Foam::tmp<T>::~tmp()
template<class T>
inline bool Foam::tmp<T>::isTmp() const
{
return isTmp_;
return type_ == TMP;
}
template<class T>
inline bool Foam::tmp<T>::empty() const
{
return (isTmp_ && !ptr_);
return (isTmp() && !ptr_);
}
template<class T>
inline bool Foam::tmp<T>::valid() const
{
return (!isTmp_ || (isTmp_ && ptr_));
return (!isTmp() || (isTmp() && ptr_));
}
template<class T>
inline T& Foam::tmp<T>::ref()
{
if (type_ == TMP)
{
if (!ptr_)
{
FatalErrorInFunction
<< "Temporary of type " << typeid(T).name() << " deallocated"
<< abort(FatalError);
}
return *ptr_;
}
else if (type_ == REF)
{
return *ptr_;
}
else
{
FatalErrorInFunction << "Const object cast to non-const"
<< abort(FatalError);
return *ptr_;
}
}
template<class T>
inline T* Foam::tmp<T>::ptr() const
{
if (isTmp_)
if (isTmp())
{
if (!ptr_)
{
FatalErrorInFunction
<< "temporary of type " << typeid(T).name() << " deallocated"
<< "Temporary of type " << typeid(T).name() << " deallocated"
<< abort(FatalError);
}
@ -163,7 +221,7 @@ inline T* Foam::tmp<T>::ptr() const
}
else
{
return new T(ref_);
return new T(*ptr_);
}
}
@ -171,7 +229,7 @@ inline T* Foam::tmp<T>::ptr() const
template<class T>
inline void Foam::tmp<T>::clear() const
{
if (isTmp_ && ptr_) // Skip this bit: && ptr_->okToDelete())
if (isTmp() && ptr_) // Skip this bit: && ptr_->okToDelete())
{
delete ptr_;
ptr_ = 0;
@ -181,15 +239,16 @@ inline void Foam::tmp<T>::clear() const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
#ifndef CONST_TMP
template<class T>
inline T& Foam::tmp<T>::operator()()
{
if (isTmp_)
if (type_ == TMP)
{
if (!ptr_)
{
FatalErrorInFunction
<< "temporary of type " << typeid(T).name() << " deallocated"
<< "Temporary of type " << typeid(T).name() << " deallocated"
<< abort(FatalError);
}
@ -197,28 +256,23 @@ inline T& Foam::tmp<T>::operator()()
}
else
{
// Note: const is cast away!
// Perhaps there should be two refs, one for const and one for non const
// and if the ref is actually const then you cannot return it here.
//
// Another possibility would be to store a const ref and a flag to say
// whether the tmp was constructed with a const or a non-const argument.
//
// eg, enum refType { POINTER = 0, REF = 1, CONSTREF = 2 };
return const_cast<T&>(ref_);
// Const-ness is automatically cast-away which is why this operator is
// deprecated. Use ref() where non-const access is required.
return *ptr_;
}
}
#endif
template<class T>
inline const T& Foam::tmp<T>::operator()() const
{
if (isTmp_)
if (type_ == TMP)
{
if (!ptr_)
{
FatalErrorInFunction
<< "temporary of type " << typeid(T).name() << " deallocated"
<< "Temporary of type " << typeid(T).name() << " deallocated"
<< abort(FatalError);
}
@ -226,7 +280,8 @@ inline const T& Foam::tmp<T>::operator()() const
}
else
{
return ref_;
// Return const reference
return *ptr_;
}
}
@ -241,20 +296,26 @@ inline Foam::tmp<T>::operator const T&() const
template<class T>
inline T* Foam::tmp<T>::operator->()
{
if (isTmp_)
if (isTmp())
{
if (!ptr_)
{
FatalErrorInFunction
<< "temporary of type " << typeid(T).name() << " deallocated"
<< "Temporary of type " << typeid(T).name() << " deallocated"
<< abort(FatalError);
}
return ptr_;
}
else if (type_ == REF)
{
return ptr_;
}
else
{
return &const_cast<T&>(ref_);
FatalErrorInFunction << "Const object cast to non-const"
<< abort(FatalError);
return ptr_;
}
}
@ -262,14 +323,28 @@ inline T* Foam::tmp<T>::operator->()
template<class T>
inline const T* Foam::tmp<T>::operator->() const
{
return const_cast<tmp<T>&>(*this).operator->();
if (isTmp())
{
if (!ptr_)
{
FatalErrorInFunction
<< "Temporary of type " << typeid(T).name() << " deallocated"
<< abort(FatalError);
}
return ptr_;
}
else
{
return ptr_;
}
}
template<class T>
inline void Foam::tmp<T>::operator=(T* tPtr)
{
if (isTmp_ && ptr_)
if (isTmp() && ptr_)
{
if (ptr_->okToDelete())
{
@ -282,12 +357,12 @@ inline void Foam::tmp<T>::operator=(T* tPtr)
}
}
isTmp_ = true;
type_ = TMP;
if (!tPtr)
{
FatalErrorInFunction
<< "attempted copy of a deallocated temporary"
<< "Attempted copy of a deallocated temporary"
<< " of type " << typeid(T).name()
<< abort(FatalError);
}
@ -300,7 +375,7 @@ inline void Foam::tmp<T>::operator=(T* tPtr)
template<class T>
inline void Foam::tmp<T>::operator=(const tmp<T>& t)
{
if (isTmp_ && ptr_)
if (isTmp() && ptr_)
{
if (ptr_->okToDelete())
{
@ -313,14 +388,14 @@ inline void Foam::tmp<T>::operator=(const tmp<T>& t)
}
}
if (t.isTmp_)
if (t.isTmp())
{
isTmp_ = true;
type_ = TMP;
if (!t.ptr_)
{
FatalErrorInFunction
<< "attempted assignment to a deallocated temporary"
<< "Attempted assignment to a deallocated temporary"
<< " of type " << typeid(T).name()
<< abort(FatalError);
}
@ -332,11 +407,27 @@ inline void Foam::tmp<T>::operator=(const tmp<T>& t)
else
{
FatalErrorInFunction
<< "attempted assignment to a const reference to constant object"
<< "Attempted assignment to a const reference to constant object"
<< " of type " << typeid(T).name()
<< abort(FatalError);
}
}
//- Return the const reference of the non-const reference argument
template<typename T>
inline const T& Const(T& t)
{
return t;
}
//- Return the const reference of the non-const rvalue reference argument
template<typename T>
inline const T& Const(T&& t)
{
return t;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -149,7 +149,7 @@ Foam::boundBox::boundBox
Foam::tmp<Foam::pointField> Foam::boundBox::points() const
{
tmp<pointField> tPts = tmp<pointField>(new pointField(8));
pointField& pt = tPts();
pointField& pt = tPts.ref();
pt[0] = min_; // min-x, min-y, min-z
pt[1] = point(max_.x(), min_.y(), min_.z()); // max-x, min-y, min-z

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -41,7 +41,7 @@ Foam::tmp<Foam::vectorField>
Foam::face::calcEdges(const pointField& points) const
{
tmp<vectorField> tedges(new vectorField(size()));
vectorField& edges = tedges();
vectorField& edges = tedges.ref();
forAll(*this, i)
{

View File

@ -55,7 +55,7 @@ bool Foam::polyMesh::checkFaceOrthogonality
fAreas,
cellCtrs
);
const scalarField& ortho = tortho();
const scalarField& ortho = tortho.ref();
// Severe nonorthogonality threshold
const scalar severeNonorthogonalityThreshold =
@ -197,7 +197,7 @@ bool Foam::polyMesh::checkFaceSkewness
fAreas,
cellCtrs
);
const scalarField& skew = tskew();
const scalarField& skew = tskew.ref();
scalar maxSkew = max(skew);
label nWarnSkew = 0;
@ -426,7 +426,7 @@ bool Foam::polyMesh::checkCellDeterminant
faceAreas,
syncTools::getInternalOrCoupledFaces(*this)
);
scalarField& cellDeterminant = tcellDeterminant();
scalarField& cellDeterminant = tcellDeterminant.ref();
label nErrorCells = 0;
@ -508,7 +508,7 @@ bool Foam::polyMesh::checkFaceWeight
fAreas,
cellCtrs
);
scalarField& faceWght = tfaceWght();
scalarField& faceWght = tfaceWght.ref();
label nErrorFaces = 0;
@ -595,7 +595,7 @@ bool Foam::polyMesh::checkVolRatio
}
tmp<scalarField> tvolRatio = polyMeshTools::volRatio(*this, cellVols);
scalarField& volRatio = tvolRatio();
scalarField& volRatio = tvolRatio.ref();
label nErrorFaces = 0;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -43,7 +43,7 @@ Foam::tmp<Foam::scalarField> Foam::polyMeshTools::faceOrthogonality
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
tmp<scalarField> tortho(new scalarField(mesh.nFaces(), 1.0));
scalarField& ortho = tortho();
scalarField& ortho = tortho.ref();
// Internal faces
forAll(nei, faceI)
@ -100,7 +100,7 @@ Foam::tmp<Foam::scalarField> Foam::polyMeshTools::faceSkewness
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
tmp<scalarField> tskew(new scalarField(mesh.nFaces()));
scalarField& skew = tskew();
scalarField& skew = tskew.ref();
forAll(nei, faceI)
{
@ -184,7 +184,7 @@ Foam::tmp<Foam::scalarField> Foam::polyMeshTools::faceWeights
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
tmp<scalarField> tweight(new scalarField(mesh.nFaces(), 1.0));
scalarField& weight = tweight();
scalarField& weight = tweight.ref();
// Internal faces
forAll(nei, faceI)
@ -240,7 +240,7 @@ Foam::tmp<Foam::scalarField> Foam::polyMeshTools::volRatio
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
tmp<scalarField> tratio(new scalarField(mesh.nFaces(), 1.0));
scalarField& ratio = tratio();
scalarField& ratio = tratio.ref();
// Internal faces
forAll(nei, faceI)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -297,7 +297,7 @@ const Foam::vectorField::subField Foam::polyPatch::faceAreas() const
Foam::tmp<Foam::vectorField> Foam::polyPatch::faceCellCentres() const
{
tmp<vectorField> tcc(new vectorField(size()));
vectorField& cc = tcc();
vectorField& cc = tcc.ref();
// get reference to global cell centres
const vectorField& gcc = boundaryMesh_.mesh().cellCentres();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -320,7 +320,7 @@ Foam::tmp<Foam::scalarField> Foam::primitiveMesh::movePoints
const faceList& f = faces();
tmp<scalarField> tsweptVols(new scalarField(f.size()));
scalarField& sweptVols = tsweptVols();
scalarField& sweptVols = tsweptVols.ref();
forAll(f, faceI)
{

View File

@ -130,7 +130,7 @@ Foam::tmp<Foam::scalarField> Foam::primitiveMeshTools::faceOrthogonality
const labelList& nei = mesh.faceNeighbour();
tmp<scalarField> tortho(new scalarField(mesh.nInternalFaces()));
scalarField& ortho = tortho();
scalarField& ortho = tortho.ref();
// Internal faces
forAll(nei, faceI)
@ -160,7 +160,7 @@ Foam::tmp<Foam::scalarField> Foam::primitiveMeshTools::faceSkewness
const labelList& nei = mesh.faceNeighbour();
tmp<scalarField> tskew(new scalarField(mesh.nFaces()));
scalarField& skew = tskew();
scalarField& skew = tskew.ref();
forAll(nei, faceI)
{
@ -345,7 +345,7 @@ Foam::tmp<Foam::scalarField> Foam::primitiveMeshTools::faceConcavity
faceNormals /= mag(faceNormals) + ROOTVSMALL;
tmp<scalarField> tfaceAngles(new scalarField(mesh.nFaces()));
scalarField& faceAngles = tfaceAngles();
scalarField& faceAngles = tfaceAngles.ref();
forAll(fcs, faceI)
@ -416,7 +416,7 @@ Foam::tmp<Foam::scalarField> Foam::primitiveMeshTools::faceFlatness
scalarField magAreas(mag(faceAreas));
tmp<scalarField> tfaceFlatness(new scalarField(mesh.nFaces(), 1.0));
scalarField& faceFlatness = tfaceFlatness();
scalarField& faceFlatness = tfaceFlatness.ref();
forAll(fcs, faceI)
@ -474,7 +474,7 @@ Foam::tmp<Foam::scalarField> Foam::primitiveMeshTools::cellDeterminant
}
tmp<scalarField> tcellDeterminant(new scalarField(mesh.nCells()));
scalarField& cellDeterminant = tcellDeterminant();
scalarField& cellDeterminant = tcellDeterminant.ref();
const cellList& c = mesh.cells();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -163,8 +163,7 @@ Foam::treeBoundBox::treeBoundBox
Foam::tmp<Foam::pointField> Foam::treeBoundBox::points() const
{
tmp<pointField> tPts = tmp<pointField>(new pointField(8));
pointField& points = tPts();
pointField& points = tPts.ref();
forAll(points, octant)
{

View File

@ -92,7 +92,7 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::value
) const
{
tmp<Field<Type>> tfld(new Field<Type>(x.size()));
Field<Type>& fld = tfld();
Field<Type>& fld = tfld.ref();
forAll(x, i)
{
@ -110,7 +110,7 @@ Foam::tmp<Foam::Field<Type>> Foam::Function1<Type>::integrate
) const
{
tmp<Field<Type>> tfld(new Field<Type>(x1.size()));
Field<Type>& fld = tfld();
Field<Type>& fld = tfld.ref();
forAll(x1, i)
{

View File

@ -380,7 +380,7 @@ template<class Type>
Foam::tmp<Foam::scalarField> Foam::Function1Types::TableBase<Type>::x() const
{
tmp<scalarField> tfld(new scalarField(table_.size(), 0.0));
scalarField& fld = tfld();
scalarField& fld = tfld.ref();
forAll(table_, i)
{
@ -395,7 +395,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::Function1Types::TableBase<Type>::y() const
{
tmp<Field<Type>> tfld(new Field<Type>(table_.size(), pTraits<Type>::zero));
Field<Type>& fld = tfld();
Field<Type>& fld = tfld.ref();
forAll(table_, i)
{

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -147,7 +147,7 @@ void Foam::DispersionRASModel<CloudType>::cacheFields(const bool store)
}
else
{
kPtr_ = tk.operator->();
kPtr_ = &tk();
ownK_ = false;
}
@ -159,7 +159,7 @@ void Foam::DispersionRASModel<CloudType>::cacheFields(const bool store)
}
else
{
epsilonPtr_ = tepsilon.operator->();
epsilonPtr_ = &tepsilon();
ownEpsilon_ = false;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -139,7 +139,7 @@ void Foam::BrownianMotionForce<CloudType>::cacheFields(const bool store)
}
else
{
kPtr_ = tk.operator->();
kPtr_ = &tk();
ownK_ = false;
}
}