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

make a dimensionedScalar to be volScalarField

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Display Modes
Old   April 2, 2014, 04:39
Default make a dimensionedScalar to be volScalarField
  #1
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 676
Rep Power: 8
sharonyue is on a distinguished road
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.
sharonyue is offline   Reply With Quote

Old   April 2, 2014, 05:23
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,133
Rep Power: 20
alexeym will become famous soon enoughalexeym will become famous soon enough
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.
alexeym is offline   Reply With Quote

Old   April 2, 2014, 05:33
Default
  #3
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 676
Rep Power: 8
sharonyue is on a distinguished road
Quote:
Originally Posted by alexeym View Post
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.
sharonyue is offline   Reply With Quote

Old   April 2, 2014, 05:41
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,133
Rep Power: 20
alexeym will become famous soon enoughalexeym will become famous soon enough
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 likes this.

Last edited by alexeym; April 2, 2014 at 05:45. Reason: additional comment
alexeym is offline   Reply With Quote

Old   April 2, 2014, 05:44
Default
  #5
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 676
Rep Power: 8
sharonyue is on a distinguished road
Quote:
Originally Posted by alexeym View Post
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.
sharonyue is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
libOpenSMOKE Tobi OpenFOAM Programming & Development 502 July 23, 2015 21:14
changing a volScalarField to a dimensionedScalar wschosta OpenFOAM Running, Solving & CFD 5 May 6, 2015 10:20
multiplicate all elements of volScalarField with scalar to get new volScalarField maybee OpenFOAM Programming & Development 2 February 18, 2014 16:43
Problem with pow and volScalarField _Stefan_ OpenFOAM Programming & Development 14 August 7, 2012 11:04
Confused about how OF handles operation between volScalarField and dimensionedScalar Edy OpenFOAM 3 September 30, 2010 10:07


All times are GMT -4. The time now is 01:46.