CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Accessing private variables (http://www.cfd-online.com/Forums/openfoam-programming-development/88826-accessing-private-variables.html)

robertmaier9 May 27, 2011 02:44

Accessing private variables
 
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

gschaider May 27, 2011 05:28

Quote:

Originally Posted by robertmaier9 (Post 309448)
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

r08n May 27, 2011 07:10

There is a public function interfaceProperties::nHatf (). Can it be of any help?

r08n May 30, 2011 03:14

And I forgot to mention this: http://en.wikipedia.org/wiki/Visitor_pattern

gschaider May 30, 2011 07:06

Quote:

Originally Posted by r08n (Post 309491)
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


All times are GMT -4. The time now is 12:41.