RhoCentralFoam sampling mass flow rate over time
Hi everyone,
I am trying to sample the mass flow rate over time of a patch (inlet) during runtime. I am using OpenFOAM 4 and the solver rhoCentralFoam. I have found a couple of older threads but unfortunately the suggested solutions did not work for me. First I have tried to add to my controldict: Code:
functions Code:
Starting time loop postProcess -func 'flowRatePatch(name=inlet)' That didnt work aswell, because phi is missing. Ofc I could create an output for phi, but since I would like to calculate the mass flow rate of a patch during runtime, this wouldnt solve the problem, besides I write out many time steps. Does anyone know a solution? |
Hi,
Try using type surfaceRegion instead of surfaceFieldValue (the functions names tend to evolve from one version to another) Code:
inletMassFlow Let us know if it solves your problem! Yann |
Hi Yann,
thank you very much for your help! It works like a charm. :) It still takes a while until I can evaluate the results and see whether they are correct. I have another question about sum (phi): Phi is calculated with rho * U. With the function sum, is the integral calculated over the area, which is approximated as the sum, or do I have to multiply the result by the area? Kind regards, shock77 |
Hi Shock77,
Phi is the flux on each face of your patch. So sum(phi) is the total flux on the patch, there is no integration or area to take into account, you directly get the flowrate on the patch, either mass or volumetric flowrate depending on the solver. With rhoCentralFoam it should be the mass flow rate but you can verify it by checking the units in the phi files. Cheers, Yann |
Hi Yann,
thanks again, you are completely right! Phi is indeed rho*U*A for compressible solvers, U*A for incompressible, since the momentum equation is divided by rho. I have also found it in the rhoCentralFoam sourcecode of createFields.H: Code:
surfaceScalarField phi("phi", fvc::flux(rhoU)); Is there actually a way to get the mass flow rate in x-direction instead of the total mass flow rate? Ofc it is possible to code it, just asking if there is an easy way to do it. Kind regards, shock77 |
I'm not sure what you mean by "flow rate in x-direction" since, in my understanding, flow rate should be relative to the face normal.
Maybe you can manage to do it with function objects but I'm not sure how. You can still use the codedFunctionObject which is a convenient way to add a specific function and use it at runtime, but as you said you need to write the code to achieve what you want. I'm not sure this is very helpful though! Yann |
I thought since U is a vector, the total flow rate is calculated. It might be interesting to be able to divide the flow rate in the x,y and z components.
Do you mean, that only the normal component relative to the face is used? |
Thank you very much for the clarification and your kind help! :)
I got it now. |
Hey, I am doing the same case(sampling mass flow rate) on OpenFoam v11,
the contradict code is: Code:
inMassFlow But it seems this function is not available. moreover, only one valid function is shown to be available... Code:
--> FOAM FATAL ERROR: can anyone help me regarding this. |
I think its a simple naming issue. The name changed in the past various times, like surfaceFieldValue or surfaceRegion. I dont know how its names atm, since I wonly worked with OF up to OF 5, but you should find it in the source code.
Edit: From a quick search I think "sampledSurface" or "fieldValue" might be the types to look at. I hope it works! |
All times are GMT -4. The time now is 21:22. |