CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Instruction if

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 27, 2012, 07:48
Default Instruction if
  #1
New Member
 
Nabil MEAH
Join Date: Apr 2012
Posts: 8
Rep Power: 13
bluemind is on a distinguished road
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,
bluemind is offline   Reply With Quote

Old   April 27, 2012, 09:07
Default
  #2
New Member
 
Nabil MEAH
Join Date: Apr 2012
Posts: 8
Rep Power: 13
bluemind is on a distinguished road
I found the command :

forAll( alpha1,celli){
if ( alpha1[celli] < 1.e-5 )
{
...

}
}
bluemind is offline   Reply With Quote

Old   April 29, 2012, 05:25
Default
  #3
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
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.
Bernhard is offline   Reply With Quote

Old   April 29, 2012, 14:28
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
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
marupio is offline   Reply With Quote

Old   June 14, 2016, 15:14
Exclamation Problem with if Loop in interFoam
  #5
New Member
 
Rimsha
Join Date: Jan 2016
Posts: 25
Rep Power: 10
block is on a distinguished road
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
block is offline   Reply With Quote

Reply

Tags
instruction

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Instalation on ubuntu 710 basilwatson OpenFOAM Installation 17 March 16, 2012 21:16
Pls help last problem to be solved for installing OPENfoam daydayuper OpenFOAM Installation 5 November 9, 2008 05:59
[OpenFOAM] Who help to give a instruction how to install paraFoam correctly liugx212 ParaView 0 April 17, 2006 16:32
64-bit processors for home computing Ananda Himansu Main CFD Forum 2 March 16, 2004 13:48
Web-based CFD/HT instruction Graham de Vahl Davis Main CFD Forum 0 April 2, 1999 17:49


All times are GMT -4. The time now is 02:01.