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

For loops in OpenFoam

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 6, 2010, 08:44
Default For loops in OpenFoam
  #1
Senior Member
 
Balkrishna Patankar
Join Date: Mar 2009
Location: Pune
Posts: 123
Rep Power: 17
balkrishna is on a distinguished road
I am generalising the twoPhase Euler Foam to handle n Phases . In the file pEqn.H I want to sum up the phase fraction of all the dispersed phases to get the dispersed phase . To do so I programmed the following :
Code:
 PtrList<surfaceScalarField>alphaf(nPhases);                                                                                               
                                                                                                                                              
    //just an initialization                                                                                                                  
    surfaceScalarField af ;                                                                                                                   
    surfaceScalarField betaf = scalar(1) - af;                                                                                                
                                                                                                                                              
    forAll(alphaf,aPh)                                                                                                                        
    {                                                                                                                                         
        alphaf.set(aPh,fvc::interpolate(phases[aPh].alpha()));                                                                                
        af= af + alphaf[aPh];                                                                                                                 
    }                                                                                                                                         
    betaf = scalar(1) - af ;
On compilation I got the following error :
Code:
error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>::GeometricField()’
/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude/GeometricField.C:652: note: candidates are: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::wordList&) [with Type = double, PatchField = Foam::fvsPatchField, GeoMesh = Foam::surfaceMesh]
balkrishna is offline   Reply With Quote

Old   September 6, 2010, 17:46
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
The problem isn't the for loop, it's your PtrList .set command:

Code:
alphaf.set(aPh,fvc::interpolate(phases[aPh].alpha()));
You have to create a GeometricField on the freestore for this pointer list... and you have to use a proper GeometricField constructor.

Code:
alphaf.set
(
    aPh,
    new surfaceScalarField
    (
        IOobject
        (
            // IOobject constructor parameters - you decide
        ),
        mesh,
        fvc::interpolate(phases[aPh].alpha())
    )
);
Hope that helps!
marupio is offline   Reply With Quote

Old   September 7, 2010, 01:37
Default
  #3
Senior Member
 
Balkrishna Patankar
Join Date: Mar 2009
Location: Pune
Posts: 123
Rep Power: 17
balkrishna is on a distinguished road
The error wasnt for the alphaf.set line . It was for the "surfaceScalarField alphaf ; " line
balkrishna is offline   Reply With Quote

Old   September 7, 2010, 05:06
Default
  #4
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 30
akidess will become famous soon enough
Duplicate: http://www.cfd-online.com/Forums/ope...-openfoam.html
akidess is offline   Reply With Quote

Old   September 7, 2010, 12:54
Default
  #5
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
there is no default constructor for the surfaceScalarField.

it needs to know about its size, take any available surfaceScalarField available and use that.
For instance phi and

surfaceScalarField alphaf(phi.size());
niklas is offline   Reply With Quote

Old   September 7, 2010, 13:01
Default
  #6
Senior Member
 
Balkrishna Patankar
Join Date: Mar 2009
Location: Pune
Posts: 123
Rep Power: 17
balkrishna is on a distinguished road
Thanks evry1 .... my problem was solved ... i initialized af in createFields.H and that solved the problem as suggested by alberto here ...

Last edited by balkrishna; September 8, 2010 at 03:29. Reason: accurate reference
balkrishna is offline   Reply With Quote

Reply

Tags
error, multiphase flow


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
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06:36
Modified OpenFOAM Forum Structure and New Mailing-List pete Site News & Announcements 0 June 29, 2009 06:56
64bitrhel5 OF installation instructions mirko OpenFOAM Installation 2 August 12, 2008 19:07
Adventure of fisrst openfoam installation on Ubuntu 710 jussi OpenFOAM Installation 0 April 24, 2008 15:25
OpenFOAM Debian packaging current status problems and TODOs oseen OpenFOAM Installation 9 August 26, 2007 14:50


All times are GMT -4. The time now is 14:08.