CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Post-Processing

how to calculate mass flow rate on patches and summation of that during the run?

Register Blogs Community New Posts Updated Threads Search

Like Tree23Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 7, 2013, 13:26
Default
  #41
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
i created a text file named flowRate in case folder and typed in terminal this:
funkyDoCalc flowRate but this error displayed:
Code:
--> FOAM FATAL ERROR: 
funkyDoCalc: time/latestTime option is required


    From function main()
    in file funkyDoCalc.C at line 124.

FOAM exiting
when i typed:
Code:
funkyDoCalc ':.000539' flowRate
or:
Code:
funkyDoCalc :.000539 flowRate
the error changed:
Code:
--> FOAM FATAL ERROR: 
funkyDoCalc: time/latestTime option is required


    From function main()
    in file funkyDoCalc.C at line 124.

FOAM exiting

ehsan@Ehsan-com:~/Desktop/WR_pimple_limited$ funkyDoCalc ':.000539' flowRate

Usage: funkyDoCalc [OPTIONS] <expressionDict>
options:
  -case <dir>       specify alternate case directory, default is the cwd
  -foreignMeshesThatFollowTime <<list of mesh names>>
  -latestTime       select the latest time
  -noDimensionChecking
  -noFunctionObjects
                    do not execute functionObjects
  -noZero           exclude the '0/' dir from the times list, has precedence
                    over the -zeroTime option
  -parallel         run in parallel
  -region <name>    specify alternative mesh region
  -roots <(dir1 .. dirN)>
                    slave root directories for distributed running
  -time <ranges>    comma-separated time ranges - eg, ':10,20,40:70,1000:'
  -srcDoc           display source code in browser
  -doc              display application documentation in browser
  -help             print the usage

Using: OpenFOAM-2.2.0 (see www.OpenFOAM.org)
Build: 2.2.0-b363e8d14789



--> FOAM FATAL ERROR: 
Wrong number of arguments, expected 1 found 2


FOAM exiting
i also changed latestTime to startTime but nothing in error changed.
(different subject,different post)
could you please test in according to my case?
Attached Files
File Type: gz Nazeri.tar.gz (9.9 KB, 9 views)
immortality is offline   Reply With Quote

Old   April 7, 2013, 16:54
Default
  #42
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
I've edited my previous post... it was missing the "-time" argument. Try:
Code:
funkyDoCalc -time :0.000539 flowRate
Note: keep in mind that this command will only run up to the time instance "0.000539". Notice that the help text that you've been seeing from funkyDoCalc indicates various examples of time ranges and groups.

PS: weekends around the world: http://en.wikipedia.org/wiki/Workweek_and_weekend - but there is a clear reduction in posts here on the forum during Saturday and Sunday.
immortality likes this.
__________________
wyldckat is offline   Reply With Quote

Old   April 7, 2013, 18:26
Default
  #43
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by wyldckat View Post
Hi Ehsan,
[*]Instead, I've created the file "fdcMassFlow", inside the case folder, with the following content:
Code:
massFlow
{
  valueType patch;
  patchName inlet;
  variables (
    "rhoMagU{inlet} = 1000.0*( U & Sf() );"
  );
  expression "rhoMagU";
  accumulations (
    min
    max
    average
    sum
  );
}
A lot of "accumulations" here, because I wanted to check what each value provided. I used "variables", only because it was a good way to test what could be done with it.
The expression used is a replacement for the "phi" field, because in this case we don't have it.[*]Now, to run the funkyDoCalc application with the file "fdcMassFlow", I ran:
Code:
funkyDoCalc -time :200 fdcMassFlow
[*]It gave me the following output:
Code:
Time = 0
massFlow : swak4Foam: Setting default mesh
swak4Foam: Allocating new repository for sampledGlobalVariables
--> FOAM Warning : 
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResult/ExpressionResultI.H at line 324
    The minimum value -0.0178262 and the maximum -0.00313389 differ. I will use the average -0.00846667
 min=-0.00846667 max=-0.00846667 average=-0.00846667 sum=-0.254

Time = 50
massFlow : --> FOAM Warning : 
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResult/ExpressionResultI.H at line 324
    The minimum value -0.0178262 and the maximum -0.00313389 differ. I will use the average -0.00846667
 min=-0.00846667 max=-0.00846667 average=-0.00846667 sum=-0.254

