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

Method flux(...) of FOAM::fvc namespace

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 1 Post By Bernhard
  • 1 Post By akidess
  • 1 Post By Bernhard

Reply
 
LinkBack Thread Tools Display Modes
Old   January 8, 2014, 07:40
Default Method flux(...) of FOAM::fvc namespace
  #1
Senior Member
 
Join Date: Jan 2012
Posts: 159
Rep Power: 6
maybee is on a distinguished road
When looking at the code of the following flux method

Code:
template<class Type>
   43 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
   44 flux
   45 (
   46     const surfaceScalarField& phi,
   47     const GeometricField<Type, fvPatchField, volMesh>& vf,
   48     const word& name
   49 )
   50 {
   51     return fv::convectionScheme<Type>::New
   52     (
   53         vf.mesh(),
   54         phi,
   55         vf.mesh().divScheme(name)
   56     )().flux(phi, vf);
   57 }
in line 56 an operator method () is called on the temporary object of type "fv::convectionScheme<Type>" (line 51).
Can someone tell me where to find the operator (), because in "fv::convectionScheme<Type>" I can't find them?

greetings
maybee
maybee is offline   Reply With Quote

Old   January 8, 2014, 08:02
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 13
Bernhard is on a distinguished road
Please correct me if I'm wrong.

The operator(), is not of the class fv::convectionScheme, but from the class of the return type of fvc::convectionScheme::New. I.e, of the class tmp<Type>, i.e.: http://foam.sourceforge.net/docs/cpp...ce.html#l00184

The reason it is there, is for some smart handling of pointers. For more info on the tmp class, you can read here http://openfoamwiki.net/index.php/OpenFOAM_guide/tmp
I think the operator() (which is called dereference operator), as far as I know makes sure the object becomes a "real" object, and not just a pointer to the object.

I hope this helps and I hope anyone can correct me if I made a conceptual mistake here
ngj likes this.
Bernhard is offline   Reply With Quote

Old   January 8, 2014, 15:21
Default
  #3
Senior Member
 
Join Date: Jan 2012
Posts: 159
Rep Power: 6
maybee is on a distinguished road
Hi,

1. So the "<Type>" within "fv::convectionScheme<Type>" in this case is "tmp" and therefore the operator () of class tmp is called?

2. Lets say 1. is true. When calling operator on

Code:
           fv::convectionScheme<Type>::New
           (
           vf.mesh(),
           phi,
           vf.mesh().divScheme(name)
            )
where Type is tmp, operator returns the geometricField within the tmp object?

3. Afterwards on the geometricField is called

Code:
 
virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > flux	
(	const surfaceScalarField&, 
const GeometricField< Type, fvPatchField, volMesh > &   pure virtual
)  const
with the description

Quote:
Implemented in gaussConvectionScheme< Type >, boundedConvectionScheme< Type >, and multivariateGaussConvectionScheme< Type >.
right? The method shown under 3. must return a tmp object since the first called method (See 1.) is of return type tmp?
maybee is offline   Reply With Quote

Old   January 9, 2014, 03:20
Default
  #4
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 13
Bernhard is on a distinguished road
Quote:
Originally Posted by maybee View Post
Hi,

