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/)
-   -   Problems with creating a volScalarField (http://www.cfd-online.com/Forums/openfoam-programming-development/76491-problems-creating-volscalarfield.html)

georlade May 27, 2010 01:31

Problems with creating a volScalarField
 
Hi,

I've got a question about a (at least for me) weird problem.
I'm working with a coupled solver based on the solidparticlecloud and interfoam. I want to create a volScalarField in the solidParticleCloud.
I tried the following:

-I created a variable volScalarField alphap in solidParticleCloud.H by using:

Code:

alphap
    (
      IOobject
        (
        "alphap",
            runTime.timeName(),           
            mesh_,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
      mesh_,
      dimensionedScalar(0.)
    );

after Compiling I get the following:
Code:

$ wmake libso .
Making dependency list for source file oilParticleCloud.C
Making dependency list for source file oilParticle.C
SOURCE=oilParticle.C ;  g++ -m32 -Dlinux -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3  -DNoRepository -ftemplate-depth-40 -I/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/finiteVolume/lnInclude -I/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/lagrangian/basic/lnInclude -IlnInclude -I. -I/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude -I/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linuxGccDPOpt/oilParticle.o
In file included from oilParticle.C:27:
oilParticleCloud.H:122: error: expected ‘)’ before string constant
oilParticleCloud.H:122: error: expected ‘)’ before string constant
oilParticleCloud.H:122: error: expected ‘;’ before string constant
oilParticle.C: In member function ‘bool Foam::oilParticle::move(Foam::oilParticle::trackData&)’:
oilParticle.C:173: warning: unused variable ‘volp’
oilParticle.C:174: warning: unused variable ‘volcell’
make: *** [Make/linuxGccDPOpt/oilParticle.o] Error 1

I don't understand the error message at all.

Next thing I tried:
- declaration of volScalarField alpha in solidParticleCloud.H and creating the IOobject in the constructor
in solidParticleCloud::solidParticleCloud :
Code:

