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

volumeIntegrate ?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By flowman

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 12, 2011, 12:28
Default volumeIntegrate ?
  #1
Senior Member
 
Join Date: Sep 2010
Posts: 226
Rep Power: 17
T.D. is on a distinguished road
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.
T.D. is offline   Reply With Quote

Old   September 1, 2011, 12:05
Default
  #2
Member
 
Join Date: Aug 2011
Posts: 33
Rep Power: 15
seboxx is on a distinguished road
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
seboxx is offline   Reply With Quote

Old   September 1, 2011, 14:21
Default
  #3
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: San Francisco, CA USA
Posts: 323
Rep Power: 18
kmooney is on a distinguished road
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];
        }
        }
kmooney is offline   Reply With Quote

Old   September 1, 2011, 20:43
Default
  #4
New Member
 
Aidan
Join Date: Apr 2010
Posts: 18
Rep Power: 16
flowman is on a distinguished road
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;
mm.abdollahzadeh and ashvinc9 like this.
flowman is offline   Reply With Quote

Old   September 5, 2011, 05:25
Default
  #5
Member
 
Join Date: Aug 2011
Posts: 33
Rep Power: 15
seboxx is on a distinguished road
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
seboxx is offline   Reply With Quote

Old   September 5, 2011, 07:27
Default
  #6
Member
 
Join Date: Aug 2011
Posts: 33
Rep Power: 15
seboxx is on a distinguished road
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;
All the best,

seboxx
seboxx 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



All times are GMT -4. The time now is 20:01.