OpenFOAM-4.x/applications/solvers/multiphase/interFoam/interMixingFoam
Henry Weller a4e2afa4b3 Completed boundaryField() -> boundaryFieldRef()
Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1938

Because C++ does not support overloading based on the return-type there
is a problem defining both const and non-const member functions which
are resolved based on the const-ness of the object for which they are
called rather than the intent of the programmer declared via the
const-ness of the returned type.  The issue for the "boundaryField()"
member function is that the non-const version increments the
event-counter and checks the state of the stored old-time fields in case
the returned value is altered whereas the const version has no
side-effects and simply returns the reference.  If the the non-const
function is called within the patch-loop the event-counter may overflow.
To resolve this it in necessary to avoid calling the non-const form of
"boundaryField()" if the results is not altered and cache the reference
outside the patch-loop when mutation of the patch fields is needed.

The most straight forward way of resolving this problem is to name the
const and non-const forms of the member functions differently e.g. the
non-const form could be named:

    mutableBoundaryField()
    mutBoundaryField()
    nonConstBoundaryField()
    boundaryFieldRef()

Given that in C++ a reference is non-const unless specified as const:
"T&" vs "const T&" the logical convention would be

    boundaryFieldRef()
    boundaryFieldConstRef()

and given that the const form which is more commonly used is it could
simply be named "boundaryField()" then the logical convention is

    GeometricBoundaryField& boundaryFieldRef();

    inline const GeometricBoundaryField& boundaryField() const;

This is also consistent with the new "tmp" class for which non-const
access to the stored object is obtained using the ".ref()" member function.

This new convention for non-const access to the components of
GeometricField will be applied to "dimensionedInternalField()" and "internalField()" in the
future, i.e. "dimensionedInternalFieldRef()" and "internalFieldRef()".
2016-04-25 16:16:05 +01:00
..
immiscibleIncompressibleThreePhaseMixture Add the OpenFOAM source tree 2014-12-10 22:40:10 +00:00
incompressibleThreePhaseMixture Removed duplicate, inconsistent and spurious comments in .C files 2016-02-29 18:33:54 +00:00
Make fvOptions: Reorganized and updated to simplify use in sub-models and maintenance 2015-12-02 11:49:52 +00:00
threePhaseInterfaceProperties Completed boundaryField() -> boundaryFieldRef() 2016-04-25 16:16:05 +01:00
alphaControls.H Resolve various unimportant warning messages from Gcc, Clang and Icpc 2015-07-19 11:31:49 +01:00
alphaEqns.H Renamed phiAlpha -P alphaPhi for consistency with Euler-Euler solvers 2015-09-11 17:52:43 +01:00
alphaEqnsSubCycle.H Add the OpenFOAM source tree 2014-12-10 22:40:10 +00:00
createFields.H interFoam, interMixingFoam, interPhaseChangeFoam: construct rho with calculated BCs 2016-02-18 21:26:25 +00:00
interMixingFoam.C Solvers: Added support for extrapolated pressure boundary conditions 2016-02-13 17:48:26 +00:00