CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

Computing Patch Average During Simulation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 18, 2017, 21:19
Default Computing Patch Average During Simulation
  #1
New Member
 
Join Date: Nov 2016
Posts: 10
Rep Power: 10
victorious_BIG is on a distinguished road
Hi,

I spent some time trying to figure out an effective way to calculate the average of a scalar quantity of over a patch while the solver is iterating. I appended the code below to the bottom of my solver. In this example, the patch of interest is named "outlet":


runTime.write();

const label& patchID = mesh.boundaryMesh().findPatchID("outlet");
const fvPatch& outletPatch = mesh.boundary()[patchID];
const fvPatchField<scalar>& T =
outletPatch.lookupPatchField<volScalarField, scalar>("T");

Info << "Average Outlet Temp: "
<< sum(T * T.patch().magSf()) / sum(T.patch().magSf()) << endl;


This gave me the same result as running the post processing command from the terminal prompt:

>> postProcess -func 'patchAverage(name=outlet,T)'

Note: I have only tested this on a regular mesh.

I'd be happy to hear feedback as to whether there is a more effective/efficient method to do this than what I have written above.
victorious_BIG is offline   Reply With Quote

Old   August 29, 2017, 13:28
Default Post-processing Function Object Definitions
  #2
New Member
 
Join Date: Nov 2016
Posts: 10
Rep Power: 10
victorious_BIG is on a distinguished road
Hi,

I have been trying to search the source code for the location of the function object definitions. For example, in my post above I am using a possible definition to determine an average concentration. I've tried to find the location of the function object definitions in the source code using oxygen but haven't had much luck.

Does anyone know where the specific source code files for the function definition is located?

Thanks!
victorious_BIG is offline   Reply With Quote

Old   November 28, 2018, 06:23
Default
  #3
New Member
 
Arthur
Join Date: Oct 2018
Location: Glasgow
Posts: 20
Rep Power: 8
amdk136 is on a distinguished road
Quote:
Originally Posted by victorious_BIG View Post
Hi,

I spent some time trying to figure out an effective way to calculate the average of a scalar quantity of over a patch while the solver is iterating. I appended the code below to the bottom of my solver. In this example, the patch of interest is named "outlet":

runTime.write();

const label& patchID = mesh.boundaryMesh().findPatchID("outlet");
const fvPatch& outletPatch = mesh.boundary()[patchID];
const fvPatchField<scalar>& T =
outletPatch.lookupPatchField<volScalarField, scalar>("T");

Info << "Average Outlet Temp: "
<< sum(T * T.patch().magSf()) / sum(T.patch().magSf()) << endl;

This gave me the same result as running the post processing command from the terminal prompt:

>> postProcess -func 'patchAverage(name=outlet,T)'

Note: I have only tested this on a regular mesh.

I'd be happy to hear feedback as to whether there is a more effective/efficient method to do this than what I have written above.
Hi,

I was wondering what file you have the first section of code in?:
Quote:
runTime.write();

const label& patchID = mesh.boundaryMesh().findPatchID("outlet");
const fvPatch& outletPatch = mesh.boundary()[patchID];
const fvPatchField<scalar>& T =
outletPatch.lookupPatchField<volScalarField, scalar>("T");

Info << "Average Outlet Temp: "
<< sum(T * T.patch().magSf()) / sum(T.patch().magSf()) << endl;
I am interested in this, however I am unsure where it should be put!

Thanks,
Arthur

Last edited by amdk136; November 28, 2018 at 06:25. Reason: formatting
amdk136 is offline   Reply With Quote

Reply

Tags
co-processing, patch average, post processing


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
Near wall treatment in k-omega SST Arnoldinho OpenFOAM Running, Solving & CFD 38 March 8, 2017 14:48
[OpenFOAM.org] Compile OF 2.3 on Mac OS X .... the patch gschaider OpenFOAM Installation 225 August 25, 2015 20:43
[Commercial meshers] Using starToFoam clo OpenFOAM Meshing & Mesh Conversion 33 September 26, 2012 05:04
chtMultiRegionFoam Tutorial m.nichols19 OpenFOAM 12 September 9, 2010 12:56
[Other] StarToFoam error Kart OpenFOAM Meshing & Mesh Conversion 1 February 4, 2010 05:38


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