# How to calculate a zone Average

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

 September 23, 2010, 08:01 How to calculate a zone Average #1 New Member   CFD user Join Date: Apr 2010 Location: Germany Posts: 28 Rep Power: 8 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, 09:58
#2
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,934
Rep Power: 41
Quote:
 Originally Posted by subhkirti 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.
Beware:
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, 04:39 #3 New Member   CFD user Join Date: Apr 2010 Location: Germany Posts: 28 Rep Power: 8 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, 07:37
#4
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,934
Rep Power: 41
Quote:
 Originally Posted by subhkirti 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.
a) the stuff that is currently distributed only consists of functionObjects. That means that the calculations can be done during the run not afterwards (but of course it is easy to write a utility that does it after the fact)
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, 08:36
#5
New Member

CFD user
Join Date: Apr 2010
Location: Germany
Posts: 28
Rep Power: 8
Quote:
 Originally Posted by gschaider a) the stuff that is currently distributed only consists of functionObjects. That means that the calculations can be done during the run not afterwards (but of course it is easy to write a utility that does it after the fact) 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
Dear Bernhard,

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, 09:51
#6
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,934
Rep Power: 41
Quote:
 Originally Posted by subhkirti Dear Bernhard, 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.
Have a look at Examples/other/angledDuct/system/controlDict for some examples. The easiest would be to add to the controlDict something like
Code:
```
functions
(
averageVel
{
type swakExpression;
valueType cellZone;
zoneName heater; // or whatever is your zoneName
accumulations (
average
);
expression "U";
verbose true;
}
);```
That would give you the arithmetic average of the vector value over all cells. Volume weighted average over all cells of the velocity magnitude would be
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;
}
);```
Note that as the average velocity is already calculated in the expression every accumulation except sum gives you the same result.

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;
}
);```
(Havn't tested these expressions so there might be typos in there)

Bernhard

 September 27, 2010, 11:08 #7 New Member   CFD user Join Date: Apr 2010 Location: Germany Posts: 28 Rep Power: 8 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, 06:29 #8 Senior Member   Anne Gerdes Join Date: Aug 2010 Location: Hamburg Posts: 168 Rep Power: 8 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, 12:44
#9
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,934
Rep Power: 41
Quote:
 Originally Posted by Anne Lincke 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
If a functionObject is enough for you: follow the link in my first posting in this thread.
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, 05:04 #10 Senior Member   Anne Gerdes Join Date: Aug 2010 Location: Hamburg Posts: 168 Rep Power: 8 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, 05:47
#11
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,934
Rep Power: 41
Quote:
 Originally Posted by Anne Lincke 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!
As long as you download the whole folder and do a "wmake all" inside it there is no constraint on the location. Include-search-paths etc are relative inside that directory. Only external dependency (for some of the functionObjects) is that you have the simpleFunctionObjects installed at \$(WM_PROJECT_USER_DIR)/Libraries/simpleFunctionObjects

But without further information what exactly is your problem I will not be able to help you

Bernhard

 October 1, 2010, 08:51 #12 Senior Member   Anne Gerdes Join Date: Aug 2010 Location: Hamburg Posts: 168 Rep Power: 8 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, 07:02
#13
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,934
Rep Power: 41
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:
 Originally Posted by Anne Lincke 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, 09:16 #14 Senior Member   Anne Gerdes Join Date: Aug 2010 Location: Hamburg Posts: 168 Rep Power: 8 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, 07:57
#15
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,934
Rep Power: 41
Quote:
 Originally Posted by Anne Lincke Hallo Bernhard, 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!
I'm afraid the problem is bison. The smallest version I use is 2.3 (and I remember having to adapt funkySetFields for that).

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, 09:55 #16 Senior Member   Anne Gerdes Join Date: Aug 2010 Location: Hamburg Posts: 168 Rep Power: 8 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, 13:09
#17
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,934
Rep Power: 41
Quote:
 Originally Posted by Anne Lincke 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
Have a looked at the pulsedPitzDaily in the examples. There are two functionObjects there: expressionField and manipulateField. manipulateField can modify the field in a region specified by mask. The problem is that it currently doesn't know the variables-entry that most of the other functionObjects have. But maybe you'll find a way to work around that (or if the value you want to set doesn't depend on anything else - cellSets etc - it should work without problems)

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, 09:34 #18 Senior Member   Anne Gerdes Join Date: Aug 2010 Location: Hamburg Posts: 168 Rep Power: 8 Hey Bernhard, I added the line reduce(average,sumOp()); 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, 10:47
#19
Assistant Moderator

Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,934
Rep Power: 41
Quote:
 Originally Posted by Anne Lincke Hey Bernhard, I added the line reduce(average,sumOp()); 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!
Glad you find it useful. Please always check the numbers you get (whether they make sense). The stuff is still in beta

Bernhard

October 31, 2012, 10:44
#20
Member

Join Date: Mar 2009
Posts: 75
Rep Power: 9
Quote:
 Originally Posted by gschaider Code: ``` functions ( averageVel { type swakExpression; valueType cellZone; zoneName heater; // or whatever is your zoneName accumulations ( average ); expression "U"; verbose true; }``` Bernhard
I just download swak4foam, and right now I just want to get the average pressure and total mass flow rate at my velocity inlet, to compare with hand calcs and make sure I am using it correctly. To sum these, I am doing the following:

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;
}```
I get the following error for averaging p, and I get the same error when performing the operation on faceZones.

[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

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post spwater OpenFOAM 2 February 24, 2010 09:04 csvirume FLUENT 2 September 9, 2009 01:08 robert FLUENT 0 August 1, 2008 09:44 J.Gimbun FLUENT 0 April 27, 2006 08:42 Karl Kevala FLUENT 4 February 21, 2001 16:52

All times are GMT -4. The time now is 22:58.