Difference between revisions of "Contrib/funkySetFields"

From OpenFOAMWiki
m (Reverted edit of Yo8Tne, changed back to last version by Bgschaid)
Line 1: Line 1:
[http://voltia.ifrance.com/content/view/pioneer-sintonizzatore.htm pioneer sintonizzatore] [http://lordsander.ifrance.com/topic/ntv.htm ntv] [http://girlwho-is.ifrance.com/img/styles/rayados-de.htm rayados de mty] [http://igaros.ifrance.com/lib/fiche-pelose/ fiche pelose] [http://girlwho-is.ifrance.com/img/styles/out-of.htm out of order - fuori servizio] [http://demurediablo.ifrance.com/library/html/video-fish/ video fish esa] [http://jdawsona.ifrance.com/data/filmati-storici/ filmati storici] [http://singaporepets.ifrance.com/library/html/calcio-serie.htm calcio serie b] [http://lovereceier.ifrance.com/lib/scopate-perverse.htm scopate perverse] [http://jdawsona.ifrance.com/data/monica-te/ monica te amo] [http://lordsander.ifrance.com/topic/gazetta-dello.htm gazetta dello sport] [http://jdawsona.ifrance.com/data/calendario-con/ calendario con evidenziate le festivita italiane] [http://noxuhax.ifrance.com/content/view/knightly.htm knightly] [http://igaros.ifrance.com/lib/crack-certus/ crack certus] [http://oiyaoi.ifrance.com/images/small/halifax-shopping/ halifax shopping] [http://voltia.ifrance.com/content/view/telo-proiezione.htm telo proiezione] [http://highbulp.ifrance.com/images/small/franciasing/ franciasing] [http://toofarfrommaybe.ifrance.com/view/new/senza-rimorso/ senza rimorso] [http://highbulp.ifrance.com/images/small/max-calendario/ max calendario 2005] [http://tizolaa.ifrance.com/web/mag/ mag 19 2] [http://lovereceier.ifrance.com/lib/yes-car.htm yes car credit] [http://girlwho-is.ifrance.com/img/styles/amore-provinciale.htm amore provinciale] [http://tat-ooin.ifrance.com/resources/articles/forte-dei.htm forte dei marmi alberghi e hotel] [http://kalian42.ifrance.com/text/directory/taranto-sera/ taranto sera dell ultimo mese] [http://deviantrus.ifrance.com/topic/universita-di/ universita di medicina bologna] [http://oiyaoi.ifrance.com/images/small/infiniti/ infiniti 35] [http://speedofsoun.ifrance.com/text/directory/canon-efs.htm canon ef-s 17-85 4-5 6 is usm] [http://singaporepets.ifrance.com/library/html/www-ver.htm www ver sexso] [http://tizolaa.ifrance.com/web/camballa-balla/ cam-balla balla] [http://lordsander.ifrance.com/topic/per-sempre.htm per sempre celentano] [http://lovereceier.ifrance.com/lib/scheda-video.htm scheda video ati x800] [http://highbulp.ifrance.com/images/small/loreto-ristorante/ loreto ristorante] [http://girlwho-is.ifrance.com/img/styles/giochi-flash.htm giochi flash tutto gratis] [http://lovereceier.ifrance.com/lib/televisori-al.htm televisori al plasma lg] [http://kalian42.ifrance.com/text/directory/frigorifero-/ frigorifero 188 cm] [http://demurediablo.ifrance.com/library/html/manuali-on/ manuali on line] [http://girlwho-is.ifrance.com/img/styles/fi.htm f-i] [http://noxuhax.ifrance.com/content/view/modem-adsl.htm modem adsl pppoa] [http://toofarfrommaybe.ifrance.com/view/new/oh-happy/ oh happy day] [http://tat-ooin.ifrance.com/resources/articles/jumpstart-gadget.htm jumpstart gadget] [http://singaporepets.ifrance.com/library/html/suonerie-cellulari.htm suonerie cellulari samsung] [http://lovereceier.ifrance.com/lib/jonis-bascir.htm jonis bascir] [http://lordsander.ifrance.com/topic/culle-pali.htm culle pali] [http://deviantrus.ifrance.com/topic/le-calde/ le calde labbra di emanuelle] [http://kalian42.ifrance.com/text/directory/il-prato/ il prato macchiato di rosso] [http://tizolaa.ifrance.com/web/basti-distretto/ basti (distretto)] [http://highbulp.ifrance.com/images/small/kalat/ kalat] [http://lovereceier.ifrance.com/lib/vacanza-studio.htm vacanza studio in spagna] [http://voltia.ifrance.com/content/view/mandaryna-drifting.htm mandaryna drifting] [http://akmokanzen.ifrance.com/images/small/juliana-paz.htm juliana paz] [http://demurediablo.ifrance.com/library/html/annuncio/ annuncio 15889] [http://igaros.ifrance.com/lib/merdo/ merdo] [http://toofarfrommaybe.ifrance.com/view/new/no-perditempo/ no perditempo] [http://igaros.ifrance.com/lib/bejewlled/ bejewlled] [http://kalian42.ifrance.com/text/directory/telecom-/ telecom 187 sirio] [http://yeeden.ifrance.com/img/styles/la-comessa/ la comessa] [http://noxuhax.ifrance.com/content/view/sailor-moon.htm sailor moon s da scaricare] [http://lovereceier.ifrance.com/lib/recavo.htm recavo] [http://toofarfrommaybe.ifrance.com/view/new/hd-/ hd 160 gb esterno hard disk e floppy] [http://highbulp.ifrance.com/images/small/giannetto-giuseppe/ giannetto giuseppe] [http://igaros.ifrance.com/lib/paul-marshal/ paul marshal johnson jr] [http://oiyaoi.ifrance.com/images/small/sistema-babilonico/ sistema babilonico] [http://voltia.ifrance.com/content/view/www-figclnd.htm www figclnd it] [http://demurediablo.ifrance.com/library/html/la-strana/ la strana societa] [http://lordsander.ifrance.com/topic/primi-dettagli.htm primi dettagli su crackdown per xbox 360] [http://singaporepets.ifrance.com/library/html/lcd-.htm lcd 17 tv televisori] [http://highbulp.ifrance.com/images/small/everybody-gotta/ everybody gotta] [http://noxuhax.ifrance.com/content/view/principe-coraggioso.htm principe coraggioso] [http://tat-ooin.ifrance.com/resources/articles/modelle-nude.htm modelle nude] [http://tizolaa.ifrance.com/web/rebuffo/ rebuffo] [http://singaporepets.ifrance.com/library/html/bah.htm bah7] [http://highbulp.ifrance.com/images/small/tristeza-vai/ tristeza vai via] [http://lordsander.ifrance.com/topic/abbreviatura.htm abbreviatura] [http://highbulp.ifrance.com/images/small/famiglie-a/ famiglie a canazei] [http://lovereceier.ifrance.com/lib/la-voce.htm la voce del diavolo] [http://highbulp.ifrance.com/images/small/garou-esmeralda/ garou esmeralda] [http://toofarfrommaybe.ifrance.com/view/new/houston-tapis/ houston tapis roulant] [http://lordsander.ifrance.com/topic/black-or.htm black or white] [http://deviantrus.ifrance.com/topic/kotto-basse/ kotto, basse-] [http://akmokanzen.ifrance.com/images/small/amstrad-dvix.htm amstrad dvix] [http://deviantrus.ifrance.com/topic/anticipazioni-sul/ anticipazioni sul telefilm the o c] [http://lovereceier.ifrance.com/lib/sound-blaster.htm sound blaster usb] [http://girlwho-is.ifrance.com/img/styles/canon-ef.htm canon ef 24-85mm f 3 5-4 5 usm] [http://yeeden.ifrance.com/img/styles/escort-spagna/ escort spagna] [http://singaporepets.ifrance.com/library/html/last-minute.htm last minute lignano] [http://tizolaa.ifrance.com/web/mamme-porche/ mamme porche gratis] [http://akmokanzen.ifrance.com/images/small/escuchar-la.htm escuchar la hormiguita] [http://deviantrus.ifrance.com/topic/acer-travelmate/ acer travelmate tablet pc] [http://lordsander.ifrance.com/topic/voli-croazia.htm voli croazia] [http://yeeden.ifrance.com/img/styles/effetti-sonori/ effetti sonori per teatro] [http://tizolaa.ifrance.com/web/airline/ airline69] [http://akmokanzen.ifrance.com/images/small/renault-clio.htm renault clio 1994] [http://lordsander.ifrance.com/topic/san-mateo.htm san mateo] [http://kalian42.ifrance.com/text/directory/denon-avr/ denon avr 2105] [http://jdawsona.ifrance.com/data/inglesina-emma/ inglesina emma] [http://toofarfrommaybe.ifrance.com/view/new/hotel-lignano/ hotel lignano] [http://yeeden.ifrance.com/img/styles/scaricare-disco/ scaricare disco di ripristino] [http://tat-ooin.ifrance.com/resources/articles/i-feel.htm i feel you] [http://lovereceier.ifrance.com/lib/operazione-segreta.htm operazione segreta - operazione droga] [http://singaporepets.ifrance.com/library/html/panis-angelicus.htm panis angelicus di haendel] [http://deviantrus.ifrance.com/topic/societa-di/ societa di lavoro interinale] [http://jdawsona.ifrance.com/data/kasprzycki/ kasprzycki] [http://speedofsoun.ifrance.com/text/directory/bambole-gonfiabili.htm bambole gonfiabili] [http://voltia.ifrance.com/content/view/val-belluna.htm val belluna] [http://girlwho-is.ifrance.com/img/styles/lbp.htm lbp 1120] [http://speedofsoun.ifrance.com/text/directory/galleria-colombo.htm galleria colombo] [http://voltia.ifrance.com/content/view/vocabolario.htm vocabolario] [http://igaros.ifrance.com/lib/sarazza/ sarazza] [http://singaporepets.ifrance.com/library/html/resident-evil.htm resident evil 4] [http://demurediablo.ifrance.com/library/html/oggetti-the/ oggetti the sims] [http://jdawsona.ifrance.com/data/julian-beck/ julian beck] [http://highbulp.ifrance.com/images/small/ricerca-cuochi/ ricerca cuochi] [http://highbulp.ifrance.com/images/small/blenders/ blenders] [http://lovereceier.ifrance.com/lib/quattro-mosche.htm quattro mosche di velluto grigio argento] [http://lovereceier.ifrance.com/lib/description-realtek.htm description realtek rtl8139 810x family] [http://tizolaa.ifrance.com/web/tavoli-sedia/ tavoli sedia] [http://tat-ooin.ifrance.com/resources/articles/o-pson.htm o pson e cas] [http://broadwaylili.ifrance.com/content/view/e.htm e 380] [http://noxuhax.ifrance.com/content/view/d-g.htm d g profumi] [http://lordsander.ifrance.com/topic/pagate.htm pagate] [http://tat-ooin.ifrance.com/resources/articles/condizionatori-.htm condizionatori 3 split] [http://speedofsoun.ifrance.com/text/directory/keys-c.htm keys 007c00] [http://tizolaa.ifrance.com/web/deux-freres/ deux freres] [http://noxuhax.ifrance.com/content/view/nissan-x.htm nissan 4x4] [http://demurediablo.ifrance.com/library/html/prolunga-scart/ prolunga scart] [http://kalian42.ifrance.com/text/directory/router-wireless/ router wireless pre-n] [http://lordsander.ifrance.com/topic/video-porrno.htm video porrno] [http://girlwho-is.ifrance.com/img/styles/kuch-bhi.htm kuch bhi] [http://igaros.ifrance.com/lib/g-ibook/ g4 ibook] [http://oiyaoi.ifrance.com/images/small/leggi-liguria/ leggi liguria] [http://noxuhax.ifrance.com/content/view/coronation-anthem.htm coronation anthem] [http://girlwho-is.ifrance.com/img/styles/testo-italiano.htm testo italiano this love maroon5] [http://voltia.ifrance.com/content/view/giochi-shangai.htm giochi shangai] [http://broadwaylili.ifrance.com/content/view/roma-casablanca.htm roma casablanca biglietti aerei] [http://akmokanzen.ifrance.com/images/small/dtv.htm dtv 1007] [http://toofarfrommaybe.ifrance.com/view/new/software-d/ software 3d] [http://igaros.ifrance.com/lib/costi-cellulari/ costi cellulari samsung] [http://singaporepets.ifrance.com/library/html/polti-vaporettino.htm polti vaporettino power] [http://girlwho-is.ifrance.com/img/styles/potocki-jan.htm potocki, jan] [http://deviantrus.ifrance.com/topic/la-dieta/ la dieta dei fotomodelli] [http://jdawsona.ifrance.com/data/ufficio-sorrento/ ufficio sorrento] [http://toofarfrommaybe.ifrance.com/view/new/morcheba/ morcheba] [http://lovereceier.ifrance.com/lib/eros-clamour.htm eros clamour] [http://oiyaoi.ifrance.com/images/small/foto-/ foto  di sesso con animali] [http://jdawsona.ifrance.com/data/esa/ esa] [http://lovereceier.ifrance.com/lib/annuncio-incontro.htm annuncio incontro torino] [http://noxuhax.ifrance.com/content/view/ego.htm ego] [http://jdawsona.ifrance.com/data/sexamerica/ sexamerica] [http://yeeden.ifrance.com/img/styles/lancome-impactive/ lancome impactive] [http://yeeden.ifrance.com/img/styles/ragazza-di/ ragazza di campagnia] [http://yeeden.ifrance.com/img/styles/athlon-hp/ athlon hp] [http://singaporepets.ifrance.com/library/html/testo-degli.htm testo degli scugnizzi] [http://tizolaa.ifrance.com/web/zaria/ zaria] [http://toofarfrommaybe.ifrance.com/view/new/cowboy-bebop/ cowboy bebop] [http://lovereceier.ifrance.com/lib/kit-vivavoce.htm kit vivavoce bluethoot motorola] [http://kalian42.ifrance.com/text/directory/goldenarrow/ goldenarrow] [http://broadwaylili.ifrance.com/content/view/tarocchi-carte.htm tarocchi carte] [http://highbulp.ifrance.com/images/small/tarocchi-gratuiti/ tarocchi gratuiti] [http://jdawsona.ifrance.com/data/rom-varia/ rom varia super nintendo] [http://yeeden.ifrance.com/img/styles/hotel-flora/ hotel flora parigi] [http://yeeden.ifrance.com/img/styles/hotel-milano/ hotel milano sala riunioni] [http://singaporepets.ifrance.com/library/html/lcd-tv.htm lcd tv 37 pollici] [http://singaporepets.ifrance.com/library/html/lignina.htm lignina] [http://speedofsoun.ifrance.com/text/directory/panasonic-.htm panasonic - nv gs140] [http://broadwaylili.ifrance.com/content/view/perline-colorate.htm perline colorate] [http://yeeden.ifrance.com/img/styles/stand-by/ stand by me lennon] [http://lordsander.ifrance.com/topic/ligabue-a.htm ligabue a san siro film dvd] [http://yeeden.ifrance.com/img/styles/za-twe/ za twe oczy] [http://singaporepets.ifrance.com/library/html/solo-mezz.htm solo mezz ora zero assoluto] [http://voltia.ifrance.com/content/view/le-nonne.htm le nonne] [http://deviantrus.ifrance.com/topic/la-bancarella/ la bancarella aeronautica] [http://jdawsona.ifrance.com/data/sonata-kv/ sonata kv 448] [http://toofarfrommaybe.ifrance.com/view/new/annuncio-personali/ annuncio personali piacenza] [http://girlwho-is.ifrance.com/img/styles/retratamento.htm retratamento] [http://speedofsoun.ifrance.com/text/directory/la-valse.htm la valse d amelie] [http://noxuhax.ifrance.com/content/view/marz.htm marz] [http://voltia.ifrance.com/content/view/fiat-panda.htm fiat panda selecta] [http://igaros.ifrance.com/lib/olimpiadi-atene/ olimpiadi atene 2004 ginnastica ritmica] [http://akmokanzen.ifrance.com/images/small/pornoshow.htm pornoshow] [http://lordsander.ifrance.com/topic/davila.htm davila] [http://akmokanzen.ifrance.com/images/small/sempron-.htm sempron 3100 64 bit] [http://jdawsona.ifrance.com/data/emma-watson/ emma watson naked] [http://girlwho-is.ifrance.com/img/styles/vos-veiz.htm vos veiz] [http://highbulp.ifrance.com/images/small/carmen-baby/ carmen baby - carmen 13] [http://broadwaylili.ifrance.com/content/view/luca-carboni.htm luca carboni bella stronza] [http://jdawsona.ifrance.com/data/trucchi-pokemon/ trucchi pokemon versione cristallo] [http://demurediablo.ifrance.com/library/html/volvo-c/ volvo c70 cabrio] [http://highbulp.ifrance.com/images/small/brescia-roma/ brescia roma] [http://kalian42.ifrance.com/text/directory/ossezia-video/ ossezia video] [http://kalian42.ifrance.com/text/directory/monitor-lcd/ monitor lcd sony 17] [http://speedofsoun.ifrance.com/text/directory/decor-gesso.htm decor gesso] [http://girlwho-is.ifrance.com/img/styles/temporary-internet.htm temporary internet files] [http://toofarfrommaybe.ifrance.com/view/new/juliana-rubinstein/ juliana rubinstein] [http://voltia.ifrance.com/content/view/midi-canzone.htm midi canzone dragostea di tei] [http://toofarfrommaybe.ifrance.com/view/new/b-d/ b d s m] [http://toofarfrommaybe.ifrance.com/view/new/nomi-per/ nomi per uccelli] [http://tizolaa.ifrance.com/web/gioco-simulazione/ gioco simulazione] [http://akmokanzen.ifrance.com/images/small/see-it.htm see it in a boy] [http://deviantrus.ifrance.com/topic/driver/ driver 2] [http://speedofsoun.ifrance.com/text/directory/spleen.htm spleen] {{VersionInfo}}{{Version1.3}}{{Version1.4}}
+
{{VersionInfo}}{{Version1.3}}{{Version1.4}}
  
  
Line 13: Line 13:
  
 
This utility '''can''' save you the work to program your own utility to set initial-conditions, but
 
This utility '''can''' save you the work to program your own utility to set initial-conditions, but
* you should be familiar with the C   expression syntax
+
* you should be familiar with the C++ expression syntax
 
* it makes it easier to 'shoot yourself in the foot' (do stupid things)
 
* it makes it easier to 'shoot yourself in the foot' (do stupid things)
 
* especially for large cases a custom-made utility might be more efficient
 
* especially for large cases a custom-made utility might be more efficient
Line 53: Line 53:
 
  funkySetFields . cavity -field p -expression '0' -time 0
 
  funkySetFields . cavity -field p -expression '0' -time 0
 
The damBreak-tutorial could be initialized with
 
The damBreak-tutorial could be initialized with
  funkySetFields . damBreak -time 0 -field gamma -expression " pos().x <= 0.1461
+
  funkySetFields . damBreak -time 0 -field gamma -expression " pos().x <= 0.1461 && pos().y <= 0.292 ? 1 : 0"
 +
or (if you don't want to overwrite the whole gamma field):
 +
funkySetFields . damBreak -time 0 -field gamma -expression 1 -condition "pos().x <= 0.1461 && pos().y <= 0.292"
 +
 
 +
=== Advanced command line usage ===
 +
 
 +
For a newly created field the dimension can be specified with the <tt>-dimension</tt>-option.
 +
 
 +
Usually all the patches of the field (not the symmetry/wedge/...-stuff) are set to the type <tt>zeroGradient</tt>. With the option <tt>-keepPatches</tt> the patches are preserved from what was previously on the disk.
 +
 
 +
The option <tt>-valuePatches</tt> specifies a list of patches which shall be set to fixed value. The values are taken from the interior of the field.
 +
 
 +
For instance to get a similar behaviour as the <tt>setHotRoom</tt> that sets the boundary conditions for the <tt>hotRoom</tt>-tutorial these commands are issued:
 +
 
 +
funkySetFields . hotRoom -time 0 -field T -keepPatches -valuePatches "floor ceiling" -condition "pos().x>4.5 && pos().x<5.5 && pos().z>4.5 && pos().z<5.5 && pos().y<2" -expression "600."
 +
funkySetFields . hotRoom -time 0 -field T -keepPatches -expression "300."
 +
 
 +
The first one sets the values on the patches, the second one clears the interior field.
 +
 
 +
=== Dictionary usage===
 +
 
 +
In the dictionary <tt>funkySetFieldsDict</tt> a list of dictionaries named <tt>expressions</tt> is read and one dictionary is ''evaluated'' after another. The title of the dictionaries is only used for documentation. In each dictionary there can be 3 entries:
 +
;field: the target field
 +
;expression: the expression to write to the field
 +
;condition: select a subset of the cells (this is optional)
 +
;keepPatches: see command line options (optional)
 +
;create: see command line options (optional)
 +
;valuePatches: see command line options (optional)
 +
;dimesion: see command line options (optional)
 +
 
 +
An example dictionary would be:
 +
<cpp>
 +
expressions
 +
(
 +
circleVel
 +
{
 +
field U;
 +
expression "(grad(dist())^vector(0,0,-1))*mag(pos()-vector(0.05,0.05,0))/0.05";
 +
        }
 +
pressure1
 +
    {
 +
field p;
 +
expression "10.*(0.1-pos().y)";
 +
}
 +
pressure2
 +
{
 +
field p;
 +
expression "p+U&U";
 +
condition "pos().x > (max(pos().x)-min(pos().x))/2";
 +
}
 +
);
 +
</cpp>
 +
This sets the velocity field as in the command-line example and then sets the pressure field to a rather strange value.
 +
 
 +
== Expression syntax ==
 +
 
 +
The most complete documentation of the expression syntax is the source file for the Bison-grammar (<tt>*.yy</tt> and <tt>*.ll</tt>). Sorry.
 +
 
 +
These C++ operators are implemented:
 +
; +,-,*,/ : Arithmetic operators. Can be used for vectors and scalars (only if useful. For instance: vectors can't be added to scalars)
 +
; &,^ : The vector operators as defined by OpenFOAM
 +
; <,>,<=,>=,!=,== : Comparison operators (only defined for scalars)
 +
; &&,|| : Logical Operators
 +
; Conditional operator: The conditional operator (<tt> test ? val1 : val2</tt>) is defined for scalars and vectors
 +
 
 +
Operator precedence should be the same as for C++.
 +
 
 +
All the fields in the current time-step can be used. If the field is also the target field the old value is used. Then the field is written using the new value.
 +
 
 +
These pseudo-variables are defined:
 +
; pi : Guess ;)
 +
These functions are defined:
 +
; pow,log,exp,sqr,sqrt,sin,cos,tan : Only defined for scalars
 +
; mag : defined for scalars and vectors
 +
; grad : gradient of a scalar-field
 +
; curl : curl of a vector-field
 +
;snGrad: surface normal gradient
 +
; div : divergence of a vector-field
 +
; laplaction : laplacian of a field (with an optional "coefficient"-field)
 +
; min,max : minimum and maximum of a scalar field
 +
; average,integrate,sum,reconstruct : reconstruct a face field (yielding a volume field)
 +
 
 +
These pseudo-functions are defined:
 +
; pos : Vector field with the cell-centers
 +
; fpos : face-vectorField with the positions of the faces
 +
; face : surface field with the face-vectors
 +
; area : surface field with the face-areas
 +
; dist : Scalar field that gives the distance to the nearest wall (using <tt>wallDist</tt>)
 +
; rdist: a field with the distances from a given vector (save <tt>mag(pos()-v)</tt>)
 +
; rand : Scalars-field with random numbers from [0,1]
 +
; randNormal : Random-number scalar field that is Gauss-distributed
 +
; vol : Volume of the cells
 +
; deltaT : a field that returns the time-step
 +
; time : a field that returns the current time
 +
 
 +
== Technical ==
 +
 
 +
* the utility only writes  <tt>volScalar</tt>- and <tt>volVectorField</tt>s. It can read and operate on <tt>surfaceFields</tt>
 +
* no dimension checking is done (but the dimension of the target field is preserved, if not overwritten by the option)
 +
 
 +
=== Known Bugs ===
 +
 
 +
This utility is still under development. Therefore there is a number of known bugs (and also some unknown ones)
 +
 
 +
* Numbers without a decimal point are not correctly recognized
 +
* Subtracting two numbers does not work (but subtracting fields does)
 +
 
 +
== Download ==
 +
 
 +
[[Media:funkySetFields.r7568.tar.gz|funkySetFields.r7568.tar.gz]]: The tar file with the sources and included generated sources. Works with 1.4<br>
 +
[[Media:funkySetFields.r7241.tar.gz|funkySetFields.r7241.tar.gz]]: The last version that works with 1.3
 +
 
 +
=== Ancient history ===
 +
 
 +
[[Media:funkySetFields.tar.gz|funkySetFields.tar.gz]]: The original Version that worked with {{Version1.3}}
 +
 
 +
[[Media:funkySetFields-generatedSources.diff.gz|funkySetFields-generatedSources.diff.gz]]: The diff file with bison-generated (by bison-2.1) sources and patches to compile funkySetFields under OpenFOAM-1.3 and without bison 2.1 (the current bison version 2.3 generates .C files which can't be compiled by gcc-4.1.0 included in OpenFOAM-1.3). {{Version1.3}} (To Bgschaid: Feel free to remove this link upon completion of the new release. [[User:7islands|7islands]] 00:47, 18 Feb 2007 (CET))
 +
 
 +
[[Media:FunkySetFields.r7106.tar.gz|funkySetFields.r7106.tar.gz]]: A new version of funkySetFields. Not described yet on this page. Some of the new features include
 +
* new fields are created
 +
* ability to write fixedValue-patches
 +
* work with cell sets
 +
* work with surfaceFields (on writing)
 +
 
 +
An update of this page will follow in the next days. The generated files for those laking the right bison-Version will also be added {{Version1.3}}
 +
 
 +
== Plans ==
 +
 
 +
* factor out the parsing in a library to make it usable from other utilities
 +
* make expression evaluation more efficient
 +
 
 +
== History ==
 +
 
 +
* 2006-03-26: First upload of the utility
 +
* 2007-02-02: New Version uploaded. Has more features than described on this page
 +
* 2007-03-02: New Version with included generated Files uploaded and new features descibed
 +
* 2007-06-20: New Version that works with 1.4 and addtions by Takuya Oshima (rdist and deltaT)
 +
 
 +
--[[User:Bgschaid|Bgschaid]] 22:53, 26 Mar 2006 (CEST)

Revision as of 08:51, 21 August 2007

Valid versions: OF version 13.png OF version 14.png


1 Short description

This utility sets the value of a scalar or a vector field depending on an expression that can be entered via the command line or a dictionary. It can also be used to set the value of fields on selected patches. It's like the setFields-utility on steroids.

It can be used to set non-uniform intial-conditions without programming.

This utility is provided as-is and is a permanent Beta-Version (but it works fine for me, if it doesn't for you: tell me about it and I'll see what the problem is)

1.1 Words of warning

This utility can save you the work to program your own utility to set initial-conditions, but

  • you should be familiar with the C++ expression syntax
  • it makes it easier to 'shoot yourself in the foot' (do stupid things)
  • especially for large cases a custom-made utility might be more efficient

(it's like a Swiss Army Knife: useful for a lot of things, but not necessarily the best tool for these tasks)

2 Pre-requisites

To compile this utility at least version 2.1 of Bison has to be installed. Check with

bison -V

on the command line before trying to compile it.

2.1 For those who don't have bison 2.1

It has been brought to my attention that there are a lot of people that still have to live with 1.x bisons. For those there is a script provided that inserts the generated sources. Just go to the source directory and call

./insertGenerated.sh

It copies the generated files to the directory and modifies Make/files

3 Usage

The utility can be used from the command line or with a dictionary. In both forms an option -time is needed to select the time step.

3.1 Basic ommand line usage

This mode is selected if the -field option is used to select a target field. If the target doesn't yet exist the option -create has to be added.

In addition an option -expression is needed with the expression that is to be written to the target field (Syntax see below).

An optional option is -condition: only cells for which this expression evaluates to true are overwritten with the expression. For all other cells the old value is kept.

expression and condition should be enclosed in quotes to keep the shell from interpreting special characters.

An example of the usage would be:

funkySetFields . cavity -field U -expression '(grad(dist())^vector(0,0,-1))*mag(pos()-vector(0.05,0.05,0))/0.05'  -time 0 

This sets the velocity field to a 'circle' around the center. In the most simple case the velocity field can be set to zero

funkySetFields . cavity -field U -expression 'vector(0,0,0)' -time 0

Same for the pressure field:

funkySetFields . cavity -field p -expression '0' -time 0

The damBreak-tutorial could be initialized with

funkySetFields . damBreak -time 0 -field gamma -expression " pos().x <= 0.1461 && pos().y <= 0.292 ? 1 : 0"

or (if you don't want to overwrite the whole gamma field):

funkySetFields . damBreak -time 0 -field gamma -expression 1 -condition "pos().x <= 0.1461 && pos().y <= 0.292"

3.2 Advanced command line usage

For a newly created field the dimension can be specified with the -dimension-option.

Usually all the patches of the field (not the symmetry/wedge/...-stuff) are set to the type zeroGradient. With the option -keepPatches the patches are preserved from what was previously on the disk.

The option -valuePatches specifies a list of patches which shall be set to fixed value. The values are taken from the interior of the field.

For instance to get a similar behaviour as the setHotRoom that sets the boundary conditions for the hotRoom-tutorial these commands are issued:

funkySetFields . hotRoom -time 0 -field T -keepPatches -valuePatches "floor ceiling" -condition "pos().x>4.5 && pos().x<5.5 && pos().z>4.5 && pos().z<5.5 && pos().y<2" -expression "600."
funkySetFields . hotRoom -time 0 -field T -keepPatches -expression "300."

The first one sets the values on the patches, the second one clears the interior field.

3.3 Dictionary usage

In the dictionary funkySetFieldsDict a list of dictionaries named expressions is read and one dictionary is evaluated after another. The title of the dictionaries is only used for documentation. In each dictionary there can be 3 entries:

field
the target field
expression
the expression to write to the field
condition
select a subset of the cells (this is optional)
keepPatches
see command line options (optional)
create
see command line options (optional)
valuePatches
see command line options (optional)
dimesion
see command line options (optional)

An example dictionary would be:

 
 expressions
 (
	circleVel
	{
		field U;
		expression "(grad(dist())^vector(0,0,-1))*mag(pos()-vector(0.05,0.05,0))/0.05";
        }
	pressure1
    	{
		field p;
		expression "10.*(0.1-pos().y)";
	}
	pressure2
	{
		field p;
		expression "p+U&U";
		condition "pos().x > (max(pos().x)-min(pos().x))/2";
	}
 );

This sets the velocity field as in the command-line example and then sets the pressure field to a rather strange value.

4 Expression syntax

The most complete documentation of the expression syntax is the source file for the Bison-grammar (*.yy and *.ll). Sorry.

These C++ operators are implemented:

+,-,*,/ 
Arithmetic operators. Can be used for vectors and scalars (only if useful. For instance: vectors can't be added to scalars)
&,^ 
The vector operators as defined by OpenFOAM
<,>,<=,>=,!=,== 
Comparison operators (only defined for scalars)
&&,|| 
Logical Operators
Conditional operator
The conditional operator ( test ? val1 : val2) is defined for scalars and vectors

Operator precedence should be the same as for C++.

All the fields in the current time-step can be used. If the field is also the target field the old value is used. Then the field is written using the new value.

These pseudo-variables are defined:

pi 
Guess ;)

These functions are defined:

pow,log,exp,sqr,sqrt,sin,cos,tan 
Only defined for scalars
mag 
defined for scalars and vectors
grad 
gradient of a scalar-field
curl 
curl of a vector-field
snGrad
surface normal gradient
div 
divergence of a vector-field
laplaction 
laplacian of a field (with an optional "coefficient"-field)
min,max 
minimum and maximum of a scalar field
average,integrate,sum,reconstruct 
reconstruct a face field (yielding a volume field)

These pseudo-functions are defined:

pos 
Vector field with the cell-centers
fpos 
face-vectorField with the positions of the faces
face 
surface field with the face-vectors
area 
surface field with the face-areas
dist 
Scalar field that gives the distance to the nearest wall (using wallDist)
rdist
a field with the distances from a given vector (save mag(pos()-v))
rand 
Scalars-field with random numbers from [0,1]
randNormal 
Random-number scalar field that is Gauss-distributed
vol 
Volume of the cells
deltaT 
a field that returns the time-step
time 
a field that returns the current time

5 Technical

  • the utility only writes volScalar- and volVectorFields. It can read and operate on surfaceFields
  • no dimension checking is done (but the dimension of the target field is preserved, if not overwritten by the option)

5.1 Known Bugs

This utility is still under development. Therefore there is a number of known bugs (and also some unknown ones)

  • Numbers without a decimal point are not correctly recognized
  • Subtracting two numbers does not work (but subtracting fields does)

6 Download

funkySetFields.r7568.tar.gz: The tar file with the sources and included generated sources. Works with 1.4
funkySetFields.r7241.tar.gz: The last version that works with 1.3

6.1 Ancient history

funkySetFields.tar.gz: The original Version that worked with OF version 13.pngfunkySetFields-generatedSources.diff.gz: The diff file with bison-generated (by bison-2.1) sources and patches to compile funkySetFields under OpenFOAM-1.3 and without bison 2.1 (the current bison version 2.3 generates .C files which can't be compiled by gcc-4.1.0 included in OpenFOAM-1.3). OF version 13.png (To Bgschaid: Feel free to remove this link upon completion of the new release. 7islands 00:47, 18 Feb 2007 (CET))

funkySetFields.r7106.tar.gz: A new version of funkySetFields. Not described yet on this page. Some of the new features include

  • new fields are created
  • ability to write fixedValue-patches
  • work with cell sets
  • work with surfaceFields (on writing)

An update of this page will follow in the next days. The generated files for those laking the right bison-Version will also be added OF version 13.png

7 Plans

  • factor out the parsing in a library to make it usable from other utilities
  • make expression evaluation more efficient

8 History

  • 2006-03-26: First upload of the utility
  • 2007-02-02: New Version uploaded. Has more features than described on this page
  • 2007-03-02: New Version with included generated Files uploaded and new features descibed
  • 2007-06-20: New Version that works with 1.4 and addtions by Takuya Oshima (rdist and deltaT)

--Bgschaid 22:53, 26 Mar 2006 (CEST)