How to use if statement in openFoam solver?
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: |
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 |
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... |
Quote:
thank you. |
You should post more context, i.e. where Re and CD are initialized.
|
how to assign a vlue of a variable to each cell
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 |
Here just some code lines, how you can do it. You will find it preat all over the code:
Code:
forAll(owner, facei) This will not work in some part of the code, e.g. in matrix solvers, but elsewhere it does. Regards, Daniel |
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 |
All times are GMT -4. The time now is 19:04. |