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/)
-   -   what is useUserTime flag in function objects? (https://www.cfd-online.com/Forums/openfoam-solving/253659-what-useusertime-flag-function-objects.html)

NotOverUnderated December 21, 2023 14:57

what is useUserTime flag in function objects?
 
Hi,

In function objects, there is a flag 'useUserTime'.

Could you please explain what does thid flag do? what is its purpose? Any examples to clarify this are appreciated.

Regards

olesen January 4, 2024 03:52

Did you already read the documentation note on writeFile.H ?

Tobermory January 4, 2024 04:30

This may save you some time in the future, and allow you to avoid pointless posts ;).
1. Open up Doxygen (you are using the ESI version, I think, so that would be https://www.openfoam.com/documentati...doc/index.html).
2. Type in the thing that you are searching for in the search box, i.e. useUserTime here; if it finds the search item, a drop down of hyperlink(s) will appear with all items starting with your string - click on the appropriate one
3. this will open up the Doxygen pages for the thing you are searching for.

In other words, within just a few seconds you would get:
Code:

bool useUserTime_
protected
Flag to use the specified user time, e.g. CA deg instead of seconds. Default = true
Definition at line 152 of file writeFile.H.

which would give you a high level description and tell you to go look in writeFile.H, as Mark suggested.

Doxygen can be a bit clunky sometimes, but is your key to unlocking the mysteries of OF! Good luck and Happy New Year!

NotOverUnderated January 4, 2024 04:41

Quote:

Originally Posted by Tobermory (Post 862567)
This may save you some time in the future, and allow you to avoid pointless posts ;).
1. Open up Doxygen (you are using the ESI version, I think, so that would be https://www.openfoam.com/documentati...doc/index.html).
2. Type in the thing that you are searching for in the search box, i.e. useUserTime here; if it finds the search item, a drop down of hyperlink(s) will appear with all items starting with your string - click on the appropriate one
3. this will open up the Doxygen pages for the thing you are searching for.

In other words, within just a few seconds you would get:
Code:

bool useUserTime_
protected
Flag to use the specified user time, e.g. CA deg instead of seconds. Default = true
Definition at line 152 of file writeFile.H.

which would give you a high level description and tell you to go look in writeFile.H, as Mark suggested.

Doxygen can be a bit clunky sometimes, but is your key to unlocking the mysteries of OF! Good luck and Happy New Year!

Dear Tobermory, Thank you very much for your reply. Sorry I didn't mention that I have searched the documentation, and I have even checked the source code.

But the description does not make sense for me at all.

The short description says: "... to use the specified user time..": What is a user time? how can I specify it?
Also in the description: "CA deg instead of seconds": What is CA deg?????

You can see clearly that this description does not make sense without context, that's why I have asked for clarification and examples.


Best regards

NotOverUnderated January 4, 2024 04:43

Quote:

Originally Posted by olesen (Post 862565)
Did you already read the documentation note on writeFile.H ?

Thank you for your reply. Yes, I have checked the documentation, but unfortunately it is not clear. An example showing how to use this flag in practice would be much helpful.

Thank you.

Tobermory January 4, 2024 05:03

Aaah - well, now that's a much better question. "CA" stands for crank angle and comes from the development of engineFoam I believe (correct me Mark if I am wrong).

The userTime is whatever you want it to be ... it suggests degrees in the header, but it could be anything. To see what the useUserTime flag does, take a look at writeFile.C, where you'll see:

Code:

        if (useUserTime_)
        {
            timeValue = fileObr_.time().timeToUserTime(timeValue);
        }
 
        const word timeName = Time::timeName(timeValue);

So now you need to hunt down timeToUserTime, which is defined as a virtual function in TimeState.H, although it seems clear what it's doing - it constructs the name of the time folder from the simulation time and the timeToUserTime function. In other words, the intent is that you generate your own version of the time class with its own version of the timeToUserTime function, and this allows you to name the time folders in a more logical fashion (eg crank angle setting).

If you really want to dig into it, I suggest starting with https://www.openfoam.com/documentati...9ee65af8a.html ... and in particular https://www.openfoam.com/documentati...8C_source.html where you'll see the above being implemented. I found this pretty quickly with a command line grep command.

Good luck again.

NotOverUnderated January 4, 2024 06:01

Quote:

Originally Posted by Tobermory (Post 862573)
Aaah - well, now that's a much better question. "CA" stands for crank angle and comes from the development of engineFoam I believe (correct me Mark if I am wrong).

The userTime is whatever you want it to be ... it suggests degrees in the header, but it could be anything. To see what the useUserTime flag does, take a look at writeFile.C, where you'll see:

Code:

        if (useUserTime_)
        {
            timeValue = fileObr_.time().timeToUserTime(timeValue);
        }
 
        const word timeName = Time::timeName(timeValue);

So now you need to hunt down timeToUserTime, which is defined as a virtual function in TimeState.H, although it seems clear what it's doing - it constructs the name of the time folder from the simulation time and the timeToUserTime function. In other words, the intent is that you generate your own version of the time class with its own version of the timeToUserTime function, and this allows you to name the time folders in a more logical fashion (eg crank angle setting).

If you really want to dig into it, I suggest starting with https://www.openfoam.com/documentati...9ee65af8a.html ... and in particular https://www.openfoam.com/documentati...8C_source.html where you'll see the above being implemented. I found this pretty quickly with a command line grep command.

Good luck again.


Nice explanation :)

Assuming that I understand that and it does what I think it does, I wonder how I can use this in my simulations. Is there a minimal tutorial where this is used? can I use it with pimpleFoam? how?

Tobermory January 4, 2024 07:01

Quote:

Originally Posted by NotOverUnderated (Post 862575)
Nice explanation :)

Assuming that I understand that and it does what I think it does, I wonder how I can use this in my simulations. Is there a minimal tutorial where this is used? can I use it with pimpleFoam? how?

No - I don't think so - it's a much more fundamental feature, and you would have to build it into a bespoke solver, including your own definition of the time class etc. This probably means redefining a whole bunch of classes ... but that's just speculation on my part, I haven't researched it fully. The engineFoam solver that I pointed you to gives you an idea of the effort involved.


All times are GMT -4. The time now is 13:18.