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

multiphaseEulerFoam: Method forAllIter(...) within solve()

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 19, 2013, 16:59
Default multiphaseEulerFoam: Method forAllIter(...) within solve()
  #1
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
hi,

within method solve() of multiphaseEulerFoam is found:

Code:
void Foam::multiphaseSystem::solve() 
{ 
forAllIter(PtrDictionary<phaseModel>, phases_, iter) //PtrDictionary<phaseModel> 
    {  
        iter().correct();      
    } 
.
.
.
where forAllIter(...) is defined as

Code:
forAllIter (...) is defined as

for                                                                        \
    (                                                                          \
        Container::iterator iter = (container).begin();                        \
        iter != (container).end();                                             \
        ++iter                                                                 \
    )
Iterate across all elements in the container object of type Container.
Usage
forAll(ContainerType, container, iter)
{
    statements;
}
My question is about the command "iter().correct();" in the first codesnippet. I guess "iter" is here the variable "Container::iterator iter" of the second codesnippet.
Where can I find the class (or struct?) "Container::iterator" , because I need to know what the operator () is doing when called on "iter" ?

greetings
maybee
maybee is offline   Reply With Quote

Old   December 20, 2013, 06:41
Default
  #2
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 339
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
I don't know if this answers your Question, but here is some code of the file $FOAM_SRC/OpenFOAM/containers/PtrListI.H

I assume that phases_ is a pointer list or is based on a pointer list.


So my guess is that phases_ is a dynamic data structure and iter() returns the actual element of this list. So iter().correct() calls the correct() method of the phase class.


Code:
template<class T>
inline T& Foam::PtrList<T>::iterator::operator*()
{
    return **ptr_;
}


template<class T>
inline T& Foam::PtrList<T>::iterator::operator()()
{
    return operator*();
}
GerhardHolzinger is offline   Reply With Quote

Old   December 21, 2013, 05:01
Default
  #3
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
hi,
first of all thx for the help, but I am not really sure if the operators you have listed are the right ones, because when I look in class multiphaseSystem (multiphaseSystem.H) I find
for phases_ :

Code:
PtrDictionary<phaseModel> phases_; //in multiphaseSystem.H
Neither in class PtrDictionary, nor in class phaseModel I can find an operator ().
However, when looking at the methods you' ve posted I think they could be the right ones since iterator iter is some kind of pointer and phases_ is a pointer dictionary -> the double dereferenziation therefore seems logical.

How could you find these operators and how can I be sure that these are the right ones, since even when I look in class PtrList<T> I can't find them?

greetings
maybee
maybee is offline   Reply With Quote

Old   January 6, 2014, 12:56
Default
  #4
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 339
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
The answer to your question is inhertitance and polymorphism. Both are concepts in computer science and C++ implements them.

phases_ is of the type PtrDictionary<T>

The T means any data type that is compatible with all the operations performed on T.

If the class PtrDictionary does not define an operator (), then this class must have inherited this operator, otherwise the compiler would throw an error when compiling OpenFOAM.

Take a look from which class PtrDictionary is derived and then check this class. Note: C++ allows multiple inhertitance, i.e. class X can be derived from the classes A and B.
Somewhere up the family tree you will find a definition for the operator or function you are interested in.
GerhardHolzinger is offline   Reply With Quote

Old   January 7, 2014, 04:35
Default
  #5
Senior Member
 
Join Date: Jan 2012
Posts: 166
Rep Power: 14
maybee is on a distinguished road
Quote:
If the class PtrDictionary does not define an operator (), then this class must have inherited this operator, otherwise the compiler would throw an error when compiling OpenFOAM.
In the PtrDictionary class reference also the inherited methods should be shown. Furthermore I have looked up the classes PtrDictionary is derived from. See:

http://foam.sourceforge.net/docs/cpp...ce.html#l00055

Also here I canīt find the operator (). See:

http://foam.sourceforge.net/docs/cpp...ce.html#l00055

and

http://foam.sourceforge.net/docs/cpp/a06384_source.html
maybee 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
On the alpha Eqn of VOF method when using Immersed boundary method in OpenFOAM keepfit OpenFOAM 4 January 31, 2014 14:32
Lattice Boltzmann method vs Finite Element Method and Finite Volume Method solemnpriest Main CFD Forum 3 August 12, 2013 11:00
[ANSYS Meshing] Hex dominant method and local inflation carlp ANSYS Meshing & Geometry 8 July 12, 2012 08:02
Reversed Time Marching Method (RTMM) paillou FLUENT 0 July 12, 2011 06:45
use of MAC method to solve sloshing problem. S.R.SAHI Main CFD Forum 1 April 15, 1999 22:28


All times are GMT -4. The time now is 14:08.