CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (https://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   is there a post processing keyword for obtaining mass flow rate and total mass? (https://www.cfd-online.com/Forums/openfoam-post-processing/115525-there-post-processing-keyword-obtaining-mass-flow-rate-total-mass.html)

immortality April 1, 2013 17:07

is there a post processing keyword for obtaining mass flow rate and total mass?
 
I was searching about a function to calculate mass flow rate during the run.now i need to calculate mass flow rate and also total mass entering in or exiting from a patch after the end of run.does anyone know the related keyword or way to do this?

sharonyue April 1, 2013 23:06

Quote:

Originally Posted by immortality (Post 417682)
I was searching about a function to calculate mass flow rate during the run.now i need to calculate mass flow rate and also total mass entering in or exiting from a patch after the end of run.does anyone know the related keyword or way to do this?


Hi,

Try this code from Mr.Prasant

Code:

functions
{
    massflow
    {
        type            faceSource;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled        true;
        outputControl    timeStep;
        log            true;
        valueOutput    false;
        source          patch;
        sourceName      yourpatchname;
        operation      sum;

        fields
        (
            phi
        );
    }
}

Regards,

immortality April 2, 2013 00:15

thank you.then type massflow in the terminal?

sharonyue April 2, 2013 02:35

Quote:

Originally Posted by immortality (Post 417732)
thank you.then type massflow in the terminal?

Nope,just add this in controlDict, and see what happens in the terminal.

Regards,

immortality April 2, 2013 05:27

i think this add mass flow rates in new time folders.is there a way to calculating it after the run has done?like keywords Mach,Pe,vorticity,etc in postProcessing?

immortality April 2, 2013 08:57

can write phi in previous time folders?

sharonyue April 2, 2013 08:59

Quote:

Originally Posted by immortality (Post 417777)
i think this add mass flow rates in new time folders.is there a way to calculating it after the run has done?like keywords Mach,Pe,vorticity,etc in postProcessing?

I am not sure for that,if you know just let me know.Thanks

Regards,

immortality April 2, 2013 09:08

do you know what does valueOutput mean and why is set to false?

sharonyue April 2, 2013 19:29

Quote:

Originally Posted by immortality (Post 417842)
do you know what does valueOutput mean and why is set to false?

Sorry,I forget that,but you can alter that and see what happens.

Regards,

immortality April 3, 2013 04:05

how to obtain mass balance after run?
 
i want a code that can calculate net mass on patches(add mass inflow and outflow on patches) preferably in a time period.

Bernhard April 3, 2013 06:31

Check out the patchAverage and patchIntegrate utilities. They should be able to do what you need.

immortality April 3, 2013 09:44

how can move this thread to post processing forum to get more helps and answers?

immortality April 3, 2013 16:48

patchAverage and patchIntegrate doesn't work on surfaceScalarFields.
any idea?
thanks.

immortality April 3, 2013 17:04

whats the command for calculating mass flow?
 
I was searching about a function to calculate mass flow rate during the run.now i need to calculate mass flow rate and also total mass entering in or exiting from a patch after the end of run.does anyone know the related keyword or way to do this?

wyldckat April 3, 2013 19:19

Greetings to all,

I've moved this thread to the post-processing forum. And to quote my answer from a few minutes ago on another thread:
Quote:

Originally Posted by wyldckat (Post 418191)
For calculating mass flow, the following has been around for several years now: http://openfoamwiki.net/index.php/Contrib_calcMassFlow

Best regards,
Bruno

PS: also moved a few other related posts/threads started by Ehsan...

immortality April 4, 2013 08:02

thank you dear Bruno for moving!
the thread gives this error in compiling as I put in Cp thread for more convenience of readers:
Code:

ehsan@Ehsan-com:~/Desktop/calcMassFlow$ wmake
Making dependency list for source file calcMassFlow.C
could not open file fvCFD.H for source file calcMassFlow.C
could not open file FaceSetUtilities.H for source file calcMassFlow.C
SOURCE=calcMassFlow.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/cfdTools/lnInclude -I/opt/openfoam220/src/cfdTools/general/lnInclude          -I/opt/openfoam220/src/meshTools/lnInclude          -I/home/ehsan/OpenFOAM/ehsan-2.2.0/Libraries/cellFaceSetUtilities/lnInclude -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude  -fPIC -c $SOURCE -o Make/linux64GccDPOpt/calcMassFlow.o
calcMassFlow.C:33:19: fatal error: fvCFD.H: No such file or directory
compilation terminated.
make: *** [Make/linux64GccDPOpt/calcMassFlow.o] Error 1

could you please help to modify it too?
if mass flow trouble resolves almost my work can be finished successfully.

immortality April 4, 2013 17:54

is it possible to use a mass flow rate and/or summation of mass on patches during an interval code for compiling?

wyldckat April 6, 2013 07:51

2 Attachment(s)
Hi Ehsan,

Just a little pointer before continuing to the issue with calcMassFlow - simpleFunctionObjects can easily be used for calculating the mass flow during run: http://www.cfd-online.com/Forums/ope...tml#post418739 - although I vaguely remember you writing somewhere about how you need to calculate it after the solver had already been executed.

So, moving onto the adaptation of calcMassFlow to OpenFOAM 2.2:
  • Attached is the adaptation I've quickly made, based on the following sources:
  • After unpacking it, go into the unpacked folder and run:
    Code:

    wmake
  • An example of a "system/calcMassFlowDict" is as follows:
    Code:

    /*--------------------------------*- C++ -*----------------------------------*\
    | =========                |                                                |
    | \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
    |  \\    /  O peration    | Version:  2.2.x                                |
    |  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
    |    \\/    M anipulation  |                                                |
    \*---------------------------------------------------------------------------*/
    FoamFile
    {
        version    2.0;
        format      ascii;
        class      dictionary;
        location    "system";
        object      calcMassFlowDict;
    }
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    bcs
    (
    left 
    right
    );

    //Example for setting rho - uncomment the next line
    //rho rho [ 1 -3 0 0 0 0 0 ] 1.0;

WARNING: I have not thoroughly tested this... I've only made a quick adaptation of the code. Therefore, I advise you to use funkyDoCalc, as addressed on the other thread: http://www.cfd-online.com/Forums/ope...uring-run.html

_________________________
Edit: as per requested, I've managed to create a variant that writes to file instead of the standard output. Based on the instructions above, here's the ones for calcMassFlow2File to OpenFOAM 2.2:
  • After unpacking it, go into the unpacked folder and run:
    Code:

    wmake
  • An example of a "system/calcMassFlowDict" is as follows:
    Code:

    /*--------------------------------*- C++ -*----------------------------------*\
    | =========                |                                                |
    | \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
    |  \\    /  O peration    | Version:  2.2.x                                |
    |  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
    |    \\/    M anipulation  |                                                |
    \*---------------------------------------------------------------------------*/
    FoamFile
    {
        version    2.0;
        format      ascii;
        class      dictionary;
        location    "system";
        object      calcMassFlowDict;
    }
    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    bcs
    (
    left 
    right
    );

    //Output file name
    outputFileName "inlet_outlet.log";

    //option for outputting with no units
    outputWithoutUnits yes;

    //Example for setting rho - uncomment the next line
    //rho rho [ 1 -3 0 0 0 0 0 ] 1.0;

  • The new keyword "outputFileName" is for defining the file where the values are saved.
  • The other new keyword "outputWithoutUnits" is for choosing whether the units should be present inside the file or not, but just for the mass flow values.
  • The application name is calcMassFlow2File.

Best regards,
Bruno

immortality April 6, 2013 09:47

Thank you dear Bruno.it works.i put the results in a log file.
is it possible that all left flow rate values be writed separately and after ending of left values right values be writed too.
like:
left:
time0 value0
time1 value1
time2 value2
.
.
.
right:
time0 value0
time1 value1
time2 value2

immortality April 9, 2013 05:51

could you please do some modifications in very useful (i think the sole)post processing tool for calculating mass flow rate to write in a file with a good order?then it will be a complete nice tool for anyone to refer to(and specially for me ;) )

