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

codeInclude in coded function in controlDict, and yPlus

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By LuisAlberto

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 16, 2015, 13:25
Default codeInclude in coded function in controlDict, and yPlus
  #1
New Member
 
Luis Alberto
Join Date: Aug 2015
Location: Spain
Posts: 8
Rep Power: 11
LuisAlberto is on a distinguished road
Good afternoon everyone,

I am trying to write a coded function object into my controlDict in order to play around with the calculation of yPlus and, by the way, learn more about programming in OpenFOAM.

At the moment, I am trying to do it in the way it is done in nutkWallFunctionFvPatchScalarField.C

The thing is that I need to include the header "incompressible/turbulenceModel/turbulenceModel.H" where the type turbulenceModel is defined, but when I run pisoFoam, he does not find the file.

However, he is able to find pointField.H (I don't need it, it is just for testing) Why does he find this one and not turbulenceModel.H? Code and errors below.

Any help is appreciated.

At the same time, any suggestions about how to compute the distance from the wall at the cells adjacent to it in a coded function objetct?

Code:
functions
{
    test
    {
        // Load the library containing the 'coded' functionObject
        functionObjectLibs ("libutilityFunctionObjects.so");
        type coded;
        // Name of on-the-fly generated functionObject
        redirectType error;

        codeInclude
        #{
        #include "pointField.H" // Why does he find this one but not the rest??
        #include "nutkWallFunctionFvPatchScalarField.H" // only in case he needed this to find the next, but not.
        #include "incompressible/turbulenceModel/turbulenceModel.H"
        #};

        codeOptions  // To try to fix the above files not found, but does not work
        #{
        -I /opt/openfoam231/src/turbulenceModels/
        #};

        code
        #{

        label patchID = mesh().boundaryMesh().findPatchID("movingWall");
        const turbulenceModel& turbModel =
                db().lookupObject<turbulenceModel>("turbulenceModel");
        const scalarField& y = turbModel.y()[patchID];
        #};
    }
}
Code:
could not open file nutkWallFunctionFvPatchScalarField.H for source file functionObjectTemplate.C due to No such file or directory
could not open file incompressible/turbulenceModel/turbulenceModel.H for source file functionObjectTemplate.C due to No such file or directory
Making dependency list for source file FilterFunctionObjectTemplate.C
could not open file nutkWallFunctionFvPatchScalarField.H for source file FilterFunctionObjectTemplate.C due to No such file or directory
could not open file incompressible/turbulenceModel/turbulenceModel.H for source file FilterFunctionObjectTemplate.C due to No such file or directory
In file included from functionObjectTemplate.C:26:0:
Thanks,

Luis
LuisAlberto is offline   Reply With Quote

Old   August 16, 2015, 14:06
Default
  #2
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
The problem is that you must point include directory "-I" to lnInclude, for example

Code:
-I$(FOAM_SRC)/turbulenceModels/incompressible/turbulenceModel/lnInclude \
-I$(FOAM_SRC)/turbulenceModels/incompressible/RAS/lnInclude \
You can find how to add proper include directories for RAS/LES incompressible models in file Make/options of pimpleFoam solver ($FOAM_APP/solvers/incompressible/pimpleFoam)
mkraposhin is offline   Reply With Quote

Old   August 16, 2015, 15:50
Default
  #3
New Member
 
Luis Alberto
Join Date: Aug 2015
Location: Spain
Posts: 8
Rep Power: 11
LuisAlberto is on a distinguished road
Thank you very much mkraposhin,

Following your suggestion, it finally finds it using

Code:
        codeOptions
        #{
        -I$(FOAM_SRC)/turbulenceModels/incompressible/turbulenceModel/lnInclude \
        -I$(FOAM_SRC)/transportModels \
        #};
However, even after including turbulenceModel.H, it still says that 'burbulenceModel' does not name a type. Any clue why, or any suggestions for a work-around for obtaining the distances to the wall? (I am going to try to do it also following the way it is done in yPlusRAS or yPlusLES).

Code:
/home/lpadron/OpenFOAM/lpadron-2.3.1/run/tutorials/incompressible/pisoFoam/ras/cavity-test-yplus-coded/system/controlDict.functions.test:74:8: error: ‘turbulenceModel’ does not name a type
Any suggestiong?

thanks!
LuisAlberto is offline   Reply With Quote

Old   August 17, 2015, 03:12
Default
  #4
Senior Member
 
mkraposhin's Avatar
 
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21
mkraposhin is on a distinguished road
Hello, are using incompressible or compressible turbulence model?

If turbulence mode is incompressible, then you must declare variable for it using namespace Foam::incompressible, for example:

Code:
const Foam::incompressible::turbulenceModel& turbModel =
                db().lookupObject<Foam::incompressible::turbulenceModel>("turbulenceModel");
You can see example in "createFields.H" of pimpleFoam solver sources
mkraposhin is offline   Reply With Quote

Old   August 18, 2015, 13:48
Default
  #5
New Member
 
Luis Alberto
Join Date: Aug 2015
Location: Spain
Posts: 8
Rep Power: 11
LuisAlberto is on a distinguished road
Thank you very much mkraposhin,

It indeed works that way. I should have realized that it was a TypeName that could be found in Doxygen and going to Namespaces->Incompressible (Foam::incompressible) ->class turbulenceModel (the one whose header I include), and there you find typeName turbulenceModel as the run-time information for the turbulence model. Of course, you can directly search for turbulence model in Doxygen. Thanks.

My only doubt there, perhaps you can help me, is why 'turbulenceModel' does not appear in Doxygne's Namespaces -> Namespace members.

In case it might be of use to someone in the future, the final working code to add at the end of controlDict is:

Code:
functions
{
    test
    {
        // Load the library containing the 'coded' functionObject
        functionObjectLibs ("libutilityFunctionObjects.so");
        type coded;
        // Name of on-the-fly generated functionObject
        redirectType error;

        codeInclude
        #{
        #include "turbulenceModel.H"
        #};

        codeOptions
        #{
        -I$(FOAM_SRC)/turbulenceModels/incompressible/turbulenceModel/lnInclude \
        -I$(FOAM_SRC)/transportModels \
        #};

        code
        #{

        label patchID = mesh().boundaryMesh().findPatchID("movingWall");
        const Foam::incompressible::turbulenceModel& turbModel =
                mesh().thisDb().lookupObject<Foam::incompressible::turbulenceModel>("turbulenceModel");

        const scalarField& y = turbModel.y()[patchID];

        Info << "y= " << y << endl;
        #};
    }
}
stamufa likes this.
LuisAlberto is offline   Reply With Quote

Reply

Tags
codeinclude, codestream, yplus


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



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