|
[Sponsors] |
Confused about how OF handles operation between volScalarField and dimensionedScalar |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 30, 2010, 08:40 |
Confused about how OF handles operation between volScalarField and dimensionedScalar
|
#1 |
Member
Join Date: Sep 2010
Posts: 35
Rep Power: 16 |
Hi,
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 : volScalarField TsatField ( IOobject ( "TsatField", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, Tsat ); 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, Regards |
|
September 30, 2010, 09:23 |
|
#2 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
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.
|
|
September 30, 2010, 10:45 |
|
#3 |
Member
Join Date: Sep 2010
Posts: 35
Rep Power: 16 |
Hi,
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. Thanks again! Best |
|
September 30, 2010, 11:07 |
|
#4 |
Senior Member
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30 |
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.
|
|
|
|