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/)
-   -   Run-time Code Compilation in controlDict (https://www.cfd-online.com/Forums/openfoam-programming-development/97005-run-time-code-compilation-controldict.html)

JNSN February 7, 2012 04:40

Run-time Code Compilation in controlDict
 
Hi Foamers,

I try to implement a variable time Step in the controlDict with the #codeStream directive based on the actual time. Something like
Code:

this->db().time().value()
produces the error massage "invalid use of ‘this’ in non-member function". Does anyone have an idea to get a reference to time?

Thanks and best regards,
Jan

lliyuu October 16, 2022 22:53

May I ask if you have solved this problem? I have also encountered this problem.

JNSN October 17, 2022 10:46

sorry, but It's has been to long, can't remember. But as far as I know, there is now a functionObject available to control the time step. May this is helpful for your requirements.



Best,
Jan

lliyuu October 17, 2022 21:08

Thank you very much for your help. I will try this method.

LongGe October 17, 2022 23:51

Quote:

Originally Posted by JNSN (Post 343073)
Hi Foamers,

I try to implement a variable time Step in the controlDict with the #codeStream directive based on the actual time. Something like
Code:

this->db().time().value()
produces the error massage "invalid use of ‘this’ in non-member function". Does anyone have an idea to get a reference to time?

Thanks and best regards,
Jan


Hi

Can't you access time() of db() with the following code?

const IOdictionary& d = static_cast<const IOdictionary&>(dict);
scalar t = d.db().time().value();

lliyuu October 19, 2022 04:15

2 Attachment(s)
Thank you very much for your help. I'm a novice. I've tried this method. It works. Why?
I can use scalar t=this ->db(). time(). value() in the u file;
However, it is not allowed in the coalcloudproperties file.
In addition, vectorField&field=* this; The same problem will arise.
Thanks and best regards,
liyuu

lliyuu October 24, 2022 05:23

2 Attachment(s)
Quote:

Originally Posted by LongGe (Post 837710)
Hi

Can't you access time() of db() with the following code?

const IOdictionary& d = static_cast<const IOdictionary&>(dict);
scalar t = d.db().time().value();

Thank you very much for your help. I'm a novice. I've tried this method. It works. Why?
I can use scalar t=this ->db(). time(). value() in the u file;
However, it is not allowed in the coalcloudproperties file.
In addition, vectorField&field=* this; The same problem will arise.
Thanks and best regards,
liyuu


All times are GMT -4. The time now is 18:00.