Time = 100
massFlow : --> FOAM Warning : 
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResult/ExpressionResultI.H at line 324
    The minimum value -0.0178262 and the maximum -0.00313389 differ. I will use the average -0.00846667
 min=-0.00846667 max=-0.00846667 average=-0.00846667 sum=-0.254

Time = 150
massFlow : --> FOAM Warning : 
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResult/ExpressionResultI.H at line 324
    The minimum value -0.0178262 and the maximum -0.00313389 differ. I will use the average -0.00846667
 min=-0.00846667 max=-0.00846667 average=-0.00846667 sum=-0.254

Time = 200
massFlow : --> FOAM Warning : 
    From function ExpressionResult::getUniformInternal(const label size,bool noWarn)
    in file ExpressionResult/ExpressionResultI.H at line 324
    The minimum value -0.0178262 and the maximum -0.00313389 differ. I will use the average -0.00846667
 min=-0.00846667 max=-0.00846667 average=-0.00846667 sum=-0.254
End
Which is... strange Well, the "sum" result seems to be correct, from what I calculated in ParaView.[/LIST]Best regards,
Bruno
Bruno: you'll want your variable to be "rhoMagU = 1000.0*( U & Sf() );". It is calculated on the patch inlet anyway. As soon as you use {} it assumes that you calculate on some other patch (or cellSet, or ...) and in that general case it can only handle uniform values (that's why you'll have to accumulate THERE. Something like "rhoSumOut{outlet} = sum(1000.0*( U & Sf() ));" which might be a first step towards calculating the mass-balance of the case)
wyldckat and immortality like this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   April 8, 2013, 08:19
Default
  #44
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
I typed this:
Code:
funkyDoCalc -time :.000539 flowRate
but the error is:
Code:
Create time

Create mesh for time = 0

No information about foreign meshes in "flowRate.flowInlet"

No information about foreign meshes in "flowRate.flowOutlet"

No information about foreign meshes in "flowRate.surfacePlane"


Time = 0
flowInlet : swak4Foam: Setting default mesh
swak4Foam: Allocating new repository for sampledGlobalVariables
--> FOAM Warning : 
    From function ConcretePluginFunction<DriverType>::exists
    in file lnInclude/ConcretePluginFunction.C at line 111
    Constructor table of plugin functions for PatchValueExpressionDriver is not initialized


--> FOAM FATAL ERROR: 
 Parser Error for driver PatchValueExpressionDriver at "1.1-3" :"field phi not existing or of wrong type"
"phi"
  ^^^
--|  

Context of the error:


- From dictionary: flowRate.flowInlet
  Evaluating expression "phi"


    From function parsingValue
    in file lnInclude/CommonValueExpressionDriverI.H at line 1039.

FOAM exiting
immortality is offline   Reply With Quote

Old   April 8, 2013, 08:44
Default
  #45
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
I added a phi file in 0 folder.now the results are computed in command shell but no files is created for flowInlet and flowOutlet like what was been doing before in run-time condition.
how to have flow rate written files like before(during run)?
immortality is offline   Reply With Quote

Old   April 9, 2013, 05:18
Default
  #46
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Quote:
Originally Posted by immortality View Post
I added a phi file in 0 folder.now the results are computed in command shell but no files is created for flowInlet and flowOutlet like what was been doing before in run-time condition.
how to have flow rate written files like before(during run)?
Quick answer: "phi" doesn't seem to be outputted (or even used?) by your solver. Try using "U & Sf()" instead.
__________________
wyldckat is offline   Reply With Quote

Old   April 9, 2013, 06:42
Default
  #47
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
yes phi is calculated and outputted in rhoPimpleFoam.there was not a phi file in 0 folder that i added it by calculated type.
I think its because of funkyDoCalc function fault tha only outputs in command shell and doesn't categorize them in a file like original functios do during run.
any help or opinion?

Last edited by immortality; April 10, 2013 at 13:23.
immortality is offline   Reply With Quote

Old   April 10, 2013, 18:18
Default
  #48
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Ehsan,

It took me a while to understand what you meant... but only after testing and looking at the code for funkyDoCalc did I fully understand it. You're correct, funkyDoCalc does output only onto screen, since it seems hard-coded to do so in the file "funkyDoCalc.C":
Code:
Info << " " << aName << "=" << val;
This is basically the same issue that calcMassFlow has got.

Unfortunately, right now I can't remember how OpenFOAM handles file output. My quickest suggestion is to look at a C++ tutorial on the topic: http://www.cplusplus.com/doc/tutorial/files/

