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/)
-   -   Sampling surfaces (https://www.cfd-online.com/Forums/openfoam-post-processing/66274-sampling-surfaces.html)

sega July 10, 2009 06:28

Sampling surfaces
 
Hello World.

I have found it very useful to create foamFile's out of sample when sampling surfaces.

Is it possible to write these foamFiles with the appropriate headers?
Is there even a way of omitting the distinctive folders for scalar or vector fields?

S.

feijooos July 21, 2009 17:39

Sega,

I have some problems with sampling surfaces. I was wondering if you can point me in the right direction?

I want to sample the heat transfer coefficient that I output on the bottom wall of my domain. The heat transfer coefficient is defined as a surfaceScalarField. How do I set up my sampleDict to sample this surface?

Thanks

sega July 22, 2009 01:49

As far as I can tell you this is rather simple.
Is assume the "bottom" is identical to a boundary patch?
If that's true you can sample this patch by putting its name to patchName:
Code:

surfaces(
    nameOfYourSampleSurface
    {
        type            patch;
        patchName      nameOfYourPatch;
    }
);

And don't forget to specify an appropriate output format
Code:

// Surface output format. Choice of
//      null        : suppress output
//      foamFile    : separate points, faces and values file
//      dx          : DX scalar or vector format
//      vtk        : VTK ascii format
//      raw        : x y z value format for use with e.g. gnuplot 'splot'.
//      stl        : ascii stl. Does not contain values!
surfaceFormat vtk;

Hope this helps.

olesen July 22, 2009 02:42

Quote:

Originally Posted by sega (Post 222226)
Is it possible to write these foamFiles with the appropriate headers?

As a quick hack that almost always works, you can force writing of the headers only. See, for example, the cellTable::writeDict() method in
src/conversion/meshTables/cellTable.C for an idea of how you might do it.

/mark

sega July 22, 2009 05:00

Yes, looks like something I intend to do, but I'm not getting to it.

I don't see where I can input the class and object entries.
Is there some mapping involved?! (IOMap<...>)

braennstroem July 23, 2009 14:24

Hi,

does anyone know, if there is an option for the foamFile output, which omits the output of the points and faces except for the last write out? This would help saving disk space.

Fabian

sega July 27, 2009 12:41

Quote:

Originally Posted by braennstroem (Post 223895)
Hi,

does anyone know, if there is an option for the foamFile output, which omits the output of the points and faces except for the last write out? This would help saving disk space.

Fabian

I'm not sure about this.
Maybe you can have a look into the code of the sample tool and find the place where the points and faces files are written.

Maybe you can wrap these lines in an if-Statement which checks if the last time step is reached.

sven November 8, 2009 02:09

Unfortunately i dont completely understand how you sample surfaces. As far as I saw, this is what I have to put in my control dict-file:
Code:

surfaces(
    nameOfYourSampleSurface
    {
        type            patch;
        patchName      nameOfYourPatch;
    }
);

This leads to two questions:

  1. What is the difference between nameOfYourSampleSurface and nameOfYourPatch? Isnt this the same?
  2. How exactly d I put the lines above in the controlDict? like this
    Code:

    probes1
        {
            // Type of functionObject
            type probes;

            // Where to load it from (if not already in solver)
            functionObjectLibs ("libsampling.so");
           
            // Fields to be probed. runTime modifiable!
            fields
            (           
                gradT
            );
         

          outputControl outputTime;
            outputInterval 2;



          surfaces(
          NameOfYourSampleSurface
          {
            type            patch;
            patchname          YourPatchName;
          }
          );

        }

Thanks a lot!

sega November 8, 2009 05:26

Quote:

Originally Posted by sven (Post 235466)
Unfortunately i dont completely understand how you sample surfaces. As far as I saw, this is what I have to put in my control dict-file:
Code:

surfaces(
    nameOfYourSampleSurface
    {
        type            patch;
        patchName      nameOfYourPatch;
    }
);


Yes and No. Your code is right so far, but you have to put it into a system/sampleDict! But together with many other informations about the sampling-process itself.

An example of a complete sampleDict can be found in
OpenFOAM/OpenFOAM-1.6/applications/utilities/postProcessing/sampling/sample/sampleDict

Quote:

Originally Posted by sven (Post 235466)
What is the difference between nameOfYourSampleSurface and nameOfYourPatch? Isnt this the same?

With the code mentioned above you will sample a patch which will be a boundary of your flow.
With patchName (nameOfYourPatch) you will define which patch you want to sample according to its name in blockMesh and with nameOfYourSampleSurface you will give the sample output a name.
So, the output file will be named after the latter.

Quote:

Originally Posted by sven (Post 235466)
How exactly d I put the lines above in the controlDict?

As mentioned above you will have to put the lines into its own dictionary.

Get back to us If you have further questions!

carmir December 8, 2009 08:45

sampling near to a curved surface
 
Hello to All,

I have a question concerning the sample utility, and since I already got some help from this thread, I posted it here instead of creating a new one.

I'm simulating the flow past a circular cylinder and I'm interested in the skin friction (dU/dr) along its no slip surface. My idea is to get the velocity components at the cell centers of the first cell-row, and with the coordinates of the corresponding points compute afterwards in Matlab the gradients.

With the help of this thread I was able to sample the velocity fields on the cylinder surface using the patch option of the sample utility, but instead of getting the cell-center values, I got the surface values, which are of course zero (No slip boundary condition). Is there a posibility to sample the values at the center of the cells attached to the boundary patch? Here is my sampleDict file:

Code:

  8 FoamFile
  9 {
 10    version    2.0;
 11    format      ascii;
 12    class      dictionary;
 13    location    "system";
 14    object      sampleDict;
 15 }
 16 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 17
 18 setFormat    raw;
 19
 20 surfaceFormat raw;
 21
 22 interpolationScheme cell;
 23
 24 fields
 25 (
 26    U
 27 );
 28
 29 sets
 30 (
 31 );
 32
 33 surfaces
 34 (
 35        Zylinder
 36        {
 37            type        patch;
 38            patchName    CYLINDER;
 39        }
 40 );
 41

Thank you very much in advance for any help and suggestions.

Alejandro

feijooos December 8, 2009 10:22

Alejandro,

Of course you are getting the values at the surface, since you've specified that:

33 surfaces
34 (
35 Zylinder
36 {
37 type patch;
38 patchName CYLINDER;
39 }

Look into sampling a field instead of a surface. There is a example 'sampleDict' in applications/utilities/postProcessing/sampling/sample which can help you out.

sven December 8, 2009 13:37

I think there are better ways to do what you want. There are two post processing tools you can use:

  1. wallShearStress, which calculates the wall shear stress at each patch (note that the number itself is already divided by density)
  2. wallGradU which calculates the velocity gradient at each boundary, which is exactly what you want
I hope this helps.

Sven

carmir December 9, 2009 07:59

Eelco, thanks for the confirmation, so the surface sample makes only sense for values other than the imposed ones.

Sven, both utilities wallShearStress and wallGradU helped me a lot, thank you very much for the hint. They even give the derivatives already in normal and tangential direcctions, exactly in the way I need them.

So, thanks again!

Alejandro

panda60 April 2, 2010 11:51

Dear Sebastian,
Have you solve your problem ? Maybe the things we want to do is the same.
I use functionObject to sampling internal surface data, and will generate many folders, like scalarField, vectorField. The data format whick TimeVaryingMappedFixedValue needed is a little difference from sampling data. Because I have 100000 time steps, and total 150 G space. If modify every time step data one by one will need a lot of time. Maybe we can make our own code to do this convertion, but 150G data is also a large work.
So the best way is to sample the data and save to correct data format and folder.
Do you have some commont ?
Thank you.

panda60 April 27, 2010 08:08

Dear all,
How can I create my own functionObject ?
my purpose is to extract a plane data of internal domain in every time step, and save to disk.
I noticed "surfaces functionObject" can do the similar thing, so I want to modify surfaces functionObject.I found it belongs to sampling,
So I copy src/sampling directory to another position.
I changed the name to LIB = $(FOAM_USER_LIBBIN)/libmysampling.

in sampling\sampledSurface\sampledSurfaces, I found 2 places had name "surfaces",

*.H file:
public:
//- Runtime type information
TypeName("surfaces");
*.C文file:
PtrList<sampledSurface> newList
(
dict.lookup("surfaces"),
sampledSurface::iNew(mesh_)
);

I changed these "surfaces" to "mysurfaces", and compiled, no problem.
but when I used, had the following mistake,

Starting time loop
--> FOAM Warning :
From function dlLibraryTable::open(const dictionary& dict, const word& libsEntry, const TablePtr tablePtr)
in file lnInclude/dlLibraryTableTemplates.C at line 68
library "libmysampling.so" did not introduce any new entries

Unknown function type mysurfaces
Valid functions are :
5
(
surfaces
fieldAverage
fieldMinMax
sets
probes
)

From function functionObject::New(const word& name, const Time&, const dictionary&)
in file db/functionObjects/functionObject/functionObject.C at line 89.
FOAM exiting

It seems that my modified name haven't been registed in functionObject.
Could anyone can give me some help ?

Thanks.

I am using like this in my controlDict file:
extraction
{
type mysurfaces;
functionObjectLibs ("libmysampling.so");
enabled true;
outputControl timeStep;
outputInterval 1;
surfaceFormat foamFile;
interpolationScheme cellPointFace;
fields
(
U
T
);
mysurfaces
(
aplane
{
type plane;
basePoint (-0.4 0 0.5);
normalVector (1.0 0 0);
}
);
}

Subodh May 27, 2010 03:27

Hello Panda,

It might be late to reply your post.
you are getting those error because you might have forgotten to override following virtual functions, and to add FuctionObjects header file and C file in your mysampling directory, and of course include functionObject.C in Make/files file.

updateMesh(const mapPolyMesh&)

movePoints(const pointField&)

naveen May 28, 2010 02:03

vortex shedding frequency
 
hi,

myself Naveen working on flow around a circular cylinder of diameter 2m using OpenFOAM 1.4.1 and 1.5 versions past 1 month. I am getting pressure and velocity contours correctly in both the versions.I am facing difficult to get the vortex shedding frequency in OpenFOAM.

Can you please suggest me how to get the strouhal number and vortex shedding frequency in OpenFOAM 1.5.

Flow conditions (laminar flow):

Reynolds number---------> 150 (based on cylinder diameter)
velocity------------------------>1 m/s
viscosity------>0.01333 m2/sec(based on cylinder diameter)
diameter of cylinder--------> 2 meters
OpenFOAM version-------->1.4.1, 1.5
solver----------------------------->icoFoam

can you please give me a suggestion how to get these values using the probes function and FFT.

waiting for your response

Regards,

Naveen

panda60 May 28, 2010 05:47

Dear Subodh Kumar,

I modified the original sample tool in OpenFOAM-1.6/SRC directory and recompile again. If it will bring some risk to my simulation ?

Because I don't know how functionObject works. For example, If I generate another functionObject "libmysampling.so" , and then I delete this libmysampling.so , if this new name still exists in functionObject list ?

Subodh May 28, 2010 10:45

Hello Panda,

No, modifying sample utility not bring any risk to your simulation. sample is not at all related to simulation. It is a post processing tool, which you could used after simulation.

According to me modifying sample is not a good idea, because you will not be able to get standard behavior of it if you need in future, thats why it is always recommended to customize and created new library according to your requirements.

Library and Functionobject are two different thing. Library could be used for many purposes for example to convert Cartesian coordinate to cylindrical, or to calculate and print parameters values at every iteration and stuff like that. FunctionObject is a way through which a exe is asked to repeat a action at every iteration.

Now if we want to calculate something and print it at every iteration then we create a functionObject in controlDict file and in body of functionObject we load library by command " functionObjectLibs ("libmysampling.so"); ".

To answer your another question, if you have deleted the library that you are loading through functionObject, then OpenFOAM will throw error, saying your library does not exist. If you have deleted the library and not loading it through functionObject then there should not be any problem at all.

Above is my understanding about Function Object and library, Please correct me if I am wrong.

panda60 May 29, 2010 08:39

Dear Subodh Kumar,

Thank you very much. Now I am little understand. I think you are right. Modifying the original one is not a good idea.

braennstroem April 7, 2011 14:07

Hello,

me again... fyi: basically I just commented out the not needed points and faces... this worked quite good.

Now, I would like actually write out the complete mesh information including a boundary, neighbour, owner files.

Do you have a hint, how I can do this?
Best REgards!
FAbian

gpextra November 18, 2011 15:37

Dear foamers

Sampling data from the cells close to a boundary or a wall might not be a trivial matter. That is why I am calling back this some two years old thread, which is closely related to my present question.

My geometry is composed of some curved walls and I need to collect some data, like U and p, from the very first layer of cells near the wall. It seems pretty straightforward to do that with the "sample" utility, if I new the coordinates of each cell centre, by just listing them under the type "cloud" in the sampleDict file. But this is where things go awry.

So, is there an easy way to get the coordinates of some specific cells, in particular those bordering a wall? I would guess that cellSet might be an answer, but I could not find something like a source "boundaryToCell" in the topoSetDict.

Or, alternatively, can anyone devise another approach to pick these close-to-the-wall cells values of velocity and pressure? BTW, this is almost exactly the question posed by Alejandro, above, but his problem was solved in a different way, so the the question remains alive. I would appreciate any suggestion on that.

I am using OpenFOAM 2.0.0.

Regards.
G.Oliveira

Prakriti November 5, 2020 23:19

arcUniform sampling utility
 
Hi all,


Has anyone tried using the arcUniform utility for postProcessing (https://cpp.openfoam.org/v6/classFoa...Uniform.html)?


When I try to implement it, it just gives me an error saying "keyword endAngle is undefined in dictionary "controlDict.functions.sample.sample.sets""


I was wondering why it would do that?

Krapf November 6, 2020 01:52

You need to define endAngel. Or is the problem that you defined it but OpenFOAM is still complaining?

nishant.kumar December 23, 2021 08:57

Quote:

Originally Posted by braennstroem (Post 223895)
Hi,

does anyone know, if there is an option for the foamFile output, which omits the output of the points and faces except for the last write out? This would help saving disk space.

Fabian

Hello Fabian, were you able to do this? I want to exclude the output of coordinates in all the sampling output files as I am passing this information externally and it remains constant throughout the simulation.

You mentioned this in another reply as a solution(?):
Quote:

Originally Posted by braennstroem (Post 302700)
me again... fyi: basically I just commented out the not needed points and faces... this worked quite good.

Can you please explain where exactly this change is made?


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