CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Programming issues

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 24, 2010, 09:10
Default Programming issues
  #1
Senior Member
 
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20
vkrastev is on a distinguished road
Hi everybody, I have some compiling problems which are very probably due to my lack of knowledge in programming inside the OpenFOAM/C++ frame...however, I'm trying to compile a .C source file which contains the following piece of code:

tmp<volScalarField> kOmegaSI::kiKappa() const
{
return (1/(pow(omega_,3.0)))*((fvc::grad(k_))&(fvc::grad(ome ga_)));
}

tmp<volScalarField> kOmegaSI::fBetaStar() const
{
{
if (kiKappa() > scalar(0.0)) {
return ((scalar(680.0)+sqr(kiKappa()))/(scalar(400.0)+sqr(kiKappa())));
}
else {
return scalar(1.0);
}
}
}

and this is the error message after runninng the wmake utility

kOmegaSI/kOmegaSI.C:56: error: no match for ‘operator>’ in ‘Foam::incompressible::RASModels::kOmegaSI::kiKapp a() const() > 0.0’
kOmegaSI/kOmegaSI.C:60: error: conversion from ‘double’ to non-scalar type ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ requested

Line 56 is:

if (kiKappa() > scalar(0.0)) {

Line 60 is:

return scalar(1.0);

Can someone please give me some help about it? Thank you in advance

PS - What I'm trying to do is to implement the revised version of Wilcox's k-omega turbulence model. For the definition of the correction-functions of the closure coefficients (such as fBetaStar) I've took some inspiration from the Launder-Sharma Low-Re k-epsilon model source code.
vkrastev is offline   Reply With Quote

Old   August 24, 2010, 11:41
Default
  #2
Senior Member
 
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20
vkrastev is on a distinguished road
Any replies? I could post more information if necessary...
vkrastev is offline   Reply With Quote

Old   August 24, 2010, 11:50
Default
  #3
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
kiKappa seems to be a tmp<volScalarField>

so what does it mean when you write kiKappa() > 0?
Thats what it tells you on the line:
kOmegaSI/kOmegaSI.C:56: error: no match for ‘operator>’ in ‘Foam::incompressible::RASModels::kOmegaSI::kiKapp a() const() > 0.0’

Does it mean that every element of kiKappa should be larger than zero?
what about the ones that are not?

you cant compare fields to a scalar, its like you have a vector a=(1, 2, 3)
and you write
a > 0.
What does that mean?...nothing.

You have to rethink your code there.
niklas is offline   Reply With Quote

Old   August 24, 2010, 12:36
Default
  #4
Senior Member
 
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20
vkrastev is on a distinguished road
Quote:
Originally Posted by niklas View Post
kiKappa seems to be a tmp<volScalarField>

so what does it mean when you write kiKappa() > 0?
Thats what it tells you on the line:
kOmegaSI/kOmegaSI.C:56: error: no match for ‘operator>’ in ‘Foam::incompressible::RASModels::kOmegaSI::kiKapp a() const() > 0.0’

Does it mean that every element of kiKappa should be larger than zero?
what about the ones that are not?

you cant compare fields to a scalar, its like you have a vector a=(1, 2, 3)
and you write
a > 0.
What does that mean?...nothing.

You have to rethink your code there.
First of all thanks for your reply. I can say that my original goal was: 1) to calculate kiKappa as a field of scalar values; 2) to search inside this field for positive and negative values (that's the reason for posing the if....else condition); 3) depending of the kiKappa's sign, to impose a value (which can depend on kiKappa or not) for the next field of scalar values (namely, the fBetaStar parameter).
As you have noticed, I've made some conceptual mistakes, so I will really appreciate if you could give me some advices about how to correct the code...anyway, thank you once again
vkrastev is offline   Reply With Quote

Old   August 24, 2010, 20:21
Default
  #5
Senior Member
 
Hassan Kassem
Join Date: May 2010
Location: Germany
Posts: 242
Rep Power: 17
hk318i is on a distinguished road
try kiKappa.value() > 0.

I am not sure it will work or not
hk318i is offline   Reply With Quote

Old   August 25, 2010, 02:34
Default
  #6
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
I havent compiled this, so it probably wont work, but you have to do it
something like this.
you probably dont have access to runTime and mesh, so you need to replace runTime_ and mesh_ with
the appropriate equivalents and set the correct dimension in dimensionSet
Code:
    tmp<volScalarField> kOmegaSI::fBetaStar() const
    {
        tmp<volScalarField> tBeta
        (
            new volScalarField
            (
                IOobject
                (
                    "fBetaStar",
                    runTime_.timeName(),
                    mesh_,
                    IOobject::NO_READ,
                    IOobject::NO_WRITE
                ),
                mesh_,
                dimensionedScalar("one", dimensionSet(0, 0, 0, 0, 0), 1.0)
            )
        );

    forAll(tBeta(), i)
    {
        if (kiKappa()[i] > 0)
        {
            tBeta()[i] = ....
        }
    }

    return tBeta;
}
niklas is offline   Reply With Quote

Old   August 25, 2010, 04:56
Default
  #7
Senior Member
 
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20
vkrastev is on a distinguished road
Quote:
Originally Posted by hk318i View Post
try kiKappa.value() > 0.

I am not sure it will work or not
Thank you, but I've already tried it and it doesn't work (I mean not simply like this, maybe with some other modifications it will be different)
vkrastev is offline   Reply With Quote

Old   August 25, 2010, 04:57
Default
  #8
Senior Member
 
Vesselin Krastev
Join Date: Jan 2010
Location: University of Tor Vergata, Rome
Posts: 368
Rep Power: 20
vkrastev is on a distinguished road
Quote:
Originally Posted by niklas View Post
I havent compiled this, so it probably wont work, but you have to do it
something like this.
you probably dont have access to runTime and mesh, so you need to replace runTime_ and mesh_ with
the appropriate equivalents and set the correct dimension in dimensionSet
Code:
    tmp<volScalarField> kOmegaSI::fBetaStar() const
    {
        tmp<volScalarField> tBeta
        (
            new volScalarField
            (
                IOobject
                (
                    "fBetaStar",
                    runTime_.timeName(),
                    mesh_,
                    IOobject::NO_READ,
                    IOobject::NO_WRITE
                ),
                mesh_,
                dimensionedScalar("one", dimensionSet(0, 0, 0, 0, 0), 1.0)
            )
        );

    forAll(tBeta(), i)
    {
        if (kiKappa()[i] > 0)
        {
            tBeta()[i] = ....
        }
    }

    return tBeta;
}
Ok, I'll try to modify the source code and then I'll let you know if it works. Thanks a lot
vkrastev is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
A book for a beginner wanting to learn programming frank Main CFD Forum 9 May 12, 2014 23:15
OpenFoam programming prapanj OpenFOAM 10 March 18, 2010 07:23
Programming for CFD atmcfd Main CFD Forum 7 September 9, 2009 01:48
Programming in OpenFOAM vinu OpenFOAM 2 July 11, 2009 10:16
new CFD Programming Forum Thinker Main CFD Forum 14 November 19, 2002 16:03


All times are GMT -4. The time now is 06:41.