Another suggestion is to look into the "$WM_PROJECT_DIR/applications/test" folder and look for coding examples.

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   April 12, 2013, 14:20
Default
  #49
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
thank you.how to use test folder?!
it is better to write in a file by arrangement than only in screen.
immortality is offline   Reply With Quote

Old   April 14, 2013, 07:41
Default
  #50
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
I finally managed to get some time to investigate this. Here's what I found out:
  1. funkyDoCalc is a simpler code implementation of the "swakExpressionFunctionObject" class.
  2. Therefore, it seems to have been specifically implemented to output only to screen. (I'm having a déjà-vu... but I can't remember from when...)
  3. A good way of revamping funkyDoCalc would be either one of the following:
    • Use the class "swakExpressionFunctionObject" directly, instead of re-applying existing code. The verbose option in the dictionary file would then cover for the original funkyDoCalc capabilities.
    • Or make funkyDoCalc work in a way that would explicitly run function objects. I think execFlowFunctionObjects was meant to do this, but I think it's specific for certain cases only... but I'm not familiar enough with it.
I would like to do one of the point #3 possibilities, but currently I don't have the time and patience to look into this.


In the mean time, I'll update the other thread on calcMassFlow, with a variant that outputs to a file: http://www.cfd-online.com/Forums/ope...tml#post418748


@Ehsan: After so many posts from you, I was expecting you knew what to do with a path and source code . Anyway, the idea from my previous post was:
  1. Check what folder I was talking about by running:
    Code:
    echo $WM_PROJECT_DIR/applications/test
  2. Then look into the sub-folders present at that path and look at existing code for ideas.
  3. Adapt the ideas to the funkyDoCalc source code.
immortality likes this.
__________________
wyldckat is offline   Reply With Quote

Old   April 14, 2013, 10:50
Default
  #51
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by wyldckat View Post
I finally managed to get some time to investigate this. Here's what I found out:
[LIST=1][*]funkyDoCalc is a simpler code implementation of the "swakExpressionFunctionObject" class.
I guess you can see it that way. But you don't have to deal with functionObject-specific stuff like "outputTime" etc
Quote:
Originally Posted by wyldckat View Post
[*]Therefore, it seems to have been specifically implemented to output only to screen. (I'm having a déjà-vu... but I can't remember from when...)
Well. It's the Unix-way. Output to the screen and let the user decide what utility to pipe it into.

I once felt tempted to add file-output but at the time it was faster for me to use the pyFoamUtilityRunner.py to run it to get the results into a file. The there were some micro-decisions to be handled (like how to output it: multiple-files or single file, directory, header-line yes/no, filenames) and I felt at the time "I don't need it right now and any of these decisions will feel 'wrong' to 40% of the people as there is no convention for that kind of thing in OF (patchAverage etc don't write files)"
Quote:
Originally Posted by wyldckat View Post
[*]A good way of revamping funkyDoCalc would be either one of the following:
  • Use the class "swakExpressionFunctionObject" directly, instead of re-applying existing code. The verbose option in the dictionary file would then cover for the original funkyDoCalc capabilities.
  • As I said above: there's a bit of ballast involved with having functionObjects.
    Quote:
    Originally Posted by wyldckat View Post
  • Or make funkyDoCalc work in a way that would explicitly run function objects. I think execFlowFunctionObjects was meant to do this, but I think it's specific for certain cases only... but I'm not familiar enough with it.
Thing is that EFFO preloads certain fields for functionObjects that need them. The problem with using swak-functionObjects is the same: they assume that fields are already in memory (but that is a solvable problem)

All that being said: I understand that funkyDoCalc has its shortcomings, but it was written at the time as a utility to quickly do some checks on an existing run (like checking mass conservation etc) and for the other stuff that I'm using it for (checking results inside of a testsuite) output to stdout, parsing it with PyFoam is actually more convenient. Having output for it is on my to-do list but not very high
immortality likes this.
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   April 14, 2013, 11:20
Default
  #52
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Bernhard,

I had already guessed as much; handling stuff directly from stdout is also my usual way of handling this kind of data. But unfortunately I'm not yet familiar enough with PyFoam or which exact PyFoam script, in order to suggest a solution based on it... and I wasn't in the mood for suggesting a solution based on grep+sed+awk...

