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

A quite simple if() condition statement.

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By ARTem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 6, 2014, 12:18
Default A quite simple if() condition statement.
  #1
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
Hi guys,

In my phase dictionary, this is a sub dictionary for a specific phase. for example: the subdic for air:

In file:Phaseproperties
Code:
phases (air water);

air
{
    //diameterModel   sauter;
    diameterModel   constant;

....................
I wish my solver can choose whether or not to run a function depending on this diameterModel entry. In human language....It should be something like:

Code:
 if(diameter model is sauter, we run this function...)
{
}
Im new to C++ code. So could you guys give me a hint? Thanks very much.

Or can I ask ubuntu to learn human language? lol

Last edited by sharonyue; November 7, 2014 at 01:45.
sharonyue is offline   Reply With Quote

Old   November 20, 2014, 08:29
Default
  #2
Member
 
Artem Shaklein
Join Date: Feb 2010
Location: Russia, Izhevsk
Posts: 43
Rep Power: 16
ARTem is on a distinguished road
Hi, sharonyue.
Can't find what kind of standard mathematical model uses diameterModel class. So, I give you analog example. If one wants to check turbulence model typeName, he can write next code:

createFields.H
Code:
...
    const word modelType
    (
        IOdictionary
        (
            IOobject
            (
                "RASProperties",
                U.time().constant(),
                U.db(),
                IOobject::MUST_READ_IF_MODIFIED,
                IOobject::NO_WRITE,
                false
            )
        ).lookup("RASModel")
    );

    const word turbType
    (
        IOdictionary
        (
            IOobject
            (
                "turbulenceProperties",
                U.time().constant(),
                U.db(),
                IOobject::MUST_READ_IF_MODIFIED,
                IOobject::NO_WRITE,
                false
            )
        ).lookup("simulationType")
    );

    Info << "Turbulence model type is " << turbType << "\n"
          << "Turbulence model name is " << modelType << "\n";
...
So, one can use word modelType in the next code

Code:
if (modelType == "kEpsilon" && turbType == "RASModel")
{
     // Do operations based on assumption that kEpsilon model is used
}
turbType is used in case when in file "turbulenceProperties" "laminar" keyword is enabled instead of "RASModel".
sharonyue likes this.
ARTem is offline   Reply With Quote

Old   November 20, 2014, 09:52
Default
  #3
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Beijing, China
Posts: 838
Rep Power: 17
sharonyue is on a distinguished road
Quote:
Originally Posted by ARTem View Post
Hi, sharonyue.
Can't find what kind of standard mathematical model uses diameterModel class. So, I give you analog example. If one wants to check turbulence model typeName, he can write next code:

createFields.H
Code:
...
    const word modelType
    (
        IOdictionary
        (
            IOobject
            (
                "RASProperties",
                U.time().constant(),
                U.db(),
                IOobject::MUST_READ_IF_MODIFIED,
                IOobject::NO_WRITE,
                false
            )
        ).lookup("RASModel")
    );

    const word turbType
    (
        IOdictionary
        (
            IOobject
            (
                "turbulenceProperties",
                U.time().constant(),
                U.db(),
                IOobject::MUST_READ_IF_MODIFIED,
                IOobject::NO_WRITE,
                false
            )
        ).lookup("simulationType")
    );

    Info << "Turbulence model type is " << turbType << "\n"
          << "Turbulence model name is " << modelType << "\n";
...
So, one can use word modelType in the next code

Code:
if (modelType == "kEpsilon" && turbType == "RASModel")
{
     // Do operations based on assumption that kEpsilon model is used
}
turbType is used in case when in file "turbulenceProperties" "laminar" keyword is enabled instead of "RASModel".
Cool, this is what I need. I will try it n give a feedback. Thank you bro.
sharonyue 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
Boundary Condition for granular temperature Theta cheng1988sjtu OpenFOAM Programming & Development 4 July 4, 2016 16:08
about the implemention of periodic boundary condition harbinyg Main CFD Forum 5 July 12, 2012 04:30
asking for Boundary condition in FLUENT Destry FLUENT 0 July 27, 2010 00:55
External Radiation Boundary Condition for Grid Interface CFD XUE FLUENT 0 July 9, 2010 02:53
vorticity boundary condition bearcharge Main CFD Forum 0 May 14, 2010 11:32


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