CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   For loops in OpenFoam (https://www.cfd-online.com/Forums/openfoam-solving/79840-loops-openfoam.html)

balkrishna September 6, 2010 07:54

For loops in OpenFoam
 
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]


alberto September 7, 2010 02:48

Hi,

af must be initialized on declaration. You can define it with IObject, but specifying NO_READ, NO_WRITE as options, and setting it to zero (see how this is done for ppMagf in twoPhaseEulerFoam for example).

Best,

balkrishna September 7, 2010 02:52

Ok ... Thanks ...


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