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

BasicTurbulenceModel class declaration in OpenFOAM 6

Register Blogs Community New Posts Updated Threads Search

Like Tree8Likes
  • 1 Post By GerhardHolzinger
  • 7 Post By zhangyan

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 12, 2019, 15:34
Default BasicTurbulenceModel class declaration in OpenFOAM 6
  #1
New Member
 
Rodrigo Petrone dos Anjos
Join Date: May 2014
Posts: 4
Rep Power: 11
rod_petrone is on a distinguished road
Hello,


I was trying to understand turbulence models implementation in OpenFOAM 6. Nevertheless, in linearViscousStress. H, it is used a parent class called BasicTurbulenceModel, which is the class template parameter too.

I have not been able to find BasicTurbulenceModel declaration and definition. Does someone know where it is in OpenFOAM? Or is it a declaration way that i am not familarizied with?




Codes:


linearViscousStress.H:

Code:
#ifndef linearViscousStress_H
#define linearViscousStress_H

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

/*---------------------------------------------------------------------------*\
                           Class linearViscousStress Declaration
\*---------------------------------------------------------------------------*/

template<class BasicTurbulenceModel>
class linearViscousStress
:
    public BasicTurbulenceModel
{

public:

    typedef typename BasicTurbulenceModel::alphaField alphaField;
    typedef typename BasicTurbulenceModel::rhoField rhoField;
    typedef typename BasicTurbulenceModel::transportModel transportModel;


    // Constructors

        //- Construct from components
        linearViscousStress
        (
            const word& modelName,
            const alphaField& alpha,
            const rhoField& rho,
            const volVectorField& U,
            const surfaceScalarField& alphaRhoPhi,
            const surfaceScalarField& phi,
            const transportModel& transport,
            const word& propertiesName
        );


    //- Destructor
    virtual ~linearViscousStress()
    {}


    // Member Functions

        //- Re-read model coefficients if they have changed
        virtual bool read() = 0;

        //- Return the effective stress tensor
        virtual tmp<volSymmTensorField> devRhoReff() const;

        //- Return the source term for the momentum equation
        virtual tmp<fvVectorMatrix> divDevRhoReff(volVectorField& U) const;

        //- Return the source term for the momentum equation
        virtual tmp<fvVectorMatrix> divDevRhoReff
        (
            const volScalarField& rho,
            volVectorField& U
        ) const;

        //- Solve the turbulence equations and correct the turbulence viscosity
        virtual void correct() = 0;
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#ifdef NoRepository
    #include "linearViscousStress.C"
#endif

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif
linearViscousStress.C:


Code:
#include "linearViscousStress.H"
#include "fvc.H"
#include "fvm.H"

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

template<class BasicTurbulenceModel>
Foam::linearViscousStress<BasicTurbulenceModel>::linearViscousStress
(
    const word& modelName,
    const alphaField& alpha,
    const rhoField& rho,
    const volVectorField& U,
    const surfaceScalarField& alphaRhoPhi,
    const surfaceScalarField& phi,
    const transportModel& transport,
    const word& propertiesName
)
:
    BasicTurbulenceModel
    (
        modelName,
        alpha,
        rho,
        U,
        alphaRhoPhi,
        phi,
        transport,
        propertiesName
    )
{}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

template<class BasicTurbulenceModel>
bool Foam::linearViscousStress<BasicTurbulenceModel>::read()
{
    return BasicTurbulenceModel::read();
}


template<class BasicTurbulenceModel>
Foam::tmp<Foam::volSymmTensorField>
Foam::linearViscousStress<BasicTurbulenceModel>::devRhoReff() const
{
    return tmp<volSymmTensorField>
    (
        new volSymmTensorField
        (
            IOobject
            (
                IOobject::groupName("devRhoReff", this->alphaRhoPhi_.group()),
                this->runTime_.timeName(),
                this->mesh_,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            (-(this->alpha_*this->rho_*this->nuEff()))
           *dev(twoSymm(fvc::grad(this->U_)))
        )
    );
}


template<class BasicTurbulenceModel>
Foam::tmp<Foam::fvVectorMatrix>
Foam::linearViscousStress<BasicTurbulenceModel>::divDevRhoReff
(
    volVectorField& U
) const
{
    return
    (
      - fvc::div((this->alpha_*this->rho_*this->nuEff())*dev2(T(fvc::grad(U))))
      - fvm::laplacian(this->alpha_*this->rho_*this->nuEff(), U)
    );
}


template<class BasicTurbulenceModel>
Foam::tmp<Foam::fvVectorMatrix>
Foam::linearViscousStress<BasicTurbulenceModel>::divDevRhoReff
(
    const volScalarField& rho,
    volVectorField& U
) const
{
    return
    (
      - fvc::div((this->alpha_*rho*this->nuEff())*dev2(T(fvc::grad(U))))
      - fvm::laplacian(this->alpha_*rho*this->nuEff(), U)
    );
}


template<class BasicTurbulenceModel>
void Foam::linearViscousStress<BasicTurbulenceModel>::correct()
{
    BasicTurbulenceModel::correct();
}


// ************************************************************************* //

Last edited by wyldckat; August 5, 2019 at 19:21. Reason: Added [CODE][/CODE] markers
rod_petrone is offline   Reply With Quote

Old   April 15, 2019, 04:28
Default
  #2
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 339
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
There is no class named BasicTurbulenceModel, it is a template parameter from which some classes are also derived from. In order to make sense of this, get familiar with the C++ concepts of object orientation, inheritace and templates.

In OpenFOAM's hierarchy of turbulence models, there are two basic categories of turbulence models: incompressible and compressible ones.

Thus, OpenFOAM derives from the base-class of all turbulence models turbulenceModel two classes: incompressibleTurbulenceModel and compressibleTurbulenceModel.

These two classes are then used as template parameter to build the model-trees for incompressible and compressible turbulence models.

Unfortunately, the organisation of the turbulence model classes is not easy to get to understand, and it is also not easy to explain, at least for me. However, it is a brilliant way to avoid the code duplication that was there before. Download the sources of any OpenFOAM version prior to 3.0, and expore the content of $FOAM_SRC/turbulenceModels. Easier to grasp, yet lots of duplicated code.
rod_petrone likes this.
GerhardHolzinger is offline   Reply With Quote

Old   April 15, 2019, 05:16
Default
  #3
Senior Member
 
zhangyan's Avatar
 
Yan Zhang
Join Date: May 2014
Posts: 120
Rep Power: 11
zhangyan is on a distinguished road
You can find the compressible part here: https://openfoam.top/en/turb/
Sorry for that the language is Chinese.
But the UML is clear:
__________________
https://openfoam.top

Last edited by zhangyan; April 19, 2019 at 06:23.
zhangyan is offline   Reply With Quote

Old   April 15, 2019, 08:27
Default
  #4
New Member
 
Rodrigo Petrone dos Anjos
Join Date: May 2014
Posts: 4
Rep Power: 11
rod_petrone is on a distinguished road
Hi Gerhard,



I am familiar with many of this C++ concepts of object orientation, inheritace and templates, what i have not understand it was the template parameter used as a parent class, i haven't seen this before. But i think i was able to understand now. At the same time, BasicTurbulenceModel is a parameter, this parameter becomes the parent class of linearViscousStress class.



OpenFOAM version prior to 3.0 i understand the turbulence models class, because i had to implement turbulence models in OpenFOAM 2.3 to my master thesis.


Thank you for the answer.


Best regards,


Rodrigo Petrone
rod_petrone is offline   Reply With Quote

Reply

Tags
basicturbulencemodel, openfoam6, turbulencemodels


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
Map of the OpenFOAM Forum - Understanding where to post your questions! wyldckat OpenFOAM 10 September 2, 2021 05:29
OpenFOAM Training: Programming CFD Course 12-13 and 19-20 April 2016 cfd.direct OpenFOAM Announcements from Other Sources 0 January 14, 2016 10:19
OpenFOAM Training, London, Chicago, Munich, Sep-Oct 2015 cfd.direct OpenFOAM Announcements from Other Sources 2 August 31, 2015 13:36
Possible bug in OpenFoam Interpolation class MMC15 OpenFOAM Bugs 2 March 23, 2014 12:55
64bitrhel5 OF installation instructions mirko OpenFOAM Installation 2 August 12, 2008 18:07


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