CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Output meshsize/cellsize

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 19, 2010, 03:32
Default Output meshsize/cellsize
  #1
Senior Member
 
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16
Rickard.Solsjo is on a distinguished road
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
Rickard.Solsjo is offline   Reply With Quote

Old   November 19, 2010, 04:29
Default
  #2
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18
herbert is on a distinguished road
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
herbert is offline   Reply With Quote

Old   November 19, 2010, 04:36
Default
  #3
Senior Member
 
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16
Rickard.Solsjo is on a distinguished road
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
Rickard.Solsjo is offline   Reply With Quote

Old   November 19, 2010, 06:12
Default
  #4
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18
herbert is on a distinguished road
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
herbert is offline   Reply With Quote

Old   November 20, 2010, 10:35
Default
  #5
Senior Member
 
David Boger
Join Date: Mar 2009
Location: Penn State Applied Research Laboratory
Posts: 146
Rep Power: 17
boger is on a distinguished road
Simply
Code:
mesh.V().write()
should work to write the cell volumes to files in each time directory in files that look just like your solution variables.
__________________
David A. Boger
boger is offline   Reply With Quote

Old   November 22, 2010, 04:45
Default
  #6
Senior Member
 
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16
Rickard.Solsjo is on a distinguished road
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);
}
Rickard.Solsjo is offline   Reply With Quote

Old   November 22, 2010, 08:51
Default
  #7
Senior Member
 
David Boger
Join Date: Mar 2009
Location: Penn State Applied Research Laboratory
Posts: 146
Rep Power: 17
boger is on a distinguished road
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
boger is offline   Reply With Quote

Old   November 22, 2010, 09:40
Default
  #8
Senior Member
 
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16
Rickard.Solsjo is on a distinguished road
Dont know =)
Im not used to programming, I am just happy i managed this you know
Rickard.Solsjo is offline   Reply With Quote

Old   November 22, 2010, 10:18
Default
  #9
Super Moderator
 
niklas's Avatar
 
Niklas Nordin
Join Date: Mar 2009
Location: Stockholm, Sweden
Posts: 693
Rep Power: 29
niklas will become famous soon enoughniklas will become famous soon enough
why dont you just create a mass variable and extract it in the same way you extract the other variables?
niklas is offline   Reply With Quote

Old   November 22, 2010, 10:36
Default
  #10
Senior Member
 
Rickard
Join Date: May 2010
Location: Lund, Skåne, Sweden
Posts: 143
Rep Power: 16
Rickard.Solsjo is on a distinguished road
Okay, would it be easier?
Rickard.Solsjo is offline   Reply With Quote

Old   November 26, 2010, 09:31
Default
  #11
Senior Member
 
Claus Meister
Join Date: Aug 2009
Location: Wiesbaden, Germany
Posts: 241
Rep Power: 18
idrama is on a distinguished road
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.
idrama is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 22:44.