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/)
-   -   make a dimensionedScalar to be volScalarField (http://www.cfd-online.com/Forums/openfoam-programming-development/132520-make-dimensionedscalar-volscalarfield.html)

sharonyue April 2, 2014 04:39

make a dimensionedScalar to be volScalarField
 
Hi,

I wanna make the diameter of the particle to be variable. Before I revise the code, d_ is a dimensionedScalar, locates in /opt/openfoam222/applications/solvers/multiphase/twoPhaseEulerFoam/phaseModel/phaseModel

Code:

//- Characteristic diameter of phase
        dimensionedScalar d_;

Then I change it into:

Code:

//- Characteristic diameter of phase
        volScalarField d_;

.....

volScalarField& d()
        {
            return d_;
        }

....
....
    d_
    (
        IOobject
        (
            "d" + phaseName,
            mesh.time().timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    ),

I wmake this phase.C successfully. But when I wmake this dragmodel as follows:
Code:

Foam::tmp<Foam::volScalarField> Foam::GidaspowSchillerNaumann::K
(
    const volScalarField& Ur
) const
{
    volScalarField alpha2(max(scalar(1) - alpha1_, scalar(1e-6)));
    volScalarField bp(pow(alpha2, -2.65));

    volScalarField Re(max(alpha2*Ur*phase1_.d()/phase2_.nu(), scalar(1.0e-3)));

    volScalarField Cds
    (
        neg(Re - 1000)*(24.0*(1.0 + 0.15*pow(Re, 0.687))/Re)
      + pos(Re - 1000)*0.44
    );

    return 0.75*Cds*phase2_.rho()*Ur*bp/phase1_.d();
}

it said:

Code:

SOURCE=dragModels/GidaspowSchillerNaumann/GidaspowSchillerNaumann.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../phaseModel/lnInclude -IlnInclude -I. -I/opt/openfoam222/src/OpenFOAM/lnInclude -I/opt/openfoam222/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/GidaspowSchillerNaumann.o
dragModels/GidaspowSchillerNaumann/GidaspowSchillerNaumann.C: In member function ‘virtual Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::GidaspowSchillerNaumann::K(const volScalarField&) const’:
dragModels/GidaspowSchillerNaumann/GidaspowSchillerNaumann.C:74:47: error: passing ‘const Foam::phaseModel’ as ‘this’ argument of ‘Foam::volScalarField& Foam::phaseModel::d()’ discards qualifiers [-fpermissive]
dragModels/GidaspowSchillerNaumann/GidaspowSchillerNaumann.C:82:51: error: passing ‘const Foam::phaseModel’ as ‘this’ argument of ‘Foam::volScalarField& Foam::phaseModel::d()’ discards qualifiers [-fpermissive]
make: *** [Make/linux64GccDPOpt/GidaspowSchillerNaumann.o] Error 1

So in this code above, I only make a dimensionedScalar to be a volScalarField. If I delete this phase1_.d(), all is okay. How should I handle this?

Actually my thought is very simple, in twoPhaseEulerFoam, particle's diameter is constant. you can set it in your transportDict. Well cua I wanna implant PBM into it, so this diameter should be variable. So I wanna implant PBM step by step. At first I should change this constant diameter to be changeable. This is why I revise the code.

alexeym April 2, 2014 05:23

Hi,

you've changed d_ in header file but did not change initialization of the field in constructor, it still initialized like (phaseModel/phaseModel/phaseModel.C):

Code:

...
    d_
    (
        "d",
        dimLength,
        dict_.lookup("d")
    ),
...

or did you also change this piece of code?

Problem appears here (interfacialModels/dragModels/GidaspowSchillerNaumann/GidaspowSchillerNaumann.C):

Code:

volScalarField Re(max(alpha2*Ur*phase1_.d()/phase2_.nu(), scalar(1.0e-3)));
it tries to use your strangely initialized d_ volScalarField and fails.

sharonyue April 2, 2014 05:33

Quote:

Originally Posted by alexeym (Post 483400)
Hi,

you've changed d_ in header file but did not change initialization of the field in constructor, it still initialized like (phaseModel/phaseModel/phaseModel.C):

Code:

...
    d_
    (
        "d",
        dimLength,
        dict_.lookup("d")
    ),
...

or did you also change this piece of code?

Problem appears here (interfacialModels/dragModels/GidaspowSchillerNaumann/GidaspowSchillerNaumann.C):

Code:

volScalarField Re(max(alpha2*Ur*phase1_.d()/phase2_.nu(), scalar(1.0e-3)));
it tries to use your strangely initialized d_ volScalarField and fails.

Hi,

Yes, I also changed that. So phase.C is wmaked successfully. But when I wmake GidaspowSchillerNaumann.C, it failed.
Code:

volScalarField Re(max(alpha2*Ur*phase1_.d()/phase2_.nu(), scalar(1.0e-3)));
In this code, phase1_.d() is dimensionedScalar. but when I change it into volScalarField, it can not be wmake.

You get my point, Thanks anyway.

alexeym April 2, 2014 05:41

Well,

you can change

Code:

volScalarField& d()
{
    return d_;
}

to

Code:

const volScalarField& d() const
{
    return d_;
}

as obviously you don't want interfacial model to change it. Or you can return tmp<volScalarField>:

Code:

tmp<volScalarField> d() const
{
  return d_;
}

cause volScalarField has this constructor:

Code:

GeometricField (const GeometricField< Type, PatchField, GeoMesh > &)
as you are trying to use it with just volScalarField& compiler complains about discarded const specifier.

sharonyue April 2, 2014 05:44

Quote:

Originally Posted by alexeym (Post 483407)
Well,

you can change

Code:

volScalarField& d()
{
    return d_;
}

to

Code:

const volScalarField& d() const
{
    return d_;
}

as obviously you don't want interfacial model to change it. Or you can return tmp<volScalarField>:

Code:

tmp<volScalarField> d() const
{
  return d_;
}


Neat! it is solved !!!beautiful!Thanks bro.


All times are GMT -4. The time now is 20:56.