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

How to output values only on cell center or vertex?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 24, 2014, 10:45
Default How to output values only on cell center or vertex?
  #1
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Hi,all:
I want to extract the data on a cutting plane. Grid 128*128, however, the output data contains 32768 points rather than 16384, it's quite inconvenient to find which value corresponding to the specific point listed in the output data. For example(xz plane), if you range the x value from small to large, than you will find 256 x values, however, each x corresponds to 128 z values. The same to z
So I'd like to know how can I output the value only at cell center or vertex.
Thanks
huangxianbei is offline   Reply With Quote

Old   April 24, 2014, 12:28
Default
  #2
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Anyone can help? Any comment is OK, I'm looking forward for the way to solve it, I have stuck with this for several days
huangxianbei is offline   Reply With Quote

Old   April 24, 2014, 14:04
Default
  #3
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Post your samlpleDict as from the post it's not quite clean what sampling mechanism you're using. If it is cuttingPlane, then AFAIK it's usually triangulated, that's why there's a difference between number of points in mesh and in sample output.

And if you'd like to have a table with columns |x y value|, it's quite simple to implement utility for this output yourself (though maybe there is already one).
alexeym is offline   Reply With Quote

Old   April 24, 2014, 22:24
Default
  #4
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

Post your samlpleDict as from the post it's not quite clean what sampling mechanism you're using. If it is cuttingPlane, then AFAIK it's usually triangulated, that's why there's a difference between number of points in mesh and in sample output.

And if you'd like to have a table with columns |x y value|, it's quite simple to implement utility for this output yourself (though maybe there is already one).
Hi,Alexey:
Thank you.This is my sampleDict
Code:
setFormat raw;

surfaceFormat raw;

fields
(
    UMean
    U
);

surfaces
(
    constantPlane
    {
        type            plane;    // always triangulated
        basePoint       (0 0.041 0);
        normalVector    (0 1 0);
    }

);
So if I want to get the value whose number equals to the grids, what should I do in cutting plane?
huangxianbei is offline   Reply With Quote

Old   April 24, 2014, 22:50
Default
  #5
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

Post your samlpleDict as from the post it's not quite clean what sampling mechanism you're using. If it is cuttingPlane, then AFAIK it's usually triangulated, that's why there's a difference between number of points in mesh and in sample output.

And if you'd like to have a table with columns |x y value|, it's quite simple to implement utility for this output yourself (though maybe there is already one).
thank you very much, it's really helpful. I look into the sampleDict and find all are trianulated except type-patchInternalField.
Code:
nearWalls_interpolated
    {
        // Sample cell values off patch. Does not need to be the near-wall
        // cell, can be arbitrarily far away.
        type            patchInternalField;
        patches         ( "bottomWall" );
        interpolate     true;


        // Optional: specify how to obtain sampling points from the patch
        //           face centres (default is 'normal')
        //
        //  //- Specify distance to offset in normal direction
        offsetMode  normal;
        distance    0.0407;
        //
        //  //- Specify single uniform offset
        //  offsetMode  uniform;
        //  offset      (0 0 0.0001);
        //
        //  //- Specify offset per patch face
        //  offsetMode  nonuniform;
        //  offsets     ((0 0 0.0001) (0 0 0.0002));


        // Optional: whether to leave as faces (=default) or triangulate
        // triangulate     false;
    }
Now the result is what I want.
huangxianbei is offline   Reply With Quote

Old   April 25, 2014, 01:44
Default
  #6
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

Post your samlpleDict as from the post it's not quite clean what sampling mechanism you're using. If it is cuttingPlane, then AFAIK it's usually triangulated, that's why there's a difference between number of points in mesh and in sample output.

And if you'd like to have a table with columns |x y value|, it's quite simple to implement utility for this output yourself (though maybe there is already one).
I'm sorry, but the offset seems not work at all. Since I specified the offset distance(y direction), y=0 all the time.Is this means that the output x,y,z is related to the patch I specified, while the values based on (x y z) such as U at (x y z) is the offset value? Could you please help me?
huangxianbei is offline   Reply With Quote

Old   April 25, 2014, 09:35
Default
  #7
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

in fact at least in 2.2.2 triangulation of a plane is optional:

