|
[Sponsors] |
[swak4Foam] groovyBC and funkySetFields married and got a kid named swak4Foam |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 13, 2010, 21:14 |
groovyBC and funkySetFields married and got a kid named swak4Foam
|
#1 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Those who think that groovyBC makes it possible to do stupid things, but think it could be worse, might be interested in avoiding swak4Foam (http://openfoamwiki.net/index.php/Contrib/swak4Foam). It has all the destructive power of this and funkySetFields and allows you to crash simulations, fill disk-space and use more memory than before in many different ways. But if you use it sensible it can be quite useful (but this is boring)
The basic idea behind swak4Foam was to factor out the expression-parsers from groovyBC and funkySetFields and put them into a separate library. That way they can be easily incorporated into other libraries and utilities. As an additional bonus expressions for calculations on cell/face-sets and cell/face-zones are present. Expressions can access values on other entities (patches, zones, etc) the way "old" groovyBC can access other patches Apart from the core-library the bundle contains: - the new groovyBC - the new funkySetFields - functionObjects for arbitrary calculations (as long as there is a field it can be used) on patches and other stuff - a new utility to statically set boundary fields to non-uniform values - and some other little things It was tested on 1.7, but it compiles on 1.6, too. Please note that it is very BETA. So if you want a stable version of funkySetFields or groovyBC get the 1.6-versions. They compile on 1.7 without problems. There will never be a separate version of these two (groovy and funky) for 1.7 All documentation is currently in the Wiki-page and the README. Further hints can be found by looking at the examples (and of course the sources). I have some additional stuff planed, but the basic syntax of the expressions should not change anymore. The API probably will change a bit as I plan to clean it up (but this only affects those who use the core-library for their own stuff) BTW: swak4Foam stands for "SWiss Army Knife For FOAM". I know this is a bit immodest but I couldn't think of any better name ("expressionParsersForFoam": accurate but boring). And the original name was "Project MacGuyver". But I think that is trademarked. Have fun with it and report bugs at http://sourceforge.net/apps/mantisbt...e_status_id=90 Bernhard |
|
September 14, 2010, 03:09 |
|
#2 |
Senior Member
Alberto Passalacqua
Join Date: Mar 2009
Location: Ames, Iowa, United States
Posts: 1,912
Rep Power: 36 |
As usual, thank you!
__________________
Alberto Passalacqua GeekoCFD - A free distribution based on openSUSE 64 bit with CFD tools, including OpenFOAM. Available as in both physical and virtual formats (current status: http://albertopassalacqua.com/?p=1541) OpenQBMM - An open-source implementation of quadrature-based moment methods. To obtain more accurate answers, please specify the version of OpenFOAM you are using. |
|
September 27, 2010, 20:29 |
|
#3 |
Member
Robin Gilbert
Join Date: Jan 2010
Posts: 66
Rep Power: 16 |
Bernhard,
Thank you so much for conducting the marriage . I was looking for a tool to calculate flow rate through a faceZone. |
|
October 6, 2010, 10:15 |
|
#4 |
Member
Fábio César Canesin
Join Date: Mar 2010
Location: Florianópolis
Posts: 67
Rep Power: 16 |
Bernhard,
Thanks for all the contributions, I was looking for an way to insert an equation to eval a variable cp in my code.. I don't want to hardcode the equation, it will be nice to have it written in an dictionary and them parse and eval it. Can I use the swak4Foam parser to do it ?? How ?? In my code cp is very sensible to the magnetic field and temperature.. so I need to include the evaluation of it rigth after the temperature equation solving and do a loop in it, so I have to calculate the volScalarField some times in it... Code:
while () { cpOld = cp; for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { tmp<fvScalarMatrix> TEqn ( fvm::ddt(rho*cp, T) - fvm::laplacian(K, T) ); TEqn().relax(); TEqn().solve(); #include cpEqn.H } if ((sum(cpOld)-sum(cp))/sum(cp) < 1e-6) { delete cpOld; break; } } I believe that this is possible using swak4Foam parser, but how is it ?? I will be very glad if you can help me.. Thanks, Fábio C. Canesin |
|
October 6, 2010, 13:28 |
|
#5 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Have a look at the Examples-Folder: there is a folder called "InterFoamWithSources". The class expressionSource that is used there might be a open to abuse. Basically an expressionSource-object cpExpr is evaluated every time it is called with cpExpr() and it returns a temporay field. So it might even be possible to insert it into the equation like this ddt(rho*cpExpr(),T) (but be aware that it is evaluated every time it is called so from a performance point of view it's better to evaluate it and assign it once) That example is the only time I have used that thing yet, so you might experience problems Bernhard PS: if this is what you're looking for and if it works for you it would be nice if you added a short section on it to the swak-Wikipage |
||
October 7, 2010, 12:10 |
|
#6 | |
Member
Fábio César Canesin
Join Date: Mar 2010
Location: Florianópolis
Posts: 67
Rep Power: 16 |
Quote:
It looks like to be it.. I will adapt and run it as soon as I can. To justify the need for read at run time: my solver is multi-region so every solid region has an cp(T,H) expression. And also I want that the solver is generic enough to run in multiple cases... I will add the cpExp() after the temperature non-orthogonal loop since evaluating it many times with a bad temperature field looks to be an bad solution physically and in performance terms. As soon as I get it running I will report here and add in the swak wikipage .. Best regards, Fabio C. Canesin |
||
October 10, 2010, 14:51 |
|
#7 |
Senior Member
Pierre-Olivier Dallaire
Join Date: Mar 2009
Location: Montreal, Quebec, Canada
Posts: 192
Rep Power: 17 |
Hi Bernhard,
thanks for this great contribution ! I'm trying to compile with gcc 4.3 but have some issues with swakExpressionFunctionObject.C / can you confirm that gcc-4.4 or > is needed ? Regards, PO |
|
October 11, 2010, 05:38 |
|
#8 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Bernhard |
||
October 11, 2010, 06:10 |
|
#9 |
Member
|
Hi Bernhard!
Once more a great tool. Thank you! I'm trying to model an azimuthal magnetic field in a tube. And I want set a non uniform intenal field whith the x and y components of the magnetic field, here are the expressions: Bx=-0.0012/sqrt(x^2+y^20)*sen(arctan(y/x)); By=0.0012/sqrt(x^2+y^20)*cos(arctan(y/x)); Bz=0. This could be done with funkySetFields? At the same time I want to impose this components as a non-uniform boundary conditions at the inlet. For this I can use the groovyBc? Thanks again for your great work! Carlos |
|
October 11, 2010, 09:19 |
|
#10 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
"vector(-0.0012/sqrt(x^2+y^20)*sen(arctan(y/x)),0.0012/sqrt(x^2+y^20)*cos(arctan(y/x)),0)" Either that, or if it is fixed in time you can use the -keepPatches/-valuePatches options of funky. Or if you are adventurous you can use the new funkySetBoundaryFields-utility |
||
October 11, 2010, 09:23 |
|
#11 |
Member
|
I already use both.
funkySetFields and funkySetBoundaryFilelds And it works for me. Excellent tool. Thanks. Carlos |
|
October 11, 2010, 21:08 |
|
#12 | |
Senior Member
Pierre-Olivier Dallaire
Join Date: Mar 2009
Location: Montreal, Quebec, Canada
Posts: 192
Rep Power: 17 |
Quote:
here is what i'm getting : SOURCE=general/swakExpressionFunctionObject.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3 -DNoRepository -ftemplate-depth-40 -I/data-cfd01/projects/OpenFOAM/pod-1.7.x/Libraries/simpleFunctionObjects/lnInclude -I../swak4FoamParsers/lnInclude -I/data-cfd01/software/OpenFOAM/OpenFOAM-1.7.x/src/finiteVolume/lnInclude -I/data-cfd01/software/OpenFOAM/OpenFOAM-1.7.x/src/meshTools/lnInclude -I/data-cfd01/software/OpenFOAM/OpenFOAM-1.7.x/src/sampling/lnInclude -I/data-cfd01/software/OpenFOAM/OpenFOAM-1.7.x/src/triSurface/lnInclude -I/data-cfd01/software/OpenFOAM/OpenFOAM-1.7.x/src/lagrangian/basic/lnInclude -IlnInclude -I. -I/data-cfd01/software/OpenFOAM/OpenFOAM-1.7.x/src/OpenFOAM/lnInclude -I/data-cfd01/software/OpenFOAM/OpenFOAM-1.7.x/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/swakExpressionFunctionObject.o In file included from general/swakExpressionFunctionObject.C:28: general/swakExpressionFunctionObject.H:40:36: error: timelineFunctionObject.H: No such file or directory In file included from general/swakExpressionFunctionObject.C:28: general/swakExpressionFunctionObject.H:56: error: expected class-name before ‘{’ token general/swakExpressionFunctionObject.H:56: warning: ‘class Foam::swakExpressionFunctionObject’ has virtual functions and accessible non-virtual destructor In file included from general/swakExpressionFunctionObject.H:115, from general/swakExpressionFunctionObject.C:28: general/swakExpressionFunctionObjectTemplates.C: In member function ‘void Foam::swakExpressionFunctionObject::writeData(Foam ::CommonValueExpressionDriver&)’: general/swakExpressionFunctionObjectTemplates.C:68: error: there are no arguments to ‘verbose’ that depend on a template parameter, so a declaration of ‘verbose’ must be available general/swakExpressionFunctionObjectTemplates.C:68: error: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated) general/swakExpressionFunctionObjectTemplates.C:76: error: ‘OFstream’ was not declared in this scope general/swakExpressionFunctionObjectTemplates.C:76: error: ‘o’ was not declared in this scope general/swakExpressionFunctionObjectTemplates.C:76: error: ‘filePtrs_’ was not declared in this scope general/swakExpressionFunctionObjectTemplates.C:76: error: no matching function for call to ‘name()’ ... For some reason, file timelineFunctionObject.H is not available. Thanks PO |
||
October 12, 2010, 08:17 |
|
#13 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
/data-cfd01/projects/OpenFOAM/pod-1.7.x/Libraries/simpleFunctionObjects/ Bernhard |
||
October 12, 2010, 08:42 |
|
#14 | |
Senior Member
Pierre-Olivier Dallaire
Join Date: Mar 2009
Location: Montreal, Quebec, Canada
Posts: 192
Rep Power: 17 |
Quote:
|
||
November 22, 2010, 05:05 |
|
#15 |
Member
Antonio Liggieri
Join Date: Aug 2010
Posts: 76
Rep Power: 15 |
Hello Bernhard,
I need to create a source and a sink in a model using reacting foam, but with reactions switched off. I have a region acting as source for the components CO2, H2O and CO, and a region acting as a sink for O2. 1.Question: is this pricipally realizable with swak4Foam? if so 2. As I didn't find any example for swakSourceFields in the net, could you post an example for the synthax to creating a source/sink? Thanks a lot in advance, Tony |
|
November 22, 2010, 06:45 |
|
#16 | ||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Quote:
https://openfoam-extend.svn.sourcefo...amWithSources/ in fact it is described in the README (https://openfoam-extend.svn.sourcefo...ak4Foam/README) Anyway. The problem is in your case that the fields for which the expressions should be applied are only known at runtime so a single source-field won't do, but you'll need a Map of sourceFields where the appropriate one is chosen according to the name of the currently used field (nothing impossible, just an interesting programming problem). Anyway. You'll have to modify the solver anyway. Bernhard |
|||
November 24, 2010, 12:01 |
ternary operators and polar coordinates in groovyBC
|
#17 |
Senior Member
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19 |
Bernard,
Thanks a lot, I have just downloaded and installed the new groovyBC, funkySetField and the swap4Foam part, and already encountered all kind of very handy new features. Brilliant! Well, let me take to opportunity to ask two small questions I of features I was looking for for a while. Perhaps you (or anybody) knows a quick answer. 1: is it possible to make an 'if-then-elseif-then-else-' construction with the ternary expression? In gnuplot (also based on c-ternaries) it is possible for instance to do f(x)= x<0 ? 0 : x>=0 && x<1 ? 2 : 1 but this doesn't seem to work in groovyBC. No I solve it by splitting it up: f1(x) = x<0?0:0 f2(x) = x>=0 && x<1 ? 2 : 0 f3(x) = x>=1 ? 1:0 f(x)=f1(x)+f2(x)+f3(x) it works, but expressions tend to become rather complex. Well, perhaps there is a way to do it easier 2: Is there a way to convert cartesian coordinates into polar coordinates of a vector easily ? Or should I just write down the conversion expressions based on x,y, and z ? Well, again. Thanks! With groovyBC, openFOAM life definitely becomes a lot easier! Regards, Eelco |
|
November 25, 2010, 08:04 |
|
#18 | |||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Quote:
Code:
x<0 ? 0 : x>=0 && x<1 ? 2 : 1 Anyway. I'm notoriously bad with remembering operator precedence and therefor believe "brackets are our friend": Code:
x<0 ? 0 : (x>=0 && x<1 ? 2 : 1) Code:
x<0 ? 0 : ((x>=0 && x<1) ? 2 : 1) Quote:
Not sure whether funkySetFields supports "variables" yet (it was on the TODO-list once) but that would make these expressions more readable Bernhard |
||||
November 25, 2010, 12:30 |
thanks!
|
#19 |
Senior Member
Eelco van Vliet
Join Date: Mar 2009
Location: The Netherlands
Posts: 124
Rep Power: 19 |
Hi Bernard,
The way you are suggesting works! Using the nesting brackets around each 'then statement' is the key. Thanks! Regards Eelco |
|
November 29, 2010, 09:57 |
|
#20 |
Member
Antonio Liggieri
Join Date: Aug 2010
Posts: 76
Rep Power: 15 |
Hello Bernhard,
I am currently trying to setup a case using groovyBC for a heatflux BC. The heatflux is adressed to a surface. The area of the surface is fixed but apperently far too small for the given heat release rate - the temperatures close to the surface are exorbitant high. In CFX I would define a subdomain with a volume source term. Is this with your new tool possible? Best, Tony |
|
|
|