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

Access turbulence model in coded functionobjectlibs

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

Like Tree1Likes
  • 1 Post By eelcovv

Reply
 
LinkBack Thread Tools 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: 122
Rep Power: 9
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 online now   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: 122
Rep Power: 9
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 online now   Reply With Quote

Old   August 12, 2012, 00:18
Default
  #3
Member
 
ak
Join Date: May 2011
Posts: 71
Rep Power: 6
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, 07:54
Default
  #4
Senior Member
 
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 166
Rep Power: 14
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:

OpenCFD release OpenFOAMŪ version 2.0.0
GerhardHolzinger is offline   Reply With Quote

Old   August 22, 2013, 12:03
Default
  #5
New Member
 
Alex
Join Date: Jun 2011
Posts: 14
Rep Power: 6
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

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
Superlinear speedup in OpenFOAM 13 msrinath80 OpenFOAM Running, Solving & CFD 18 March 3, 2015 06: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 17:42


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