|
[Sponsors] |
November 19, 2010, 03:32 |
Output meshsize/cellsize
|
#1 |
Senior Member
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16 |
Hi, I want to do postprocessing of my data in MatLab and need the size of my cells corresponding to the value in that cell.
Basically, if I do mass-averaged PDF I need to include the volume of my cell, but since I have used SnappyHexMesh to refine Im in a pickle. Does anyone know the output order of OpenFoam Regards me |
|
November 19, 2010, 04:29 |
|
#2 |
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18 |
Hi Rickard,
if I got you right, you are already able to export some data to Matlab. You can do it with the cell volumes in the same way by simply creating a volScalarField which holds the cell volumes (access with mesh.V()) and exporting it like the other values. The ordering will of course be the same. Regards, Stefan |
|
November 19, 2010, 04:36 |
|
#3 |
Senior Member
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16 |
Thx for your reply!
Transporting the data to matlab from openfoam is okay; either just the raw data in ascii form or using sampleDict where I can split the plane. Since I am new to this kind of postprocessing, perhaps I can ask you in detail what you mean by creating a volScalarField with mesh.V() The information about cell volumes are already accessable? Regards R |
|
November 19, 2010, 06:12 |
|
#4 |
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18 |
Hi,
you would have to code it inside your solver just like any other field that is written to disk. If you had no experience in doing so, there might be an easier way I don't know. Regards, Stefan |
|
November 20, 2010, 10:35 |
|
#5 |
Senior Member
David Boger
Join Date: Mar 2009
Location: Penn State Applied Research Laboratory
Posts: 146
Rep Power: 17 |
Simply
Code:
mesh.V().write()
__________________
David A. Boger |
|
November 22, 2010, 04:45 |
|
#6 |
Senior Member
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16 |
Hey man, I solved it like this.
*---------------------------------------------------------------------------*/ #include "fvCFD.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" volScalarField checkvol ( IOobject ( "checkvol", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar("checkvol",dimensionSet(0,3,0,0, 0),0 ) ); checkvol.internalField()=mesh.V(); checkvol.write(); Info<< "End\n" << endl; return(0); } |
|
November 22, 2010, 08:51 |
|
#7 |
Senior Member
David Boger
Join Date: Mar 2009
Location: Penn State Applied Research Laboratory
Posts: 146
Rep Power: 17 |
Looks great, but I'm curious: Does all of that get you something that you don't get with a simple mesh.V().write()?
__________________
David A. Boger |
|
November 22, 2010, 09:40 |
|
#8 |
Senior Member
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16 |
Dont know =)
Im not used to programming, I am just happy i managed this you know |
|
November 22, 2010, 10:18 |
|
#9 |
Super Moderator
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29 |
why dont you just create a mass variable and extract it in the same way you extract the other variables?
|
|
November 22, 2010, 10:36 |
|
#10 |
Senior Member
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16 |
Okay, would it be easier?
|
|
November 26, 2010, 09:31 |
|
#11 |
Senior Member
Claus Meister
Join Date: Aug 2009
Location: Wiesbaden, Germany
Posts: 241
Rep Power: 18 |
Hello Folks!
Has anybody managed it to write program which computes the cell volume of alpha1? I have done something, but I am struggling with result, i.e. the data are strange. My code is #include "fvCFD.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // using namespace std; int main(int argc, char *argv[]) { timeSelector::addOptions(); #include "setRootCase.H" #include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); #include "createMesh.H" runTime.setTime(timeDirs[0], 0); #include "createFields.H" volScalarField cellVolume ( IOobject ( "cellVolume", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensionedScalar ("cellAlpha1Volume",dimensionSet(0,3,0,0,0,0,0) ,0) ); cellVolume.internalField() = mesh.V(); volScalarField cellAlpha1Volume ( IOobject ( "cellAlpha1Volume", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensionedScalar ("cellAlpha1Volume",dimensionSet(0,3,0,0,0,0,0) ,0) ); Info << "\nStarting Time loop\n" << endl; forAll(timeDirs, timeI) { Info << "Time = " << runTime.timeName() << endl; runTime.setTime(timeDirs[timeI], timeI); //mesh.readUpdate(); // // Info << "Computing" << nl << endl; volScalarField alpha1 ( IOobject ( "alpha1", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh ); cellAlpha1Volume = cellAlpha1Volume + alpha1*cellVolume; Info << "Max value = " << max(cellAlpha1Volume).value() << endl << "Min value = " << min(cellAlpha1Volume).value() << nl << endl; } runTime.setTime(timeDirs[0],0); Info << "Writing cellAlpha1Volume to time directory 0"<< nl; cellAlpha1Volume.write(); Info<< "End" << endl; return 0; } Hopefully anybody can check it. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Questions about data output | aki_yafuji | OpenFOAM Running, Solving & CFD | 3 | September 9, 2010 02:59 |
lift and drag on ship superstructures | vaina74 | OpenFOAM Running, Solving & CFD | 3 | June 8, 2010 13:30 |
[Other] Output Format of MetaMesh | t42 | OpenFOAM Meshing & Mesh Conversion | 0 | August 3, 2007 05:28 |
can "output control " output Nu in expression? | prayskyer | CFX | 3 | July 7, 2006 20:37 |
Help with DPM UDF for OUTPUT needed | Zhengcai Ye | FLUENT | 0 | January 5, 2004 17:58 |