GeometricField: New non-const access function boundaryFieldRef()

There is a need to specify const or non-const access to a non-const
object which is not currently possible with the "boundaryField()" access
function the const-ness of the return of which is defined by the
const-ness of the object for which it is called.  For consistency with
the latest "tmp" storage class in which non-const access is obtained
with the "ref()" function it is proposed to replace the non-const form
of "boundaryField()" with "boundaryFieldRef()".

Thanks to Mattijs Janssens for starting the process of migration to
"boundaryFieldRef()" and providing a patch for the OpenFOAM and
finiteVolume libraries.
This commit is contained in:
Henry Weller
2016-04-23 23:07:28 +01:00
parent 88561eea95
commit 45f73bf64f
59 changed files with 369 additions and 245 deletions

View File

@ -712,7 +712,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::internalField()
template<class Type, template<class> class PatchField, class GeoMesh>
typename
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricBoundaryField&
Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField()
Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryFieldRef()
{
this->setUpToDate();
storeOldTimes();
@ -993,7 +993,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::T() const
);
Foam::T(result.ref().internalField(), internalField());
Foam::T(result.ref().boundaryField(), boundaryField());
Foam::T(result.ref().boundaryFieldRef(), boundaryField());
return result;
}
@ -1030,7 +1030,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::component
);
Foam::component(Component.ref().internalField(), internalField(), d);
Foam::component(Component.ref().boundaryField(), boundaryField(), d);
Foam::component(Component.ref().boundaryFieldRef(), boundaryField(), d);
return Component;
}
@ -1049,7 +1049,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::replace
)
{
internalField().replace(d, gcf.internalField());
boundaryField().replace(d, gcf.boundaryField());
boundaryFieldRef().replace(d, gcf.boundaryField());
}
@ -1061,7 +1061,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::replace
)
{
internalField().replace(d, ds.value());
boundaryField().replace(d, ds.value());
boundaryFieldRef().replace(d, ds.value());
}
@ -1072,7 +1072,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::max
)
{
Foam::max(internalField(), internalField(), dt.value());
Foam::max(boundaryField(), boundaryField(), dt.value());
Foam::max(boundaryFieldRef(), boundaryField(), dt.value());
}
@ -1083,7 +1083,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::min
)
{
Foam::min(internalField(), internalField(), dt.value());
Foam::min(boundaryField(), boundaryField(), dt.value());
Foam::min(boundaryFieldRef(), boundaryField(), dt.value());
}
@ -1091,7 +1091,7 @@ template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::negate()
{
internalField().negate();
boundaryField().negate();
boundaryFieldRef().negate();
}
@ -1115,7 +1115,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
// only equate field contents not ID
dimensionedInternalField() = gf.dimensionedInternalField();
boundaryField() = gf.boundaryField();
boundaryFieldRef() = gf.boundaryField();
}
@ -1146,7 +1146,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
const_cast<Field<Type>&>(gf.internalField())
);
boundaryField() = gf.boundaryField();
boundaryFieldRef() = gf.boundaryField();
tgf.clear();
}
@ -1159,7 +1159,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator=
)
{
dimensionedInternalField() = dt;
boundaryField() = dt.value();
boundaryFieldRef() = dt.value();
}
@ -1176,7 +1176,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
// only equate field contents not ID
dimensionedInternalField() = gf.dimensionedInternalField();
boundaryField() == gf.boundaryField();
boundaryFieldRef() == gf.boundaryField();
tgf.clear();
}
@ -1189,7 +1189,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==
)
{
dimensionedInternalField() = dt;
boundaryField() == dt.value();
boundaryFieldRef() == dt.value();
}
@ -1204,7 +1204,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
checkField(*this, gf, #op); \
\
dimensionedInternalField() op gf.dimensionedInternalField(); \
boundaryField() op gf.boundaryField(); \
boundaryFieldRef() op gf.boundaryField(); \
} \
\
template<class Type, template<class> class PatchField, class GeoMesh> \
@ -1224,7 +1224,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::operator op \
) \
{ \
dimensionedInternalField() op dt; \
boundaryField() op dt.value(); \
boundaryFieldRef() op dt.value(); \
}
COMPUTED_ASSIGNMENT(Type, +=)

View File

@ -442,7 +442,15 @@ public:
inline const InternalField& internalField() const;
//- Return reference to GeometricBoundaryField
GeometricBoundaryField& boundaryField();
GeometricBoundaryField& boundaryFieldRef();
//- Return reference to GeometricBoundaryField
#ifndef BOUNDARY_FIELD_REF
GeometricBoundaryField& boundaryField()
{
return boundaryFieldRef();
}
#endif
//- Return reference to GeometricBoundaryField for const field
inline const GeometricBoundaryField& boundaryField() const;

View File

