|
[Sponsors] |
How to calculate double integration in OpenFOAM |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 9, 2010, 02:18 |
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 |
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 |
|
December 9, 2010, 09:15 |
|
#2 |
New Member
Bill Rosemurgy
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 20
Rep Power: 17 |
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 |
|
December 9, 2010, 12:52 |
|
#3 |
Senior Member
Vishal Nandigana
Join Date: Mar 2009
Location: Champaign, Illinois, U.S.A
Posts: 208
Rep Power: 18 |
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 |
|
December 9, 2010, 14:38 |
|
#4 |
New Member
Bill Rosemurgy
Join Date: Mar 2009
Location: Ann Arbor, MI
Posts: 20
Rep Power: 17 |
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 |
|
December 9, 2010, 14:57 |
|
#5 |
Senior Member
Vishal Nandigana
Join Date: Mar 2009
Location: Champaign, Illinois, U.S.A
Posts: 208
Rep Power: 18 |
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 |
|
September 1, 2011, 07:41 |
|
#6 |
Senior Member
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17 |
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. |
|
September 1, 2011, 11:27 |
|
#7 |
Senior Member
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17 |
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? |
|
September 1, 2011, 12:01 |
|
#8 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
||
September 1, 2011, 15:10 |
|
#9 |
Senior Member
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17 |
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. |
|
|
|
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 |