1. So the "<Type>" within "fv::convectionScheme<Type>" in this case is "tmp" and therefore the operator () of class tmp is called?
No, the tmp is associated with the return type of the function New. This is not so exciting
See: src/finiteVolume/finiteVolume/convectionSchemes/convectionScheme/convectionScheme.C (line 57 for example).
Code:
tmp<convectionScheme<Type> > convectionScheme<Type>::New
My educated guess is that Type refers to scalar, vector, etc (it would make sense to define them for any type of variable, and it would not be in the OpenFOAM spirit if they use Type for other thing. I did not check it in the code, however.

Quote:
2. Lets say 1. is true. When calling operator on

Code:
           fv::convectionScheme<Type>::New
           (
           vf.mesh(),
           phi,
           vf.mesh().divScheme(name)
            )
where Type is tmp, operator returns the geometricField within the tmp object?
I don't know what you mean here. Basically you are just explicitly creating an object of class convectionScheme, of which you call the member flux(), which is probably redefined in a derived class, during the run-time-selection.

Quote:
3. Afterwards on the geometricField is called

Code:
 
virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > flux    
(    const surfaceScalarField&, 
const GeometricField< Type, fvPatchField, volMesh > &   pure virtual
)  const
with the description right? The method shown under 3. must return a tmp object since the first called method (See 1.) is of return type tmp?
Where did you find this code snippet?
Bernhard is offline   Reply With Quote

Old   January 9, 2014, 05:02
Default
  #5
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 1,130
Rep Power: 20
akidess will become famous soon enough
Quote:
Originally Posted by Bernhard View Post
Please correct me if I'm wrong.

The operator(), is not of the class fv::convectionScheme, but from the class of the return type of fvc::convectionScheme::New. I.e, of the class tmp<Type>, i.e.: http://foam.sourceforge.net/docs/cpp...ce.html#l00184

The reason it is there, is for some smart handling of pointers. For more info on the tmp class, you can read here http://openfoamwiki.net/index.php/OpenFOAM_guide/tmp
I think the operator() (which is called dereference operator), as far as I know makes sure the object becomes a "real" object, and not just a pointer to the object.

I hope this helps and I hope anyone can correct me if I made a conceptual mistake here
Just a minor remark: * is the dereference operator (also "->"). I don't think there is an official name for "()" in the context of the tmp-class, but I usually call it unpacking or stripping

[Edit] Bernhard wins this one, the comments in the code actually do refer to the operator as dereference: http://foam.sourceforge.net/docs/cpp...ad06354be9ca09
Bernhard likes this.
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
*Join the OpenFOAM stackexchange Q&A site: http://area51.stackexchange.com/prop...oHPxcPqde7HtA2
akidess is offline   Reply With Quote

Old   January 9, 2014, 12:01
Default
  #6
Senior Member
 
Join Date: Jan 2012
Posts: 159
Rep Power: 6
maybee is on a distinguished road
Quote:
Quote:
3. Afterwards on the geometricField is called

Code:

virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > flux
( const surfaceScalarField&,
const GeometricField< Type, fvPatchField, volMesh > & pure virtual
) const
with the description right? The method shown under 3. must return a tmp object since the first called method (See 1.) is of return type tmp?

Where did you find this code snippet?
Search for the flux(...) method I have posted in my first post -> see:

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

Afterwards just click at the second flux method within the flux method of the link, you will be forwarded to the flux method above.

Got the rest now. Thx for the help. Obviously I slept a little bit when looking at the code .

Last edited by maybee; January 9, 2014 at 13:26.
maybee is offline   Reply With Quote

Old   January 10, 2014, 03:08
Default
  #7
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 13
Bernhard is on a distinguished road
Quote:
Originally Posted by maybee View Post
Afterwards just click at the second flux method within the flux method of the link, you will be forwarded to the flux method above.
Too complicated instructions. Do you still have any questions about it? (Filename + linenumber or direct reference would be nicer )
akidess likes this.
Bernhard is offline   Reply With Quote

Old   January 10, 2014, 05:38
Default
  #8
Senior Member
 
Join Date: Jan 2012
Posts: 159
Rep Power: 6
maybee is on a distinguished road
Quote:
Too complicated instructions. Do you still have any questions about it? (Filename + linenumber or direct reference would be nicer )
Too complicated to click the link and afterwards the flux method in line 56 of the link?
I just wanted to show the way I had found the method to make sure it is the right one, but here we go:

http://foam.sourceforge.net/docs/cpp...071d0d5b6d6208
maybee is offline   Reply With Quote

Old   January 10, 2014, 06:44
Default
  #9
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 13
Bernhard is on a distinguished road
Quote:
Originally Posted by maybee View Post
Too complicated to click the link and afterwards the flux method in line 56 of the link?
I just wanted to show the way I had found the method to make sure it is the right one, but here we go:

http://foam.sourceforge.net/docs/cpp...071d0d5b6d6208
Well, it is very easy to look at the wrong piece of code. But is your question what flux function is actually called in the top code snipped (after the dereference operator)?
Bernhard is offline   Reply With Quote

Old   January 10, 2014, 06:54
Default
  #10
Senior Member
 
Join Date: Jan 2012
Posts: 159
Rep Power: 6
maybee is on a distinguished road
Hi,

the quesiton is solved. I just misinterpreted "fv::convectionScheme<Type>::New" and did not realize that the method is of type tmp, Therefore I was wondering what operator () is used.

greetings
maybee
maybee is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
chtMultiRegionFoam heat flux sailor79 OpenFOAM Running, Solving & CFD 0 September 27, 2013 08:08
Question about heat transfer coefficient setting for CFX Anna Tian CFX 1 June 16, 2013 06:28
Info on method of lines approach charlie ryan Main CFD Forum 2 August 9, 2007 11:06
UDS flux and boundaries Kasper Skriver FLUENT 0 April 18, 2006 08:36
Replace periodic by inlet-outlet pair lego CFX 3 November 5, 2002 21:09


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