CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   How to calculate Volume averaged species/temperature (http://www.cfd-online.com/Forums/openfoam-post-processing/92888-how-calculate-volume-averaged-species-temperature.html)

will_avoid_comm_solvers September 28, 2011 11:10

How to calculate Volume averaged species/temperature
 
Dear All

In OpenFOAM, is there a way to estimate volume averaged temperature or species concentration for my entire flow domain.

When I use the intergrate variable filter in paraFoam, I do get the integrated temperture. Can I divide this number by the domain volume to get the volume averaged temperature?

Thanks

chegdan September 28, 2011 15:29

Quote:

Originally Posted by will_avoid_comm_solvers (Post 325943)
Dear All

In OpenFOAM, is there a way to estimate volume averaged temperature or species concentration for my entire flow domain.

When I use the intergrate variable filter in paraFoam, I do get the integrated temperture. Can I divide this number by the domain volume to get the volume averaged temperature?

Thanks

Take a look at the simpleFunctionObjects tool at ( http://openfoamwiki.net/index.php/Co...unctionObjects ) or if you think are going to use groovyBC, go ahead and get swak4foam at (http://openfoamwiki.net/index.php/Contrib/swak4Foam)


Dan

Bernhard September 28, 2011 17:33

Alternatively, you can use sample as a post processing tools (see the utilities folder for an example of the dictionary)

despaired student February 19, 2013 08:59

surfaceAverage values
 
Hello,

is there also a possibility to get a "surfaceAverage" instead of a patchAverage as it is described in http://openfoamwiki.net/index.php/Co...unctionObjects --> 2.3

My aim is to make a surface-sample and then -somehow- calculate the averaged value for the concentration referred to this surface or to calculate the flux of a scalar through the mentioned surface.

Is this possible and is there an easy way to do that...?


kind regards

gschaider February 22, 2013 16:44

Quote:

Originally Posted by despaired student (Post 408713)
Hello,

is there also a possibility to get a "surfaceAverage" instead of a patchAverage as it is described in http://openfoamwiki.net/index.php/Co...unctionObjects --> 2.3

My aim is to make a surface-sample and then -somehow- calculate the averaged value for the concentration referred to this surface or to calculate the flux of a scalar through the mentioned surface.

Is this possible and is there an easy way to do that...?


kind regards

Yep. You've only got to look one door further: the simpleFunctionObjects are now part of swak4Foam. In swak4Foam you can (amongst other things) calculate expressions on sampledSurfaces. So there is no readymade solution for what you want but a flexible one. grep the Examples for function objects of "type swakExpression" which have a "valueType surface"

despaired student April 6, 2013 07:31

three different methods three different results
 
Hi,

it's been some days since I've worked on this problem...
Now I've tried some possibilieties (A, B, C) and all of them are delivering a different result... :(
I've been working/looking throug the net and some examples yet but I'm becoming more confused than I'm getting a clear vision of what to do.


My aims are to determine
1. the area-averaged concentration (T) of 2 surfaces (volume-averaged concentration of a user-defined region of the mesh would also be nice...if possible?)
2. the area-averaged flux (massflow per area) and the total massflow of a specific area.

Is it correct to assume that area-averaged means the same as area-weighted in OpenFoam?

To determine the area-averaged concentration I used three different ways (A,B,C). Can somebody explain why these three ways lead to three different results?
For the massflow I haven't really tried yet.


Thanks for your help.

Way A:
Quote:

surfacePlaneT1a
{
type swakExpression;
valueType surface;
surfaceName testPlaneT1;
surface {
type plane;
basePoint (0 0 0.0105);
normalVector (0 0 1);
interpolate false;
}
verbose true;
expression " T";
accumulations (average);
}

Way B:
Quote:

test_01
{
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; //true;
// Type of source: patch/faceZone/sampledSurface
source sampledSurface;//faceZone;
sourceName face_set_10,5mm;
sampledSurfaceDict
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
basePoint ( 0 0 0.0105 );
normalVector ( 0 0 1 );
}
source cells;
interpolate true;
}
// Operation: areaAverage/sum/weightedAverage ...
operation areaAverage;
//weightField phi;
fields (T);
}
Way C:
Quote:

test_02
{
type faceSource;
functionObjectLibs ("libfieldFunctionObjects.so");
enabled true;
outputControl outputTime;
log true;
valueOutput true;
source sampledSurface;
sourceName face_set2_10,5mm;
sampledSurfaceDict
{
type plane; // always triangulated
basePoint (0 0 0.0105);
normalVector (0 0 1);
}
operation areaAverage;
fields ( T );
}

