|
[Sponsors] |
Access turbulence model in coded functionobjectlibs |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 11, 2012, 11:23 |
Access turbulence model in coded functionobjectlibs
|
#1 |
Senior Member
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19 |
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 ; #}; } Regards Eelco |
|
July 12, 2012, 10:46 |
work-around
|
#2 |
Senior Member
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19 |
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 ; #}; } |
|
August 12, 2012, 00:18 |
|
#3 |
Member
ak
Join Date: May 2011
Posts: 64
Rep Power: 14 |
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 |
|
March 7, 2013, 06:54 |
|
#4 |
Senior Member
Gerhard Holzinger
Join Date: Feb 2012
Location: Austria
Posts: 339
Rep Power: 28 |
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 |
|
August 22, 2013, 12:03 |
|
#5 |
Member
Alex
Join Date: Jun 2011
Posts: 33
Rep Power: 14 |
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. |
|
December 6, 2016, 21:01 |
|
#6 |
Senior Member
Mahdi Hosseinali
Join Date: Apr 2009
Location: NB, Canada
Posts: 273
Rep Power: 18 |
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. |
|
December 1, 2018, 18:43 |
|
#7 | |
New Member
Terrence Nguyen
Join Date: Jan 2012
Posts: 13
Rep Power: 14 |
Quote:
thank you. |
||
|
|
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 |