wyldckat April 10, 2013 16:47

I'll try to look into it this weekend.

immortality April 12, 2013 13:30

dear Bruno its the begining of weekend in your place!:D
please see how can modifying calcMassFlow.thanks.

wyldckat April 14, 2013 06:48

FYI: I've updated the post #18: http://www.cfd-online.com/Forums/ope...tml#post418748

immortality April 14, 2013 07:14

thank you so much dear Bruno.
I'll test it a tell you.
Why rho is there in comment?
My case is compressible.its not necessary for me,is it?

wyldckat April 14, 2013 07:22

Quote:

Originally Posted by immortality (Post 420398)
Why rho is there in comment?
My case is compressible.its not necessary for me,is it?

If you check the example file "calcMassFlowDict" that is in the attached tarballs on post #18, you'll see these lines:
Code:

// Factor to multiply the results with (for symmetric or axial cases)
// scaleFactor 72.;

// Density for incompressible cases
// rho rho [1 -3 0 0 0 0 0] 0.41;

So I can only guess that you can leave that line commented... although I would suggest that you first confirm with a case that you fully know of what goes in and what goes out...

immortality April 14, 2013 11:56

it works nice.the output is like what swak4Foam run time function gives.
but how can increase time step decimal numbers? and if it can be done that a summation on phi's multiply to time step is outputted then total mass on each patch is obtained in the whole time (like: Total Mass = SUM(mass_flow_rate * time_step_size) ) and it is not required to external softwares. could you please have a look into this work? and it will be fully completed;)
thanks.

wyldckat April 14, 2013 13:08

Unfortunately I'm not 100% certain if I understand your request correctly.
If the time step is now of fixed size, then you only need to define "scaleFactor" accordingly.
If the time step varies... it depends on whether you've saved all of the iterations or not... because with only a few iterations, it will lead to a non-measurable error...

... wait... you want the summation of all results... and place it were?.. I guess at the bottom of the file...

If the time step is fixed, you'll be the one assuming the resulting error isn't relevant. Otherwise, you should have calculated this while the solver is running, not after it's finished.

I'll try to see if I can still implement this today. Otherwise, it will have to wait till next weekend.

immortality April 20, 2013 08:05

I use adjustableRunTime.I think it could be possible to multiply each value in column right to difference of value of column left(time)and its before time(upper value) to program.
yes at the end of file or better at a time that user specifies when execute calcMassFlow in terminal in seconds (like:calcMassFlow .002)
:rolleyes:

immortality July 4, 2013 16:49

Hi Bruno
I executed calcMassFlow on a case but this showed:
Code:

Create time

fileName::stripInvalid() called for invalid fileName UntitledFolder
    For debug level (= 2) > 1 this is considered fatal
Aborted


immortality July 6, 2013 01:08

it resolved.an untitled folder had been created accidently in the case folder.


All times are GMT -4. The time now is 06:55.