How to calculate double integration in OpenFOAM
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 
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 1D integration function that you mentioned?  Bill 
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 1D is integratevariable function in paraview. Thanks Vishal Nandigana 
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 ifstatements 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 
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 
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 
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? 

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 
All times are GMT 4. The time now is 22:48. 