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

probelm in Implementing dynamic Vreman model(LES)

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 19, 2014, 05:20
Default probelm in Implementing dynamic Vreman model(LES)
  #1
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Hi,all
I want to implement dynamic Vreman model proposed by You(2006),
A dynamic global-coefficient subgrid-scale eddy-viscosity model for large-eddy simulation in complex geometries, Annual Research Briefs,2006. Most of the code is finished as follows
dynamicVreman.tar.gz

While when compiling it , an error occurs:
Code:
dynamicVreman.C:64:32: error: could not convert ‘Foam::average(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]()’ from ‘Foam::dimensioned<double>’ to ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’
Any help is appreciated.

Xianbei
huangxianbei is offline   Reply With Quote

Old   August 19, 2014, 05:26
Default
  #2
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
cD and cI represents numerator and denominator respectively in formula 3.6
huangxianbei is offline   Reply With Quote

Old   August 19, 2014, 08:26
Default
  #3
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
hi Huang,

AFAIK, average() will return a dimensionedScalar and you used a volScalarField instead. So, I think you should modify your code like below:

Code:
//volScalarField dynamicVreman::cD
dimensionedScalar dynamicVreman::cD
(
    const volTensorField& gradU
) const
{

     const volScalarField aafil = filter_(sqr(mag(alpha(gradU))));
     const volScalarField filaa = sqr(mag(filter_(alpha(gradU))));
     return average(aafil-filaa);
}
And the same thing for dynamicVreman::cI.

I just see your code and I didn't compile it. hope it helps.

Regards,
Mostafa
adambarfi is offline   Reply With Quote

Old   August 19, 2014, 10:52
Default
  #4
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by adambarfi View Post
hi Huang,

AFAIK, average() will return a dimensionedScalar and you used a volScalarField instead. So, I think you should modify your code like below:

Code:
//volScalarField dynamicVreman::cD
dimensionedScalar dynamicVreman::cD
(
    const volTensorField& gradU
) const
{

     const volScalarField aafil = filter_(sqr(mag(alpha(gradU))));
     const volScalarField filaa = sqr(mag(filter_(alpha(gradU))));
     return average(aafil-filaa);
}
And the same thing for dynamicVreman::cI.

I just see your code and I didn't compile it. hope it helps.

Regards,
Mostafa
Hi,Mostafa:
Thank you very much for your help. Yes, the type of cD should be dimensionedScalar , while cI should be volScalarField because
Code:
return average(filter_(II*sqr(mag(D)))-filII*sqr(mag(filter_(D))))/filII
Which means, dimensionedScalar/ volScalarField should be volScalarField.
Now this error is modified, also, the SGS kinetic energy should be added. Here, I have a question about the order in the constructors(dynamicVreman.C)
if the code is written like this
Code:
// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

dynamicVreman::dynamicVreman
(
    const volVectorField& U,
    const surfaceScalarField& phi,
    transportModel& transport,
    const word& turbulenceModelName,
    const word& modelName
)
:
    LESModel(typeName, U, phi, transport),
    GenEddyVisc(U, phi, transport),

    filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
    filter_(filterPtr_()),
    ck_
    (
        dimensioned<scalar>::lookupOrAddToDict
        (
            "ck",
            coeffDict_,
            0.094
        )
    ),
    small1_
    (
        dimensioned<scalar>
        (
            "small1_",
             dimensionSet(0,0,-1,0,0,0,0),
             1e-10
        )
    ) 

    
{
    updateSubGridScaleFields(dev(symm(fvc::grad(U))),fvc::grad(U));

    printCoeffs();
}
There is no warning
However, if the code is written like this
Code:
// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

dynamicVreman::dynamicVreman
(
    const volVectorField& U,
    const surfaceScalarField& phi,
    transportModel& transport,
    const word& turbulenceModelName,
    const word& modelName
)
:
    LESModel(typeName, U, phi, transport),
    GenEddyVisc(U, phi, transport),

    
    ck_
    (
        dimensioned<scalar>::lookupOrAddToDict
        (
            "ck",
            coeffDict_,
            0.094
        )
    ),
    small1_
    (
        dimensioned<scalar>
        (
            "small1_",
             dimensionSet(0,0,-1,0,0,0,0),
             1e-10
        )
    ),
filterPtr_(LESfilter::New(U.mesh(), coeffDict())),
    filter_(filterPtr_()) 

    
{
    updateSubGridScaleFields(dev(symm(fvc::grad(U))),fvc::grad(U));

    printCoeffs();
}
It says
Code:
dynamicVreman.H:111:27: warning: ‘Foam::incompressible::LESModels::dynamicVreman::small1_’will [-Wreorder]
dynamicVreman.H:108:28: warning:   ‘Foam::autoPtr<Foam::LESfilter> Foam::incompressible::LESModels::dynamicVreman::filterPtr_’ [-Wreorder]
dynamicVreman.C:83:1: warning:  initialized here after initialization [-Wreorder]
Why?

