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

How to calculate double integration in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 9, 2010, 02:18
Default How to calculate double integration in OpenFOAM
  #1
Senior Member
 
Vishal Nandigana
Join Date: Mar 2009
Location: Champaign, Illinois, U.S.A
Posts: 208
Rep Power: 18
nandiganavishal is on a distinguished road
Dear Foamers,

I would like to know if we could integrate a variable over x and y at the same time respectively. I know integrate variable function can perform integration along x or y direction at a time. But is it possible to perform double integration in OpenFOAM.

Kindly let me know.

Thanks

Vishal Nandigana
nandiganavishal is offline   Reply With Quote

Old   December 9, 2010, 09:15
Default
  #2
New Member
 
Bill Rosemurgy
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 20
Rep Power: 17
brosemu is on a distinguished road
Hi Vishal,

Could you provide some more information about what you are trying to integrate and what it is you are trying to integrate over? I think I can help...

What is the name of the 1-D integration function that you mentioned?

- Bill
brosemu is offline   Reply With Quote

Old   December 9, 2010, 12:52
Default
  #3
Senior Member
 
Vishal Nandigana
Join Date: Mar 2009
Location: Champaign, Illinois, U.S.A
Posts: 208
Rep Power: 18
nandiganavishal is on a distinguished road
Dear Bill,

Thanks for the response. Basically I have a rectangular channel and I want to integrate a variable say 'u' along a desired length (say from x1 to x2) and across the entire cross section of the channel (i.e from y1 to y2). I would like you to throw some light with regard to this. I hope I made my point more clear now.

The function I was talking about to integrate in 1-D is integratevariable function in paraview.

Thanks

Vishal Nandigana
nandiganavishal is offline   Reply With Quote

Old   December 9, 2010, 14:38
Default
  #4
New Member
 
Bill Rosemurgy
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 20
Rep Power: 17
brosemu is on a distinguished road
Ok, so the method I was thinking of involves simply (or not so simply...) editing the actual solver that you are using to perform the integration for you. A for loop and some if-statements would do the trick, but only if you're comfortable doing that. Otherwise, it may be possible in Paraview, but I don't know how you'd do it.

- Bill
brosemu is offline   Reply With Quote

Old   December 9, 2010, 14:57
Default
  #5
Senior Member
 
Vishal Nandigana
Join Date: Mar 2009
Location: Champaign, Illinois, U.S.A
Posts: 208
Rep Power: 18
nandiganavishal is on a distinguished road
Dear Bill,

Thanks for the reply. The problem is the area I would like to integrate is not constant for all cases. The y direction is constant but not in x direction. I have to view the result and only then perform the x integration. So I wonder if changing the solver would help. Do correct me if I am wrong.

Thanks

Vishal Nandigana
nandiganavishal is offline   Reply With Quote

Old   September 1, 2011, 07:41
Default
  #6
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Dear everybody,


I need to integrate a variable over x and y in a boundary condition. Can somebody write an example of how to do it?


Thanks in advance

Last edited by isabel; September 1, 2011 at 09:27.
isabel is offline   Reply With Quote

Old   September 1, 2011, 11:27
Default
  #7
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
Dear everybody,

I was able to integrate a variable. I want to integrate a variable to obtain the average temperature and the average temperature gradient in a boundary condition, so I wrote this code:


label patchID = mesh.boundaryMesh().findPatchID("ABAJO");
const polyPatch& cPatch = mesh.boundaryMesh()[patchID];
const surfaceScalarField& magSf = mesh.magSf();

scalar Area = 0.0;
scalar sumArea = 0.0; //area of the boundary condition
scalar sumT = 0.0; //average temperature
scalar sumgradT = 0.0; //average temperature gradient

forAll(cPatch, facei)
{
Area = magSf.boundaryField()[patchID][facei];
sumArea += magSf.boundaryField()[patchID][facei];
sumT += T.boundaryField()[patchID][facei]*Area;
sumgradT += T.boundaryField()[patchID].snGrad();
}

Info << "Area " << sumArea << endl; //area of the boundary condition
Info << "Average T " << sumT/sumArea << endl; //average temperature
Info << "Average T " << sumgradT/sumArea << endl; //average temperature gradient


My code computes the average temperature Ok, but the line of the temperature gradient "sumgradT+=T.boundaryField()[patchID].snGrad(); " gives the following error:

integracion.H:41: error: no match for ‘operator+=’ in ‘sumgradT += Foam::fvPatchField<Type>::snGrad [with Type = double]()’


How can I obtain the magnitude of the temperature gradient?
isabel is offline   Reply With Quote

Old   September 1, 2011, 12:01
Default
  #8
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
Maybe this piece of code may be helpfull?

http://foam.sourceforge.net/docs/cpp/a03267_source.html
Bernhard is offline   Reply With Quote

Old   September 1, 2011, 15:10
Default
  #9
Senior Member
 
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17
isabel is on a distinguished road
It is very interesting, thanks. Finally, I was able to compute the average temperature and the average temperature gradient in the boundary condition. The problem is that the gradient computed is exactly half of the real gradient. Does anybody know why? The code is here:


label patchID = mesh.boundaryMesh().findPatchID("ABAJO");
const polyPatch& cPatch = mesh.boundaryMesh()[patchID];
const surfaceScalarField& magSf = mesh.magSf();

scalar Area = 0.0;
scalar sumArea = 0.0; //area of the boundary condition
scalar sumT = 0.0; //average temperature
scalar sumgradT = 0.0; //average temperature gradient

volScalarField gradT = mag(fvc::grad(T));
gradT.boundaryField()[patchID]=T.boundaryField()[patchID].snGrad();

forAll(cPatch, facei)
{
Area = magSf.boundaryField()[patchID][facei];
sumArea += magSf.boundaryField()[patchID][facei];
sumT += T.boundaryField()[patchID][facei]*Area;
sumgradT += gradT[facei]*Area;
}

Info << "Area " << sumArea << endl; //area of the boundary condition
Info << "Average T " << sumT/sumArea << endl; //average temperature
Info << "Average gradT " << sumgradT/sumArea << endl; //average temperature gradient

Last edited by isabel; September 1, 2011 at 15:44.
isabel is offline   Reply With Quote

Reply


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
[OpenFOAM] How to calculate a custom field rres ParaView 4 November 16, 2012 05:24
[Gmsh] 2D Mesh Generation Tutorial for GMSH aeroslacker OpenFOAM Meshing & Mesh Conversion 12 January 19, 2012 04:52
OpenFOAM 1.5.x package - CentOS 5.3 x86_64 linnemann OpenFOAM Installation 7 July 30, 2009 04:14
Missing math.h header Travis FLUENT 4 January 15, 2009 12:48
Testing of OpenFOAM 1.3alpha Commenced OpenFOAM discussion board administrator OpenFOAM Announcements from ESI-OpenCFD 0 February 7, 2006 08:31


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