CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   ‘mesh’ was not declared in this scope (http://www.cfd-online.com/Forums/openfoam-programming-development/132931-mesh-not-declared-scope.html)

sharonyue April 8, 2014 03:04

‘mesh’ was not declared in this scope
 
Hi guys,

I wanna change d0 as a dimensionedScalar to a volScalarField. So I revise the code:

in solvers/compressibleTwoPhaseEulerFoam/phaseModel/diameterModels/isothermalDiameter.C

Code:

class isothermal
:
    public diameterModel
{
    // Private data

        //- Reference diameter for the isothermal expansion
        //dimensionedScalar d0_; This is original
        volScalarField d0_;
   

        //- Reference pressure for the isothermal expansion
        dimensionedScalar p0_;
       
        //- Reference pressure for the isothermal expansion
        dimensionedScalar n0_;


public:
.....................

in solvers/compressibleTwoPhaseEulerFoam/phaseModel/diameterModels/isothermalDiameter.H
Code:


// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::diameterModels::isothermal::isothermal
(
    const dictionary& dict,
    const phaseModel& phase
)
:
    diameterModel(dict, phase),
    d0_
    (
        IOobject
        (
            "d0",
            mesh.time().timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    ), 
    //d0_("d0", dimLength, dict.lookup("d0")), This is original
    p0_("p0", dimPressure, dict.lookup("p0")),
    n0_("n0", dimDensity, dict.lookup("n0"))
{}


// * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //

When I wmake libso, it said:
Code:

SOURCE=diameterModels/isothermalDiameter/isothermalDiameter.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam222/src/finiteVolume/lnInclude -I/opt/openfoam222/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam222/src/transportModels/incompressible/lnInclude -IlnInclude -I. -I/opt/openfoam222/src/OpenFOAM/lnInclude -I/opt/openfoam222/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/isothermalDiameter.o
diameterModels/isothermalDiameter/isothermalDiameter.C: In constructor ‘Foam::diameterModels::isothermal::isothermal(const Foam::dictionary&, const Foam::phaseModel&)’:
diameterModels/isothermalDiameter/isothermalDiameter.C:63:13: error: ‘mesh’ was not declared in this scope

make: *** [Make/linux64GccDPOpt/isothermalDiameter.o] Error 1
a@a:~/OpenFOAM/myCase/solvers/compressibleTwoPhaseEulerFoam/phaseModel$

So how should I handle this? Thanks in advance.

alexeym April 8, 2014 03:28

Hi,

as phase is a child class of volScalarField it has mesh() method which will return constant reference to the mesh. So the code can be:

Code:

    d0_
    (
        IOobject
        (
            "d0",
            phase.mesh().time().timeName(),
            phase.mesh(),
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        phase.mesh()
    ),

or

Code:

    d0_
    (
        IOobject
        (
            "d0",
            phase.time().timeName(),
            phase.db(),
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        phase.mesh()
    ),


sharonyue April 8, 2014 03:33

@Alexey Matveichev

Solved! so quick! Thanks very much.!!


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