CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   lookupObject (https://www.cfd-online.com/Forums/openfoam-solving/103238-lookupobject.html)

nimasam June 14, 2012 11:22

lookupObject
 
Hi dear foamer
i need to read runTime from main solver in a class, i tried to use the following implementation:
const Time& runTime = alpha1_.db().lookupObject<Time>("runTime");

it compiles fine, but when it runs it gives the following error:

request for time runTime from objectRegistry region0 failed
available objects of type time are

0
(
)

now:
How can i resolve this error?
and better question :D How i can read runTime.deltaT() in subclass from solver.C ?

Best Regards

mturcios777 June 14, 2012 14:07

In chemistryModel and other classes, I've seen time access handled through the mesh, like mesh.time().timeName(). Its been a while before I looked at it, but I think that mesh is a part of that class (referencing a previously created mesh.

nimasam June 15, 2012 09:28

yep, it works ;)
Code:

dimensionedScalar deltaT = U.mesh().time().deltaT();

mturcios777 June 15, 2012 12:23

Awesome, glad it works.


All times are GMT -4. The time now is 02:03.