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/)
-   -   sample from curved surface (https://www.cfd-online.com/Forums/openfoam-post-processing/100034-sample-curved-surface.html)

Smed April 18, 2012 21:58

sample from curved surface
 
1 Attachment(s)
Is it possible to sample data from a curved surface? I know that you can sample from a plane by specifying the base point and normal vector, but I want to specify an arc, as shown in the attached drawing.

linnemann April 19, 2012 03:19

Hi

Yes it certainly is. Below is some code that shows how to use a stl surface to sample with. Note that the mesh resolution of the stl file will influence how well it interpolates/averages. Also make sure that the stl file is only as large as the mesh as it will produce false data if the stl file expands larger than the mesh domain.

I have checked it and it works correctly even with odd shapes. The stl file must reside in the constant/triSurface/ folder.

Code:

functions
{
    faceObj1
    {
        type            faceSource;
        functionObjectLibs ("libfieldFunctionObjects.so");

        enabled        true;
        outputControl  outputTime;

        // Output to log&file (true) or to file only
        log            true;

        // Output field values as well
        valueOutput    true;

        // Type of source: patch/faceZone/sampledSurface
        source          sampledSurface;

//        // if patch or faceZone: name of patch or faceZone
//        sourceName      movingWall;

        //// if sampledSurface: dictionary with a sampledSurface
        //// Note: will not sample surface fields.
        sampledSurfaceDict
        {
          // Sampling on triSurface
          type        sampledTriSurfaceMesh;
          surface    Scale_1.stl;
          source      cells;  // sample cells or boundaryFaces
          interpolate false;
        }

        // Operation: areaAverage/sum/weightedAverage ...
        operation      areaNormalIntegrate;

        fields
        (
            p
            U
        );
    }
}

The following operations are available.

Code:

        "none",
        "sum",
        "average",
        "weightedAverage",       
        "areaAverage",       
        "areaIntegrate",
        "min",
        "max",
        "CoV",
        "areaNormalAverage",
        "areaNormalIntegrate"


Smed April 19, 2012 11:54

Niels,

Thanks for your response! Can this code be executed as a post process (like sampleDict) or does it need to be placed in controlDict before the case is run?

mihaipruna April 25, 2012 13:39

hi, if I want to use the STL from SHM, do I have to give it the relative path?

linnemann April 25, 2012 15:28

my own words in the above post

Quote:

The stl file must reside in the constant/triSurface/ folder.

mihaipruna April 25, 2012 15:35

sorry I should have read more carefully.

that's where I had the STL.
The mistake I made must lie elsewhere in my sampledict file.
So I'm going to use the example you provided :)

mihaipruna April 26, 2012 14:29

linneman. can you please post your entire sampleDict?
I don't get any output. It just says Time 0, 100 etc.

nm seems to work now!

tfuwa March 5, 2013 02:39

Hi Foamers,

This may sound silly, but how to generate a stl file for the curved surface in the first place? Thanks.


Quote:

Originally Posted by linnemann (Post 355535)
Hi

Yes it certainly is. Below is some code that shows how to use a stl surface to sample with. Note that the mesh resolution of the stl file will influence how well it interpolates/averages. Also make sure that the stl file is only as large as the mesh as it will produce false data if the stl file expands larger than the mesh domain.

I have checked it and it works correctly even with odd shapes. The stl file must reside in the constant/triSurface/ folder.

Code:

functions
{
    faceObj1
    {
        type            faceSource;
        functionObjectLibs ("libfieldFunctionObjects.so");

        enabled        true;
        outputControl  outputTime;

        // Output to log&file (true) or to file only
        log            true;

        // Output field values as well
        valueOutput    true;

        // Type of source: patch/faceZone/sampledSurface
        source          sampledSurface;

//        // if patch or faceZone: name of patch or faceZone
//        sourceName      movingWall;

        //// if sampledSurface: dictionary with a sampledSurface
        //// Note: will not sample surface fields.
        sampledSurfaceDict
        {
          // Sampling on triSurface
          type        sampledTriSurfaceMesh;
          surface    Scale_1.stl;
          source      cells;  // sample cells or boundaryFaces
          interpolate false;
        }

        // Operation: areaAverage/sum/weightedAverage ...
        operation      areaNormalIntegrate;

        fields
        (
            p
            U
        );
    }
}

The following operations are available.

Code:

        "none",
        "sum",
        "average",
        "weightedAverage",   
        "areaAverage",   
        "areaIntegrate",
        "min",
        "max",
        "CoV",
        "areaNormalAverage",
        "areaNormalIntegrate"



Smed March 5, 2013 08:57

Quote:

Originally Posted by tfuwa (Post 411555)
Hi Foamers,

This may sound silly, but how to generate a stl file for the curved surface in the first place? Thanks.

Pretty much any method that can be used to create a mesh can also create an stl file. I created the desired sampling surface with blockMesh (curved it using the edges keyword), then converted it to an stl using foamToSurface. You could also use a program like gmsh or any of the commercial options.

Chenelle October 12, 2015 19:30

Not sure how to interpret the resulting data from using an .stl file to sample data.
 
Hi!

I have used the .stl method for sampling data on a curved surface and as a result obtain many data files, but I'm not sure what data is being stored in these files.

I have used the areaNormalIntegrate operation on the velocity field in order to obtain the massflow through certain parts of my domain.

In the post processing folder I have a folder for each of the .stl surfaces that I sample for instance 'F:\Axial\1\postProcessing\A1' (where the surface is named A1). In this folder I find a folder named '2' (which is my 'startTime') and a folder named 'surface'. The folder named 'surface' contains a folder for each time step.

The file I find in 'F:\Axial\1\postProcessing\A1\2' is called 'faceSource.dat' and looks as follows:

# Source : sampledSurface sampledSurface
# Faces : 10364
# Time sum(magSf) areaNormalIntegrate(U)
2.010000e+00 2.444231e-05 (1.517481e-07 0.000000e+00 0.000000e+00)
2.020000e+00 2.444231e-05 (3.455922e-07 0.000000e+00 0.000000e+00)
2.030000e+00 2.444231e-05 (3.599368e-07 0.000000e+00 0.000000e+00)
.
.
.

This continues on until my final time step.

In the folder named 'surface' containing folders for each timestep I find the following file named 'U_sampledSurface_sampledSurface.dat' (the path is 'F:\Axial\1\postProcessing\A1\surface\2.01'):

# vtk DataFile Version 2.0
sampleSurface
ASCII
DATASET POLYDATA
POINTS 5480 float
-7.21109e-05 -0.0471719 -0.152
-5.07447e-05 -0.047172 -0.152
-4.00616e-05 -0.047172 -0.152
-2.4037e-05 -0.047172 -0.152
-6.67693e-05 -0.047172 -0.152
-5.8757e-05 -0.047172 -0.152
-7.47816e-05 -0.0471719 -0.152
0 -0.047172 -0.152
.
.
.

POLYGONS 10364 41456
3 399 214 190
3 50 190 49
3 387 190 212
3 125 212 50
3 2327 2386 1916
3 1503 1916 2045
.
.
.
CELL_DATA 10364
FIELD attributes 1
U 3 10364 float
-0.0382099 -0.00668583 -1.65843
-0.0382099 -0.00668583 -1.65843
-0.0382099 -0.00668583 -1.65843
-0.0382099 -0.00668583 -1.65843
-0.172477 0.0544543 -1.70722
-0.113396 0.0566717 -1.65732
-0.172477 0.0544543 -1.70722
-0.172477 0.0544543 -1.70722
-0.172477 0.0544543 -1.70722
-0.172477 0.0544543 -1.70722
-0.172477 0.0544543 -1.70722
.
.
.

I have gathered that the 'POINTS 5480 float' in the 'U_sampledSurface_sampledSurface.dat' file is the xyz location of each of the points that are being sampled and that the 'POLYGONS 10364 41456' are the numbers of the surfaces being sampled. However, as far as I can gather 'CELL_DATA 10364 FIELD attributes 1 U 3 10364 float' gives me the velocity at each of the points and not the area integrated velocity.

I'm not sure what the 'faceSource.dat' file represents. Any help would be greatly appreciated.

Thank you!

linnemann October 13, 2015 01:30

Hi

Well it can be a bit misleading.

The reason being that when you sample U it is a vector with three components.

Now I haven't looked at the code that actually writes the data but I'm suspecting that to keep things KISS they keep the vector notation and only write the result to the first part.

So in you output you have

Code:

# Time        sum(magSf)        areaNormalIntegrate(U)
2.010000e+00        2.444231e-05        (1.517481e-07 0.000000e+00 0.000000e+00)

So you actual volume flow is the first part in red.

The VTK data is the raw data and you could take that into paraview and use a calculator to get the massflow.

Chenelle October 13, 2015 03:35

Quote:

Originally Posted by linnemann (Post 567844)
Hi

Well it can be a bit misleading.

The reason being that when you sample U it is a vector with three components.

Now I haven't looked at the code that actually writes the data but I'm suspecting that to keep things KISS they keep the vector notation and only write the result to the first part.

So in you output you have

Code:

# Time    sum(magSf)    areaNormalIntegrate(U)
2.010000e+00    2.444231e-05    (1.517481e-07 0.000000e+00 0.000000e+00)

So you actual volume flow is the first part in red.

The VTK data is the raw data and you could take that into paraview and use a calculator to get the massflow.

Hi!

Thank you for your prompt response. I suspected that the value in red was the massflow as well, but it is a few magnitudes smaller than the massflow I expect. Do you know what the units are? I was expecting it to be kg/s, maybe I am going wrong there?

Thank you for your help.

linnemann October 13, 2015 03:36

Hi

If you run a compressible simulation it is kg/s if it is an in-compressible it is m3/s.

Chenelle October 13, 2015 03:44

Quote:

Originally Posted by linnemann (Post 567866)
Hi

If you run a compressible simulation it is kg/s if it is an in-compressible it is m3/s.

Thank you so much!

I will go see if it that solves the problem. :)

Tellur October 21, 2015 00:02

Hello,

I have been trying to calculate on the fly area average velocities using topoSet and swak4foam in order to acquire the faceZones and then calculate my results.

However, as I posted in another thread, my topoSet created zones are nowhere near my actual surfaces. I wonder if I can use your code in order to do that.

Silly question: you mention the surface cannot expand more than your mesh. Is it ok if it is just a small part of the mesh (e.g. a plane 1.2m vertical from the floor of one room, in one appartment, in one tower, in a small neighbourhood)?

Another silly question: Is the function object in controlDict all I need, that is all you used in your example, or do we need additional files?

And final silly question: Is there a way to use one function object for multiple surfaces? I have around 183 surfaces I have to calculate average velocities for, so I wouldn't want to copy/paste this as many times. Also, I imagine if the above is possible they would all come out in a single file which makes it easier for post-processing.

Thank you so much in advance!

Kind regards,
Theodore.


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