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

Instruction if

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

Reply
 
LinkBack Thread Tools Display Modes
Old   April 27, 2012, 06:48
Default Instruction if
  #1
New Member
 
Nabil MEAH
Join Date: Apr 2012
Posts: 8
Rep Power: 5
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, 08:07
Default
  #2
New Member
 
Nabil MEAH
Join Date: Apr 2012
Posts: 8
Rep Power: 5
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, 04:25
Default
  #3
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
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, 13:28
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 397
Rep Power: 12
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

Reply

Tags
instruction

Thread Tools
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 On
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
Who help to give a instruction how to install paraFoam correctly liugx212 OpenFOAM Paraview & paraFoam 0 April 17, 2006 15: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 16:49


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