|
[Sponsors] |
April 28, 2012, 17:37 |
if statement for volScalarField
|
#1 |
New Member
reza
Join Date: Apr 2012
Posts: 7
Rep Power: 13 |
hi
i'm a new user of openFoam, i try to do something when a volScalarFied like p is in the specific number like smaller than 1 i tried this in solver. if ( p < 1) { ..... } when p is volScalarField and i got som error for operator < thanks to help me. |
|
April 29, 2012, 05:27 |
|
#2 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
It depends a bit of what you want to do precisely. It is always a good idea to carefully read the errormessages. If you don't understand them, it is still worth to post them in a thread.
See also: http://www.cfd-online.com/Forums/ope...uction-if.html |
|
April 29, 2012, 06:56 |
|
#3 |
New Member
reza
Join Date: Apr 2012
Posts: 7
Rep Power: 13 |
Thanks dear Bernhard, you got me and my problem has been solved.
|
|
June 14, 2016, 15:55 |
|
#4 |
New Member
Rimsha
Join Date: Jan 2016
Posts: 25
Rep Power: 10 |
Hi guys i am trying to implement a if loop in one of the libraries of interFoam where a variable called "kappaf" is depend on the alpha1f value, where i want to impose a condition where kappaf is alpha1f * DI for alpha1f >0.5 or zero if alphaf < 0.5.
I have written the loop ifloop.png I am getting this error errorloop.png I am new to openfoam and C++ coding so not familiar with how to write this. Kind Regards Rimsha |
|
June 15, 2016, 14:40 |
|
#5 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21 |
You can't put a for loop within a function call like that.
Code:
return tmp<surfaceScalarField> ( new surfaceScalarField ( // This is a function call - specifically, a constructor ) ); Code:
if (condition) { // statements } else if (anotherCondition) { // statements } else { // statements }
__________________
~~~ Follow me on twitter @DavidGaden Last edited by marupio; June 15, 2016 at 14:40. Reason: bad code tags |
|
June 17, 2016, 13:32 |
|
#6 | |
New Member
Rimsha
Join Date: Jan 2016
Posts: 25
Rep Power: 10 |
Quote:
Thank you so much for helping. I have taken your advice and imposed the for loop just before the equation instead and it works fine. Below is the procedure i followed. I imposed the two diffusion coefficients in create fields for the solver DIsetfields.png wrote this loop before the equation that i imposed in runtime. creatingI.png In the above loop i am trying to switch between diffusion coefficient depending on the cell face value of the alpha (a phase volume fraction in interFoam). Hope this helps anyone trying to do something similar. Thanks again. Rimsha Last edited by block; June 19, 2016 at 11:42. Reason: adding details |
||
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
if statement for volScalarField | AnjaMiehe | OpenFOAM Programming & Development | 2 | April 24, 2012 08:01 |
If Statement | Zaktatir | CFX | 5 | June 19, 2010 07:09 |
Weak statement for Galerkin Method | rugabug | Main CFD Forum | 0 | March 26, 2010 20:19 |
Problem Statement | balkrishna | Main CFD Forum | 0 | October 7, 2009 00:55 |
marking statement in Latex | mike | Main CFD Forum | 0 | October 8, 2006 13:01 |