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

Read IOdictionary entries from within turbulence model

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   August 2, 2012, 10: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: 8
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 12:15. Reason: More details given
Arnoldinho is offline   Reply With Quote

Old   August 3, 2012, 03:02
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
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, 03:15
Default
  #3
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 8
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, 11:59
Default
  #4
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 8
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, 14:36
Default
  #5
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,258
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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, 11:31
Default
  #6
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 8
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, 12:38
Default
  #7
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 8
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
Arnoldinho is offline   Reply With Quote

Old   August 11, 2012, 06:59
Default
  #8
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 8
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, 07:13
Default
  #9
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 8
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, 07:15
Default
  #10
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 8
Hisham is on a distinguished road
Maybe it is the OF version???
Hisham is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
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 09: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 13:37


All times are GMT -4. The time now is 15:32.