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/)
-   -   What's the reason of two turbulencemodels folder? (https://www.cfd-online.com/Forums/openfoam-programming-development/131841-whats-reason-two-turbulencemodels-folder.html)

lakeat March 21, 2014 14:28

What's the reason of two turbulencemodels folder?
 
What's the reason of two turbulenceModels folder? What's the philosophy behind this new folder restructuring?

wyldckat March 21, 2014 15:06

Hi Daniel,

I'd like you to meet the Release Notes for OpenFOAM 2.3.0: http://www.openfoam.org/version2.3.0/ :D

Now, when you get to the "Multiphase" page: http://www.openfoam.org/version2.3.0/multiphase.php - you'll find the section "Multiphase Turbulence" after a bit of reading. There everything is mostly explained.

Beyond that, what I can say is this (actually, mostly just rant about how great it is ;)): OpenFOAM is chock-full with C++ templates, so much that at this point in time, the flag "template-depth" is set to 100! https://github.com/OpenFOAM/OpenFOAM...c48/c%2B%2B#L9

The advantage of this is that it allows us to easily (i.e., after we understand how templates in OpenFOAM work):
  • Add new derived boundary conditions. Example: 1 single template class can be used to work with any fields that are of type scalar, vector and mostly any kind of tensor! Instead of having to manually code 5 or 8 classes per boundary condition, or instead of having to use hacks with "#define".
  • Extend thermodynamic modelling, which allows us to easily add a new specie model, a new chemistry model... and I forgot what else. Basically, remember when the thermodynamic models were defined like this: http://www.openfoam.org/version2.2.0/thermophysical.php
    Code:

    thermoType hPsiThermo<pureMixture<constTransport<specieThermo<hConstThermo<perfectGas>>>>>;
    There was actually the full template structure for the thermodynamic model in question. That combo of template classes was actually compiled as a single monolithic class, done by the compiler, and fully optimized by the same compiler. And in OpenFOAM, it's sometimes fully embed into any and all files that include the header file for a template class. Result: to get the utmost performance out of your solvers.
  • And now: Turbulence! It's probably now somewhat easy to add a hyper-sonic-combustion-with-200-different-species or more and with any turbulence model using RANS or LES :rolleyes: OK, I am exaggerating on purpose :D
Any questions? :)

Best regards,
Bruno

lakeat March 21, 2014 15:24

Thanks! But with all due respect, I still feel putting two identical names (except letter "T") under the same src/ folder is not a good idea.

wyldckat March 21, 2014 16:18

Quote:

Originally Posted by lakeat (Post 481343)
Thanks! But with all due respect, I still feel putting two identical names (except letter "T") under the same src/ folder is not a good idea.

It's how OpenFOAM is coded. In other words, it's as old as its own origins in FOAM.

If you have a look into the folder "src/OpenFOAM/lnInclude", you'll see several files that only differ in the case of the first letter. The simplest is "Vector.H" vs "vector.H".
It's due to nomenclature used in OpenFOAM:
  • When the first letter is upper case, it's a C++ Template class.
  • When the first letter lower case, then it's a normal C++ class.
Ever wonder why the file extensions don't end in "h" and "cpp", but instead "H" and "C"? I think it's due to a particular standard, but essentially it means that "C" is for C++ and "c" is for plain C language.

My belief is that is this way, in order to make it perfectly clear to those who look at OpenFOAM: every single detail, no matter how small, is more important than one is willing to believe.


Of course that once we start delving into OpenFOAM's inner workings, we start finding class files that are not abiding to this nomenclature, because they belong to the "fvc" namespace. Or because the model is the name of the author(s) of said model. Details, details, details... it's all about the details :rolleyes:

But let's face it:
  • "cvector.cxx" or "cvector.cpp" is ugly.
  • "vector.C" is pretty :)


Ah, then there's another issue you might find out sooner or later: did you know that there are files in OpenFOAM's source code that have the same identical name, but don't even belong in different namespaces, even though they are meant for different features? Here's some examples I can remember+find:

lakeat March 21, 2014 16:23

I am 100% okay with files (you explained it very well), but as top-level source folders under src/, hmm, sorry, I just can't get it, I don't think it's a good practice. :)

wyldckat March 21, 2014 16:31

Mmmm... Then you're OK with this?
Code:

ls -A1 $FOAM_SRC/thermophysicalModels/specie/reaction/

reactionRate
reactions
Reactions

:)

lakeat March 21, 2014 16:38

4th level, let them. But as a top level folder, it does not look very "organized". Sorry, maybe it's just my personal opinion, :)

wyldckat May 25, 2014 19:05

Hi Daniel,

Just a mild update on this topic: if I interpreted correctly a comment on the bug tracker sometime ago, it seems that the old "turbulenceModels" folder may be deprecated in future releases, as soon as they are able to port everything to the new template mechanism. If my memory doesn't fail me, the comment in question is the last one here: http://www.openfoam.org/mantisbt/view.php?id=1259

Best regards,
Bruno


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