CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Accurately calculate boundaryField average

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 10, 2014, 00:45
Default Accurately calculate boundaryField average
  #1
Member
 
Ripudaman Manchanda
Join Date: May 2013
Posts: 55
Rep Power: 12
ripudaman is on a distinguished road
Hi fellow Foamers,

I am having some trouble identifying the best way to calculate the boundaryField average on a patch. I have tried three techniques and all of them give me different answers :-
Code:
label wallPatch1 = mesh.boundaryMesh().findPatchID("ff");
scalar area1 = gSum(mesh.magSf().boundaryField()[wallPatch1]);
if (area1 > 0)
{
    sumW111 = gSum
    (
        mesh.magSf().boundaryField()[wallPatch1]
      * mag(D.boundaryField()[wallPatch1])
    ) / area1;
}
forAll(D.boundaryField()[wallPatch1], face1)
{
    D1 = D.boundaryField()[wallPatch1][face1];
    N1 = mesh.Sf().boundaryField()[wallPatch1][face1]
         /mesh.magSf().boundaryField()[wallPatch1][face1];
    disp1 = -1.0 * (D1.component(vector::X) * N1.component(vector::X));
    disp1+= -1.0 * (D1.component(vector::Y) * N1.component(vector::Y));
    disp1+= -1.0 * (D1.component(vector::Z) * N1.component(vector::Z));
    disp1 = disp1/mag(N1);
    sumW1+=mag(disp1);
    sumW11+=mag(D.boundaryField()[wallPatch1][face1]);
    nF1+=1;
}
Info<<sumW1/nF1<<nl<<sumW11/nF1<<nl<<sumW111<<nl;
For the above code different values are printed to the screen. What am I missing here?

FYI, the above snippet is added as a separate .H file in the runTime loop.

Foamers please help me here.

Thank you.
Regards,
Ripu
ripudaman is offline   Reply With Quote

Old   March 10, 2014, 06:32
Default
  #2
Senior Member
 
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21
jherb is on a distinguished road
For OpenFOAM operators see: http://www.foamcfd.org/Nabla/guides/...sGuidese4.html

I guess you want the inner/dot product of the surface vectors of the patch with your field? Then you have to use the operator "&" instead of "*" in your sum for W111. At least for W1 you are calculating the inner product. W11 just sums the unweighted absolute values of your field on the patch to calculate the mean of all these values.

So in fact, you calculate three different thing. They would be equal, if all faces of the patch had the same size and the field was parallel to the faces' normal vectors.
jherb is offline   Reply With Quote

Old   March 10, 2014, 20:35
Default
  #3
Member
 
Ripudaman Manchanda
Join Date: May 2013
Posts: 55
Rep Power: 12
ripudaman is on a distinguished road
Joachim,

Thank you very much for the explanation. I highly appreciate it.

Regards,
Ripu
ripudaman is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to calculate the average of torque in transient Ansys CFX Simulation xtphgu CFX 23 June 17, 2020 07:17
How to calculate a zone Average subhkirti OpenFOAM Post-Processing 36 October 27, 2015 09:30
calculate the average velocity of particles robert FLUENT 0 August 1, 2008 09:44
Average of a UDMI in UDF milan FLUENT 0 April 15, 2008 12:37
Can FLUENT calculate the boundary layer accurately Bob FLUENT 2 August 25, 2007 01:23


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