function within solver
Hi Foamers,
I was wondering about a defintion of a little function within a solver. If I, for example, want to calculate the square of x in a function within a solver it would look like this: Code:
scalar xsquare Any advises? Thanks in advance! |
Did you try putting them in front of "int main()"? If I remember correctly, functions are always defined outside the main program. createFields.H is included in the main program.
|
Good hint, but then I need to set the namespace correctly, right?
Code:
interFoam.C:57:4: warning: type qualifiers ignored on function return type [-Wignored-qualifiers] thanks! |
The only other hint I can give you, is to put it below other includes like fvCFD.H, but probably you tried that.
|
Yes, what I did was
Code:
#include "fvCFD.H" Greetings |
In that case you can try Foam::scalar instead of just scalar, but I am absolutely not sure about that. Good luck!
|
Yeah, tried several of these combinations, but unsuccessfully. I got to understand that, otherwise it's just trial and error..
|
Hey all,
This is how I would do it. Add Code:
scalar xsquare(const scalar& x); This way you can simply add your function at the bottom of the file so after the } of int main. But you should remove the 'const' after the (const scalar& x). So the function becomes: Code:
scalar xsquare(const scalar& x) |
Thank you! Just works :)
Greetings |
All times are GMT -4. The time now is 18:30. |