# help:How to get mass integral axial Velocity & momentum

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

 October 3, 2010, 07:04 help:How to get mass integral axial Velocity & momentum #1 Member   Alex Join Date: Mar 2010 Posts: 33 Rep Power: 8 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

 October 4, 2010, 06:03 partial solution #2 Senior Member   Emanuele Join Date: Mar 2009 Posts: 110 Rep Power: 9 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

 October 4, 2010, 06:22 #3 Member   Alex Join Date: Mar 2010 Posts: 33 Rep Power: 8 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

 October 4, 2010, 06:37 #4 Senior Member   Emanuele Join Date: Mar 2009 Posts: 110 Rep Power: 9 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

 October 4, 2010, 06:44 #5 Member   Alex Join Date: Mar 2010 Posts: 33 Rep Power: 8 Really Thanks a lot Emanuele, I'll try it and i'll keep you informed. Thanks again!!

 October 4, 2010, 08:04 #6 Member   Alex Join Date: Mar 2010 Posts: 33 Rep Power: 8 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

 October 4, 2010, 08:21 text file #7 Senior Member   Emanuele Join Date: Mar 2009 Posts: 110 Rep Power: 9 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

 October 4, 2010, 08:29 #8 Member   Alex Join Date: Mar 2010 Posts: 33 Rep Power: 8 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

 October 4, 2010, 08:34 recompile the solver #9 Senior Member   Emanuele Join Date: Mar 2009 Posts: 110 Rep Power: 9 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

 October 4, 2010, 08:41 #10 Member   Alex Join Date: Mar 2010 Posts: 33 Rep Power: 8 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.

 October 4, 2010, 08:55 adding lines #11 Senior Member   Emanuele Join Date: Mar 2009 Posts: 110 Rep Power: 9 Add these lines before the int main on solver .C file: Code: ```#include "OFstream.H" #include #include #include ``` and modify the Code: `mesh.V()[cellii]` to Code: `mesh.V()[celli]` Bye Emanuele

 October 4, 2010, 09:03 #12 Member   Alex Join Date: Mar 2010 Posts: 33 Rep Power: 8 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::component(Foam::direction) const [with Type = Foam::Vector, 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

 October 4, 2010, 09:06 #13 Senior Member     Santiago Marquez Damian Join Date: Aug 2009 Location: Santa Fe, Santa Fe, Argentina Posts: 430 Rep Power: 16 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

 October 4, 2010, 09:12 #14 Member   Alex Join Date: Mar 2010 Posts: 33 Rep Power: 8 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

 October 4, 2010, 12:46 #15 Senior Member     Santiago Marquez Damian Join Date: Aug 2009 Location: Santa Fe, Santa Fe, Argentina Posts: 430 Rep Power: 16 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

 October 4, 2010, 13:47 #16 Member   Alex Join Date: Mar 2010 Posts: 33 Rep Power: 8 Hi santiagomarquezd, Is it the same for an axisymetric geometry?

 October 7, 2010, 07:30 Problem solved #17 Member   Alex Join Date: Mar 2010 Posts: 33 Rep Power: 8 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.

 October 7, 2010, 23:41 #18 Member   Daniel Join Date: Jul 2010 Location: California Posts: 39 Rep Power: 8 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

 October 8, 2010, 05:57 #19 Member   Alex Join Date: Mar 2010 Posts: 33 Rep Power: 8 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.

 October 8, 2010, 10:36 #20 Senior Member   Ben K Join Date: Feb 2010 Location: Ottawa, Canada Posts: 140 Rep Power: 11 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.

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Saturn CFX 45 February 8, 2016 05:42 cfdiscool FLUENT 4 June 26, 2014 03:00 saii CFX 2 September 18, 2009 08:07 omez CFX 1 August 3, 2009 18:59 Abhi Main CFD Forum 12 July 8, 2002 09:11

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