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

Access turbulence model in coded functionobjectlibs

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By eelcovv

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 11, 2012, 11:23
Default Access turbulence model in coded functionobjectlibs
  #1
Senior Member
 
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19
eelcovv is on a distinguished road
Dear foamers,

I have been using function object libs now for a while to be able to do some extra coding at run time without modifying the solver.

Now I want to create a code snipped which calculates the RMS value of the solution matrix being solved, so you can access the accuracy of the solution.

My code snipped would look like

Code:
 

errorAnalysis
{
    functionObjectLibs ("libutilityFunctionObjects.so");
    type coded;
    redirectType average;
    outputControl timeStep;
    code
    #{
      const volVectorField&      U=mesh().lookupObject<volVectorField>("U");
      const surfaceScalarField& phi=mesh().lookupObject<surfaceScalarField>("phi");
      const volScalarField&      p=mesh().lookupObject<volScalarField>("p");



fvVectorMatrix residualMatrix
         (
                fvm::ddt(U)
            +  fvm::div(phi, U)  
            +  turbulence->divDevReff(U)
            +  fvc::grad(p)
         );

        Info << "RMS residualMatrix: " << Foam::sqrt(gSumMag(magSqr(residualMatrix.residual()))) << nl  ;


    #};
}
This piece of code works if I put it in the solver, but in the coded functionobject libs I do not know how to access the turbulence pointer using the lookupObject. Would somebode know how to access the divDevReff in code snipped dynamically linked at the case level ?

Regards

Eelco
eelcovv is offline   Reply With Quote

Old   July 12, 2012, 10:46
Default work-around
  #2
Senior Member
 
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19
eelcovv is on a distinguished road
As a work around in order to access the turbulence->divDevReff from the dynamically linked function object I found the following.

Code:
errorAnalysis
{
    functionObjectLibs ("libutilityFunctionObjects.so");
    type coded;
    redirectType average;
    outputControl timeStep;
    code
    #{

      const volVectorField&      U=mesh().lookupObject<volVectorField>("U");
      const surfaceScalarField&  phi=mesh().lookupObject<surfaceScalarField>("phi");
      const volScalarField&      p=mesh().lookupObject<volScalarField>("p");
      const volScalarField&      nuSgs=U.db().lookupObject<volScalarField>("nuSgs");
      const dictionary& transportProperties = U.db().lookupObject<IOdictionary>
      (
         "transportProperties"
      );
      const dimensionedScalar&   nu(transportProperties.lookup("nu"));

      fvVectorMatrix residualMatrix
         (
              fvm::ddt(U)
            + fvm::div(phi, U)
            - fvm::laplacian(nu+nuSgs, U) - fvc::div((nu+nuSgs)*dev(T(fvc::grad(U))))
            + fvc::grad(p)
         );

       Info << "RMS residualMatrix: " << Foam::sqrt(gSumMag(magSqr(residualMatrix.residual()))) << nl  ;
    #};
}
It works, but is rather ugly. I prefer to replace the line fvc::div((nu+nuSgs)*dev(T(fvc::grad(U)))) with turbulence-> value. Does anybody has a hint?
liquidspoon likes this.
eelcovv is offline   Reply With Quote

Old   August 12, 2012, 00:18
Default
  #3
Member
 
ak
Join Date: May 2011
Posts: 64
Rep Power: 14
newOFuser is on a distinguished road
Hello

Is the 'type coded' option available in OF 1.7.1? I get an error: Unknown function type coded
Is there a way to implement it in OF 1.7.1?

Thanks!
ak
newOFuser is offline   Reply With Quote

Old   March 7, 2013, 06:54
Default
  #4
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 339
Rep Power: 28
GerhardHolzinger will become famous soon enoughGerhardHolzinger will become famous soon enough
The coded functionObjects seem to be only available in OpenFOAM 2.0+

See this release notes:

http://www.cfd-online.com/Forums/ope...unction+object
GerhardHolzinger is offline   Reply With Quote

Old   August 22, 2013, 12:03
Default
  #5
Member
 
Alex
Join Date: Jun 2011
Posts: 33
Rep Power: 14
liquidspoon is on a distinguished road
Hi Eelcovv,

Did you ever have any more success trying to access the turbulence data from coded function objects? I was trying to do something similar, and found the obr() function. This returns a reference to the object registry, which lists the turbulence model, and can supposedly return a reference to it. However, I kept getting errors when I tried to get at the turbulence model through the lookupObject function, but kept getting errors (type incompressible::turbulenceModel not found, foundObject method not valid), and wasn't sure how to link in the required libraries.
liquidspoon is offline   Reply With Quote

Old   December 6, 2016, 21:01
Default
  #6
Senior Member
 
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18
anishtain4 is on a distinguished road
Can anyone please advise how to access turbulenceModel in a coded functionObject?
obr() which is mentioned is the same as mesh() but it only has a reference to turbulence dictionary, not the object itself! I need to access epsilon of an LES simulation which cannot be found through lookupObject. I looked into the file and to calculate it directly I still need k which is the subgridscale kinetic energy in an LES simulation.
anishtain4 is offline   Reply With Quote

Old   December 1, 2018, 18:43
Default
  #7
New Member
 
Terrence Nguyen
Join Date: Jan 2012
Posts: 13
Rep Power: 14
hismother is on a distinguished road
Quote:
Originally Posted by anishtain4 View Post
Can anyone please advise how to access turbulenceModel in a coded functionObject?
obr() which is mentioned is the same as mesh() but it only has a reference to turbulence dictionary, not the object itself! I need to access epsilon of an LES simulation which cannot be found through lookupObject. I looked into the file and to calculate it directly I still need k which is the subgridscale kinetic energy in an LES simulation.
i am having the same problem. anyone has the solution???

thank you.
hismother 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
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 05:36
Turbulence model for mixing problem nileshjrane OpenFOAM Running, Solving & CFD 1 September 7, 2010 17:48
Low Reynolds k-epsilon model YJZ ANSYS 1 August 20, 2010 13:57
KOmega Turbulence model from wwwopenFOAMWikinet philippose OpenFOAM Running, Solving & CFD 30 August 4, 2010 10:26
Fan heater model: what turbulence source to use? andy20 CFX 7 March 3, 2008 16:42


All times are GMT -4. The time now is 16:55.