|
[Sponsors] |
April 12, 2011, 12:28 |
volumeIntegrate ?
|
#1 |
Senior Member
Join Date: Sep 2010
Posts: 226
Rep Power: 17 |
Hi Foamers,
any ideas how to code the volumeIntegrate function inside the solver, in order to get the volume integral on a group of cells, let's say for example "a sphere" inside the mesh ? thanks, T.D. |
|
September 1, 2011, 12:05 |
|
#2 |
Member
Join Date: Aug 2011
Posts: 33
Rep Power: 15 |
Hi T.D.
have you had any success on this one? I am facing a pretty similiar question right now. Can post my results once I have achieved something... was just wondering whether you got it already. Cheers, seboxx |
|
September 1, 2011, 14:21 |
|
#3 |
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18 |
I've written a pre-Processing app that initializes a spherical vof field. I'm thinking you could do something like this:
Code:
volVectorField positions ( IOobject ( "positions", runTime.timeName(), mesh, IOobject::NO_READ ), mesh.C() ); volScalarField myScalarValueToIntegrate = 0; scalar integratedValue = 0; forAll(positions, cellI) { if(mag(positions[cellI].x()*positions[cellI].x() + positions[cellI].y()*positions[cellI].y() + positions[cellI].z()*positions[cellI].z() < someRadius)) { integratedValue += myScalarValueToIntegrate[cellI]; } } |
|
September 1, 2011, 20:43 |
|
#4 |
New Member
Aidan
Join Date: Apr 2010
Posts: 18
Rep Power: 16 |
The OpenFOAM library provides a function to compute integrals over the domain: fvc::domainIntegrate.
To integrate a scalar solution variable (volScalarField) p over the domain and write the answer to the standard output, add the following line to the solver source code. Code:
Info<< nl << "Integral of p: " << fvc::domainIntegrate(p).value () << endl; |
|
September 5, 2011, 05:25 |
|
#5 |
Member
Join Date: Aug 2011
Posts: 33
Rep Power: 15 |
Hi there,
thank you for the comments. I know that domainIntegrate works, but what if my problem is a little more complex. Like, I wanna calculate an Integral of the Heaviside function over the domain. I thought I can do a simple if(mag(u)>0) then add the volume of the cell that I am currently in. But I am not quite sure how to get that to work. My volScalarField is named u, and so far I can't access the magnitude of u, I simply don't know how to address it... Then my idea was to do a for-loop over the whole domain, with the if condition check whether u is above a certain threshold, and when that is the case just add the volume over all those cells where the threshold condition is fulfilled. How to I get the volume of that cell I am working with? Any comment is greatly appreciated. seboxx |
|
September 5, 2011, 07:27 |
|
#6 |
Member
Join Date: Aug 2011
Posts: 33
Rep Power: 15 |
Oh it's actually not complex at all, after the hint of flowman at least
All I did is something like: Code:
Info<< nl << "Integral of p: " << fvc::domainIntegrate(pos(p-1e-6)).value () << endl; seboxx |
|
|
|