|
[Sponsors] |
September 16, 2013, 05:22 |
runtime sample plan: how to get gradP
|
#1 |
New Member
Marcel Vonlanthen
Join Date: Nov 2012
Location: Zurich, Switzerland
Posts: 28
Rep Power: 13 |
Dear Foamer,
for a LES run, I would like to extract sample planes of gradP during runtime. For this, I'm using this tool:http://www.openfoam.com/features/run...processing.php. It works perfectly for U or p, but not for gradP, as this variable doesn't exist at runtime. So until now I simply modified pimpleFoam and add the following lines: Code:
volVectorField gradP ( IOobject ( "gradP", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), fvc::grad(p) ); Code:
type surfaces; functionObjectLibs ("libsampling.so"); outputControl timeStep; outputInterval 1; surfaceFormat vtk; fields #codeStream code #{ volVectorField gradP ( IOobject ( "gradP", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), fvc::grad(p) ); const wordList sampleFields = ("gradP"); //is that correct? os << sampleFields;//is that correct? #} interpolationScheme cellPointFace; Marcel |
|
September 16, 2013, 05:48 |
|
#2 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
What do you mean with: "it doesn't work"
I think you need to use a coded functionobject to create the field, and then use it in the sampling functionobject. |
|
September 16, 2013, 08:21 |
|
#3 |
New Member
Marcel Vonlanthen
Join Date: Nov 2012
Location: Zurich, Switzerland
Posts: 28
Rep Power: 13 |
Hi Berhnard,
Thanks for your post, it gave me new ideas As example, I use OF221 and the LES tutorial case "pitzDaily", located in the foam tutorials folder: $FOAM_TUTORIALS/incompressible/pisoFoam/les/pitzDaily Replace the controlDict by this one: Code:
FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application pisoFoam; startFrom startTime; startTime 0; stopAt endTime; endTime 0.1; deltaT 1e-05; writeControl timeStep; writeInterval 100; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable true; functions { gradP { functionObjectLibs ("libutilityFunctionObjects.so"); type coded; redirectType average; outputControl timeStep; code #{ const volScalarField& p = mesh().lookupObject<volScalarField>("p"); const volVectorField gradP = fvc::grad(p); Info << "gradP[0] =" << gradP[0] << endl; Info << "gradP[5] =" << gradP[5] << endl; #}; } surfaceSampling { type surfaces; functionObjectLibs ("libsampling.so"); enabled true; outputControl timeStep; interpolationScheme cellPoint; surfaceFormat foamFile; fields (p gradP); surfaces ( plane01 { type cuttingPlane; planeType pointAndNormal; pointAndNormalDict { basePoint (0.001 0.001 0); normalVector (0 1 0); } interpolate true; } ); } } Code:
FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application pisoFoam; startFrom startTime; startTime 0; stopAt endTime; endTime 0.1; deltaT 1e-05; writeControl timeStep; writeInterval 100; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable true; functions { gradP { functionObjectLibs ("libutilityFunctionObjects.so"); type coded; redirectType average; outputControl timeStep; code #{ const volScalarField& p = mesh().lookupObject<volScalarField>("p"); volVectorField gradP ( IOobject ( "gradP", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), fvc::grad(p) ); Info << "gradP[0] =" << gradP[0] << endl; Info << "gradP[5] =" << gradP[5] << endl; #}; } surfaceSampling { type surfaces; functionObjectLibs ("libsampling.so"); enabled true; outputControl timeStep; interpolationScheme cellPoint; surfaceFormat foamFile; fields (p gradP); surfaces ( plane01 { type cuttingPlane; planeType pointAndNormal; pointAndNormalDict { basePoint (0.001 0.001 0); normalVector (0 1 0); } interpolate true; } ); } } How could I generate the volVectorField gradP, which can be used by the sample tool? |
|
September 16, 2013, 08:26 |
|
#4 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
I think you can access the runTime by something (untested!) like
Code:
const Time& runTime = mesh.time() |
|
September 17, 2013, 03:31 |
|
#5 |
New Member
Marcel Vonlanthen
Join Date: Nov 2012
Location: Zurich, Switzerland
Posts: 28
Rep Power: 13 |
Hi Foamer,
So Bernhard, I add your line of code: Code:
const Time& runTime = mesh().time(); Code:
const fvMesh& mesh = mesh().lookup("mesh"); Code:
const fvMesh& mesh = mesh().Mesh Code:
fvMesh mesh ( IOobject ( fvMesh::defaultRegion, runTime.timeName(), runTime, IOobject::MUST_READ ) ); |
|
September 17, 2013, 03:35 |
|
#6 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
Isn't mesh() itself already a reference to the mesh that you need?
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem in3D model processing | mebinitap | OpenFOAM | 2 | December 12, 2014 04:40 |
How to sample (with interpolation) at runtime | ole | OpenFOAM Programming & Development | 4 | December 14, 2010 12:57 |
How to sample ptot at runtime | pad | OpenFOAM Post-Processing | 0 | August 26, 2010 07:45 |
heat conducting in a solid domain | Rogerio Fernandes Brito | FLUENT | 0 | March 18, 2008 17:25 |
heat conducting in a solid domain | Rogerio Fernandes Brito | CFX | 0 | March 18, 2008 17:20 |