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

RhoCentralFoam sampling mass flow rate over time

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

Like Tree5Likes
  • 1 Post By Yann
  • 1 Post By shock77
  • 1 Post By Yann
  • 1 Post By Yann
  • 1 Post By shock77

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 13, 2020, 11:07
Default RhoCentralFoam sampling mass flow rate over time
  #1
Senior Member
 
Join Date: Dec 2019
Posts: 215
Rep Power: 7
shock77 is on a distinguished road
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
        );
   }
    

}
But it seems this function is not available in OpenFOAM 4, I get:


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.
I have also tried the postProcessing utility:


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?
shock77 is offline   Reply With Quote

Old   October 13, 2020, 12:22
Default
  #2
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,026
Rep Power: 25
Yann will become famous soon enough
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
shock77 likes this.
Yann is offline   Reply With Quote

Old   October 14, 2020, 06:01
Default
  #3
Senior Member
 
Join Date: Dec 2019
Posts: 215
Rep Power: 7
shock77 is on a distinguished road
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
Yann likes this.
shock77 is offline   Reply With Quote

Old   October 14, 2020, 06:38
Default
  #4
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,026
Rep Power: 25
Yann will become famous soon enough
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
shock77 likes this.
Yann is offline   Reply With Quote

Old   October 14, 2020, 08:03
Default
  #5
Senior Member
 
Join Date: Dec 2019
Posts: 215
Rep Power: 7
shock77 is on a distinguished road
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
shock77 is offline   Reply With Quote

Old   October 14, 2020, 10:18
Default
  #6
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,026
Rep Power: 25
Yann will become famous soon enough
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
Yann is offline   Reply With Quote

Old   October 14, 2020, 10:47
Default
  #7
Senior Member
 
Join Date: Dec 2019
Posts: 215
Rep Power: 7
shock77 is on a distinguished road
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?
shock77 is offline   Reply With Quote

Old   October 14, 2020, 11:26
Default
  #8
Senior Member
 
Yann
Join Date: Apr 2012
Location: France
Posts: 1,026
Rep Power: 25
Yann will become famous soon enough
Here is the expression of flow rate:

\dot{m}= \int\int_{S} \rho \vec{U} \vec{dS}

With

\vec{S}=S.\vec{n}

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
shock77 likes this.
Yann is offline   Reply With Quote

Old   October 14, 2020, 11:43
Default
  #9
Senior Member
 
Join Date: Dec 2019
Posts: 215
Rep Power: 7
shock77 is on a distinguished road
Thank you very much for the clarification and your kind help!


I got it now.
Yann likes this.
shock77 is offline   Reply With Quote

Old   October 25, 2023, 09:08
Default
  #10
New Member
 
Ashish Kumar
Join Date: Oct 2023
Posts: 1
Rep Power: 0
Ashish_KG is on a distinguished road
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
which is not working anyway.

can anyone help me regarding this.
Ashish_KG is offline   Reply With Quote

Old   October 25, 2023, 09:19
Default
  #11
Senior Member
 
Join Date: Dec 2019
Posts: 215
Rep Power: 7
shock77 is on a distinguished road
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!
shock77 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
bash script for pseudo-parallel usage of reconstructPar kwardle OpenFOAM Post-Processing 41 August 23, 2023 03:48
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


All times are GMT -4. The time now is 09:23.