gschaider April 6, 2013 11:59

Quote:

Originally Posted by despaired student (Post 418746)
Hi,

it's been some days since I've worked on this problem...
Now I've tried some possibilieties (A, B, C) and all of them are delivering a different result... :(
I've been working/looking throug the net and some examples yet but I'm becoming more confused than I'm getting a clear vision of what to do.


My aims are to determine
1. the area-averaged concentration (T) of 2 surfaces (volume-averaged concentration of a user-defined region of the mesh would also be nice...if possible?)
2. the area-averaged flux (massflow per area) and the total massflow of a specific area.

Is it correct to assume that area-averaged means the same as area-weighted in OpenFoam?

To determine the area-averaged concentration I used three different ways (A,B,C). Can somebody explain why these three ways lead to three different results?
For the massflow I haven't really tried yet.


Thanks for your help.

Way A:

At first: next time use CODE instead of QUOTE for your examples:
a) the formatting is better
b) it will be there when others quote you

I can only comment on example A (the swak one): that certainly does not do what you want from it. "average" in swak means (and that is because it uses the OF-functions of the same name) is "only" the arithmetic average: so a small face of the surface has the same influence as one 10 time its size (very democratic, but not very physical). So with an expression "T*area()/sum(area())" and an accumulation "sum" you might get the result you want. The latest version of swak has an accumulation weightedAverage but I'm not sure whether it works OK for sampledSurfaces.

Volume averaged will work similar "T*vol()/sum(vol())"

Mass flow per area: just calculate the mass-flow and divide it by "sum(area())"

Don't know the difference between area-weighted and averaged in OF (would have to look that up myself)

despaired student April 6, 2013 13:32

Quote:

At first: next time use CODE instead of QUOTE for your examples:
a) the formatting is better
b) it will be there when others quote you
--->OK



