View Issue Details

IDProjectCategoryView StatusLast Update
0002134OpenFOAMBugpublic2017-05-07 12:11
Reporterngj Assigned Tohenry  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionno change required 
PlatformLinuxOSUbuntu OS Version14.04LTS
Summary0002134: internalFieldRef not recognised
DescriptionI am trying to compile waves2Foam under OpenFoam-4.0 and I noticed the following command in the release form:

============================================
Robust data handling: new convention for const and non-const reference functions of fields where the non-const function name ends …Ref(); for example, where internalField() provides the const reference to the internal field, internalFieldRef() provides a non-const reference. » more »; for tmp objects, non-const access uses a ref() function rather than the () dereferencing operator. » more »
============================================

The problem is that the openfoam4 version provided through the repository does not supply internalFieldRef(), but internalField() has effectively made const as the only option.

I have also checked the source pack from the 28th of June and the problem also persists there.

Kind regards

Niels
Steps To ReproducePerform the following search in all of the OpenFoam source code:

find ./ -name "*" -type f | xargs grep internalFieldRef

This will come out empty, i.e. there is no implementation of internalFieldRef.
TagsNo tags attached.

Activities

henry

2016-06-29 21:13

manager   ~0006472

.internalFieldRef() has been superceded by the simpler .ref()

Are you planning to contribute waves2Foam to the OpenFOAM Foundation for inclusion in future OpenFOAM releases?

ngj

2016-06-29 21:20

reporter   ~0006473

Last edited: 2016-06-29 21:21

Thank you for the fast reply. Does this mean the internalFieldRef(), as mentioned in the release notes, will not been incorporated at a later stage? To be honest, I feel that .ref() is much harder to understand, when reading the code than internalFieldRef(), which will then also match the difference between boundaryField() and boundaryFieldRef().

With respect to contributing waves2Foam, then I do not have any immediate plans of changing its status as an independent plug-in to a multiple of OpenFoam versions/branches.

Edit: I have tried with .ref() and the code compiles.

henry

2016-06-29 21:50

manager   ~0006474

Last edited: 2016-06-30 08:12

Note that GeometricField is derived from the internal field, access to which is a form of dereferencing, whereas the boundary field is private member data requiring an access function. This is my argument for using the simplified access methods for the internal field which is/will be commonly used in expressions. In addition to the '.ref()' simplification I added the '()' operator for the more common const-dereferencing:

        //- Return a const-reference to the dimensioned internal field
        // Useful in the formulation of source-terms for FV equations
        inline const Internal& operator()() const;

and demonstrated the new form of efficient source term construction in the kEpsilon model:

    // Turbulent kinetic energy equation
    tmp<fvScalarMatrix> kEqn
    (
        fvm::ddt(alpha, rho, k_)
      + fvm::div(alphaRhoPhi, k_)
      - fvm::laplacian(alpha*rho*DkEff(), k_)
     ==
        alpha()*rho()*G
      - fvm::SuSp((2.0/3.0)*alpha()*rho()*divU, k_)
      - fvm::Sp(alpha()*rho()*epsilon_()/k_(), k_)
      + kSource()
      + fvOptions(alpha, rho, k_)
    );

If every occurrence of '()' were replaced by 'internalField()' it would be very messy and hard to read.

I intend to update all equations to use this new form of dimensioned internal field source construction eventually but it will take some time.

Issue History

Date Modified Username Field Change
2016-06-29 20:53 ngj New Issue
2016-06-29 21:13 henry Note Added: 0006472
2016-06-29 21:20 ngj Note Added: 0006473
2016-06-29 21:21 ngj Note Edited: 0006473
2016-06-29 21:50 henry Note Added: 0006474
2016-06-30 07:15 henry Note Edited: 0006474
2016-06-30 07:16 henry Note Edited: 0006474
2016-06-30 08:12 henry Note Edited: 0006474
2016-07-01 10:40 henry Status new => closed
2016-07-01 10:41 henry Assigned To => henry
2016-07-01 10:41 henry Resolution open => no change required
2016-07-01 10:41 henry Fixed in Version => 4.0