@ -50,7 +50,7 @@ void component
)
{
component(gcf.internalField(), gf.internalField(), d);
component(gcf.boundaryField(), gf.boundaryField(), d);
component(gcf.boundaryFieldRef(), gf.boundaryField(), d);
}
@ -62,7 +62,7 @@ void T
)
{
T(gf.internalField(), gf1.internalField());
T(gf.boundaryField(), gf1.boundaryField());
T(gf.boundaryFieldRef(), gf1.boundaryField());
}
@ -80,7 +80,7 @@ void pow
)
{
pow(gf.internalField(), gf1.internalField(), r);
pow(gf.boundaryField(), gf1.boundaryField(), r);
pow(gf.boundaryFieldRef(), gf1.boundaryField(), r);
}
template
@ -174,7 +174,7 @@ void sqr
)
{
sqr(gf.internalField(), gf1.internalField());
sqr(gf.boundaryField(), gf1.boundaryField());
sqr(gf.boundaryFieldRef(), gf1.boundaryField());
}
template<class Type, template<class> class PatchField, class GeoMesh>
@ -262,7 +262,7 @@ void magSqr
)
{
magSqr(gsf.internalField(), gf.internalField());
magSqr(gsf.boundaryField(), gf.boundaryField());
magSqr(gsf.boundaryFieldRef(), gf.boundaryField());
}
template<class Type, template<class> class PatchField, class GeoMesh>
@ -334,7 +334,7 @@ void mag
)
{
mag(gsf.internalField(), gf.internalField());
mag(gsf.boundaryField(), gf.boundaryField());
mag(gsf.boundaryFieldRef(), gf.boundaryField());
}
template<class Type, template<class> class PatchField, class GeoMesh>
@ -411,7 +411,7 @@ void cmptAv
)
{
cmptAv(gcf.internalField(), gf.internalField());
cmptAv(gcf.boundaryField(), gf.boundaryField());
cmptAv(gcf.boundaryFieldRef(), gf.boundaryField());
}
template<class Type, template<class> class PatchField, class GeoMesh>
@ -600,7 +600,12 @@ void opFunc \
) \
{ \
Foam::opFunc(gf.internalField(), gf1.internalField(), gf2.internalField());\
Foam::opFunc(gf.boundaryField(), gf1.boundaryField(), gf2.boundaryField());\
Foam::opFunc \
( \
gf.boundaryFieldRef(), \
gf1.boundaryField(), \
gf2.boundaryField() \
);\
} \
\
template \
@ -746,7 +751,7 @@ void opFunc \
) \
{ \
Foam::opFunc(gf.internalField(), gf1.internalField(), dvs.value()); \
Foam::opFunc(gf.boundaryField(), gf1.boundaryField(), dvs.value()); \
Foam::opFunc(gf.boundaryFieldRef(), gf1.boundaryField(), dvs.value()); \
} \
\
template \
@ -859,7 +864,7 @@ void opFunc \
) \
{ \
Foam::opFunc(gf.internalField(), dvs.value(), gf1.internalField()); \
Foam::opFunc(gf.boundaryField(), dvs.value(), gf1.boundaryField()); \
Foam::opFunc(gf.boundaryFieldRef(), dvs.value(), gf1.boundaryField()); \
} \
\
template \

View File

@ -42,7 +42,7 @@ void Func \
) \
{ \
Foam::Func(res.internalField(), gf1.internalField()); \
Foam::Func(res.boundaryField(), gf1.boundaryField()); \
Foam::Func(res.boundaryFieldRef(), gf1.boundaryField()); \
} \
\
TEMPLATE \
@ -111,7 +111,7 @@ void OpFunc \
) \
{ \
Foam::OpFunc(res.internalField(), gf1.internalField()); \
Foam::OpFunc(res.boundaryField(), gf1.boundaryField()); \
Foam::OpFunc(res.boundaryFieldRef(), gf1.boundaryField()); \
} \
\
TEMPLATE \
@ -180,8 +180,13 @@ void Func \
const GeometricField<Type2, PatchField, GeoMesh>& gf2 \
) \
{ \
Foam::Func(res.internalField(), gf1.internalField(), gf2.internalField());\
Foam::Func(res.boundaryField(), gf1.boundaryField(), gf2.boundaryField());\
Foam::Func(res.internalField(), gf1.internalField(), gf2.internalField()); \
Foam::Func \
( \
res.boundaryFieldRef(), \
gf1.boundaryField(), \
gf2.boundaryField() \
);\
} \
\
TEMPLATE \
@ -309,7 +314,7 @@ void Func \
) \
{ \
Foam::Func(res.internalField(), dt1.value(), gf2.internalField()); \
Foam::Func(res.boundaryField(), dt1.value(), gf2.boundaryField()); \
Foam::Func(res.boundaryFieldRef(), dt1.value(), gf2.boundaryField()); \
} \
\
TEMPLATE \
@ -400,7 +405,7 @@ void Func \
) \
{ \
Foam::Func(res.internalField(), gf1.internalField(), dt2.value()); \
Foam::Func(res.boundaryField(), gf1.boundaryField(), dt2.value()); \
Foam::Func(res.boundaryFieldRef(), gf1.boundaryField(), dt2.value()); \
} \
\
TEMPLATE \
@ -500,7 +505,7 @@ void OpFunc \
Foam::OpFunc \
(res.internalField(), gf1.internalField(), gf2.internalField()); \
Foam::OpFunc \
(res.boundaryField(), gf1.boundaryField(), gf2.boundaryField()); \
(res.boundaryFieldRef(), gf1.boundaryField(), gf2.boundaryField()); \
} \
\
TEMPLATE \
@ -628,7 +633,7 @@ void OpFunc \
) \
{ \
Foam::OpFunc(res.internalField(), dt1.value(), gf2.internalField()); \
Foam::OpFunc(res.boundaryField(), dt1.value(), gf2.boundaryField()); \
Foam::OpFunc(res.boundaryFieldRef(), dt1.value(), gf2.boundaryField()); \
} \
\
TEMPLATE \
@ -719,7 +724,7 @@ void OpFunc \
) \
{ \
Foam::OpFunc(res.internalField(), gf1.internalField(), dt2.value()); \
Foam::OpFunc(res.boundaryField(), gf1.boundaryField(), dt2.value()); \
Foam::OpFunc(res.boundaryFieldRef(), gf1.boundaryField(), dt2.value()); \
} \
\
TEMPLATE \

