CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How to get the case nameroot outside main (http://www.cfd-online.com/Forums/openfoam-solving/59687-how-get-case-nameroot-outside-main.html)

normunds May 16, 2007 09:41

Hello! I would like to apol
 
Hello!

I would like to apologize for rather
simple question,also
my apologies if this is already
answered somewhere.

My problem is - I need to know the case
name and root directories outside the main()
function, in some of .C files where I
would like to define more complex boundary conditions.

I can use global variables in file with
main() function, something like

#include"fvCFD.H"

...

argList* global_args;

...

main(int argc, char **argv) {
#include"setRootCase.H"
...
global_args = &args;
...
}

and than in an other file

extern argList* global_args;


however it looks for me a bit ugly. Is here
an other way arround, something like functions

global.getCaseName()
global.getRoot()

accessible from anywhere without
modification of main() body?

Is it possible to read transport
properties in a similar way, I must have mesh
for it's constructor, how to get it?

Thank you in advance!

/Normunds

eugene May 17, 2007 13:13

runTime.caseName() runTime.ro
 
runTime.caseName()
runTime.rootPath()

Check Time.H in src/OpenFOAM/lnInclude/

normunds May 18, 2007 05:31

Thank you Eugene for your answ
 
Thank you Eugene for your answer!


however, in my case it gives

error: 'runTime' was not declared in this scope

My file (globalTest.C)

***************************

#include"fvCFD.H"
#include"Time.H"
#include"GlobalTest.H" // my code with class globalTest definition


globalTest::globalTest() {
Info << runTime.caseName() << endl;
}


**************************

may be I have to include some header
file with global runTime identifier declaration?

perhaps, I can ask my question in more exact
manner -

is inside OpenFoam source any
way how to access global case information
without remembering variables
(ones which holds case name, mesh, etc) on creation by myself?
Is here some globally accessible register
or whatever in which these unique things
(by meaning one per application)
are automatically remembered when I create
them?


sincerely

/normunds


All times are GMT -4. The time now is 17:40.