CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Error while using forAllIter macro in own equation file (https://www.cfd-online.com/Forums/openfoam-programming-development/152259-error-while-using-foralliter-macro-own-equation-file.html)

anuragm April 27, 2015 11:12

Error while using forAllIter macro in own equation file
 
1 Attachment(s)
I want to solve an additional set of equations in multiphaseEulerFoam for my case, so I made a new file called DQMOMEqns_New.H.

But when I compile, I get some errors:
Code:

DQMOMEqns_New.H: In function ‘int main(int, char**)’:
DQMOMEqns_New.H:42:43: error: ‘phases_’ was not declared in this scope
    forAllIter(PtrDictionary<phaseModel>, phases_, iter)
                                          ^
/home/m/OpenFOAM/OpenFOAM-2.3.x/src/OpenFOAM/lnInclude/UList.H:443:37: note: in definition of macro ‘forAllIter’
        Container::iterator iter = (container).begin();                        \
                                    ^
In file included from multiphaseEulerPbeFoam.C:91:0:
DQMOMEqns_New.H:66:60: error: ‘phi1’ was not declared in this scope
        surfaceScalarField phir[phasei](phase.phi() - phi1());
                                                            ^
DQMOMEqns_New.H:66:61: error: variable-sized object ‘phir’ may not be initialized
        surfaceScalarField phir[phasei](phase.phi() - phi1());
                                                            ^
DQMOMEqns_New.H:72:43: error: no matching function for call to ‘div(Foam::surfaceScalarField [(((sizetype)(((ssizetype)phasei) + -1)) + 1)], Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&)’
            + fvm::div(phir,weight[phasei])
                                          ^

I have attached this file with the post. I am also quoting the offending part of the code here:

Code:

    int phasei = 0;

    forAllIter(PtrDictionary<phaseModel>, phases_, iter)
    {
        phaseModel& phase = iter();
        volScalarField& alpha = phase;
   
        if (phasei == 0)
        {
            surfaceScalarField phi1 = phase.phi();
            sumAlpha = alpha;
        }

        phasei++;
    }

Am I not using this macro correctly? Or is there something else that I have overlooked?

kwardle April 29, 2015 16:08

instead of phases_ use fluid.phases()

anuragm April 30, 2015 12:05

Thanks for the reply. This works, I do not get this error now.


All times are GMT -4. The time now is 07:34.