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

Accessing private variables

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 27, 2011, 02:44
Default Accessing private variables
  #1
New Member
 
Robert Maier
Join Date: Apr 2011
Posts: 9
Rep Power: 15
robertmaier9 is on a distinguished road
Hello,

I'm still quite new to OpenFOAM. Maybe someone can help me? I'm making a variation on the interFoam solver. I'd like to use the nHatfv variable calculated in the interfaceProperties.C code. This information is private, however. Is there a way to access this yet, or must I simply rewrite the portion of the code to get what I want?

Thanks!

Robert
robertmaier9 is offline   Reply With Quote

Old   May 27, 2011, 05:28
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by robertmaier9 View Post
Hello,

I'm still quite new to OpenFOAM. Maybe someone can help me? I'm making a variation on the interFoam solver. I'd like to use the nHatfv variable calculated in the interfaceProperties.C code. This information is private, however. Is there a way to access this yet, or must I simply rewrite the portion of the code to get what I want?

Thanks!

Robert
Not legally. The only way involves "#define class struct","#define private protected" before the include and most of the time that doesn't work.

So rewrite the model or make a bug-report requesting that variable to be moved to the protected stuff
gschaider is offline   Reply With Quote

Old   May 27, 2011, 07:10
Default
  #3
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 17
r08n is on a distinguished road
There is a public function interfaceProperties::nHatf (). Can it be of any help?
r08n is offline   Reply With Quote

Old   May 30, 2011, 03:14
Default
  #4
Member
 
Robertas N.
Join Date: Mar 2009
Location: Kaunas, Lithuania
Posts: 53
Rep Power: 17
r08n is on a distinguished road
And I forgot to mention this: http://en.wikipedia.org/wiki/Visitor_pattern
r08n is offline   Reply With Quote

Old   May 30, 2011, 07:06
Default
  #5
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by r08n View Post
There is a public function interfaceProperties::nHatf (). Can it be of any help?
That "only" gives you back a const reference so officially you can't modify the field. There is a workaround ... but you havn't got this from me and don't ask further .... google for const_cast
gschaider 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
Accessing other variables in defining boundary condition Cynthia Poon OpenFOAM Running, Solving & CFD 1 September 27, 2021 06:28
$FOAM_USER_APPBIN & LIBBIN variables not set rassilon OpenFOAM Installation 2 February 16, 2010 20:54
Accessing Variables from Previous Timestep Vinayak Barve FLUENT 1 March 10, 2004 07:40
PHI file structure Eugene Phoenics 9 November 2, 2001 22:00
Saving variables on a user patch with physical coordinates Zoltan Turzo CFX 2 April 20, 2000 15:05


All times are GMT -4. The time now is 22:09.