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/)
-   -   Now really how to avoid the dimensions (https://www.cfd-online.com/Forums/openfoam-solving/59471-now-really-how-avoid-dimensions.html)

vitke August 29, 2007 07:38

Hi all I need to compute so
 
Hi all

I need to compute some material properties from empirical polynomial corelations depending on the temperature, like this: http://users.wpi.edu/~ierardi/PDF/air_cp_plot.PDF . I have the temperature in volScalarField. Of course, dimensions do not match. I want to strip the dimension, evaluate the polynomial, and then impose propper dimensions. At the moment I define a dimensionedScalar containing one Kelvin, divide teperature with it, and finally multiply everything with another dimensionedScalar containing 1 [ 0 2 -2 -1 0]. But this is so ugly, and probably also time consuming. Is there any better way?

hjasak August 29, 2007 07:51

First, dimensions are there fo
 
First, dimensions are there for your protection: it have saved my bacon more times than I care to remember.

Second, I bet you are doing something wrong. The internal field of the temperature field can be accessed without dimensions, eg.

volScalarField T(...);

scalarField& Tin = T.internalField();

forAll (Tin, cellI)
{
Tin[cellI] = blah blah, your polynomial;

}

This will not check the dimensions at all.

Third, dimension checking in OpenFOAM is done very carefully, to be executed only once for complete arrays and not for single values. Therefore, dimension checking basically costs you nothing in execution time.


However, if you do:

T = dimensionedScalar("fromPolynomial", dimTemperature, 77);

you are setting the WHOLE field to 77 and dimensions are checked. This will check the dimensions and basically cause trouble + the result will not be what you expect.

Clear?

Hrv

vitke August 29, 2007 14:14

Thanks Hrvoje for your answer.
 
Thanks Hrvoje for your answer. Dimensions are great, I agree, but those engineering "correlations" obtained by fitting a polynomial into experimental data showing dependence of material properties on temperature are based on adding grannies and frogs, if you know what I mean http://www.cfd-online.com/OpenFOAM_D...part/happy.gif.

So I use

Cp.internalField() = myPolynomial(T.internalField());

and it works great. This is just what I wanted. Thanks again!

gschaider August 29, 2007 16:31

Hi Dragan! What Hrv didn't
 
Hi Dragan!

What Hrv didn't point out to you is that you can switch off dimension checking for your installation completely: http://www.cfd-online.com/cgi-bin/Op...how.cgi?1/5281

He propably didn't tell you, because that would be like allowing children to run around with sharp knifes. I'm not such a responsible person, so I'm telling.

BTW: Don't know if it still works for 1.4. I never tried. My parents taught me not to run around with sharp knifes

hjasak August 29, 2007 16:49

You take the fun out of being
 
You take the fun out of being a grown-up... http://www.cfd-online.com/OpenFOAM_D...part/happy.gif At least now I know what you want for Christmas!

Thanks Bernhard, a complete answer is always a pleasure to see.

Hrv

vitke August 30, 2007 05:12

Thanks Bernhard! But I prefer
 
Thanks Bernhard! But I prefer to keep sharp knifes in their folders most of the time http://www.cfd-online.com/OpenFOAM_D...part/happy.gif

vitke August 30, 2007 07:25

Hi, me again. I noticed that i
 
Hi, me again. I noticed that if I only modify the internalField, the boundary field of my Cp is not modified (of course) and becomes inconsistent. I'm not quite sure that these boundary values won't be used somewhere, so I'd be happier to make them consistent. Do I have to compute the boundary field separately, or is there finally a way to switch off the dimensions checking in the code, do the computation, and switch it back again? Bernhard, the link that you sent to me referes to this page.

Dragan

hjasak August 30, 2007 07:35

It depends on what you want to
 
It depends on what you want to do:

- if you want to calculate the values by polynomials again, do the same as for internal field for all patches of the boundary field. You probably already have the "calculated" boundary condition so no problem there

- if you want to have the boundary value sate as the cell next to it, specify the zeroGradient patch field type for the Cp field at creation, calculate the internal field and call Cp.correctBoundaryConditions();

Enjoy,

Hrv

vitke August 30, 2007 08:58

Thanks Hrvoje. Dragan
 
Thanks Hrvoje.

Dragan


All times are GMT -4. The time now is 10:31.