CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Inherit debug value in derived class? (https://www.cfd-online.com/Forums/openfoam-programming-development/165120-inherit-debug-value-derived-class.html)

pbachant January 10, 2016 10:08

Inherit debug value in derived class?
 
Is there a way to do this? I have slight variations of a model that I would like to be able to turn on debugging for by "flipping" the switch of the base class.

wyldckat January 10, 2016 17:18

Hi Pete,

An example would make it easier to give a counter example and to test it to be certain of it...
Anyway, in theory, simply use the usual "access methods and variables from the parent class by calling it directly". For example, if you have something that is somehow derived from "fvPatchField", you should be able to simply do:
Code:

fvPatchField::debug = 1;
Best regards,
Bruno

pbachant January 10, 2016 22:56

Thanks for your insight Bruno!

This seems to suit my needs (inside constructor for derived class):

Code:

    if (not debug and baseClass::debug)
    {
        debug = baseClass::debug;
    }


pbachant January 11, 2016 08:19

There is an issue with using this method, however. You can turn on debugging using the switch for the base class, but you can't turn it off.


All times are GMT -4. The time now is 19:20.