CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   How to get a slice out of my foam results (https://www.cfd-online.com/Forums/openfoam-post-processing/105508-how-get-slice-out-my-foam-results.html)

fs82 August 1, 2012 11:46

How to get a slice out of my foam results
 
Dear foamers,

I am trying to extract a slice out of my data, e.g. UMean fields. I tried the sample utility but I am not satisfied with the result. I like to have a flat plane at a constant y value. This means I set up the sampleDict as follows:

Code:

surfaceFormat raw;

interpolationScheme cell;

surfaces
(
    constantPlane
    {
        type            plane;    // always triangulated
        basePoint      (-386.0 0.0 1.0);
        normalVector    (0.0 1.0 0.0);

        //- Optional: restrict to a particular zone
        // zone        zone1;
    }
);

But the result is not as I expected. My mesh is equally spaced with spacing of 2m. The origin is at 0,0,0 and defines a cell center not a vertex. As a result I get values at points like this:

Code:

-386.333333333 0 0.666666666667
-385.666666667 0 1.33333333333
-384.333333333 0 0.666666666667

But this are not the cell centers, this are more or the less arbitrary points and the also have no 2m spacing like my mesh. Is there a way to get only the cell centers with sample utility? The coordinates has to be something like (386, 0, 1), (386, 0, 2) and so on.

kind regards,
Fabian

fs82 August 2, 2012 10:55

Is it possible that there is a bug in the sample utility? Because if I am using vtk or foamFile as export format, I am getting coordinates which make sense. Does anybody expierenced this bug to?

wyldckat August 2, 2012 15:59

Greetings Fabian,

Yes, it is possible that sample could have a bug. Any chance you can provide a tutorial case modified to reproduce the error you're getting?

Best regards,
Bruno

fs82 August 3, 2012 11:09

1 Attachment(s)
Hi Bruno,

I have played around a little bit. May be I am expecting something wrong but in the attached exampe you have a block of 4 x 4 cells with -2 <= x,y <= 2 and 0 <= z <= 4. If I am cutting a constant y plane at y = 0.5 with normal vector pointing along my y coodinate with interpolationScheme set to cell but without specifying the interpolation switch in my constantPlane subdirectory (I assume it is false) I get strange values (see sampleDict-fail and surfaces-fail). I expected to get 16 values at the cell centers but I am getting 32 values at strange positions. If I turn on the switch interpolation true I get 25 values for the vertices as expected (see sampleDict and surfaces). This behaviour is a bit strange in my opinion.

kind regards,
Fabian

wyldckat August 3, 2012 13:31

Hi Fabian,

These values on the fail version seemed familiar... they are the centers of triangles. If you check the original "sampleDict", located at "applications/utilities/postProcessing/sampling/sample":
Code:

// Surface sampling definition
//
// 1] patches are not triangulated by default
// 2] planes are always triangulated
// 3] iso-surfaces are always triangulated
surfaces
(

Hold on, now I get it! What you're saying is that there is an inconsistency in how the raw export mode is working!

This indeed seems to either be a bug, due to the inconsistent behavior, or it's a feature, that allows one to get either the values in the center of the cells or in the vertexes...


After thinking a bit about this, it feels that the concept here is this:
  • Raw format gives you direct access to the results, without the need for processing a file format per-se.
  • In OpenFOAM, the values in the cell centers are the real ones, while the vertexes have interpolated values.
  • Therefore, this export format makes some sense to be a feature!
I hope this makes it a bit more clearer...
Although this does bring up the question: then why doesn't the VTK format comply with the same criteria? If interpolate is turned off, it should provide the values in the center of the faces, not at the points as well?!

Best regards,
Bruno

fs82 August 3, 2012 16:44

Quote:

Originally Posted by wyldckat (Post 375293)
After thinking a bit about this, it feels that the concept here is this:
  • Raw format gives you direct access to the results, without the need for processing a file format per-se.
  • In OpenFOAM, the values in the cell centers are the real ones, while the vertexes have interpolated values.
  • Therefore, this export format makes some sense to be a feature!

Alright, but there is a big BUT :D If I use the interpolation (interpolation set to true) than I get interpolated values at the vertices according to the method I set up with the interpolationScheme. This is an expected behaviour. BUT if I switch off the interpolation I would like to have the real values, which are stored at the cell centers. But the failed example (sampleDict-failed) do not give you the values at the cell centers. It gives you values at some more or less arbitrary points, which may be centers of triangles. This is not a feature in my opinion it is missleading. If it is not possible to get the real values, than it would be better to remove the switch for the interpolation.

kind regards,
Fabian

wyldckat August 4, 2012 05:48

Hi Fabian,

Indeed, it still seems like an inconsistent behavior... Well, then I suggest you use the bug tracker and report this issue: http://www.openfoam.org/bugs/

Providing a good explanation about what is happening, along with the example case, will make it easier for them to diagnose and fix the issue. By the way, two details about the example you've provided:
  1. If I remember correctly, the "example.tar.gz" file you provided is considered a tarbomb, in the sense that if you unpack the contents to the current folder, it'll be a mess if there are already other files in that folder ;) http://en.wikipedia.org/wiki/Tar_%28...mat%29#Tarbomb
  2. Using potentialFoam for initializing the fields would help the diagnose process, since that way we would have different U values for each cell, making it easier for determining if each value is really interpolated or not.
Best regards,
Bruno

sanysaly April 23, 2013 13:56

slice for Tecplot
 
Hi,
It seems that the problem still persists. Did you guys find a way to solve it?
In general, any idea how to get a slice out of foam results to open in Tecplot (same feature as "slice filter in paraView")?
Thank you

fs82 April 24, 2013 05:08

No I havn't solved that issure. On my TODO list there is also still a point to submit a bug report, but sorry for that I haven't had the time up to now. I use Tecplot to extract slices from my results, which works pretty well.


All times are GMT -4. The time now is 01:11.