|
[Sponsors] |
RhoCentralFoam sampling mass flow rate over time |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 13, 2020, 11:07 |
RhoCentralFoam sampling mass flow rate over time
|
#1 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
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 { inletMassFlow { type surfaceFieldValue; functionObjectLibs ("libfieldFunctionObjects.so"); enabled true; writeControl timeStep; writeInterval 100; log true; writeFields false; regionType patch; name inlet; operation sum; fields ( phi ); } } Code:
Starting time loop --> FOAM Warning : From function bool Foam::functionObjectList::read() in file db/functionObjects/functionObjectList/functionObjectList.C at line 671 Caught FatalError --> FOAM FATAL ERROR: Unknown function type surfaceFieldValue Valid functions are : 39 ( CourantNo Lambda2 MachNo PecletNo Q blendingFactor components div enstrophy fieldAverage fieldCoordinateSystemTransform fieldMinMax fieldValueDelta flowType grad histogram mag magSqr nearWallFields patchProbes pressure probes processorField psiReactionThermoMoleFractions randomise readFields regionSizeDistribution rhoReactionThermoMoleFractions sets streamLine surfaceInterpolate surfaceRegion surfaces turbulenceFields volRegion vorticity wallBoundedStreamLine wallShearStress yPlus ) From function static Foam::autoPtr<Foam::functionObject> Foam::functionObject::New(const Foam::word&, const Foam::Time&, const Foam::dictionary&) in file db/functionObjects/functionObject/functionObject.C at line 100. 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? |
|
October 13, 2020, 12:22 |
|
#2 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,238
Rep Power: 29 |
Hi,
Try using type surfaceRegion instead of surfaceFieldValue (the functions names tend to evolve from one version to another) Code:
inletMassFlow { type surfaceRegion; functionObjectLibs ("libfieldFunctionObjects.so"); enabled true; writeControl timeStep; writeInterval 100; log true; writeFields false; regionType patch; name inlet; operation sum; fields ( phi ); } Let us know if it solves your problem! Yann |
|
October 14, 2020, 06:01 |
|
#3 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
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 |
|
October 14, 2020, 06:38 |
|
#4 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,238
Rep Power: 29 |
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 |
|
October 14, 2020, 08:03 |
|
#5 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
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)); Info<< "Creating turbulence model\n" << endl; autoPtr<compressible::turbulenceModel> turbulence ( compressible::turbulenceModel::New ( rho, U, phi, thermo ) ); 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 |
|
October 14, 2020, 10:18 |
|
#6 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,238
Rep Power: 29 |
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 |
|
October 14, 2020, 10:47 |
|
#7 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
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? |
|
October 14, 2020, 11:26 |
|
#8 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,238
Rep Power: 29 |
Here is the expression of flow rate:
With Where the n is a unit vector normal to the surface. So the flow rate is already the quantity of fluid passing through a surface. And it's a scalar quantity, not a vector. So yes, only the normal component relative to the surface is used to get the flow rate. Regards, Yann |
|
October 14, 2020, 11:43 |
|
#9 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
Thank you very much for the clarification and your kind help!
I got it now. |
|
October 25, 2023, 09:08 |
|
#10 |
New Member
Ashish Kumar
Join Date: Oct 2023
Posts: 1
Rep Power: 0 |
Hey, I am doing the same case(sampling mass flow rate) on OpenFoam v11,
the contradict code is: Code:
inMassFlow { type surface; functionObjectLibs ("libfieldFunctionObjects.so"); enabled true; // writeControl outputTime; writeControl timeStep; writeInterval 1; log true; writeFields false; regionType patch; name in; operation sum; fields ( phi ); } But it seems this function is not available. moreover, only one valid function is shown to be available... Code:
--> FOAM FATAL ERROR: Unknown function type surface Valid functions are : 1(fvModel) From function static Foam::autoPtr<Foam::functionObject> Foam::functionObject::New(const Foam::word&, const Foam::Time&, const Foam::dictionary&) in file db/functionObjects/functionObject/functionObject.C at line 108. FOAM exiting can anyone help me regarding this. |
|
October 25, 2023, 09:19 |
|
#11 |
Senior Member
Join Date: Dec 2019
Posts: 215
Rep Power: 8 |
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! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
bash script for pseudo-parallel usage of reconstructPar | kwardle | OpenFOAM Post-Processing | 42 | May 8, 2024 00:17 |
AMI speed performance | danny123 | OpenFOAM | 21 | October 24, 2020 05:13 |
Match Pressure Inlet/Outlet Boundary Condition Mass Flow Rate | MSchneid | Fluent UDF and Scheme Programming | 3 | February 23, 2019 07:00 |
How to write k and epsilon before the abnormal end | xiuying | OpenFOAM Running, Solving & CFD | 8 | August 27, 2013 16:33 |
IcoFoam parallel woes | msrinath80 | OpenFOAM Running, Solving & CFD | 9 | July 22, 2007 03:58 |