if statement in g-file
Hello!
I would like to set the gravitation g in my simulation in the first 0.5 seconds to (0,0,0). Aftwerwards it should switch to (0,0,9.81). I tried it by the us of an if-statement in my g-file with Code:
if(runTime<0.5) |
I'm afraid you can't use code in OpenFOAM dictionaries, at least in most of them. What you could do instead is run your simulation with value (0 0 0); for 0.5 sec., then change your gravitiy to value (0 0 -9.81); and resume your simulation.
Disclaimer: I'm not sure if the following idea works, it's really just a quick idea: If you dont want to stop/resume your simulation you could try setting g in its dictionary to value (0 0 0);. Then use a vectorSource in fvOptions,choose selectionMode all; and add a startTime and duration to the source. |
Thank you very much for your helo and the quick answer! I will try to apply your proposed solution!
|
simply use the timeactivatedfileupdate functionObject. Add this to your controlDict (requires a recent version of OF) and create two files g.A and g.B with the desired values.
Code:
functions |
Thank you very much Bloerb!
|
Hello,
i have just one question concerning the code above. What does -1 in Code:
timeVsFile And what does 1 in Code:
writeInterval 1; Thanks in advance! |
instead of -1 you could use 0. The update function object reads in the current time. And once your time is bigger than the listed value it replaces the file. At the start of your simulation (t=0) you are already above (t=-1) hence your g file is replaced with g.A.
These two lines are probably not needed. They state though, that this function object should execute its write function every time step. The write function here is the one replacing the file. Code:
writeControl timeStep; |
Thank you very much for the answer!
|
All times are GMT -4. The time now is 00:42. |