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

forAll loop problem!

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

Reply
 
LinkBack Thread Tools Display Modes
Old   March 10, 2014, 06:10
Default forAll loop problem!
  #1
Member
 
Join Date: Apr 2013
Posts: 32
Rep Power: 5
rajcfd is on a distinguished road
Hi everyone,

I am trying to use iterative method in one of my solver....It looks like this but I am getting error " expected primary expression before [ token "...I have marked the line of error below...Can someone point out the problem in this code? Thanks in advance!



/*..................Marking the wall cells.........*/

forAll(patches, patchi)
{

const fvPatch& thePatchItselfWall = patches[patchi];

if (isA<wallFvPatch>(thePatchItselfWall))

{
forAll (thePatchItselfWall, iFace)

{
label iCell = thePatchItselfWall.faceCells()[iFace];

vector iCellCentre = mesh.cellCentres()[iCell];


//pointed located at the centre line but at same axial position

vector bulkPoint(0,iCellCentre.y(),iCellCentre.z());

label bulkCell = mesh.findCell(bulkPoint);


do

{

dimensionedScalar nsite = nref*pow(((Twall-Tsat)/delTref),1.805); //site density correlation

/*.................................Heat flux areas....................*/

volScalarField A2F = min((3.141*pow(Ddep,2.0)*nsite), scalar(1.0)); //quenching heat flux area

volScalarField A1F = max((scalar(1.0)-A1F), scalar(0.0001)); //convective heat flux area


// calculation of site density and evaporative heat and mass flux


volScalarField mev

("mev",

((3.14/6.0)*pow(Ddep,3.0)*fdep*nsite)

);


/*......Quenching, convective, evaporative heat flux.....*/

volScalarField qe = mev*latHeat; //evaporative heat flux

volScalarField qc = A1F*hc*(Twall-Tb); // convective heat flux

volScalarField qq = A2F*hq*(Twall-Tb); //quenching heat flux

volScalarField qtotal = qe+qc+qq; //total heat flux

volScalarField error = mag (qwall-qtotal);



}while (error[iCell]>scalar(1.0)); ///ERRROR IS COMING HERE


}

}

}









//final value of site density after using iterative method to solve wall temperature Tw

dimensionedScalar nsite = nref*pow(((Twall-Tsat)/delTref),1.805);


//Storing and calcluation of source term for alpha eqn

volScalarField mevp

("mevp",

((3.14/6.0)*pow(Ddep,3.0)*fdep*nsite)

);


if (runTime.outputTime()) //storing mevp

{
mevp.write();

}

//source term for alpha eqn

volScalarField Gammaevp

("Gammaevp",

(Awall*a*mevp)

); // bubble formed at the walls due to evaporation

if (runTime.outputTime()) //storing Gammaevp

{

Gammaevp.write();

}
rajcfd is offline   Reply With Quote

Old   March 10, 2014, 06:34
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,409
Rep Power: 25
alexeym will become famous soon enoughalexeym will become famous soon enough
Hi,

you have to create 'error' volume field before 'do {} while' statement.
alexeym is offline   Reply With Quote

Old   March 10, 2014, 07:31
Default
  #3
Member
 
Join Date: Apr 2013
Posts: 32
Rep Power: 5
rajcfd is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

you have to create 'error' volume field before 'do {} while' statement.

Hi alexeym,

Thanks a lot for the reply ...It worked...
rajcfd is offline   Reply With Quote

Old   March 10, 2014, 09:17
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,409
Rep Power: 25
alexeym will become famous soon enoughalexeym will become famous soon enough
Quote:
Originally Posted by rajcfd View Post
Thanks a lot for the reply ...It worked...
In fact this error has nothing to do with forAll macros. You define a variable inside a loop and then try to use this variable in exit condition from the loop. For example, this code will also fail to compile:

Code:
do
{
    int i = call_to_some_function_returning_i();
}
while(i < 10)
while

Code:
int i = 0;
do
{
    i = call_to_some_function_returning_i();
}
while(i < 10)
will compile.
alexeym is offline   Reply With Quote

Old   March 11, 2014, 06:55
Default
  #5
Member
 
Join Date: Apr 2013
Posts: 32
Rep Power: 5
rajcfd is on a distinguished road
Quote:
Originally Posted by alexeym View Post
In fact this error has nothing to do with forAll macros. You define a variable inside a loop and then try to use this variable in exit condition from the loop. For example, this code will also fail to compile:

Code:
do
{
    int i = call_to_some_function_returning_i();
}
while(i < 10)
while

Code:
int i = 0;
do
{
    i = call_to_some_function_returning_i();
}
while(i < 10)
will compile.
...


Thanks for the info...Actually I have already made a C++ program for the same..I am just trying to put that iterative program into the solver...So I missed out that!...


Thanks a lot...Will get in touch with you if any other problem is there!
rajcfd is offline   Reply With Quote

Reply

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
Problem Importing Geometry ProE to CFX fatb0y CFX 3 January 14, 2012 20:42
Problem do loop using Scheme commands kris FLUENT 0 January 13, 2008 07:15
for loop inside a cell_loop? MHDWill FLUENT 0 September 26, 2007 21:24
natural convection problem for a CHT problem Se-Hee CFX 2 June 10, 2007 06:29
Adiabatic and Rotating wall (Convection problem) ParodDav CFX 5 April 29, 2007 19:13


All times are GMT -4. The time now is 23:21.