Another very helpful OpenFoam-expert (M. Becker - maybe he'll read this one day...?) gave me the same advise on way A.
Maybe someone else can tell me where the difference between way B and C is.


Thanks for your comment and help!

despaired student April 8, 2013 13:27

strange results
 
Hi,

after trying some methods to receive an area-averaged value for I got two results. Maybe someone can clearify why there is such a difference between my two results...:confused:
I am thankful for any ideas...

First I'll present the results:

Method | Faces | sum(magSf) | areaAverage(T)
sampledsurf-T1 | 0.10585904
test_01 | 136298 | 0.00023717965 | 0.059855598
test_02 | 63764 | 0.000237178 | 0.10585904
test_03 | 136298 | 0.00023717965 | 0.059855598

Another thing is that the value for the "Faces" differes if I use "surface type cuttingPlane" and stays constant for "surface type plane"...why? It should stay constant...

Here is the code I used in the controlDict:
Code:

functions
{

    sampledsurf-T1
    {
        type swakExpression;
        valueType surface;
        surfaceName testPlaneT1;
        surface {
            type plane;
            basePoint      (0 0 0.0105);
            normalVector    (0 0 1);
            interpolate false;
        }
        verbose true;
        expression "T*area()/sum(area())";
        accumulations (sum);
    }

    test_01

{

    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; //true;

// Type of source: patch/faceZone/sampledSurface
    source sampledSurface;//faceZone;
    sourceName face_set_10,5mm;
    sampledSurfaceDict
{
    type cuttingPlane;
    planeType pointAndNormal;
    pointAndNormalDict
    {
    basePoint ( 0 0 0.0105 );
    normalVector ( 0 0 1 );
    }
    source cells;
    interpolate true;
}

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

//weightField phi;

    fields (T);

}


    test_02
    {
        type            faceSource;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled        true;
        outputControl  outputTime;
        log            true;
        valueOutput    true;
        source          sampledSurface;
    sourceName face_set2_10,5mm;
        sampledSurfaceDict
        {
            type            plane; 
            basePoint      (0 0 0.0105);
            normalVector    (0 0 1);
        }
        operation      areaAverage;
        fields ( T );
    }



    test_03

{

    type faceSource;
    functionObjectLibs ("libfieldFunctionObjects.so");
    enabled true;
    outputControl outputTime;
    log true;
    valueOutput true; //true;
    source sampledSurface;//faceZone;
    sourceName face_set3_10,5mm;
    sampledSurfaceDict
    {
        type cuttingPlane;
        planeType pointAndNormal;
        pointAndNormalDict
        {
            basePoint ( 0 0 0.0105 );
            normalVector ( 0 0 1 );
        }
//    source cells;
//    interpolate true;
    }
// Operation: areaAverage/sum/weightedAverage ...
    operation areaAverage;
//weightField phi;
    fields (T);

}


gschaider April 8, 2013 14:06

Quote:

Originally Posted by despaired student (Post 419161)
Hi,

after trying some methods to receive an area-averaged value for I got two results. Maybe someone can clearify why there is such a difference between my two results...:confused:
I am thankful for any ideas...

First I'll present the results:

Method | Faces | sum(magSf) | areaAverage(T)
sampledsurf-T1 | 0.10585904
test_01 | 136298 | 0.00023717965 | 0.059855598
test_02 | 63764 | 0.000237178 | 0.10585904
test_03 | 136298 | 0.00023717965 | 0.059855598

Another thing is that the value for the "Faces" differes if I use "surface type cuttingPlane" and stays constant for "surface type plane"...why? It should stay constant...

No idea. The positive is that results for the plane (sampledSurf-T1 and test_02) and the cutting plane (test01, test03) are consistent. I remember in the past getting weird results with cuttingPlane, but I never bothered to track it down. I think if you rewrote sampledsurf-T1 to use the cuttingPlane you should get the same result as test_01 (BTW: "sum(area())" would give you the area for the swak-variant. But that should be the same). Maybe the differences are due to different interpolation/discretization: for instance if your T is 0 in most of the domain and only different in "boundary faces". Then the smaller boundary faces only "add" half the contribution to the sum and thus give a smaller average. But that is just a guess

As always: checking for the correct method is easiest if you know beforehand what the result will be: for instance a constant T or a T(x) (funkySetFields will help you there) where T(x) is such that you can analytically calculate the result beforehand

despaired student April 9, 2013 06:14

Possibility for a reference???
 
Quote:

As always: checking for the correct method is easiest if you know beforehand what the result will be: for instance a constant T or a T(x) (funkySetFields will help you there) where T(x) is such that you can analytically calculate the result beforehand
If I knew how to use funkySetFields I would do that for a much easier case...but my problem right now is that I'm running out of time...my professor wants me to finish in a few days but I can't be sure to deliever proper results with such a problem...


Would it be possible to use the "surfaceToPatch" - Utility to create a patch and measure the area-averaged value for T on this patch with one of the following codes:

Code:

functions
  ( 
 areaAverageConcentration-T   
  {     
    type                    patchAverage;     
    functionObjectLibs ("libsimpleFunctionObjects.so");     
    verbose true;     
    patches  (  tolles-Patch );
    fields (T);
    }
  );

With patchAverage: sum (T_i*area_i) / sum (area_i) .
(see http://openfoamwiki.net/index.php/Co...unctionObjects )

The swak4foam way using a patch would be:

Code:

    averagedConcentration-T
    {
        type patchExpression;
        accumulations (    sum    );
        patches ( tolles-Patch  );
        expression "T*area()/sum(area())";
        verbose true;
    }

The results of both codes should be the same I think...? Now, can someone please explain how to use the > surfaceToPatch < Utility ? :confused:
If you think that this way wil not provide a proper reference to judge which one of the before mentioned results are correct then please let me know.


Kind regards

despaired student April 9, 2013 07:20

Test results
 
I did a little example of a rectangular channel-flow where I measured the OUTLET Patch via SWAK4FOAM and a patchAverage as described here
http://openfoamwiki.net/index.php/Co...unctionObjects

Here are my results ordered the way they are written in the controlDict which you can see attached. The last results are taken 0.8 mm ahead of the others at the OUTLET-Patch. The rest are sampled ones. From this little try I would make the conclusion that using type cuttingPlane for a sampledSurface is less precise than plane or the swak-altenative...
I would appreciate it if someone could confirm this conclusion...

sampledSurface: 0.14318075
test_01TOutlet 0.12430655
test_02TOutlet 0.14318075
test_03TOutlet 0.12430655
areaAverageConcentration-TOutlet 0.14306758
SWAKaveragedConcentration-TOutlet 0.14306758


controlDict:
Code:

libs (
    "libOpenFOAM.so" // keeps paraFoam happy
    "libtwoPhaseInterfaceProperties.so"
    "libinterfaceProperties.so"
    "libsimpleSwakFunctionObjects.so"
    "libswakFunctionObjects.so"
);


functions
{

    sampledsurf-TOutlet
    {
        type swakExpression;
        valueType surface;
        surfaceName testPlaneT1;
        surface {
            type plane;
            basePoint      (0 0.028 0.069);
            normalVector    (0 1 0);
            interpolate false;
        }
        verbose true;
        expression "T*area()/sum(area())";
        accumulations (sum);
    }


    test_01TOutlet

{

    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; //true;

// Type of source: patch/faceZone/sampledSurface
    source sampledSurface;//faceZone;
    sourceName face_set_10,5mm;
    sampledSurfaceDict
{
    type cuttingPlane;
    planeType pointAndNormal;
    pointAndNormalDict
    {
            basePoint      (0 0.028 0.069);
            normalVector    (0 1 0);
    }
    source cells;
    interpolate true;
}

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

//weightField phi;

    fields (T);

}

    test_02TOutlet
    {
        type            faceSource;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled        true;
        outputControl  outputTime;
        log            true;
        valueOutput    true;
        source          sampledSurface;
    sourceName face_set2_10,5mm;
        sampledSurfaceDict
        {
            type            plane; 
            basePoint      (0 0.028 0.069);
            normalVector    (0 1 0);
        }
        operation      areaAverage;
        fields ( T );
    }

    test_03TOutlet

{

    type faceSource;
    functionObjectLibs ("libfieldFunctionObjects.so");
    enabled true;
    outputControl outputTime;
    log true;
    valueOutput true; //true;
    source sampledSurface;//faceZone;
    sourceName face_set3_10,5mm;
    sampledSurfaceDict
    {
        type cuttingPlane;
        planeType pointAndNormal;
        pointAndNormalDict
        {
                basePoint      (0 0.028 0.069);
              normalVector    (0 1 0);
        }
//    source cells;
//    interpolate true;
    }
// Operation: areaAverage/sum/weightedAverage ...
    operation areaAverage;
//weightField phi;
    fields (T);

}


    areaAverageConcentration-TOutlet   
      {     
        type                    patchAverage;     
        functionObjectLibs ("libsimpleFunctionObjects.so");     
        verbose true;     
        patches  (  OUTLET );
        fields (T);
      }

    SWAKaveragedConcentration-TOutlet
    {
        type patchExpression;
        accumulations (    sum    );
        patches ( OUTLET  );
        expression "T*area()/sum(area())";
        verbose true;
    }
}


gschaider April 9, 2013 08:45

Quote:

Originally Posted by despaired student (Post 419382)
I did a little example of a rectangular channel-flow where I measured the OUTLET Patch via SWAK4FOAM and a patchAverage as described here
http://openfoamwiki.net/index.php/Co...unctionObjects

Here are my results ordered the way they are written in the controlDict which you can see attached. The last results are taken 0.8 mm ahead of the others at the OUTLET-Patch. The rest are sampled ones. From this little try I would make the conclusion that using type cuttingPlane for a sampledSurface is less precise than plane or the swak-altenative...
I would appreciate it if someone could confirm this conclusion...

sampledSurface: 0.14318075
test_01TOutlet 0.12430655
test_02TOutlet 0.14318075
test_03TOutlet 0.12430655
areaAverageConcentration-TOutlet 0.14306758
SWAKaveragedConcentration-TOutlet 0.14306758

Got no time to confirm this, but my guess is that if you rewrite the swak-thing (sampledSurface) to use the cuttingPlane you'll get a similar (wrong) result. My guess is still what I said in the last post: that your T is almost a top-hat profile (constant on the interior and big increase on the boundary). Due to the smaller faces and interpolation for the cutting-plane the boundary has less influence and thus the value is different

despaired student April 9, 2013 09:04

Quote:

big increase on the boundary
--> Yes, there is a huge boundary-influence and it is somehow a "top-hat"-profile.

If I got you right, in this case the cuttingPlane is less precise.


Thanks again for your quick answer!

gschaider April 9, 2013 09:31

Quote:

Originally Posted by despaired student (Post 419408)
--> Yes, there is a huge boundary-influence and it is somehow a "top-hat"-profile.

If I got you right, in this case the cuttingPlane is less precise.

I wouldn't say it like that. It has a better resolution and therefor gives different results. It means that the result is not resolution independent


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