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/)
-   -   Find List of Options for given dictionary key programmatically (https://www.cfd-online.com/Forums/openfoam-programming-development/203521-find-list-options-given-dictionary-key-programmatically.html)

u2berggeist June 29, 2018 17:30

Find List of Options for given dictionary key programmatically
 
So I'm working on a vim plugin for OpenFOAM that will hopefully provide some completion help.

To do that, I need a list of possible options for a given dictionary key. How can I access the available options easily and programmatically?

I've found a brute force way of doing it; misname a option and the error message will show the available options:

Code:

--> FOAM FATAL IO ERROR:
Unknown ddt scheme Eulers

Valid ddt schemes are :

8
(
CoEuler
CrankNicolson
Euler
SLTS
backward
bounded
localEuler
steadyState
)

While this works, I was wondering if there was a way to get it a bit more directly.

The way I see it, it could be done by two ways: either go through OpenFOAM to find it (ie. mangle around with C++ or use a builtin function that I don't know about) OR find out how it creates the list in the first place.

I've tried looking at the source code (look at "OpenFOAM/OpenFOAM-v1712/src/finiteVolume/lnInclude/ddtScheme.C" at line 76 for the code that created the output of the above example), but I have no experience in C++ (or any statically typed language for that matter) and have had a very difficult time figuring it out.

Any help would be greatly appreciated!

u2berggeist July 3, 2018 12:32

Update on the "How do they know whether an option is available?" problem; The list that is output through the error message comes from a runTimeSelectionTable.

Now my question turns to how can I access said runTimeSelectionTable?


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