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

help:How to get mass integral axial Velocity & momentum

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By benk

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 3, 2010, 08:04
Unhappy help:How to get mass integral axial Velocity & momentum
  #1
Member
 
Alex
Join Date: Mar 2010
Posts: 33
Rep Power: 16
bruxellois is on a distinguished road
Dear Foamers,

I'm working with openFoam (sonicFoam solver), i'm interesting to calculate and plot the equivalent to ''mass integral axial velocity" in respect to this formula:

Q=∫rho U_x dV=∑ rho .U_x.V_cell

(V_cell= cell volume)

How can i calculate Q either with paraview (calculator, integratevariables filters?) Or with OpenFOAM.

Any idea please.

Any suggestions will be appreciated.

Best regards
bruxellois is offline   Reply With Quote

Old   October 4, 2010, 07:03
Default partial solution
  #2
Senior Member
 
Emanuele
Join Date: Mar 2009
Posts: 110
Rep Power: 17
nuovodna is on a distinguished road
Hi, you can compute the cell volume with OF introducing in the solver code a piece like this


Code:
	forAll(mesh.cells(), cellii)
        {   	
             cellVolume = mesh.V()[cellii];
	}
And in createFields.H file

Code:
    volScalarField cellVolume
    (
        IOobject
        (
            "PecletX",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        mesh,
	 dimensionedScalar("cellVolume", dimensionSet(0,3,0,0,0,0,0),1)
    );
These parts will be necessary to print a new variable named "cellVariable" ready to be read from paraFoam.
Then you can proceed with integrateVariables i guess


Emanuele
nuovodna is offline   Reply With Quote

Old   October 4, 2010, 07:22
Default
  #3
Member
 
Alex
Join Date: Mar 2010
Posts: 33
Rep Power: 16
bruxellois is on a distinguished road
Hi Emanuele,

Many thanks to you response.

Could you please explain the intergrate filter is it a volume integration? i have to multiply the result by the volume, the number of cells or no?


Best regards
bruxellois is offline   Reply With Quote

Old   October 4, 2010, 07:37
Default
  #4
Senior Member
 
Emanuele
Join Date: Mar 2009
Posts: 110
Rep Power: 17
nuovodna is on a distinguished road
Hi, you can bypass paraview in this way

Add this line in .C solver before the
Code:
while (runTime.run())
:

Code:
     OFstream massIntegral("massIntegral.dat");
Then in runTime loop put this line:


Code:
        forAll(mesh.cells(), celli)
	{
		Q+= rho * U[celli] * mesh.V()[cellii]; // i m not sure U = Ux it should be something like this: U.component(0)[celli]
       }

        massIntegral << runTime.timeName() << " "<< Q.value() << endl;
define Q in createFields.H

Code:
    dimensionedScalar Q
    (
        "Q",
        dimensionSet(1,-3,0,0,0),   // adjust the dimension here!!!
        0.0
    );
Forgot the previous post
nuovodna is offline   Reply With Quote

Old   October 4, 2010, 07:44
Default
  #5
Member
 
Alex
Join Date: Mar 2010
Posts: 33
Rep Power: 16
bruxellois is on a distinguished road
Really Thanks a lot Emanuele,

I'll try it and i'll keep you informed.

Thanks again!!
bruxellois is offline   Reply With Quote

Old   October 4, 2010, 09:04
Default
  #6
Member
 
Alex
Join Date: Mar 2010
Posts: 33
Rep Power: 16
bruxellois is on a distinguished road
Hi Emanuele,

I did what you said step by step but i don't receive any information about my new field Q.

Any idea?

Best regards
bruxellois is offline   Reply With Quote

Old   October 4, 2010, 09:21
Default text file
  #7
Senior Member
 
Emanuele
Join Date: Mar 2009
Posts: 110
Rep Power: 17
nuovodna is on a distinguished road
The solver should have written a file named massIntegral.dat in your case directory. The file contains the values of Q at corresponding values of time

Regards

Emanuele
nuovodna is offline   Reply With Quote

Old   October 4, 2010, 09:29
Default
  #8
Member
 
Alex
Join Date: Mar 2010
Posts: 33
Rep Power: 16
bruxellois is on a distinguished road
I didn't find massIntegral.dat,

i have to put this evrywhere (arbitrary location) in runTime loop ??


forAll(mesh.cells(), celli)
{
Q+= rho * U[celli] * mesh.V()[cellii]; // i m not sure U = Ux it should be something like this: U.component(0)[celli]
}

massIntegral << runTime.timeName() << " "<< Q.value() << endl;


The same for createFields.H ( i put the new lines in a arbitrary location)??


I have to recompile the solver with wmake??


Regards
bruxellois is offline   Reply With Quote

Old   October 4, 2010, 09:34
Default recompile the solver
  #9
Senior Member
 
Emanuele
Join Date: Mar 2009
Posts: 110
Rep Power: 17
nuovodna is on a distinguished road
In createFields.H put these lines at the top

Code:
    dimensionedScalar Q
    (
        "Q",
        dimensionSet(1,-3,0,0,0),   // adjust the dimension here!!!
        0.0
    );
Then you have to recompile the solver. Sorry i missed you to say that previously
nuovodna is offline   Reply With Quote

Old   October 4, 2010, 09:41
Default
  #10
Member
 
Alex
Join Date: Mar 2010
Posts: 33
Rep Power: 16
bruxellois is on a distinguished road
Thanks a lot for your quick response!!

I've put these lines at the top of createFields.H but i receive errors


:~/OpenFOAM/OpenFOAM-1.6/applications/solvers/compressible/sonicFoam$ wmake
Making dependency list for source file sonicFoam.C
SOURCE=sonicFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/home/moumen/OpenFOAM/OpenFOAM-1.6/src/thermophysicalModels/basic/lnInclude -I/home/moumen/OpenFOAM/OpenFOAM-1.6/src/turbulenceModels/compressible/turbulenceModel -I/home/moumen/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/moumen/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude -I/home/moumen/OpenFOAM/OpenFOAM-1.6/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/sonicFoam.o
sonicFoam.C: In function ‘int main(int, char**)’:
sonicFoam.C:51: error: ‘OFstream’ was not declared in this scope
sonicFoam.C:51: error: ‘massIntegral’ was not declared in this scope
sonicFoam.C:85: error: ‘cellii’ was not declared in this scope
/home/moumen/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readPISOControls.H:8: warning: unused variable ‘momentumPredictor’
/home/moumen/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readPISOControls.H:11: warning: unused variable ‘transonic’
/home/moumen/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readPISOControls.H:14: warning: unused variable ‘nOuterCorr’
make: *** [Make/linux64GccDPOpt/sonicFoam.o] Error 1


Regards.
bruxellois is offline   Reply With Quote

Old   October 4, 2010, 09:55
Default adding lines
  #11
Senior Member
 
Emanuele
Join Date: Mar 2009
Posts: 110
Rep Power: 17
nuovodna is on a distinguished road
Add these lines before the int main on solver .C file:

Code:
#include "OFstream.H"
#include <fstream>
#include <sstream>
#include <string>
and modify the

Code:
mesh.V()[cellii]
to

Code:
mesh.V()[celli]
Bye
Emanuele
nuovodna is offline   Reply With Quote

Old   October 4, 2010, 10:03
Default
  #12
Member
 
Alex
Join Date: Mar 2010
Posts: 33
Rep Power: 16
bruxellois is on a distinguished road
I'm sorry but i'm receiving errors



Making dependency list for source file sonicFoam.C
SOURCE=sonicFoam.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/home/moumen/OpenFOAM/OpenFOAM-1.6/src/thermophysicalModels/basic/lnInclude -I/home/moumen/OpenFOAM/OpenFOAM-1.6/src/turbulenceModels/compressible/turbulenceModel -I/home/moumen/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/moumen/OpenFOAM/OpenFOAM-1.6/src/OpenFOAM/lnInclude -I/home/moumen/OpenFOAM/OpenFOAM-1.6/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/sonicFoam.o
sonicFoam.C: In function ‘int main(int, char**)’:
sonicFoam.C:89: error: no match for ‘operator[]’ in ‘Foam::GeometricField<Type, PatchField, GeoMesh>::component(Foam::direction) const [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](0)[celli]’
/home/moumen/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readPISOControls.H:8: warning: unused variable ‘momentumPredictor’
/home/moumen/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readPISOControls.H:11: warning: unused variable ‘transonic’
/home/moumen/OpenFOAM/OpenFOAM-1.6/src/finiteVolume/lnInclude/readPISOControls.H:14: warning: unused variable ‘nOuterCorr’
make: *** [Make/linux64GccDPOpt/sonicFoam.o] Error 1
bruxellois is offline   Reply With Quote

Old   October 4, 2010, 10:06
Default
  #13
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 452
Rep Power: 23
santiagomarquezd will become famous soon enough
Alex, you can do it using Paraview. The first step is to use the Calculator filter to create the field rho*U_0, then apply the Integrate Variables filter in order to integrate this new variable in the whole domain.

Regards.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Research Scientist
Research Center for Computational Methods (CIMEC) - CONICET/UNL
Tel: 54-342-4511594 Int. 7032
Colectora Ruta Nac. 168 / Paraje El Pozo
(3000) Santa Fe - Argentina.
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Old   October 4, 2010, 10:12
Default
  #14
Member
 
Alex
Join Date: Mar 2010
Posts: 33
Rep Power: 16
bruxellois is on a distinguished road
Hi santiagomarquezd,

I did that with paraview but the result i had dont correspond for what i had with fluent, it seems tha i have to multiply it with a factor (volume, cell numbers??)

Also the integrate filter gives me one line, so i can say that's the integration of the whole domain but i'm confused it indicates cell ID 0, is it an integration for one cell volume or what?

Best regards
bruxellois is offline   Reply With Quote

Old   October 4, 2010, 13:46
Default
  #15
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 452
Rep Power: 23
santiagomarquezd will become famous soon enough
Alex, I checked the integration with a case and it seems to be OK. The line that it is shown reports the whole integral values. Maybe you could check it with a simple case, like a square cavity with given rho and U and then check the results.

Best.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Research Scientist
Research Center for Computational Methods (CIMEC) - CONICET/UNL
Tel: 54-342-4511594 Int. 7032
Colectora Ruta Nac. 168 / Paraje El Pozo
(3000) Santa Fe - Argentina.
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Old   October 4, 2010, 14:47
Default
  #16
Member
 
Alex
Join Date: Mar 2010
Posts: 33
Rep Power: 16
bruxellois is on a distinguished road
Hi santiagomarquezd,

Is it the same for an axisymetric geometry?
bruxellois is offline   Reply With Quote

Old   October 7, 2010, 08:30
Thumbs up Problem solved
  #17
Member
 
Alex
Join Date: Mar 2010
Posts: 33
Rep Power: 16
bruxellois is on a distinguished road
Just in case someone's having the same problem and is using the search-function, here's the solution:

Paraview may calculate the momentum :The first step is to use the Calculator filter to create the field then apply the Integrate Variables filter in order to integrate this new variable in the whole domain. But fo axisymetric geometry you have to multiply results by this factor (real Volume/axisymetric volume).

Best regards.
bruxellois is offline   Reply With Quote

Old   October 8, 2010, 00:41
Default
  #18
Member
 
Daniel
Join Date: Jul 2010
Location: California
Posts: 39
Rep Power: 15
hyperion is on a distinguished road
Hi Alex - I think I am trying to do something similar to what you were doing and I was hoping you might be able to explain how to do it. The solver I am using, dsmcFOAM, outputs mass density and number density (# of molecules per m^3). I was wondering if there was a way in paraFoam to output the number of molecules per cell. Thank you for any and all help.

Thanks
hyperion is offline   Reply With Quote

Old   October 8, 2010, 06:57
Default
  #19
Member
 
Alex
Join Date: Mar 2010
Posts: 33
Rep Power: 16
bruxellois is on a distinguished road
Hi hyperion,

I have any experience with dsmcFOAM but since uou have number density (# of molecules per m^3) you have to integrate (i.e paraview filter) it to obtain # of molecules in yous domaine.
bruxellois is offline   Reply With Quote

Old   October 8, 2010, 11:36
Default
  #20
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
Just out of interest, wouldn't

Code:
scalar Q = fvc::domainIntegrate(rho*U_x).value();
accomplish Q=∫rho U_x dV=∑ rho .U_x.V_cell ? ( where U_x would probably be something like U.component(0) )
mm.abdollahzadeh likes this.
benk is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wind turbine simulation Saturn CFX 58 July 3, 2020 02:13
mass flow in is not equal to mass flow out saii CFX 12 March 19, 2018 06:21
How to define a mass source at a velocity inlet ? cfdiscool FLUENT 4 June 26, 2014 04:00
Periodicity momentum instead of axial momentum omez CFX 1 August 3, 2009 19:59
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 10:11


All times are GMT -4. The time now is 14:05.