CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Units within the source code (https://www.cfd-online.com/Forums/openfoam/60729-units-within-source-code.html)

harly December 5, 2008 15:29

Hi, I was wondering how one
 
Hi,

I was wondering how one can assign a dimension (units) to a variable in the source code.

I want to specify a time for example - how would I define the variable to be able to calculate with the units ?

thanks
harly

jaswi December 5, 2008 19:20

Hi Daniel Please use: di
 
Hi Daniel

Please use:

dimensionedScalar
dimensionedVector

etc for this purpose. OpenFOAM uses a SI Units based dimensionset
[mass length time temp etc etc etc] - don't remember all of the names.

So a dimension less scalar has [0 0 0 0 0 0 0] as the dimension set

A dimesionedScalar should have a value and dimension. Taking your problem of defining the time with units:

dimensionedScalar myTime
(
"myTime",
dimensionSet(0 0 1 0 0 0 0),
0.0
)

Hope that helps. Also please try some forum browsing if your problem is not what I explain here.

Kind Regards
Jaswi

harly December 5, 2008 19:49

Hi, thanks for the answer -
 
Hi,

thanks for the answer - do I have to include sth. or do I have to define this in a special place because I am getting an error and I cannot understand what the mistake is.

I just copied your example and wanted to display myTime, but it won't compile.

thanks

jaswi December 7, 2008 16:44

Hi Daniel It will help the
 
Hi Daniel

It will help the forum to provide any feedback if you will please either post the error or the code which gives you error so that one could figure out if any of the header files to be included are missing

Kind Regards
Jaswi

harly December 7, 2008 17:33

Hi, yes you are right that
 
Hi,

yes you are right that would make it a lot easier - I will have the possibility to upload it tomorrow - maybe you can have a look at it then.

thanks
- harly


All times are GMT -4. The time now is 06:26.