CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   How to calculate double integration in OpenFOAM (https://www.cfd-online.com/Forums/openfoam/82917-how-calculate-double-integration-openfoam.html)

nandiganavishal December 9, 2010 01:18

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

brosemu December 9, 2010 08:15

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

nandiganavishal December 9, 2010 11:52

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

brosemu December 9, 2010 13:38

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

nandiganavishal December 9, 2010 13:57

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

isabel September 1, 2011 06:41

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

isabel September 1, 2011 10:27

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?

Bernhard September 1, 2011 11:01

Maybe this piece of code may be helpfull?

http://foam.sourceforge.net/docs/cpp/a03267_source.html

isabel September 1, 2011 14:10

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 15:22.