|
[Sponsors] |
Inheriting kOmega: why can't I change the constructor? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 26, 2011, 06:34 |
Inheriting kOmega: why can't I change the constructor?
|
#1 |
Senior Member
Robert Sawko
Join Date: Mar 2009
Posts: 117
Rep Power: 22 |
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 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 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? |
|
October 26, 2011, 13:09 |
|
#3 |
Senior Member
Robert Sawko
Join Date: Mar 2009
Posts: 117
Rep Power: 22 |
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 ); |
|
October 26, 2011, 22:31 |
|
#4 |
Senior Member
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16 |
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. |
|
October 27, 2011, 05:34 |
|
#5 |
Senior Member
Robert Sawko
Join Date: Mar 2009
Posts: 117
Rep Power: 22 |
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. |
|
|
|
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 |