|
[Sponsors] |
September 23, 2010, 09:01 |
How to calculate a zone Average
|
#1 |
New Member
CFD user
Join Date: Apr 2010
Location: Germany
Posts: 28
Rep Power: 16 |
Hi Everyone,
I am trying to simulate a flow over a gondola of a wind turbine using OpenFoam. I have an oil cooler sitting over the top of the gondola, which is of rectangular cross-section, with the flow of inlet air in its normal direction. I have defined the cooler as a porous region, using the Darcy's coefficient, d and f. I am trying to find out what is the mean velocity of air passing through this cooler. Since the region is not defined as patch, i cannot use the patchAverage in OF. I used the sampleDict utility to generate only the cooler section data, but i could find no means of averaging it. Can anyone suggest me a way of doing this? Thanks in Advance Subhkirti. |
|
September 23, 2010, 10:58 |
|
#2 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
a) I'm biased (I wrote this thing) b) this is to be considered beta-quality software (until I get some feedback) It will not do directly what you want but defining an arbitray expression on a cellZone/faceZone is quite easy (I think ) with this: http://www.cfd-online.com/Forums/ope...swak4foam.html Bernhard |
||
September 24, 2010, 05:39 |
|
#3 |
New Member
CFD user
Join Date: Apr 2010
Location: Germany
Posts: 28
Rep Power: 16 |
Dear Bernhard,
Thanks for the reply. The thing is that I'm very new to the use of OpenFoam, and was using sampleDict to make a cut at the surface of the cooler. My syntax is like below: // Fields to sample. fields ( U ); triangleCut { // Cutingplane using iso surface type cuttingPlane; planeType pointAndNormal; pointAndNormalDict { basePoint (7.547 0.5 0.0001); normalVector (1 0 0); } interpolate true; zone porosity; // Optional: zone only exposedPatchName gondel; // Optional: zone only regularise true; // Optional: do not simplify } How/Where do I make changes in my case setup, with the utility given by you, so that I can approach the result, Aren't there any direct methods which I can use to calculate the zone average (Average Velocity in the cooler region of the gondola)? I am sorry if these questions looks stupid, but I have just begun with OpenFoam. Regards, Subhkirti. |
|
September 27, 2010, 08:37 |
|
#4 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
b) what do you mean with zone? Have you got a cellZone or faceZone defined in your mesh? Then swak can do the calculations. Getting OF-zones depends on the way you create your mesh c) sorry. swak doesn't do sampledSurfaces - yet. But if you have got a faceZone or faceSet defined it might do the same thing for you Bernhard |
||
September 27, 2010, 09:36 |
|
#5 | |
New Member
CFD user
Join Date: Apr 2010
Location: Germany
Posts: 28
Rep Power: 16 |
Quote:
Thanks again for the reply. I have got a CellZone in the mesh. How can I call the function to calculate the average velocity in that zone? Can you give me an example. |
||
September 27, 2010, 10:51 |
|
#6 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Code:
functions ( averageVel { type swakExpression; valueType cellZone; zoneName heater; // or whatever is your zoneName accumulations ( average ); expression "U"; verbose true; } ); Code:
functions ( weightedAverageVel { type swakExpression; valueType cellZone; zoneName heater; // or whatever is your zoneName accumulations ( min ); expression "sum(mag(U)*vol())/sum(vol())"; verbose true; } ); It all depends on what your definition of "average velocity" is. If you're interested in the average velocity in a specific direction this might do the trick for you: Code:
functions ( directionAverageVel { type swakExpression; valueType cellZone; variables "direction=vector(1,1,0);dir=direction/mag(direction);"; zoneName heater; // or whatever is your zoneName accumulations ( min ); expression "sum((U & dir)*vol())/sum(vol())"; verbose true; } ); Bernhard |
||
September 27, 2010, 12:08 |
|
#7 |
New Member
CFD user
Join Date: Apr 2010
Location: Germany
Posts: 28
Rep Power: 16 |
Thank you so much Bernhard. I will try out these and comeback to you if any further clarifications are needed.
Regards, Subhkirti. |
|
September 29, 2010, 07:29 |
|
#8 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
Hey subhkirti, Hallo Bernhard
can you please tell me if you succeeded in computing the average over the cellZones and how you managed to do so? I would like to compute an average value of a scalar over several cellZones, so one average value for each cellZone and I do not know how to do it when running the case in parallel. Would be great if you could help me |
|
September 29, 2010, 13:44 |
|
#9 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
If you want to do it in your own code: the key is that the sum is local on each processor. Use "reduce(plusOp<scalar>,sum);" to get the total. Bernhard |
||
October 1, 2010, 06:04 |
|
#10 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
Thank you very much Bernhard, I think your tool would do just the right thing.
Can you please tell me where should I put the source Code and the libraries? I did not succeed in compiling so far. I am using OpenFOAM 1.7.0 It would be great if you could give me a little howto for compiling the sources, especially where to put the folder. Thank you very much! |
|
October 1, 2010, 06:47 |
|
#11 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
But without further information what exactly is your problem I will not be able to help you Bernhard |
||
October 1, 2010, 09:51 |
|
#12 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
Hey Bernhard,
thank you for answering. I downloaded the simpleFunctionObjects and compiled it via wmake libso in my $(WM_PROJECT_USER_DIR)/Libraries. That worked so far I think. But when compiling swak4foam with wmake all I get many error messages like from funkySetFields.C:41: ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: »parserField« has not been declared ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: »yylval« wurde in diesem Gültigkeitsbereich nicht definiert ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: »parserField« has not been declared ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: »yylloc« wurde in diesem Gültigkeitsbereich nicht definiert ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: expected primary-expression before »&« token ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: »driver« wurde in diesem Gültigkeitsbereich nicht definiert ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: initializer Ausdrucksliste als zusammengesetzten Ausdruck behandelt In file included from FieldValueExpressionParser.yy:67, from ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriver.H:18, from funkySetFields.C:41: ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverLogicalTemplates.H:9: Fehler: expected initializer before »<« token ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverLogicalTemplates.H:15: Fehler: expected initializer before »<« token ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverLogicalTemplates.H:23: Fehler: invalid use of incomplete type »struct Foam::FieldValueExpressionDriver« ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriver.H:13: Fehler: forward declaration of »struct Foam::FieldValueExpressionDriver« ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverLogicalTemplates.H:49: Fehler: invalid use of incomplete type »struct Foam::FieldValueExpressionDriver« ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriver.H:13: Fehler: forward declaration of »struct Foam::FieldValueExpressionDriver« ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverLogicalTemplates.H:80: Fehler: invalid use of incomplete type »struct Foam::FieldValueExpressionDriver« ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriver.H:13: Fehler: forward declaration of »struct Foam::FieldValueExpressionDriver« ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriverLogicalTemplates.H:106: Fehler: invalid use of incomplete type »struct Foam::FieldValueExpressionDriver« ../../Libraries/swak4FoamParsers/lnInclude/FieldValueExpressionDriver.H:13: Fehler: forward declaration of »struct Foam::FieldValueExpressionDriver« Something does not work with the swak4Foam Parser. I tried to install it on my home-directory of the master node of the cluster. I hope that this should not be a problem..... Have a nice weekend! Anne |
|
October 4, 2010, 08:02 |
|
#13 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Hi Anne!
What I need to diagnose the problem is the first error message. And could you check the versions of the used utilities with "bison -V" ,"flex -V" and "gcc -v" Bernhard Quote:
|
||
October 4, 2010, 10:16 |
|
#14 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
Hallo Bernhard,
1.) Here is the first error lincke@master:~/OpenFOAM/OpenFOAM-1.7.0/swak4Foam> wmake all SOURCE=FieldValueExpressionParser.yy ; rm -f Make/linux64GccDPOpt/FieldValueExpressionParser.C Make/linux64GccDPOpt/FieldValueExpressionParser.tab.hh; bison -ra -v -d $SOURCE ; mv *.tab.cc Make/linux64GccDPOpt/FieldValueExpressionParser.C ; sed -i.bak "s/position.hh/FieldValueExpressionParser_position.hh/" location.hh ; mv location.hh lnInclude/FieldValueExpressionParser_location.hh ; mv stack.hh lnInclude/FieldValueExpressionParser_stack.hh ; mv position.hh lnInclude/FieldValueExpressionParser_position.hh ; sed -i.bak "s/stack.hh/FieldValueExpressionParser_stack.hh/;s/location.hh/FieldValueExpressionParser_location.hh/" FieldValueExpressionParser.tab.hh ;mv *.hh lnInclude ; touch -r $SOURCE lnInclude/FieldValueExpressionParser*.hh ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -IMake/linux64GccDPOpt -I/home/lincke/OpenFOAM/OpenFOAM-1.7.0/src/finiteVolume/lnInclude -I/home/lincke/OpenFOAM/OpenFOAM-1.7.0/src/meshTools/lnInclude -IlnInclude -I. -I/home/lincke/OpenFOAM/OpenFOAM-1.7.0/src/OpenFOAM/lnInclude -I/home/lincke/OpenFOAM/OpenFOAM-1.7.0/src/OSspecific/POSIX/lnInclude -fPIC -c Make/linux64GccDPOpt/FieldValueExpressionParser.C -o Make/linux64GccDPOpt/FieldValueExpressionParser.o In file included from FieldValueExpressionParser.yy:66, from Make/linux64GccDPOpt/FieldValueExpressionParser.C:24: lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: incomplete type »parserField::FieldValueExpressionParser« used in nested name specifier lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: »yylval« wurde in diesem Gültigkeitsbereich nicht definiert lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: expected primary-expression before »*« token lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: »yylloc« wurde in diesem Gültigkeitsbereich nicht definiert lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: expected primary-expression before »&« token lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: »driver« wurde in diesem Gültigkeitsbereich nicht definiert lnInclude/FieldValueExpressionDriverYY.H:10: Fehler: initializer Ausdrucksliste als zusammengesetzten Ausdruck behandelt FieldValueExpressionParser.tab.cc: In member function »virtual int yy::FieldValueExpressionParser:arse()«: FieldValueExpressionParser.tab.cc:414: Fehler: »parserFieldlex« kann nicht als Funktion verwendet werden FieldValueExpressionParser.tab.cc: In member function »unsigned char yy::FieldValueExpressionParser::yytranslate_(int)« : FieldValueExpressionParser.tab.cc:2771: Warnung: Verwendung einer Typumwandlung im alten Stil FieldValueExpressionParser.yy: At global scope: FieldValueExpressionParser.yy:404: Fehler: expected unqualified-id before »&« token FieldValueExpressionParser.yy:404: Fehler: expected »)« before »&« token FieldValueExpressionParser.yy:404: Fehler: expected initializer before »&« token make: *** [Make/linux64GccDPOpt/FieldValueExpressionParser.o] Fehler 1 2.) Bison lincke@master:~/OpenFOAM/OpenFOAM-1.7.0/swak4Foam> bison -V bison (GNU Bison) 2.1 Geschrieben von Robert Corbett und Richard Stallman. Copyright © 2005 Free Software Foundation, Inc. Dies ist freie Software; die Kopierbedingungen stehen in den Quellen. Es gibt keine Garantie; auch nicht für VERKAUFBARKEIT oder FÜR SPEZIELLE ZWECKE. 3.) flex flex 2.5.31 4.) lincke@master:~/OpenFOAM/OpenFOAM-1.7.0/swak4Foam> gcc -v Es werden eingebaute Spezifikationen verwendet. Ziel: x86_64-unknown-linux-gnu Konfiguriert mit: ../configure --prefix=/home/lincke/OpenFOAM/ThirdParty-1.7.0/platforms/linux64/gcc-4.4.4 --with-gmp=/home/lincke/OpenFOAM/ThirdParty-1.7.0/platforms/linux64/gmp-5.0.1 --with-mpfr=/home/lincke/OpenFOAM/ThirdParty-1.7.0/platforms/linux64/mpfr-2.4.2 Thread-Modell: posix gcc-Version 4.4.4 (GCC) There may be a problem with the gcc version. The original version of gcc that is used by the cluster is too old for OF1.7. so I had to use my own specifications in order to be able to compile OF1.7. I hope this helps....thank you a lot! |
|
October 5, 2010, 08:57 |
|
#15 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Solution might be to download the sources for bison, compile them and add the new bison to your path. The other solution might be to compile swak on a machine with a more UpToDate bison and then use the generated files on your cluster. Like it is described in http://openfoamwiki.net/index.php/Co...sions_of_bison only you'll have to do it for 3 sets of grammars Bernhard |
||
October 12, 2010, 10:55 |
|
#16 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
Hallo Bernhard,
I compiled the swak4foam on another machine which has a newer version of Bison. Then I copied the folder which was created to the "old" system, ran a wmake libso (without changing anything) and it worked! The computation of the average works when I insert a function object in my system/controldict. I think this tool might be very helpful for future computations. Thank you for that. But I have still one questions: I need to set the value of my cellZones to the average value (which is computed by inserting a function object to system/controldict). Is there any possibility to set the value which is computed at run-time to my cellZones? I tried some things but so far it did not work for me. Thank you very much. Anne |
|
October 12, 2010, 14:09 |
|
#17 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Anyway. I recommend using that only for prototyping you calculations. In the long run I recommend building a solver that does the physics right Bernhard |
||
October 13, 2010, 10:34 |
|
#18 |
Senior Member
Anne Gerdes
Join Date: Aug 2010
Location: Hamburg
Posts: 168
Rep Power: 16 |
Hey Bernhard,
I added the line reduce(average,sumOp<scalar>()); to my code and this really worked fine and was much more easier than I expected. Nevertheless the test case you recommended me to look at seems to be interesting, especially what can be done with swak4foam. Apart from the fact that it did not help me solving my problem (which I now solved with the expression you recommended me before) I have many other things (pressure loss, uniformity of the flow) which I am now able to compute (hopefully) easily with your tool. I thank you very much! |
|
October 13, 2010, 11:47 |
|
#19 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Bernhard |
||
October 31, 2012, 10:44 |
|
#20 | |
Member
Join Date: Mar 2009
Posts: 90
Rep Power: 17 |
Quote:
Code:
mdot_inlet { type swakExpression; valueType patch patchName inlet expression "phi*flip()"; accumulations ( sum ); verbose true; } p_inlet { type swakExpression; valueType patch; patchName inlet expression "p"; accumulations ( average ); verbose true; } [44] [24] --> FOAM FATAL ERROR: [42] --> FOAM FATAL ERROR: Could not find a field name "p" of type scalar (neither surfaceScalarField nor volScalarField) Autointerpolate: 0 [16] And this one for mass flow rate. When I do mass flow rate calcs on faceZones, it works. [42] [42] --> FOAM FATAL ERROR: [42] Parser Error at "1.5-8" :"field flip not existing or of wrong type" "phi*flip()" " ^^^^ " Any ideas? As best I can tell, I am following your syntax correctly, no? |
||
Tags |
openfoam 1.7.1, patchaverage, porous modellling, sampledict |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to calculate a time average | spwater | OpenFOAM | 2 | February 24, 2010 09:04 |
Problem in IMPORT of ICEM input file in FLUENT | csvirume | FLUENT | 2 | September 9, 2009 02:08 |
calculate the average velocity of particles | robert | FLUENT | 0 | August 1, 2008 10:44 |
Error to re-open fluent case file | J.Gimbun | FLUENT | 0 | April 27, 2006 09:42 |
Sliding mesh error | Karl Kevala | FLUENT | 4 | February 21, 2001 16:52 |