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

Read IOdictionary entries from within turbulence model

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By Arnoldinho

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 2, 2012, 11:40
Default Read IOdictionary entries from within turbulence model
  #1
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18
Arnoldinho is on a distinguished road
Hi all,

I'm "unable" to read a IOdictionary from within a modified kOmegaSST turbulence model. How can I implement such a behaviour, so that I can use the variables from the dictionary for some calculations within the turbulence model?

I so far was able to make an entry of the dictionary in kOmegaSST.C (in the constructor), and in kOmegaSST.H (in the class declaration). An entry of dimensionedScalar d_grain is also in the constructor - but I'm not able to make an entry in the constructur for d_grain...

kOmegaSST.H:
Quote:
class kOmegaSSTRough
:
public RASModel
{
...
IOdictionary sedTransDict_;
dimensionedScalar dgrain;
...
}
kOmegaSST.C:
Quote:
kOmegaSSTRough::kOmegaSSTRough
(
const volVectorField& U,
const surfaceScalarField& phi,
transportModel& lamTransportModel
)
:
...
sedTransDict_
(
IOobject
(
"sedTransDict",
runTime_.system(),
runTime_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
{
...
dgrain(sedTransDict_.lookup("d_grain")/1000);
}
The latter entry does not compile, whatever I write here. I also tried variants of
Quote:
dgrain
(
"dgrain",
dimensionSet(0,1,0,0,0,0,0),
scalar(readScalar(sedTransDict_.lookup("d_grain"))/1000)
);
Maybe someone can make me a bit more 'familiar' with such declarations?

Arne

Last edited by Arnoldinho; August 2, 2012 at 13:15. Reason: More details given
Arnoldinho is offline   Reply With Quote

Old   August 3, 2012, 04:02
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
It would help if you post the first of your compilation errors.


Instead of creating a complete new dictionary file, it may be a nicer solution to include your dictionary in the RASProperties file, by using a subDict. That is relatively easy to construct I suppose. You can also have a look at how it is implemented for certain LES models. It seems a bit overkill to me to define a new dictionary file here.
Bernhard is offline   Reply With Quote

Old   August 3, 2012, 04:15
Default
  #3
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18
Arnoldinho is on a distinguished road
Yes thats true Bernhard, I should have posted the error message.

To simplify the problem, I eliminated the dimensionality and used a normal scalar. Therefore in kOmegaSSTRough.H I have
Quote:
class kOmegaSSTRough
:
public RASModel
{
...
IOdictionary sedTransDict_;
scalar dgrain;
...
public:
...
}
and in kOmegaSSTRough.C:
Quote:
kOmegaSSTRough::kOmegaSSTRough
(
const volVectorField& U,
const surfaceScalarField& phi,
transportModel& lamTransportModel
)
:
sedTransDict_
(
IOobject
(
"sedTransDict",
runTime_.system(),
runTime_,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
)
...
{
dgrain(readScalar(sedTransDict_.lookup("d_grain")) );
}
The compilation error in kOmegaSSTRough.C then is
Quote:
kOmegaSSTRough.C:293: error: ‘((Foam::incompressible::RASModels::kOmegaSSTRough *)this)->Foam::incompressible::RASModels::kOmegaSSTRough:: dgrain’ cannot be used as a function
In my case, using a seperate dictionary is not an overkill, as a lot more entries are written there which are used by the solver. The d_grain entry is used by the solver as well, so I'd like to avoid a seperate dictionary with same entries.

Arne
Arnoldinho is offline   Reply With Quote

Old   August 7, 2012, 12:59
Default
  #4
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18
Arnoldinho is on a distinguished road
Are there any hints on how to read values from a dictionary?
Arnoldinho is offline   Reply With Quote

Old   August 7, 2012, 15:36
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

@Arne:
The short DIY answer :
Code:
cd $FOAM_UTILITIES
find . -name "*Dict"
cd $FOAM_TUTORIALS
find . -name "*Properties"
The semi-short answer:
  1. From the list of files given by the above commands, you can have a look at the source code for "topoSet" for coding ideas. The downside is that there you won't find any cases with units in them.
  2. After searching a bit more, I found this valuable example of a direct access to a dictionary: "applications/solvers/compressible/rhoCentralFoam/readThermophysicalProperties.H" - online: https://github.com/OpenFOAM/OpenFOAM...alProperties.H
    There you should find how to read a value with units in it.
    I found by running:
    Code:
    cd $FOAM_APP
    find . -name "*.H" | xargs grep -sl thermophysicalProperties
Have fun!
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   August 8, 2012, 12:31
Default
  #6
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18
Arnoldinho is on a distinguished road
Thanks for your help and hints Bruno!

My problem seems nevertheless more related to "where to put the variables and declarations in the source code", i.e. public or private member functions, the constructor, namespaces, class declaration and so on. I'm afraid that I'm not familiar enough with this - but maybe this is a "standard" c++ problem and not directly related to OF.

Arne
Arnoldinho is offline   Reply With Quote

Old   August 8, 2012, 13:38
Default
  #7
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18
Arnoldinho is on a distinguished road
Ok, it seems that I was thinking a bit too complicated. So now I have just put it in void kOmegaSSTRough::correct(), where I need the value, and it works fine:

Code:
void kOmegaSSTRough::correct()
{
    IOdictionary sedTransDict_
    (
        IOobject
        (
            "sedTransDict",
             runTime_.system(),
             runTime_,
             IOobject::MUST_READ,
             IOobject::NO_WRITE
        )
    );

    dimensionedScalar dgrain_
    (
            "dgrain_",
            dimensionSet(0,1,0,0,0,0,0),
            scalar(readScalar(sedTransDict_.lookup("d_grain")))
    );
    dgrain_ /= 1000;    // convert m -> mm
    ...
}
There is just one more (not that important) thing: is dgrain_ now read every single time step? If so, how can I change this, in oder to save some time? The values are not changing and therefore need to be read only once when the simulation starts.

Arne
Luis F and CorbinMG like this.
Arnoldinho is offline   Reply With Quote

Old   August 11, 2012, 07:59
Default
  #8
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Hello Arne,

Code:
IOobject::MUST_READ_IF_MODIFIED
Regards
Hisham
Hisham is offline   Reply With Quote

Old   August 11, 2012, 08:13
Default
  #9
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 18
Arnoldinho is on a distinguished road
Thanks Hisham,

but I have already tried that: If gives me the error message
Quote:
error: ‘MUST_READ_IF_MODIFIED’ is not a member of ‘Foam::IOobject’
which is curious as I have already seen this used with an IOobject somewhere.

Any hints?
Arnoldinho is offline   Reply With Quote

Old   August 11, 2012, 08:15
Default
  #10
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Maybe it is the OF version???
Hisham 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
build your own turbulence model with buoyancy Thomas Baumann OpenFOAM 11 November 23, 2009 09:53
Discussion: Reason of Turbulence!! Wen Long Main CFD Forum 3 May 15, 2009 10:52
Fan heater model: what turbulence source to use? andy20 Main CFD Forum 0 March 2, 2008 13:46
Sinclair Model + secondary turbulence Yi FLUENT 0 October 26, 2001 14:37


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