CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Confused about how OF handles operation between volScalarField and dimensionedScalar

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 30, 2010, 07:40
Default Confused about how OF handles operation between volScalarField and dimensionedScalar
  #1
Edy
Member
 
Join Date: Sep 2010
Posts: 35
Rep Power: 15
Edy is on a distinguished road
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
Edy is offline   Reply With Quote

Old   September 30, 2010, 08:23
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
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.
akidess is offline   Reply With Quote

Old   September 30, 2010, 09:45
Default
  #3
Edy
Member
 
Join Date: Sep 2010
Posts: 35
Rep Power: 15
Edy is on a distinguished road
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
Edy is offline   Reply With Quote

Old   September 30, 2010, 10:07
Default
  #4
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
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.
akidess is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 02:07.