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()".
Showing
- applications/solvers/combustion/PDRFoam/PDRModels/turbulence/PDRkEpsilon/PDRkEpsilon.C 2 additions, 2 deletions...on/PDRFoam/PDRModels/turbulence/PDRkEpsilon/PDRkEpsilon.C
- applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.C 3 additions, 1 deletion...bustion/PDRFoam/XiModels/XiEqModels/SCOPEXiEq/SCOPEXiEq.C
- applications/solvers/combustion/PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.C 12 additions, 6 deletions.../PDRFoam/laminarFlameSpeed/SCOPE/SCOPELaminarFlameSpeed.C
- applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C 3 additions, 3 deletions...ible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C
- applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C 3 additions, 3 deletions...ions/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C
- applications/solvers/multiphase/compressibleMultiphaseInterFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C 1 addition, 1 deletion...terFoam/multiphaseMixtureThermo/multiphaseMixtureThermo.C
- applications/solvers/multiphase/interFoam/alphaEqn.H 4 additions, 1 deletionapplications/solvers/multiphase/interFoam/alphaEqn.H
- applications/solvers/multiphase/interFoam/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C 2 additions, 2 deletions...ePhaseInterfaceProperties/threePhaseInterfaceProperties.C
- applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C 13 additions, 6 deletions...e/multiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C
- applications/solvers/multiphase/multiphaseEulerFoam/pEqn.H 1 addition, 1 deletionapplications/solvers/multiphase/multiphaseEulerFoam/pEqn.H
- applications/solvers/multiphase/multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C 1 addition, 1 deletion...multiphaseInterFoam/multiphaseMixture/multiphaseMixture.C
- applications/solvers/multiphase/reactingEulerFoam/interfacialCompositionModels/saturationModels/polynomial/polynomial.C 3 additions, 1 deletion...ompositionModels/saturationModels/polynomial/polynomial.C
- applications/solvers/multiphase/reactingEulerFoam/interfacialModels/wallLubricationModels/wallLubricationModel/wallLubricationModel.C 3 additions, 1 deletion...icationModels/wallLubricationModel/wallLubricationModel.C
- applications/solvers/multiphase/reactingEulerFoam/phaseSystems/BlendedInterfacialModel/BlendedInterfacialModel.C 4 additions, 1 deletion...Systems/BlendedInterfacialModel/BlendedInterfacialModel.C
- applications/solvers/multiphase/reactingEulerFoam/phaseSystems/PhaseSystems/ThermalPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C 2 additions, 2 deletions...malPhaseChangePhaseSystem/ThermalPhaseChangePhaseSystem.C
- applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C 5 additions, 3 deletions...ngMultiphaseEulerFoam/multiphaseSystem/multiphaseSystem.C
- applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/pU/pEqn.H 5 additions, 2 deletions...e/reactingEulerFoam/reactingMultiphaseEulerFoam/pU/pEqn.H
- applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/pU/pEqn.H 18 additions, 10 deletions...ase/reactingEulerFoam/reactingTwoPhaseEulerFoam/pU/pEqn.H
- applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/pUf/pEqn.H 1 addition, 1 deletion...se/reactingEulerFoam/reactingTwoPhaseEulerFoam/pUf/pEqn.H
- applications/solvers/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/kineticTheoryModels/frictionalStressModel/JohnsonJacksonSchaeffer/JohnsonJacksonSchaefferFrictionalStress.C 3 additions, 1 deletion...acksonSchaeffer/JohnsonJacksonSchaefferFrictionalStress.C
Please register or sign in to comment