|
[Sponsors] |
April 27, 2012, 06:48 |
Instruction if
|
#1 |
New Member
Nabil MEAH
Join Date: Apr 2012
Posts: 8
Rep Power: 14 |
Hello,
I'm a student and new user of OpenFOAM, I am currently trying to modify the solver twoLiquidMixingFoam by adding the energy equation. Since I haven't use C++ so far, I'm having some trouble when I use the instruction if, for example in my case I just want to implement these simple lines : if ( alpha1 == 0 ) // l : 34 { ... } I have the following error : energyEqn.H:34: error: could not convert ‘alpha1.Foam::GeometricField<Type, PatchField, GeoMesh>:perator== [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::dimensioned<double>&)(& Foam::dimensioned<double>(((const double&)((const double*)(&0.0)))))))’ to ‘bool’ Since alpha1 is an object, I don't think this is the appropriated way to do this. Is it possible to have some help ? Thanks, |
|
April 27, 2012, 08:07 |
|
#2 |
New Member
Nabil MEAH
Join Date: Apr 2012
Posts: 8
Rep Power: 14 |
I found the command :
forAll( alpha1,celli){ if ( alpha1[celli] < 1.e-5 ) { ... } } |
|
April 29, 2012, 04:25 |
|
#3 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
Hi Nabil,
Welcome to CFD-online! The method you found should work fine, but it really depends on what you want to obtain. If you can explain a bit more on what you want exactly, there may be a nicer way. |
|
April 29, 2012, 13:28 |
|
#4 |
Senior Member
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22 |
Seconded. What you've got now is an indexed for loop over all elements in the mesh. These types of loops should be avoided whenever possible as they can be 10x slower than OpenFOAM's built-in field operations, which use optimised pointer loops.
__________________
~~~ Follow me on twitter @DavidGaden |
|
June 14, 2016, 14:14 |
Problem with if Loop in interFoam
|
#5 |
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 |
|
Tags |
instruction |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Instalation on ubuntu 710 | basilwatson | OpenFOAM Installation | 17 | March 16, 2012 20:16 |
Pls help last problem to be solved for installing OPENfoam | daydayuper | OpenFOAM Installation | 5 | November 9, 2008 04:59 |
[OpenFOAM] Who help to give a instruction how to install paraFoam correctly | liugx212 | ParaView | 0 | April 17, 2006 15:32 |
64-bit processors for home computing | Ananda Himansu | Main CFD Forum | 2 | March 16, 2004 12:48 |
Web-based CFD/HT instruction | Graham de Vahl Davis | Main CFD Forum | 0 | April 2, 1999 16:49 |