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

How to change the value of an argument of an if-test within the if-scope

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   September 29, 2010, 04:57
Default How to change the value of an argument of an if-test within the if-scope
  #1
Edy
Member
 
Join Date: Sep 2010
Posts: 35
Rep Power: 6
Edy is on a distinguished road
Hi,

I have a problem which is probably very simple to solve.
In my program, I would like to change, within an if-scope, the value of the variable used in the if-test.
Basically, what i want to do looks like this :

volScalarField Tsub = Tsat - Tb;
if (Tsub <= 0.05)
{
Tsub = 0.0;
}

BHowever, OpenFOAM operator<= should normally take references to constant volScalarField as arguments. But then I cannot modify these arguments within the if-scope...

Thanks in advance.


/Edouard
Edy is offline   Reply With Quote

Old   September 29, 2010, 07:04
Default
  #2
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 8
herbert is on a distinguished road
Hi Edy,

you have to do the change element-wise:

Code:
 forAll(Tsub, iCell)
{
    if (Tsub[iCell] <= 0.05)
    {
        Tsub[iCell] = 0.0;
    }
}
Regards,
Stefan
herbert is offline   Reply With Quote

Old   September 29, 2010, 08:25
Default
  #3
Edy
Member
 
Join Date: Sep 2010
Posts: 35
Rep Power: 6
Edy is on a distinguished road
Hi Stefan,

It works. It was obviously something quite easy but I am still not very familiar with OF, i just started few days ago and have a lot to learn.

Vielen Dank!
Edy is offline   Reply With Quote

Old   September 30, 2010, 07:11
Default
  #4
Edy
Member
 
Join Date: Sep 2010
Posts: 35
Rep Power: 6
Edy is on a distinguished road
Hi,

One more question.
Tsub is defined as a volScalarField with the dimension of temperature. Is it licit to write a test as you wrote though the LHS has a dimension and the RHS is just a scalar: Or should i define a new temperature dimensioned variable equal to 2 for the RHS of the test?

Thanks
Edy is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile calcMassFlowC aurore OpenFOAM Programming & Development 12 March 18, 2014 05:22
checking the system setup and Qt version vivek070176 OpenFOAM Installation 22 June 1, 2010 12:34
Version 15 on Mac OS X gschaider OpenFOAM Installation 120 December 2, 2009 11:23
Installation OF1.5-dev ttdtud OpenFOAM Installation 46 May 5, 2009 02:32
How to get the max value of the whole field waynezw0618 OpenFOAM Running, Solving & CFD 4 June 17, 2008 05:07


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