alphap 
 (
      IOobject
        (
        "alphap",
            runTime.timeName(),           
            mesh_,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
      mesh_,
      dimensionedScalar(0.)
    );

Here the error message is even longer:

Code:

$ wmake libso .
Making dependency list for source file oilParticleCloud.C
SOURCE=oilParticleCloud.C ;  g++ -m32 -Dlinux -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3  -DNoRepository -ftemplate-depth-40 -I/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/finiteVolume/lnInclude -I/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/lagrangian/basic/lnInclude -IlnInclude -I. -I/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude -I/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linuxGccDPOpt/oilParticleCloud.o
oilParticleCloud.C: In constructor ‘Foam::oilParticleCloud::oilParticleCloud(const Foam::fvMesh&, const Foam::word&)’:
oilParticleCloud.C:85: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField()’
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:602: 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::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:567: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:537: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:504: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:472: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:441: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:409: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:369: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, Foam::Istream&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:329: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:302: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensionSet&, const Foam::Field<Type>&, const Foam::PtrList<PatchField<Type> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:273: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensioned<Type>&, const Foam::wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:244: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensioned<Type>&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:217: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensionSet&, const Foam::wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/home/georg/OpenFOAM/OpenFOAM-1.6.x/src/OpenFOAM/lnInclude/GeometricField.C:187: note:                Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensionSet&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
oilParticleCloud.C:92: error: ‘runTime’ was not declared in this scope
make: *** [Make/linuxGccDPOpt/oilParticleCloud.o] Error 1

Ok, runTime was not declared is plausible, as the solidparticlecloud.H is included into InterFoam before the createTime.H
To fix it I used instead:
Code:

mesh_.time().timeName()
Instead of the "runTime not declared in this scope" another error occurs (all the other text is similar):
Code:

oilParticleCloud.C:99: error: no match for call to ‘(Foam::volScalarField) (Foam::IOobject, const Foam::fvMesh&, Foam::dimensionedScalar)’
make: *** [Make/linuxGccDPOpt/oilParticleCloud.o] Error 1

Then I did the following:

Code:

Foam::oilParticleCloud::oilParticleCloud
(
    const fvMesh& mesh,
    const word& cloudName
)
:
    Cloud<oilParticle>(mesh, cloudName, false),
    mesh_(mesh),
    particleProperties_
    (
        IOobject
        (
            "particleProperties",
            mesh_.time().constant(),
            mesh_,
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    ),
    injectorProperties_
    (
        IOdictionary
        (
            IOobject
            (
                "injectorProperties",
                mesh_.time().constant(),
                mesh_,
                IOobject::MUST_READ,
                IOobject::NO_WRITE
            )
        )
    ),
alphap
    (
      IOobject
        (
        "alphap",
            mesh_.time().timeName(),           
            mesh_,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
      mesh_,
      dimensionedScalar(0.)
    ),
    rhop_(dimensionedScalar(particleProperties_.lookup("rhop")).value()),
    e_(dimensionedScalar(particleProperties_.lookup("e")).value()),
    mu_(dimensionedScalar(particleProperties_.lookup("mu")).value())

    oilParticle::readFields(*this);
}

The good thing: There was no compilation error. Only some warnings:
Code:

oilParticleCloud.H: In constructor ‘Foam::oilParticleCloud::oilParticleCloud(const Foam::fvMesh&, const Foam::word&)’:
oilParticleCloud.H:118: warning: ‘Foam::oilParticleCloud::alphap’ will be initialized after
oilParticleCloud.H:100: warning:  ‘Foam::scalar Foam::oilParticleCloud::rhop_’
oilParticleCloud.C:50: warning:  when initialized here
'/home/georg/OpenFOAM/OpenFOAM-1.6.x/lib/linuxGccDPOpt/liboilParticle.so' is up to date.

The bad thing: After starting the simulation I got an Segmentation fault.
I could locate the error:
It occurs in the InterFoam.C at runTime++

So where is my mistake?
Here some backgroundinformation what I want to do:
The volScalarField alpha should be located in solidParticleCloud, as all solidParticles have to write some data into alpha (due to this, it has to be public in solidParticleCloud). After the loop over all particles is finished, alpha is read by alphaEqn.H to add a masssource into the equotation (this is, why I need the IOobject). Afterwards it is set to zero, and the particles write again and so on...

If anyone have an idea or a hint, how to solve this problem (maybe a little bit more elegant), your very welcome to enlighten me. Also it would be great to understand why all the above happens.

I'm looking forward for your answers,
Cheers,
Georg

raagh77 June 24, 2010 07:48

Hi Georg,

Even I am facing the same problem
I am not able to couple particle tracking with VOF
I mean solidParticle and interFoam

I tried to compile part pisoLagrangianFoam with interFoam and it was successful (at least code compiled without any error) but the thing is the drag coefficient is not treated well there in pisoLagrangianFoam.

I thought of coupling solidPartilce and interFoam but ended up with the same problem (I think there is some changes to be made in the soildparticle files so that it can be treated well with the piso loop of interFoam ?.. wild guess.. because solidparticle+simpleFoam works well without any problem)

if you have fixed this issue pls. let me know

Awaiting to hear from you


Regards
Raghu

georlade July 6, 2010 02:19

Hi Raghu,

Sorry for the late answer! Unfortunately I have bad news for you. I wasn't able to find the cause of the problem.
I only can show you a way to by-pass the problem. For me, it works, maybe for you as well.

What I did: I created a variable alphap_ of type scalarField (also possible vectorField...) in the solidParticleCloud.H file. With a function it is possible to access this variable and copy it into the VOF Solver. The function also converts the scalarField into a volScalarField. Declaration of the function is in solidParticleCloud.H, definition in solidParticleCloudI.H.

Code:

inline Foam::tmp<Foam::volScalarField> Foam::oilParticleCloud::alphap() const
{
    tmp<volScalarField> volfrac
    (
        new volScalarField
        (
            IOobject
            (
                "alphap",
                mesh_.time().timeName(),
                mesh_,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh_,
            dimensionedScalar
            (
                "zero",
                dimensionSet(0, 0, 0, 0, 0, 0, 0),
                0.
            )
        )
    );

    volfrac().internalField() = alphap_;

    return volfrac;
}

Maybe you can use this way as well, fingers crossed! :)

If you have questions, don't hesitate to ask me!

Regards,
Georg

elham usefi August 4, 2016 09:38

Quote:

Originally Posted by georlade (Post 265853)
Hi Raghu,

Sorry for the late answer! Unfortunately I have bad news for you. I wasn't able to find the cause of the problem.
I only can show you a way to by-pass the problem. For me, it works, maybe for you as well.

What I did: I created a variable alphap_ of type scalarField (also possible vectorField...) in the solidParticleCloud.H file. With a function it is possible to access this variable and copy it into the VOF Solver. The function also converts the scalarField into a volScalarField. Declaration of the function is in solidParticleCloud.H, definition in solidParticleCloudI.H.

Code:

inline Foam::tmp<Foam::volScalarField> Foam::oilParticleCloud::alphap() const
{
    tmp<volScalarField> volfrac
    (
        new volScalarField
        (
            IOobject
            (
                "alphap",
                mesh_.time().timeName(),
                mesh_,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh_,
            dimensionedScalar
            (
                "zero",
                dimensionSet(0, 0, 0, 0, 0, 0, 0),
                0.
            )
        )
    );

    volfrac().internalField() = alphap_;

    return volfrac;
}

Maybe you can use this way as well, fingers crossed! :)

If you have questions, don't hesitate to ask me!

Regards,
Georg

Hi georlade
I have a question! what does exactly the last zero in ("zero",dimensionSet(0, 0, 0, 0, 0, 0, 0),0.) refers to?


All times are GMT -4. The time now is 13:47.