Code:
Foam::sampledPlane::sampledPlane
(   
    const word& name,
    const polyMesh& mesh,
    const dictionary& dict
)
:
    sampledSurface(name, mesh, dict),
    cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))),
    zoneKey_(keyType::null),
    triangulate_(dict.lookupOrDefault("triangulate", true)),
    needsUpdate_(true)
{
...
so you can say "triangulate false;" in plane dictionary.

What are you trying to do with the data? Maybe there's another way of solving your problem.
alexeym is offline   Reply With Quote

Old   April 25, 2014, 10:09
Default
  #8
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

in fact at least in 2.2.2 triangulation of a plane is optional:

Code:
Foam::sampledPlane::sampledPlane
(   
    const word& name,
    const polyMesh& mesh,
    const dictionary& dict
)
:
    sampledSurface(name, mesh, dict),
    cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))),
    zoneKey_(keyType::null),
    triangulate_(dict.lookupOrDefault("triangulate", true)),
    needsUpdate_(true)
{
...
so you can say "triangulate false;" in plane dictionary.

What are you trying to do with the data? Maybe there's another way of solving your problem.
Thank you. In fact, I want to calculate the energy spectrum in channel flow. So I need the information on a plane. I think I should try OF-2.2.2 to verify the plane data I extract in OF-2.1.1. Have you ever tried to do it in OF-2.2.2? Is the triangulate false possible in all the plane dictionary? Or just in type patchInternalField as I pasted before?
huangxianbei is offline   Reply With Quote

Old   April 25, 2014, 10:25
Default
  #9
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

in fact at least in 2.2.2 triangulation of a plane is optional:

Code:
Foam::sampledPlane::sampledPlane
(   
    const word& name,
    const polyMesh& mesh,
    const dictionary& dict
)
:
    sampledSurface(name, mesh, dict),
    cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))),
    zoneKey_(keyType::null),
    triangulate_(dict.lookupOrDefault("triangulate", true)),
    needsUpdate_(true)
{
...
so you can say "triangulate false;" in plane dictionary.

What are you trying to do with the data? Maybe there's another way of solving your problem.
I just tried in OF-2.1.1 the constant plane and specify the triangulate false, however, this makes no sence, the output is still 32768.
huangxianbei is offline   Reply With Quote

Old   April 25, 2014, 14:27
Default
  #10
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

well, yes. Just checked 2.1.1 sources and there:

Code:
bool Foam::sampledPlane::update()
{
    ...
    if (selectedCells.empty())
    {
        reCut(mesh(), true);    // always triangulate. Note:Make option?
    }
    ...
So I guess, it became option only in version 2.2.x.

Just for post-processing of your case, you can change that true to false in src/sampling/sampledSurface/sampledPlane/sampledPlane.C and then run wmake in src/sampling folder. After this modification planes won't be triangulated at all (I think I've made this thing once while post-processing results on regular mesh).

What do you plan to use for calculation of energy spectrum? If it is external tool (ex. scipy, Matlab), you can interpolate that triangulated data on regular rectangular grid. If it is C++, why not do it using OpenFOAM, where you can iterate over the cells of the mesh getting values inside cells and coordinates of the centers.
mgg likes this.
alexeym is offline   Reply With Quote

Old   April 25, 2014, 20:56
Default
  #11
Senior Member
 
Huang Xianbei
Join Date: Sep 2013
Location: Yangzhou,China
Posts: 302
Rep Power: 14
huangxianbei is on a distinguished road
Quote:
Originally Posted by alexeym View Post
Hi,

well, yes. Just checked 2.1.1 sources and there:

Code:
bool Foam::sampledPlane::update()
{
    ...
    if (selectedCells.empty())
    {
        reCut(mesh(), true);    // always triangulate. Note:Make option?
    }
    ...
So I guess, it became option only in version 2.2.x.

Just for post-processing of your case, you can change that true to false in src/sampling/sampledSurface/sampledPlane/sampledPlane.C and then run wmake in src/sampling folder. After this modification planes won't be triangulated at all (I think I've made this thing once while post-processing results on regular mesh).

What do you plan to use for calculation of energy spectrum? If it is external tool (ex. scipy, Matlab), you can interpolate that triangulated data on regular rectangular grid. If it is C++, why not do it using OpenFOAM, where you can iterate over the cells of the mesh getting values inside cells and coordinates of the centers.
I want to verify my DNS calculation in different ways, such as Reynolds stress, energy spectrum and two-point correlation.
Yes, I do the post-process in Matlab. In order to simplify the process, I need to output only the point or cell center values. Although C++ is a better way, I find it's hard for me to use, for example, in structure mesh, I don't know the cell index and how to get each. If I want to do the average along a homogenous direction, I don't know how to realize this.
huangxianbei 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
[swak4Foam] outputTime in Swak function immortality OpenFOAM Community Contributions 20 October 6, 2022 12:08
Setting cell variable values in a fluid zone using UDF eromon84 Fluent UDF and Scheme Programming 6 March 28, 2021 11:59
setfields for alpha belkadi OpenFOAM Programming & Development 7 November 25, 2014 11:53
[blockMesh] Include list of points Hikachu OpenFOAM Meshing & Mesh Conversion 0 June 20, 2011 09:03
Warning 097- AB Siemens 6 November 15, 2004 04:41


All times are GMT -4. The time now is 21:55.