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

Inheriting kOmega: why can't I change the constructor?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 26, 2011, 06:34
Default Inheriting kOmega: why can't I change the constructor?
  #1
Senior Member
 
Robert Sawko
Join Date: Mar 2009
Posts: 117
Rep Power: 22
AlmostSurelyRob will become famous soon enough
Dear All,

I am modifying some RAS models in order for them to work better with two-phase stratified flows. It was observed that standard models produce excessive viscosity at the interface and due to this overpredict pressure gradients.

Anyway, I am having a problem with a fairly simple, I should think, piece of code. Please have a look at this:

Code:
#ifndef kOmegaStrat_H
#define kOmegaStrat_H

#include "kOmega.H"

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

namespace Foam
{
namespace incompressible
{
namespace RASModels
{

/*---------------------------------------------------------------------------*\
                           Class kOmega Declaration
\*---------------------------------------------------------------------------*/

class kOmegaStrat
:
    public kOmega
{
protected:
//ADDED!
    const volScalarField& alpha1_;

public:

    //- Runtime type information
    TypeName("kOmegaStrat");

    // Constructors

        //- Construct from components

    kOmegaStrat
        (
            const volVectorField& U,
            const surfaceScalarField& phi,
            transportModel& transport,
            const volScalarField& alpha1, //ADDED!
            const word& turbulenceModelName = turbulenceModel::typeName,
            const word& modelName = typeName
        )
    :
        kOmega(U, phi, transport, turbulenceModelName, modelName),
        alpha1_(alpha1) //ADDED!
    {
    }

    //- Destructor
    virtual ~kOmegaStrat()
    {}
};


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

} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam

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

#endif
So the only change I wanted to make so far is to include phase fraction from VOF equation. The error I am getting from wmake libso is:
Description Resource Path Location Type
no matching function for call to
Code:
‘Foam::incompressible::RASModels::kOmegaStrat::kOmegaStrat(const Foam::volVectorField&, const Foam::surfaceScalarField&, Foam::transportModel&, const Foam::word&)’    stratTurbulence        line 126, external location: /home/c111269/OpenFOAM/OpenFOAM-2.0.x/src/turbulenceModels/incompressible/RAS/lnInclude/RASModel.H    C/C++ Problem
Is there anything I can do about this? Please advise. If I remove alpha1 and the appropriate entries in the constructor the library compiles fine.



In fact, I have already written a small library by writing my own super class equivalent to RASModel. Then I create particular turbulence models by inheriting from this class. This approach, however, has certain drawbacks. For example I also had to rewrite yPlusRAS tool and all the Wall Functions I am using. It is a bit tedious, especially that the changes I have to implement are usually minute. Is there any way to do it more elegantly and more... pragmatically?
AlmostSurelyRob is offline   Reply With Quote

Old   October 26, 2011, 10:34
Default
  #2
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
a class can accept different constructor , so instead of changing the present constructor, add ur new constructor beside it , may be it works
nimasam is offline   Reply With Quote

Old   October 26, 2011, 13:09
Default
  #3
Senior Member
 
Robert Sawko
Join Date: Mar 2009
Posts: 117
Rep Power: 22
AlmostSurelyRob will become famous soon enough
Thanks for the reply.

I know that the class can have several constructors and indeed I have already checked that if I use a constructor without alpha1 in the argument list, the library compiles. But still I have a duty to my class to initialise alpha1 with a reasonable value and I do not feel competent to fulfil this duty without a proper reference. :-)

At the end of the day, I would like to be able to use this class in a VOF solver like interFoam in the same manner it works now i.e. by invoking turbulenceModel constructor, perhaps with a different set of parameters.

So I think that that my problem can be solved by changing the super class i.e. turbulenceModel. There's this part I don't quite understand:

Code:
        turbulenceModel
        (
            const volVectorField& U,
            const surfaceScalarField& phi,
            transportModel& transport,
            const word& turbulenceModelName = typeName
        );


    // Selectors

        //- Return a reference to the selected turbulence model
        static autoPtr<turbulenceModel> New
        (
            const volVectorField& U,
            const surfaceScalarField& phi,
            transportModel& transport,
            const word& turbulenceModelName = typeName
        );
What is a selector? What is autoPtr? Any help, references or hints will be greatly appreciated!
AlmostSurelyRob is offline   Reply With Quote

Old   October 26, 2011, 22:31
Default
  #4
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
You probably broke the runtime selection. take a look at this link, it may be useful.
http://openfoamwiki.net/index.php/Op...tion_mechanism

It is a very useful feature, especially if you do not know apriori which model will be used. But it can be touchy.
adhiraj is offline   Reply With Quote

Old   October 27, 2011, 05:34
Default
  #5
Senior Member
 
Robert Sawko
Join Date: Mar 2009
Posts: 117
Rep Power: 22
AlmostSurelyRob will become famous soon enough
Thank you - that was a very important article. Now it all makes sense. Just to make it clear - I haven't broken the run time selection mechanism yet! I intend to do it at some point, but not now.

Hopefully after reading this article I will be able to fix it.

I have also realised that for my purposes it's probably better to work with nu field which is available in standard incompressible RAS model. This would allow me to avoid changing the constructors and avoid a possibility of breaking run time selection mechanism. I simply have to save the lowest and the highest viscosity and make sure that the initial field contains the two extremes. The main idea is that I want to treat the gas phase differently than the liquid phase, so this is why I am going through all of this.

But anyhow this was a very informative discussion - thank you for all the comments.
AlmostSurelyRob 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
How to change density in OpenFoam zhaowei OpenFOAM Running, Solving & CFD 8 November 5, 2018 11:37
Solid/liquid phase change fabian_roesler OpenFOAM 10 December 24, 2012 07:37
Change cell zone index/thread during simulation neilduffy1024 FLUENT 0 January 17, 2011 10:40
no enthalpy change across the momentum source Atit Koonsrisuk CFX 2 December 19, 2005 03:33
Multicomponent fluid Andrea CFX 2 October 11, 2004 06:12


All times are GMT -4. The time now is 16:29.