CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

'this->' in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 29, 2018, 19:01
Default 'this->' in OpenFOAM
  #1
Member
 
Tony Zahtila
Join Date: Mar 2016
Posts: 33
Rep Power: 10
tzaht is on a distinguished road
Hi all,

I am having some trouble understanding the sequence, 'this->' in OpenFOAM.

Code:
template<class ParcelType>
template<class TrackCloudType>
void Foam::KinematicParcel<ParcelType>::setCellValues
(
    TrackCloudType& cloud,
    trackingData& td
)
{
    tetIndices tetIs = this->currentTetIndices();

    td.rhoc() = td.rhoInterp().interpolate(this->coordinates(), tetIs);

    if (td.rhoc() < cloud.constProps().rhoMin())
    {
        if (debug)
        {
            WarningInFunction
                << "Limiting observed density in cell " << this->cell()
                << " to " << cloud.constProps().rhoMin() <<  nl << endl;
        }

        td.rhoc() = cloud.constProps().rhoMin();
    }

    td.Uc() = td.UInterp().interpolate(this->coordinates(), tetIs);

    td.muc() = td.muInterp().interpolate(this->coordinates(), tetIs);
}
I have the following understanding of the '-> operator' in C++.

\textbf{a$\rightarrow$b} \textbf{(this$ \rightarrow b$)}, shorthand notation for (*a).b With $a \rightarrow$ b, b will be a member of the object the pointer a refers to. If, however, a is an object of a class that overloads this operator, then the overloaded operator function gets invoked. Every object in C++ has access to its own address though an important pointer called 'this'.

Let's take for example the following sequence:

Code:
this->currentTetIndices()
My point of confusion is that I cannot see the class setCellValues as having a member currentTetIndices().

I appreciate any help that comes my way.

Kind regards.
tzaht is offline   Reply With Quote

Old   December 30, 2018, 11:12
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
The right arrow is a regular pointer-to-member. If you scan the inheritance of the class, you will find the corresponding method in the hierarchy.
olesen is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenFOAM Training Beijing 22-26 Aug 2016 cfd.direct OpenFOAM Announcements from Other Sources 0 May 3, 2016 05:57
OpenFOAM Training, London, Chicago, Munich, Sep-Oct 2015 cfd.direct OpenFOAM Announcements from Other Sources 2 August 31, 2015 14:36
[Salome] hdf file example --> Internal faces Salome --> OpenFOAM student666 OpenFOAM Meshing & Mesh Conversion 1 December 7, 2013 11:09
CAD -> gMsh -> enGrid -> OpenFOAM Problem AlGates OpenFOAM 7 August 6, 2010 13:46
[Netgen] Geometry > Netgen > OpenFOAM ericnutsch OpenFOAM Meshing & Mesh Conversion 9 February 22, 2010 08:39


All times are GMT -4. The time now is 21:07.