Accessing old fields: lookupObject at user defined time
Hi all,
I would like to look up an object (e.g. U) from a user-defined time previously. I cannot hard code this as the number will change from simulation to simulation. If I am to define this number N, in a constant/*Properties file, then I would like to define something like lookupObject<volVectorField>("U") (at time: current time - N). For example, say the current time is 1s, then I would like to lookup the velocity field at 0.7s by using current time (1) minus user-defined time, N (in this case, N=0.3). Does anyone know how I can do this? Thank you, Emily |
Hello,
You can do it by using the function Code:
runtime.timeName() Code:
volScalarField Phi |
Hi,
Thanks for your reply. I should have mentioned that I am trying to write a functionObject so I don't think I can use runTime. I can however use some variant of obr_.time().something . Do you know if can get the equivalent of runTime.timeName(0.7) using obr_.time()? Thanks |
Well, I'm sorry I don't know. I'm not familiar at all with the functionObjects.
What is the type of obr_? The function Foam::Time::timeName() is pretty simple, maybe it would be possible to recode it. The only problem would be the label "precision", which describe the maximum number of decimals. Note that this precision is set at the begining then updated if needed in order to discernate the differents results. Code:
Foam::word Foam::Time::timeName(const scalar t, const int precision) |
I figured out how to do it using obr_.time().timeName(0.7) in case anyone else comes across this problem.
Thanks again for your help. |
All times are GMT -4. The time now is 08:06. |