CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   IntegrateVariables in paraview to get a average flow velocity (https://www.cfd-online.com/Forums/openfoam/196869-integratevariables-paraview-get-average-flow-velocity.html)

Qihao December 19, 2017 11:28

IntegrateVariables in paraview to get a average flow velocity
 
2 Attachment(s)
I have calculated the result of a two dimensional open channel flow in openFOAM. And I want to get the average flow velocity in a internal surface between inlet and outlet.

so I did as follows:

1. get the slide which flow through it
2. use the tool of Plot over line along the bottom to the top, then I can also get the result of the velocity distribution in vertical direction
3. use the filters of integrate variables to get the result of average of this surface, but the result seems not correct. and average velocity calculated in that face is 0.0928. anyone has used this tools?

Taataa December 19, 2017 14:43

Did you check the divide by cell volume? You better set the data type to cell instead of point, then check that box.
Why don't you use the functions in OpenFOAM itself? there is a volAverage function that you can use to get what you want easily. What I usually do is using topoSet tool to create a set of cells that I want to find the average, then add this function to controlDict.

Qihao December 20, 2017 02:48

Quote:

Originally Posted by Taataa (Post 675611)
Did you check the divide by cell volume? You better set the data type to cell instead of point, then check that box.
Why don't you use the functions in OpenFOAM itself? there is a volAverage function that you can use to get what you want easily. What I usually do is using topoSet tool to create a set of cells that I want to find the average, then add this function to controlDict.

I am new to openfoam, how to set the data type to cell? use toposet? or I may try the second method you show me.

Flowkersma December 20, 2017 08:51

Hi Qihao,

Create the slice and then apply the integrate variables filter. A spreadsheet will open. Choose "Cell data" and you have both Area and integrated U values. So, to get the average velocity just divide U by Area.

Best, Mikko

Qihao December 20, 2017 08:55

Quote:

Originally Posted by Flowkersma (Post 675700)
Hi Qihao,

Create the slice and then apply the integrate variables filter. A spreadsheet will open. Choose "Cell data" and you have both Area and integrated U values. So, to get the average velocity just divide U by Area.

Best, Mikko

Thank you. I have checked this morning. and the integrate variable should use the cell data. The point data seems not correct. I also want to use the function of openfoam in the code to determine this.

Taataa December 20, 2017 10:22

First create a cell zone using topoSet. If you don't know how, just follow the instruction here. It's better to use one of the existing OpenFOAM tutorial if haven't done this before, for example this one.

Then, just add these lines to the end of controlDict:

Code:

functions
{
  justAName // you can set whatever name you want
  {
    type            volFieldValue;
    libs            ("libfieldFunctionObjects.so");
    log            true;
    writeFields    false;
    regionType      cellZone;
    name            nameOfCellZone; //This is the name you've used in topoSet
    operation      volAverage; // There are other operations that you might use, check the doc
    fields
    (
        U //You can add other fields as well, check the doc given below
    );
  }

You can find more info here.

Flowkersma December 21, 2017 09:18

There are several threads on the forum such as this but seems like they might be outdated.

Qihao December 28, 2017 10:15

hi Taataa, I have another question want to consult you,
I have a case with pressure distribution along the bottom boundary obtained from experiments which are discrete values. Is there any utility that I can specify location vs value of bottom pressure and let the utility do the interpolation, then apply this interpolation function as another same geometry's boundary conditions?

Qihao December 28, 2017 10:16

Quote:

Originally Posted by Taataa (Post 675708)
First create a cell zone using topoSet. If you don't know how, just follow the instruction here. It's better to use one of the existing OpenFOAM tutorial if haven't done this before, for example this one.

Then, just add these lines to the end of controlDict:

Code:

functions
{
  justAName // you can set whatever name you want
  {
    type            volFieldValue;
    libs            ("libfieldFunctionObjects.so");
    log            true;
    writeFields    false;
    regionType      cellZone;
    name            nameOfCellZone; //This is the name you've used in topoSet
    operation      volAverage; // There are other operations that you might use, check the doc
    fields
    (
        U //You can add other fields as well, check the doc given below
    );
  }

You can find more info here.

hi Taataa, I have another question want to consult you,
I have a case with pressure distribution along the bottom boundary obtained from experiments which are discrete values. Is there any utility that I can specify location vs value of bottom pressure and let the utility do the interpolation, then apply this interpolation function as another same geometry's boundary conditions?

Taataa December 28, 2017 23:51

You can a nonuniform value for the boundary for example:

inlet
{
type fixedValue;
value nonuniform List<scalar>
20 //number of cells in the boundary
(
123123 //desired pressure at first cell of the first boundary
234234 //desired pressure at first cell of the second boundary
.
.
.
);
}

The difficulty is finding the number of cells and the pressure at the center of the cell. If you're mesh is not dynamic then finding the number of cells is easy. Just run the simulation with your previous boundary condition for a couple of time steps then go to the directory of, for example, the last time step and check the p file. Just find the name of the boundary by for example ctrl+F and name of the boundary. Then you will see a similar format as nonuniform List<scalar> which below it you will find a number which is the number cells.

Regarding interpolation for finding the pressure at the cell centers I would suggest to do it manually using a python script or excel. Just interpolate your experimental data at the location of cell centers.

Another way of finding number of cells is using sampling utility of OF, you can find some explanation here.

Qihao December 29, 2017 01:07

Can I use the tablefile boundary condition to load the file which consist the value of pressure and relative location, then interpolation and use it to another boundary. I think this may convenient, I have not try this now.

Taataa December 29, 2017 02:25

Yes, that's basically the same thing, instead of putting the numbers directly, you put them in a file then link it to the file.

Qihao January 5, 2018 11:22

Quote:

Originally Posted by Taataa (Post 676361)
Yes, that's basically the same thing, instead of putting the numbers directly, you put them in a file then link it to the file.

/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 5.x |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [1 -1 -2 0 0 0 0];

internalField uniform 0;

boundaryField
{
front
{
type empty;
}
cyc_left
{
type cyclic;
}
top
{
type fixedProfile;
profile csvFile;
profileCoeffs
{
nHeaderLine 0; // Number of header lines
refColumn 0; // Reference column index
componentColumns (1 2); // Component column indices
separator ","; // Optional (defaults to ",")
mergeSeparators no; // Merge multiple separators
fileName "dataFile.csv"; // name of csv data file
outOfBounds clamp; // Optional out-of-bounds handling
interpolationScheme linear; // Optional interpolation scheme
}
direction (1 0 0);
origin 0;
}
bottom
{
type zeroGradient;
}
back
{
type empty;
}
cyc_right
{
type cyclic;
}
}

dataFile.csv
0,0
0.005,0.043
0.01,0.158
0.015,0.311
0.02,0.482
0.025,0.663
0.03,0.845
0.035,1.022
0.04,1.187
0.045,1.334
0.05,1.46
0.055,1.561
0.06,1.637
0.065,1.69
0.07,1.723
0.075,1.737
0.08,1.735
0.085,1.717
0.09,1.688
0.095,1.648
0.1,1.599
0.105,1.543
0.11,1.48
0.115,1.412
0.12,1.34
0.125,1.263
0.13,1.183
0.135,1.099
0.14,1.012
0.145,0.922
0.15,0.829
0.155,0.733
0.16,0.633
0.165,0.531
0.17,0.425
0.175,0.315
0.18,0.201
0.185,0.083
0.19,-0.041
0.195,-0.172
0.2,-0.31
0.205,-0.457
0.21,-0.615
0.215,-0.789
0.22,-0.982
0.225,-1.21
0.23,-1.469
0.235,-1.853
0.24,-2.185
0.245,-2.948
0.25,-2.923
0.255,-2.011
0.26,-1.717
0.265,-1.562
0.27,-1.437
0.275,-1.32
0.28,-1.209
0.285,-1.101
0.29,-0.996
0.295,-0.894
0.3,-0.797
0.305,-0.702
0.31,-0.61
0.315,-0.521
0.32,-0.437
0.325,-0.358
0.33,-0.285
0.335,-0.22
0.34,-0.152
0.345,-0.065
0.35,-0.017 first column is x location, second column is value of pressure
I find this boundary condition may be can solve the problem last mentioned. but has the problem I can not solve.

keyword file is undefined in dictionary "/home/qihao/OpenFOAM/qihao-5.0/run/hyporheic/Hyporheic/Groundwater/Stratified/0/p.boundaryField.top.profileCoeffs"

file: /home/qihao/OpenFOAM/qihao-5.0/run/hyporheic/Hyporheic/Groundwater/Stratified/0/p.boundaryField.top.profileCoeffs from line 38 to line 45.

From function const Foam::entry& Foam::dictionary::lookupEntry(const Foam::word&, bool, bool) const
in file db/dictionary/dictionary.C at line 566.

Taataa January 5, 2018 13:27

You have set refColumn as 0 (which is the first col) then you've set componentColumns as (1 2) which means columns 2 and 3!. You should use componentColumns (1).
Also as the error suggests you should use file instead of fileName.

Qihao January 8, 2018 03:39

Quote:

Originally Posted by Taataa (Post 677070)
You have set refColumn as 0 (which is the first col) then you've set componentColumns as (1 2) which means columns 2 and 3!. You should use componentColumns (1).
Also as the error suggests you should use file instead of fileName.

I Solved this problem by using this BC. If someone wants to load files of scatters and do the interpolation. I think this is a good choice instead of using nonuiform List<>

arhabib October 30, 2019 18:55

Hi,

How can one generate maps of depth-averaged velocity in ParaView.
I am post-processing a VOF simulation (air/water) done in interFOAM.
What I am looking for is a 2D map of depth-averaged quantities such as velocity in the entire domain. Just integrating/averaging over a vertical line won't work (I need this done in the entire domain).

Thanks


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