|
[Sponsors] |
Accessing old fields: lookupObject at user defined time |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 2, 2019, 13:41 |
Accessing old fields: lookupObject at user defined time
|
#1 |
New Member
Emily
Join Date: Nov 2017
Posts: 24
Rep Power: 9 |
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 |
|
October 3, 2019, 12:05 |
|
#2 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
Hello,
You can do it by using the function Code:
runtime.timeName() Code:
volScalarField Phi ( IOobject ( "Phi", runTime.timeName(0.7), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh ); |
|
October 3, 2019, 12:53 |
|
#3 |
New Member
Emily
Join Date: Nov 2017
Posts: 24
Rep Power: 9 |
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 |
|
October 4, 2019, 05:34 |
|
#4 |
Member
Fabien Robaux
Join Date: Oct 2016
Posts: 51
Rep Power: 10 |
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) { std::ostringstream buf; buf.setf(ios_base::fmtflags(format_), ios_base::floatfield); buf.precision(precision); buf << t; return buf.str(); } |
|
October 7, 2019, 08:10 |
|
#5 |
New Member
Emily
Join Date: Nov 2017
Posts: 24
Rep Power: 9 |
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. |
|
August 11, 2024, 19:20 |
|
#6 |
New Member
Join Date: Jan 2018
Posts: 19
Rep Power: 8 |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
courant number increases to rather large values | 6863523 | OpenFOAM Running, Solving & CFD | 22 | July 6, 2023 00:48 |
LES, Courant Number, Crash, Sudden | Alhasan | OpenFOAM Running, Solving & CFD | 5 | November 22, 2019 03:05 |
High Courant Number @ icoFoam | Artex85 | OpenFOAM Running, Solving & CFD | 11 | February 16, 2017 14:40 |
a reconstructPar issue | immortality | OpenFOAM Post-Processing | 8 | June 16, 2013 12:25 |
IcoFoam parallel woes | msrinath80 | OpenFOAM Running, Solving & CFD | 9 | July 22, 2007 03:58 |