CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Extract velocity on-the-fly (http://www.cfd-online.com/Forums/openfoam-programming-development/98559-extract-velocity-fly.html)

gary7 March 13, 2012 16:32

Extract velocity on-the-fly
 
Hi all,

I'm a newbie and I really appreciate any help...I want to extract velocities on a specific plane (specific position) every n*Dt and save them in a file, e.g. in the case of cavity flow I want to keep track of the velocities on the plane (3D) or line (2D) halfway the cavity and parallel to the moving plate, and I want to have them on the fly (during time stepping) and not to extract in postprocessing stage

Thanks.

gary7 March 22, 2012 00:47

Any pointer is highly appreciated...which part of the solver has all the record of whole field variable and how can I extract a variable like Velocity at a specific location in the filed to written out to a file? :confused:

akidess March 22, 2012 03:31

The keywords you need are functionObjects and cuttingPlane: http://www.openfoam.com/features/run...processing.php

gary7 March 22, 2012 16:31

Thanks for the pointer Anton, well I searched for cuttingPlane and I'm trying to test it in my top solver I'll use it through function objects afterwards. For cuttingPlane there is a thread on that in this forum but it's for 2008 and I think cuttinPlane has had minor changes in recent version like OpenFOAM 2.1.0 that I'm using. Apparently you could use something like :
Code:

cuttingPlane cutPl(mesh,pl1)
however such a thing in the recent version caused following Error:

Code:

icoFoam_cuttingPlane.C: In function ‘int main(int, char**)’:
icoFoam_cuttingPlane.C:109: error: no matching function for call to ‘Foam::cuttingPlane::cuttingPlane(Foam::fvMesh&, Foam::plane&)’
/home/kasra/packages/OpenFOAM/OpenFOAM-2.1.0/src/sampling/lnInclude/cuttingPlane.H:138: note: candidates are: Foam::cuttingPlane::cuttingPlane(const Foam::plane&, const Foam::primitiveMesh&, bool, const Foam::labelUList&)
/home/kasra/packages/OpenFOAM/OpenFOAM-2.1.0/src/sampling/lnInclude/cuttingPlane.H:117: note:                Foam::cuttingPlane::cuttingPlane(const Foam::plane&)
/home/kasra/packages/OpenFOAM/OpenFOAM-2.1.0/src/sampling/lnInclude/cuttingPlane.H:65: note:                Foam::cuttingPlane::cuttingPlane(const Foam::cuttingPlane&)

any clue how to use cuttingPlane in recent version?

akidess March 22, 2012 18:18

You don't need to modify any code. Have a look at the tutorial "incompressible/simpleFoam/motorBike/" in OF-2.1.0, it uses a cutting plane to sample data during run time.

If you grep -r "libsampling" . in the tutorials directory you will get a list of all tutorials that use run time sampling.

- Anton

gary7 March 22, 2012 20:29

The problem is that I want to have those data to input to another simulation runs separately as a boundary condition and I want to pause the OpenFOAM simulation during the run time of the the other code, so I need to incorporate all these into the code I think, what's your opinion?

akidess March 23, 2012 04:28

If you're coupling is only one way, you still don't have to modify the code. Why would you pause the OpenFOAM simulation? Just let it run ahead, and let the program that's waiting for input do the work on synchronization.

gary7 March 23, 2012 11:41

It's a two way coupling, the OpenFOAM simulation also receives boundary condition or better say updates it's boundary condition values...well basically by defining a plane ( Naming Splane) I managed to use
Code:

cuttingPlane    cutPlane(Splane,mesh,true);
and by creating a mesh subset for that (Naming subset1) I added following lines from a thread on cutting plane (http://www.cfd-online.com/Forums/ope...l#post202501):
Code:

wordList scalarNames(1);
        scalarNames[0] = "p";
        PtrList<volScalarField> scalarFlds1(scalarNames.size());
       
        scalarFlds1.set(0, subset1.interpolate(p));

to sample out pressure on the defined cutting plane (I really don't quite understand the 2 last line, any clarification is appreciated)
Now I'm getting pressure output on that plane, however I don't know at which points on the plane the pressure are written out! are those at cell centers projection on the plane? Any idea on this way of implementation?


All times are GMT -4. The time now is 12:37.