View File

@ -132,7 +132,7 @@ void MapGeometricFields
// Map the patch fields
typename GeometricField<Type, PatchField, GeoMesh>
::GeometricBoundaryField& bfield = field.boundaryField();
::GeometricBoundaryField& bfield = field.boundaryFieldRef();
forAll(bfield, patchi)
{
// Cannot check sizes for patch fields because of

View File

@ -44,7 +44,7 @@ void stabilise
)
{
stabilise(result.internalField(), gsf.internalField(), ds.value());
stabilise(result.boundaryField(), gsf.boundaryField(), ds.value());
stabilise(result.boundaryFieldRef(), gsf.boundaryField(), ds.value());
}
@ -127,7 +127,7 @@ void pow
)
{
pow(Pow.internalField(), gsf1.internalField(), gsf2.internalField());
pow(Pow.boundaryField(), gsf1.boundaryField(), gsf2.boundaryField());
pow(Pow.boundaryFieldRef(), gsf1.boundaryField(), gsf2.boundaryField());
}
@ -270,7 +270,7 @@ void pow
)
{
pow(tPow.internalField(), gsf.internalField(), ds.value());
pow(tPow.boundaryField(), gsf.boundaryField(), ds.value());
pow(tPow.boundaryFieldRef(), gsf.boundaryField(), ds.value());
}
@ -359,7 +359,7 @@ void pow
)
{
pow(tPow.internalField(), ds.value(), gsf.internalField());
pow(tPow.boundaryField(), ds.value(), gsf.boundaryField());
pow(tPow.boundaryFieldRef(), ds.value(), gsf.boundaryField());
}
@ -451,7 +451,7 @@ void atan2
)
{
atan2(Atan2.internalField(), gsf1.internalField(), gsf2.internalField());
atan2(Atan2.boundaryField(), gsf1.boundaryField(), gsf2.boundaryField());
atan2(Atan2.boundaryFieldRef(), gsf1.boundaryField(), gsf2.boundaryField());
}
@ -578,7 +578,7 @@ void atan2
)
{
atan2(tAtan2.internalField(), gsf.internalField(), ds.value());
atan2(tAtan2.boundaryField(), gsf.boundaryField(), ds.value());
atan2(tAtan2.boundaryFieldRef(), gsf.boundaryField(), ds.value());
}
@ -667,7 +667,7 @@ void atan2
)
{
atan2(tAtan2.internalField(), ds.value(), gsf.internalField());
atan2(tAtan2.boundaryField(), ds.value(), gsf.boundaryField());
atan2(tAtan2.boundaryFieldRef(), ds.value(), gsf.boundaryField());
}
@ -800,7 +800,7 @@ void func \
) \
{ \
func(gsf.internalField(), n, gsf1.internalField()); \
func(gsf.boundaryField(), n, gsf1.boundaryField()); \
func(gsf.boundaryFieldRef(), n, gsf1.boundaryField()); \
} \
\
template<template<class> class PatchField, class GeoMesh> \

View File

@ -46,7 +46,7 @@ void transform
)
{
transform(rtf.internalField(), trf.internalField(), tf.internalField());
transform(rtf.boundaryField(), trf.boundaryField(), tf.boundaryField());
transform(rtf.boundaryFieldRef(), trf.boundaryField(), tf.boundaryField());
}
@ -132,7 +132,7 @@ void transform
)
{
transform(rtf.internalField(), t.value(), tf.internalField());
transform(rtf.boundaryField(), t.value(), tf.boundaryField());
transform(rtf.boundaryFieldRef(), t.value(), tf.boundaryField());
}