|
[Sponsors] |
June 24, 2015, 07:53 |
How to use if statement in openFoam solver?
|
#1 |
Senior Member
Hesam
Join Date: Feb 2015
Posts: 139
Rep Power: 11 |
Hi friends,
I want to add if statement to openfoam solver : if (Re > 1000) { CD=24/Re; } else { CD=0.44; } But I can't implement it!!! error is : calcVdj.H: In function ‘int main(int, char**)’: calcVdj.H:30:21: error: no match for ‘operator>’ in ‘Re > 1.0e+3’ calcVdj.H:30:21: note: candidates are: |
|
June 29, 2015, 10:25 |
|
#2 |
Senior Member
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 15 |
This is not very detailed, but maybe you have a type problem. Re must be e.g. of type scalar.
You can add a line upfront: scalar Ree = Re; Replace all your Re by Ree. Look at the compilation error. Openfoam will tell of which type Re is (e.g. it has dimensions). Regards, Daniel |
|
July 14, 2015, 09:57 |
|
#3 | |
Member
Bruno Blais
Join Date: Sep 2013
Location: Canada
Posts: 64
Rep Power: 13 |
Quote:
As the variable Re been defined as a scalar (or at least a double?) It is not a per-default variable of the solver so you need to define it. The operator > is defined for the scalar type... |
||
July 14, 2015, 12:26 |
|
#4 | |
Senior Member
Hesam
Join Date: Feb 2015
Posts: 139
Rep Power: 11 |
Quote:
thank you. |
||
August 3, 2015, 13:26 |
how to assign a vlue of a variable to each cell
|
#6 |
Member
AJAY BHANDARI
Join Date: Jul 2015
Location: INDIA
Posts: 57
Rep Power: 11 |
Hi all,
I am new to open Foam.I have the a problem same as discussed above . i want to use a for loop to assign a variable value to each cell in my mesh . How can i do it??? and where i have to create this loop. any help will be appreciated. Regards Ajay |
|
August 4, 2015, 06:15 |
|
#7 |
Senior Member
Daniel Witte
Join Date: Nov 2011
Posts: 148
Rep Power: 15 |
Here just some code lines, how you can do it. You will find it preat all over the code:
Code:
forAll(owner, facei) { ssf[facei] = deltaCoeffs[facei]*(vf[neighbour[facei]] - vf[owner[facei]]); } This will not work in some part of the code, e.g. in matrix solvers, but elsewhere it does. Regards, Daniel |
|
August 4, 2015, 06:19 |
|
#8 |
Member
AJAY BHANDARI
Join Date: Jul 2015
Location: INDIA
Posts: 57
Rep Power: 11 |
Hi danny,
First of all thanks for your quick reply. I will try what u have said. Can u tell me what is meant by this line it will not work in matrix solvers. I am working in porousSimpleFoam and basically i want to assign porosity to each cell in mesh. Regards Ajay |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Memory protection in OpenFOAM / combinig with FORTRAN | botp | OpenFOAM Programming & Development | 2 | February 15, 2016 13:25 |
Star cd es-ice solver error | ernarasimman | STAR-CD | 2 | September 12, 2014 01:01 |
Edit linear solver | luckycfd | OpenFOAM Programming & Development | 32 | January 24, 2014 14:28 |
What openFoam solver for sandstorm? | cristina87 | OpenFOAM Running, Solving & CFD | 4 | April 7, 2011 09:57 |
Working directory via command line | Luiz | CFX | 4 | March 6, 2011 21:02 |