CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Access simulation time in dictionary expression (https://www.cfd-online.com/Forums/main/238250-access-simulation-time-dictionary-expression.html)

Kraneberger September 1, 2021 10:28

Access simulation time in dictionary expression
 
Hello everyone,


I am trying to define a a time dependent rotation axis in my dynamicMeshDict. I think I also found the right tools here: https://www.openfoam.com//documentat...on-syntax.html


In my dynamicMeshDict I now want to define axisy as:



FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object dynamicMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

axisx 0;
axisy #eval "time()";
axisz 1;
...



Upon running pimpleFoam this gives me the error:


Object time does not exist or wrong type in expression
<<<<
time()
>>>>


When I instead use "pi()" instead of "time()" it correctly sets axisy to 3.141 etc. In the documentation it says about the "time()"-function:


time() : the current simulation time-value (if used by the parser)


So maybe it has something to do with the parser? I wouldn't know how to change that, though. Does anybody know what to do and could help me? Thanks in advance.



Greetings,
Kraneberger

LuckyTran September 1, 2021 17:44

PI() is a mathematical function in the math library which is linked in almost every compiled solver. This is like trying to do 2*1.

time() tries to retrieve the Foam::Time object, the variable that stores the time that you want, which isn't even created until runtime and is associated with a mesh object or a field object. E.g. mesh.time()

You are trying to make a declaration in a dict. Unfortunately I don't know enough about any of the DyM solvers to fix your issue.

Kraneberger September 2, 2021 02:18

I see, thanks for the quick answer. Is there a way to include or create a Foam object that I could then call *.time() on. For example with #codeStream?



I am using v2012.



Greetings,
Kraneberger


All times are GMT -4. The time now is 06:31.