And as I said (er, wrote), I'm interested in doing #3 myself... a funkyDoFunctionObjects seems to be a very interesting topic I'll try to look into it in my next vacation...

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   April 20, 2013, 09:09
Default
  #53
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
hi
is there a simple (for you not me ) script that it writes first and second columns in separate folders so that I can use them easier in libre Office (and get summation on mass flow values)?(because of huge numbers its so difficult to separate them manually)
immortality is offline   Reply With Quote

Old   April 20, 2013, 12:03
Default
  #54
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by immortality View Post
hi
is there a simple (for you not me ) script that it writes first and second columns in separate folders so that I can use them easier in libre Office (and get summation on mass flow values)?(because of huge numbers its so difficult to separate them manually)
What is the problem with reading in the file and then deleting one column?
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   April 20, 2013, 13:50
Default
  #55
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
how to select a column?it selects all in file while drag and paste both parts in libre office in one column and have to delete not wanted in each cell manually.
immortality is offline   Reply With Quote

Old   April 20, 2013, 14:30
Default
  #56
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
@Ehsan:
Quote:
Originally Posted by immortality View Post
how to select a column?it selects all in file while drag and paste both parts in libre office in one column and have to delete not wanted in each cell manually.
Don't you know that Libreoffice Calc is able to help you interactively import data from text files ?

There are so many ways to do it and all of the ones below will show a dialogue box that help you import data (or at least it should):
  • Through the menu: Insert -> Sheet From File...
  • Drag-and-drop the file from a file browser onto Libreoffice calc.
  • You can even copy-paste the whole file from a text editor into Calc and the importer will appear! Menu "Edit -> Select all" is pretty much the standard nowadays...
Said dialogue box looks like this one attached.

You can even choose which columns to not include! In the picture attached shows this in practice...
An explanation about each one of these controls is shown here: https://help.libreoffice.org/Common/Text_Import

As for having to erase one cell at a time... there are at least two ways to do the selection of a complete row or column:
  • The key combination Ctrl+Shift+Arrow Key (any arrow key), helps select a group of cells in the direction you used with the arrow key...
  • Or you can click on the top button that exists for each column or left button for each row...


I'm almost speechless... I understand I've known these tricks for so long, but I'm finding it very hard to believe that you don't know about none of these


Well, if you can use Libreoffice Calc to post-process data, then you don't need me to spend any more time implementing the total sum of mass flow over time, because Libreoffice Calc can easily help you do that.


Best regards,
Bruno
Attached Images
File Type: jpg Screenshot from 2013-04-20 18:15:29.jpg (52.4 KB, 32 views)
immortality likes this.
__________________
wyldckat is offline   Reply With Quote

Old   April 20, 2013, 15:31
Default
  #57
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
thanks a lot for the complete explanation!
I was not familiar with office Calc because haven't need it to import any data so far( I am only 4-5 months in Linux) .the I mport page was displayed but the fields was gray.I examined randomly "separated by" and got disappointed (but not space) !
no then you don't have to try more on it.
it has been a lot of effort you have done so far.thank you again for all help.
could you please help in how to have p,T,U on patches by swak4FOAM post processing functions(and also total pressure by defining it in postProcessing functions not by modifying solver)?

Last edited by immortality; April 20, 2013 at 16:55.
immortality is offline   Reply With Quote

Old   April 21, 2013, 05:39
Default
  #58
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 27
immortality is on a distinguished road
there are several folders of mass flow.is it possible to put them in one sheet rather than different sheets?or how to work with different sheets?
And how can i have a column of deltaT(lower value minus upper value in a time column)
I see maybe its more efficient if modify calcMassFlow.
immortality is offline   Reply With Quote

Old   April 21, 2013, 06:40
Default
  #59
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Ehsan,

I forgot that you're not familiar with Libreoffice Calc...
If you can access Youtube, here is a playlist with instructional videos on how to use Libreoffice Calc: http://www.youtube.com/watch?v=HdOLx...948B34&index=1

If for some reason you cannot access Youtube (it could be blocked at school, or bandwidth restrictions or some other reason), the following textual tutorials may help:
Best regards,
Bruno
immortality likes this.
__________________
wyldckat is offline   Reply With Quote

Old   April 21, 2013, 07:24
Default
  #60
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by wyldckat View Post
If for some reason you cannot access Youtube (it could be blocked at school, or bandwidth restrictions or some other reason), the following textual tutorials may help:
Bruno. Have you looked at the country the guy's from? The school blocking/censoring YouTube is the smallest problem
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Reply


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



All times are GMT -4. The time now is 13:48.