Here is the non-warning version
dynamicVreman.tar.gz


Xianbei
huangxianbei is offline   Reply With Quote

Old   August 19, 2014, 11:39
Default
  #5
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
yeah, you're right about cI, my bad!
I haven't seen this warning till now, but I think it's back to the .H file. you defined:

Code:
class dynamicVreman
:
    public GenEddyVisc
{
    // Private data



        autoPtr<LESfilter> filterPtr_;
        LESfilter& filter_;
        dimensionedScalar ck_;
        dimensionedScalar small1_;
.
.
.
So I think you should keep the order in .C file, too.
Sorry, what am I saying is just come from the experiences I got from modifying a LES model and there is no conception behind it!! I'm not a really openFOAM expert.

Regards,
Mostafa
adambarfi is offline   Reply With Quote

Old   August 19, 2014, 21:49
Default
  #6
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by adambarfi View Post
yeah, you're right about cI, my bad!
I haven't seen this warning till now, but I think it's back to the .H file. you defined:

Code:
class dynamicVreman
:
    public GenEddyVisc
{
    // Private data



        autoPtr<LESfilter> filterPtr_;
        LESfilter& filter_;
        dimensionedScalar ck_;
        dimensionedScalar small1_;
.
.
.
So I think you should keep the order in .C file, too.
Sorry, what am I saying is just come from the experiences I got from modifying a LES model and there is no conception behind it!! I'm not a really openFOAM expert.

Regards,
Mostafa
Thank you very much, that's the reason!
huangxianbei is offline   Reply With Quote

Old   August 20, 2014, 10:21
Default
  #7
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by adambarfi View Post

Regards,
Mostafa
Hi, Mostafa:
Problem again.Here is the new version
dynamicVreman-modify.tar.gz
, I corrected a few errors in the formulations.

I test it in a case I have already successfully performed using Smagorinsky, however, when I use the newly implemented model, error occurs:
Code:
--> FOAM FATAL ERROR: 
[0] temporary deallocated
[0] 
[0]     From function const T& Foam::tmp<T>::operator()() const
[0]     in file /home/huangxianbei/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/tmpI.H at line 187.
[0] 
FOAM parallel run aborting
[0] 
[1] --> FOAM FATAL ERROR: 
[1] temporary deallocated
[1] 
[1]     From function const T& Foam::tmp<T>::operator()() const
[1]     in file /home/huangxianbei/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/tmpI.H at line 187.
[1] 
FOAM parallel run aborting
[1] 
[0] #0  Foam::error::printStack(Foam::Ostream&)[1] #0  Foam::error::printStack(Foam::Ostream&)[2] 
[2] 
[2] --> FOAM FATAL ERROR: 
[2] temporary deallocated
[2] 
[2]     From function const T& Foam::tmp<T>::operator()() const
[2]     in file /home/huangxianbei/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/tmpI.H at line 187.
[2] 
FOAM parallel run aborting
[2] 
[2] #0  Foam::error::printStack(Foam::Ostream&)[3] 
[3] 
[3] --> FOAM FATAL ERROR: 
[3] temporary deallocated
[3] 
[3]     From function const T& Foam::tmp<T>::operator()() const
[3]     in file /home/huangxianbei/OpenFOAM/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/tmpI.H at line 187.
[3] 
FOAM parallel run aborting
[3]
Do you have any idea about that?

Xianbei
huangxianbei is offline   Reply With Quote

Old   August 20, 2014, 11:14
Default
  #8
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by adambarfi View Post

Regards,
Mostafa
Hi, I searched the forum and find that has something to do with tmp, so when I delete all the tmp used in the code , the solution can run without any error, also, I find the speed of the calculation is not affected, so I think it's no need to use tmp, however, I still want to know if it's better when tmp used or is it necessary? From my code, can you do some explain on how the error occurs? I have no idea about how

Xianbei
huangxianbei is offline   Reply With Quote

Old   August 20, 2014, 11:32
Default
  #9
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
hi Huang,

I checked your code and I found nothing!
I've been challenged by this error in two cases:

1- when I was modifying the momentum eqn I'd forgot to write UEqn() instead of UEqn.
2- when I was using cyclic bc for inlet and outlet patches, actually my inlet consisted of two patch, and the same for the outlet. When I combined the two patches into one patch the the error was solved.

try to run your case without parallel mode and see if there's this error again.

Regards,
Mostafa

P.S
why did you use T(gradU) in your .H file?
adambarfi is offline   Reply With Quote

Old   August 20, 2014, 11:46
Default
  #10
Senior Member
 
adambarfi's Avatar
 
Mostafa Mahmoudi
Join Date: Jan 2012
Posts: 322
Rep Power: 15
adambarfi is on a distinguished road
Send a message via Yahoo to adambarfi Send a message via Skype™ to adambarfi
Quote:
Originally Posted by huangxianbei View Post
Hi, I searched the forum and find that has something to do with tmp, so when I delete all the tmp used in the code , the solution can run without any error, also, I find the speed of the calculation is not affected, so I think it's no need to use tmp, however, I still want to know if it's better when tmp used or is it necessary? From my code, can you do some explain on how the error occurs? I have no idea about how

Xianbei
according to wiki:

It isn't needed at all, but it reduces the effort and increases the efficiency of your program.
When C++ returns a local object, it copies the object, returns the copy, and deletes the original. This behaviour is safe memory management; however, if you are dealing with large objects (such as a 10 million element geometric tensor field), it can be a costly process.
adambarfi is offline   Reply With Quote

Old   August 20, 2014, 21:17
Default
  #11
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by adambarfi View Post
hi Huang,

I checked your code and I found nothing!
I've been challenged by this error in two cases:

1- when I was modifying the momentum eqn I'd forgot to write UEqn() instead of UEqn.
2- when I was using cyclic bc for inlet and outlet patches, actually my inlet consisted of two patch, and the same for the outlet. When I combined the two patches into one patch the the error was solved.

try to run your case without parallel mode and see if there's this error again.

Regards,
Mostafa

P.S
why did you use T(gradU) in your .H file?
Hi, Mostafa:
Actually the above error occurs when using mpirun.
As for T(gradU), the formulation is d(alpha)ij=duj/dxi, so the T is needed.

Xianbei
huangxianbei is offline   Reply With Quote

Old   August 20, 2014, 21:24
Default
  #12
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by adambarfi View Post
according to wiki:

It isn't needed at all, but it reduces the effort and increases the efficiency of your program.
When C++ returns a local object, it copies the object, returns the copy, and deletes the original. This behaviour is safe memory management; however, if you are dealing with large objects (such as a 10 million element geometric tensor field), it can be a costly process.
Thank you very much. So that depends on how much cells in the computation domain. It's hard to handle this kind of usage, because it's hard to figure out what's wrong in the code if this error occurs.

Some more try:
I start to think the property using 'filter_' operation in the .H file when using tmp. So I add tmp in alphaij and Bbetaij , filapha and filBbeta without tmp, the calculation can still run without error. Thus the key point is that the 'filter_' operation may be not proper in the .H file when tmp is used.

Another point is that if a variant contains filter_, it's element can't be tmp either(const tmp<volTensorField>& gradU can't be used)

As you said before, the tmp can improve the efficiency, then I tried to use tmp more. I was thinking putting filalpha and filBbeta in the .C file, however, as cD and cI both contains the two variants, it may take more time to calculate them twice, hence, I give up this idea.

PS: your avatar is so cute

Last edited by huangxianbei; August 20, 2014 at 22:40.
huangxianbei is offline   Reply With Quote

Old   August 29, 2014, 05:39
Default
  #13
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by adambarfi View Post
according to wiki:

It isn't needed at all, but it reduces the effort and increases the efficiency of your program.
When C++ returns a local object, it copies the object, returns the copy, and deletes the original. This behaviour is safe memory management; however, if you are dealing with large objects (such as a 10 million element geometric tensor field), it can be a costly process.
Hi,Mostafa:Sorry to botheryou again. The model works well now, and I want to output the cI to see how it varies as time. But I'm familiar to the output of a variant, could you give me some hints?

Thank you

Xianbei
huangxianbei is offline   Reply With Quote

Old   March 31, 2015, 07:32
Default
  #14
New Member
 
Christoph Kratzsch
Join Date: Nov 2011
Location: Freiberg
Posts: 28
Rep Power: 15
PonchO is on a distinguished road
Hello Huang,

actually i want to start implementing the Vreman-SGS model by myself. Then i realized, that you have done it already. It would be glad, if you can share your final version.

Best regards,

Christoph
PonchO is offline   Reply With Quote

Reply


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
Dynamic SGS model procedure in Large eddy simulation mrf6166 Main CFD Forum 39 November 25, 2016 15:13
Implementing a dynamic retention force in interFoam u2947 OpenFOAM Programming & Development 2 June 17, 2013 10:14
Implementing Dynamic Patch/mesh Deformation linked to the flow solution fredo490 OpenFOAM Programming & Development 0 March 4, 2013 07:02
Dynamic Mesh moving interface help akash.iitb FLUENT 0 August 24, 2010 00:53


All times are GMT -4. The time now is 08:39.