|
[Sponsors] |
December 17, 2008, 08:12 |
Hi everyone,
Just a more '
|
#1 |
Senior Member
Frank Bos
Join Date: Mar 2009
Location: The Netherlands
Posts: 340
Rep Power: 18 |
Hi everyone,
Just a more 'general' C++ programming question. What is the best way to access private data member used in i.e. dynamicBodyFvMesh from your application, i.e. icoDyMFoam.C ? Regards, Frank
__________________
Frank Bos |
|
December 17, 2008, 10:08 |
Hi Frank,
private data are
|
#2 |
New Member
Daniel Conrad
Join Date: Mar 2009
Posts: 1
Rep Power: 0 |
Hi Frank,
private data are accessed via a public function, which returns the value of a private variable (by convention indicated with underscore: privateVariable_) or a reference (&privateVariable_) to it. Look through any .H file to look up you possibilities to access private data using function declared as public memberfunctions. dynamicBodyFvMesh is a meshtype and needed for the runTimeSelectionTable. Nevertheless it is derived from fvMesh. Goto src/finiteVolume/fvMesh.H to see your options. best regards, Daniel |
|
December 18, 2008, 04:02 |
Hi Frank,
Having seen your
|
#3 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Hi Frank,
Having seen your talk in Milano, I suspect that you're probably okay with C++ per se, but for your current question: if you need read-only access to a private member, just add a public const member to the header, eg. const foo& bar() const { return bar_; } and let the OpenCFD guys know that you need read access to the data for whatever reason so they can add it to the header for everyone. If you need write-access to the data member, you should either question if this is the correct approach at all, or if you actually need a derived class. If the latter is the case, it would be reasonable to provide a protected write-accessor so that your derived class can monkey with the data. One important note, however: be careful about mixing const/non-const and private/public declarations for the same member signature. If a non-const member is declared private and a const member of the same name and signature is declared public, the compiler cannot tell which one is meant when compiling your application. A simplified explanation: the first compiler pass just takes the best signature, but doesn't bother to work out if const access would have sufficed and you'll get lots of compiler complaints. |
|
May 5, 2018, 22:44 |
|
#4 | ||||
Member
|
Hello olesen,
I want to use incident radiation 'G' in my solver, which is also a private data in 'fvDOM.H'. In c++ code, it writes Quote:
Quote:
Quote:
Quote:
Now I have no idea. If you could give me some help? Best regards, Chengan |
|||||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
question on data access in parallel computation | wangrensong | FLUENT | 0 | January 7, 2009 04:24 |
UDF Data Access Macro | Woo Meng Wai | FLUENT | 0 | November 6, 2007 21:23 |
UDF's to access Postprocess data | ivor | FLUENT | 1 | December 15, 2003 11:07 |
access to FIDAP-internal data from within a UDF II | Ingo Meisel | FLUENT | 1 | April 23, 2001 12:47 |
access to FIDAP-internal data from within a UDF | Ingo Meisel | FLUENT | 0 | April 17, 2001 12:58 |