help:How to get mass integral axial Velocity & momentum
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 |
partial solution
Hi, you can compute the cell volume with OF introducing in the solver code a piece like this
Code:
forAll(mesh.cells(), cellii) Code:
volScalarField cellVolume Then you can proceed with integrateVariables i guess Emanuele |
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 |
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"); Code:
forAll(mesh.cells(), celli) Code:
dimensionedScalar Q |
Really Thanks a lot Emanuele,
I'll try it and i'll keep you informed. Thanks again!! |
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 |
text file
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 |
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 |
recompile the solver
In createFields.H put these lines at the top
Code:
dimensionedScalar Q |
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. |
adding lines
Add these lines before the int main on solver .C file:
Code:
#include "OFstream.H" Code:
mesh.V()[cellii] Code:
mesh.V()[celli] Emanuele |
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 |
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. |
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 |
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. |
Hi santiagomarquezd,
Is it the same for an axisymetric geometry? |
Problem solved
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. |
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 |
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. |
Just out of interest, wouldn't
Code:
scalar Q = fvc::domainIntegrate(rho*U_x).value(); |
All times are GMT -4. The time now is 12:14. |