Confused about how OF handles operation between volScalarField and dimensionedScalar
I created two fields volScalarField called Tsub and B. They both have the dimension dimTemp. Tsat is a dimensionedScalar read from the transportProperties and has the dimension dimTemp as well. In substance, I implemented this simple thing :
const dimensionedScalar BCons = 0.5/(1.0-rhoa/rhob);
//BCons is actually dimensionless
volScalarField Tsub = TsatField - Tb;
B[iCell] = Tsub[iCell]*BCons;
But i got this error message while compiling :
"error: cannot convert ‘Foam::dimensioned<double>’ to ‘double’ in assignment"
Could someone explain me what is wrong here?
Thanks a lot,
Accessing Tsat and B using cell labels gives you the raw values, which are double, not dimensionedScalar. So to work like this you will need BCons.value(). And I think B = TSub * BCons should work too.
ok, thanks a lot, thats clear now. Got stucked the whole day because of that... :)
I wanted to do simply B = Tsub * BCons in the beginning but this assignment is in reality done within an if-scope whose argument in the if-test is Tsub as well and I would like to modify the variable Tsub within this scope too; i.e :
if (Tsub < 2.0)
B = Tsub * BCons
// code lines
Tsub = 4.0 // for example
But OF requires references to const volScalarfield as arguments of the if-test, which means that I would not be able to modify Tsub.
I was adviced to do it component-wise to avoid this problem but if you have any other idea, please let me know.
As I said, if you need to do it component-wise, use BCons.value() to get a double out of your dimensionedScalar. I'd do it the that way.
|All times are GMT -4. The time now is 19:25.|