|
[Sponsors] |
How to change the value of an argument of an if-test within the if-scope |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 29, 2010, 04:57 |
How to change the value of an argument of an if-test within the if-scope
|
#1 |
Member
Join Date: Sep 2010
Posts: 35
Rep Power: 15 |
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 |
|
September 29, 2010, 07:04 |
|
#2 |
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 17 |
Hi Edy,
you have to do the change element-wise: Code:
forAll(Tsub, iCell) { if (Tsub[iCell] <= 0.05) { Tsub[iCell] = 0.0; } } Stefan |
|
September 29, 2010, 08:25 |
|
#3 |
Member
Join Date: Sep 2010
Posts: 35
Rep Power: 15 |
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! |
|
September 30, 2010, 07:11 |
|
#4 |
Member
Join Date: Sep 2010
Posts: 35
Rep Power: 15 |
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 |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Compile calcMassFlowC | aurore | OpenFOAM Programming & Development | 13 | March 23, 2018 07:43 |
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 | 113 | December 2, 2009 10: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 |