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/)
-   -   How to access nuSgs from pisoFoam.C (https://www.cfd-online.com/Forums/openfoam-programming-development/112301-how-access-nusgs-pisofoam-c.html)

letzel January 25, 2013 11:45

How to access nuSgs from pisoFoam.C
 
Dear Foamers,

my task is to add a passive scalar transport equation to pisoFoam.C. Since this is to be run as LES, the subgrid-scale scalar flux is also required, for which I need nuSgs. I would like to know how to access nuSgs from the modified pisoFoam.C.

Compilation of pisoModified.C
Code:

...
        turbulence->correct();

        solve
        (
            fvm::ddt(s)
          + fvm::div(phi, s)
          - fvm::laplacian(nuSgs(), s)
          ==
          sSource
        );

        runTime.write();
...

gives the error message
Code:

pisoModified.C:135: error: ´nuSgs´ was not declared in this scope
I have tried a recommendation from 2009,
Code:

sgsModel->nuSgs()
but the error message then simply changes to
Code:

pisoModified.C:135: error: ´sgsModel´ was not declared in this scope
I would be grateful for any suggestions.

Marcus

Lieven January 25, 2013 17:01

Use
Code:

turbulence->nuSgs()
Have a look at createFields.H and try to understand why this works.

If I were you, I would also include a Schmidt-number in the laplacian...

Cheers,

Lieven

letzel January 26, 2013 09:44

Thank you for your advice, Lieven.

Changing
Code:

nuSgs()
to
Code:

turbulence->nuSgs()
yields the compilation error
Code:

pisoModified.C:135: error: ‘class Foam::incompressible::turbulenceModel’ has no member named ‘nuSgs’
I have then checked the list of class members, and as far as I understand, it should be fine if I reference nuSgs() from the class LESModel as
Code:

LESModel->nuSgs()
so that my code works with any LESModel. This, however, yields the old error message again:
Code:

pisoModified.C:135: error: ´LESModel´ was not declared in this scope
Where is my mistake?

Lieven January 26, 2013 10:50

Sorry, my mistake. U should use
Code:

turbulence->nut()
which will return nuSgs() in case of an LESModel.

Cheers,


Lieven

letzel January 27, 2013 14:15

This works, thank you, Lieven.

Now, probably my final question in this thread, I would like to know how I could have deduced this information by myself. If you are aware of a relevant post or documentation that teaches users how to proceed themselves in such cases, please kindly let me know. Of course, in the end it is a matter of personal OpenFOAM experience.

Lieven January 27, 2013 14:42

Well... it's probably a combination of experience and a lot of reading on this forum/pages found via Google/tutorials/...
e.g. I just saw for example that there is a similar discussion going on here:
http://www.cfd-online.com/Forums/ope...lent-flow.html

It will probably also help to read a bit about the principles of object oriented programming, and in particular about inheritance and it's implementation in C++ cause OF is simply filled with this.

The C++ Source Guide created by Doxygen (http://www.openfoam.org/docs/cpp/) is also a huge aid in understanding the OF source code structure so I advise you to try to familiarize yourself with it (e.g. try to find the solution I gave you using Doxygen).

Of course, if you still end up stuck, there is certainly no shame in posting something on this forum ;).

Cheers,

Lieven


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