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

If-else looping issue

Register Blogs Community New Posts Updated Threads Search

 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old   September 12, 2013, 10:47
Default If-else looping issue
  #1
Member
 
Tayo
Join Date: Aug 2012
Posts: 94
Rep Power: 13
tayo is on a distinguished road
I want to include if-else loop in my interPhaseChangeFoam solver. This is supposed to be easy but it's taking some time now. Below is an illustration of the code.

Code:
Foam::volScalarField Foam::phaseChangeTwoPhaseMixture::Random::dotAlpha() const
{
 const volScalarField& p = alpha1_.db().lookupObject<volScalarField>("p");
 volScalarField x = this->x();
 forAll(p, celli)
 {
   if (p[celli] <= pSat_.value())
   {
     return volScalarField
     (
       x/y_*(p - pSat_)*(1 - alpha1_)
     );
   else
   {
     return volScalarField
     (
       x*(p - pSat_)*alpha1_
     );
   }
 }
}
pSat_ and y_ are dimensionedScalar.

Notice that I didn't index volScalarfields p and x in the if-else statement because I noticed that indexing makes it dimensionless afterwards. It however compiles the way it is now (ofcourse not correct) but gives the warning "control reaches end of non-void function". Please how do I fix this if-else loop? Thanks in advance.

Last edited by wyldckat; September 15, 2013 at 17:43. Reason: fixed broken code delimiter from [\CODE] to [/CODE]
tayo is offline   Reply With Quote

 


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
Strange issue while launching ANSYS workbench in CentOS 6.4 Philip_C ANSYS 11 August 29, 2013 06:44
CyclicAMI Issue In OpenFOAM 2.2.0 prasant OpenFOAM Running, Solving & CFD 17 March 16, 2013 02:00
Pressure boundary condition issue Vijay FLUENT 0 April 6, 2012 13:35
Meshing related issue in Flow EFD appu FloEFD, FloWorks & FloTHERM 1 May 22, 2011 08:27
Issue 4 of adapco-online Sreenadh Jonnavithula Main CFD Forum 8 January 5, 2001 13:40


All times are GMT -4. The time now is 10:18.