0% found this document useful (0 votes)
219 views20 pages

Gerris Simulation Tutorial Guide

This document is a tutorial for using the Gerris fluid simulation software. It introduces the basic structure and syntax of Gerris simulation files, which specify things like the simulation domain, boundary conditions, discretization, initial conditions, and runtime. The sample file provided defines a 2D periodic square domain with random initial vorticity values, refined to a grid resolution of 64x64 cells, to be simulated for 50 time steps. The tutorial explains how to set parameters to control the simulation runtime and outputs.

Uploaded by

Roberto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
219 views20 pages

Gerris Simulation Tutorial Guide

This document is a tutorial for using the Gerris fluid simulation software. It introduces the basic structure and syntax of Gerris simulation files, which specify things like the simulation domain, boundary conditions, discretization, initial conditions, and runtime. The sample file provided defines a 2D periodic square domain with random initial vorticity values, refined to a grid resolution of 64x64 cells, to be simulated for 50 time steps. The tutorial explains how to set parameters to control the simulation runtime and outputs.

Uploaded by

Roberto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

12/1/2015

Gerristutorial

TheGerrisTutorial
Version1.3.2
StphanePopinet
[email protected]

March23,2011
Contents
1Introduction
1.1Simulationfile
2Asimplesimulationfile
2.1Afewcommentsonsyntax
2.2Topologydescriptionofthesimulationdomain
2.3Controllingthesimulation
2.3.1Spatialdiscretisation
2.3.2Initialconditions
2.3.3Writingresults
3Amorecomplexexamplewithsolidboundaries
3.1Domaingeometryandboundaryconditions
3.1.1Boundaryconditions
3.1.2Solidboundaries
3.2Savingthewholesimulation
3.3Visualisation
3.3.1GfsView
3.3.2Somepostprocessingusinggfs2oogl
3.4Usingdynamicadaptivemeshrefinement
4Goingfurther
4.1Moreonboundaryconditions
4.2Addingtracers
4.3Addingdiffusionterms
4.3.1Boundaryconditionsfordiffusionterms
4.4Outputs
4.5Boundaryconditions
5RunningGerrisinparallel
6Learningmore
7Doyouwanttohelp?

1Introduction
ThistutorialisastepbystepintroductiontothedifferentconceptsnecessarytouseGerris.Itisspecificallydesignedfor
aenduserandisnotatechnicaldescriptionofthenumericaltechniquesusedwithinGerris.Ifyouareinterestedbythat,
youshouldconsultthebibliographysectionontheGerriswebsite.
Variousversionsofthistutorialareavailable:
Printableformat:PDF.
HTML:directlinkorcompressedarchive.
InthistutorialIwillassumethatyouarefamiliarwiththeUnixshell(andthatyouarerunningsomeversionofaUnix
system).SomeknowledgeofCprogrammingwouldalsobeveryhelpfulifyouintendtoextendGerriswithyourown
objects.
IfGerrisisnotalreadyinstalledonyoursystem,havealookattheinstallationinstructionsontheGerriswebsite.
Wearenowreadytostart.Justtocheckthateverythingisokaytry:
%gerris2DV
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

1/20

12/1/2015

Gerristutorial

1.1Simulationfile
Gerrisisaconsolebasedprogram.Ittakesaparameterorsimulationfileasinputandproducesvarioustypesoffilesas
output.Everythingneededtorunthesimulationisspecifiedintheparameterfile,thisincludes:
Layoutofthesimulationdomain
Initialconditions
Boundaryconditions
Solidboundaries
Whattooutput(andwhen)
Controlparametersforthenumericalschemes

2Asimplesimulationfile
InthissectionwewillseehowtowriteasimulationfilefortheinitialrandomvorticityexampleintheGerriswebsite
gallery.Firstofall,itisalwaysagoodideatorunsimulationsintheirowndirectory.Typethisatyourshellprompt:
%mkdirvorticity
%cdvorticity
Asastartingpointwewillusethefollowingsimulationfile:vorticity.gfs
12GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=0}
}
GfsBox{}
11right
11top
Thisisavalidsimulationfilebutitdoesnotdomuchasyoucanseebytyping
%gerris2Dvorticity.gfs
Itisagoodstartingpointhowevertoexplainthegeneralstructureofasimulationfile.

2.1Afewcommentsonsyntax
Firstofall,therearetwotypesofparametersinasimulationfile:compulsoryandoptionalparameters.Optional
parametersarealwaysspecifiedwithinabracedblock(i.e.ablockoftextdelimitedbybraces({likethis}).They
alsooftentaketheform
parameter=value
whereparameterisanuniqueidentifier(withinthisbracedblock).Alltheotherparametersarecompulsoryparameters.
Forexample,invorticity.gfsboth
GfsTime{end=0}
and
end=0
areoptionalparameters.
Thesecondimportantsyntaxpointregardsthewayvariousfieldsaredelimited.Newline(orcarriagereturn)characters
aregenerallyusedtodelimitatedifferentobjectsinthesimulationfile.Theonlycasewherethisruledoesnotapplyis
withinbracedblocksdefiningoptionalargumentsoftheform

http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

2/20

12/1/2015

Gerristutorial

parameter=value
Forexample,invorticity.gfsthefollowingblocksoftextareallobjects:
12GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=0}
}

GfsTime{end=0}

GfsBox{}

11right

11top
Followingthisrule,vorticty.gfscouldhavebeenwrittenequivalentlyas:
12GfsSimulationGfsBoxGfsGEdge{}{GfsTime{
end=0}
}
GfsBox{}
11right
11top

2.2Topologydescriptionofthesimulationdomain
Ok,sowhatarealltheseobjectsfor?Thefirstlineofthesimulationfiledefinesagraphrepresentingthegenerallayout
ofthesimulationdomainandfollowsthissyntax:
1stfield
numberofnodesinthegraph(1)
2ndfield
numberofedgesconnectingthenodes(2)
3rdfield
objecttypeforthegraph(GfsSimulation)
4thfield
defaultobjecttypeforthenodes(GfsBox)
5thfield
objecttypefortheedges(GfsGEdge)
6thfield
1stoptionalparameters(bracedblock)
7thfield
2ndoptionalparameters(bracedblock)
Wethenjumptotheendofthe2ndoptionalparameterstoline
GfsBox{}
whichdescribesthefirst(anduniqueinthiscase)nodeofthegraph.Thefirstfieldistheobjecttypeofthenode
(GfsBox),thesecondfieldcontainsoptionalparameters.Thefollowingtwolines
11right
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

3/20

12/1/2015

Gerristutorial

11top
definetheedgesofthegraphasfollows:
1stfield
indexofthestartingnode(1)
2ndfield
indexoftheendingnode(1)
3rdfield
spatialdirectioninwhichthetwonodesareconnected(rightandtop)
Thenodesarealwaysindexedstartingfromone.Thespatialdirectionsaredefinedonfigure1.Fromthis,weseethat
thisfiledefinesasimulationdomaincontainingonenode(aGfsBox)connectedwithitselfinboththehorizontal(right)
andvertical(top)directions.

Figure1:Definitionofspatialdirections

Bydefault,aGfsBoxisasquare(in2D)oracube(in3D)ofsizeunity.Thefirstnodeofthegraphisalwayscenteredon
theoriginandisusedasthereferencetopositiontheothernodes.Wehaveconsequentlydefinedasquaresimulation
domainofsizeunity,centeredontheoriginandusingperiodicboundaryconditions.

2.3Controllingthesimulation
Nowthatwehavedefinedthesimulationdomainandtheboundaryconditions,weneedtospecifytheinitialconditions,
numericalschemesparametersandsoon.Thisisalldonewithinthesecondoptionalparametersblockofthegraph
definition.
Inourfilewehaveforthemomentonlyoneobjectinthisblock:
GfsTime{end=0}
Asitsnameindicate,thisobjectdefinesthephysicalandthecomputationaltime.BycomputationaltimeImeanthe
numberoftimestepsperformed.Bydefaultboththephysicaltimeandthetimestepnumberarezerowhentheprogram
starts.Itispossibletosetdifferentvaluesusingforexample
GfsTime{t=1.4i=32end=0}
whereiisthetimestepnumberandtisthephysicaltime.Theendidentifierspecifiesthatthesimulationshouldstop
whenthephysicaltimereachesthegivenvalue.Itisalsopossibletostopthesimulationwhenaspecifiednumberof
timestepsisreached,usingtheiendidentifier.Ifbothendandiendarespecified,thesimulationstopswheneitherof
thesearereached.Bydefault,bothendandiendvaluesareinfinite.
Ok,letsthenchangethisobjectto
GfsTime{end=50}
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

4/20

12/1/2015

Gerristutorial

2.3.1Spatialdiscretisation
Thenextstepistospecifywhatspatialresolutionwewantforthediscretisation.Forthemoment,theonlythingwehave
definedistherootofthequad/octree.Thewholedomainisthusdiscretisedwithonlyonegridpoint
Weneedtospecifyhowwewanttorefinethisinitialrootcell.ThisisdonebyusinganGfsRefineobject.Wecandothis
byaddingtheline
GfsRefine6
tothesecondoptionalparameterblock.Thisisthesimplestpossiblewaytorefinetheinitialrootcell.Wetelltheprogram
thatwewanttokeeprefiningthecelltree(bydividingeachcellinfourchildrencells(in2D,eightin3D))untilthelevelof
thecellisequaltofive.Theleveloftherootcelliszero,thelevelofallitschildrencellsisoneandsoonrecursively.
AfterthisrefinementprocesscompleteswehavecreatedaregularCartesiangridwith26=64cellsineachdimensionon
thefinestlevel(6).

2.3.2Initialconditions
Wenowneedtospecifytheinitialconditionsandthevariousactions(suchaswritingresults,informationmessages
etc)wewanttoperformwhenthesimulationisrunning.AllthesethingsaretreatedbyGerrisasvarioustypesof
events,allrepresentedbyobjectsderivedfromthesameparentobjectGfsEvent.
Initialconditionsareaparticulartypeofeventhappeningonlyonceandbeforeanyothertypeofevent,theyareall
derivedfromthesameparentobjectGfsInit.
Gerriscomeswithafewdifferentobjectsdescribingvariousinitialconditions.AsthereisnowayGerriscouldprovideall
thedifferentinitialconditionsuserscouldthinkof,Gerrismakesiteasyforuserstocreatetheirowninitialisationobjects
byextendingtheGfsInitobjectclass.Inordernottohavetorecompile(ormoreexactlyrelink)thewholecode
everytimeanewclassisadded,Gerrisusesdynamicallylinkedmoduleswhichcanbeloadedatruntime.Wewillsee
laterhowtowriteyourownmodules.
Forthemoment,wewillusethedefaultGfsInitobject.Justaddthefollowinglinestovorticity.gfs:
12GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=50}
GfsRefine6
GfsInit{}{
U=(0.5rand()/(double)RAND_MAX)
V=(0.5rand()/(double)RAND_MAX)
}
}
GfsBox{}
11right
11top
UsingGfsInititispossibletosettheinitialvalueofeachofthesimulationvariables.Bydefaultallvariablesaresetto
zeroinitially.InourcasewetellGerristodefinethetwocomponentsofthevelocityfieldUandVasCfunctions.The
standardrandfunctionoftheClibraryreturnsa(pseudo)randomnumberbetween0andRAND_MAX.Thetwofunctions
wedefinedthussetthecomponentsofthevelocitiesineachcellasrandomnumbersbetween0.5and0.5.
Thisisapowerfulfeatureoftheparameterfile.InmostcaseswhereGerrisrequiresanumber(suchastheGfsRefine6
line,afunctionofspaceandtimecanbeusedinstead.Forexample,avalidparameterfilecouldinclude:
...
GfsRefine6.*(1.sqrt(x*x+y*y))
...
whichwoulddefineameshrefinedinconcentriccircles.
Usingthisfeature,itispossibletodefinemostinitialconditionsdirectlyintheparameterfile.

2.3.3Writingresults
Thevorticity.gfsfilewehavenowisallGerrisneedstorunthesimulation.However,forthisruntobeanyuse,we
needtospecifyhowandwhentooutputtheresults.Thisisdonebyusinganotherclassofobjects:GfsOutput,derived
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

5/20

12/1/2015

Gerristutorial

fromGfsEvent.Gerriscomeswithanumberoftheseobjectsallowingtooutputvariousaspectsofthesimulation.
ThegeneralsyntaxforanGfsEventobjectisasfollows:
GfsEvent{
start=0.5step=1e2end=3.4
istart=10iend=46
}
thisdefinesanevent:
startingwheneverthephysicaltimeislargerthan(orequalto)0.5orthetimestepnumberislargerthan(orequal
to)10,
endingwheneverthephysicaltimeisstrictlylargerthan3.4orthetimestepnumberisstrictlylargerthan46,
andoccurringevery102physicaltimeunits.
Itisalsopossibletospecifyaneventstepasanumberoftimestepsusingtheistepidentifier.Note,however,thatyou
cannotspecifybothstepandistepforthesameevent.Bydefault,startandistartarezeroandend,iend,step
andistepareinfinite.
AnGfsOutputobjectisderivedfromGfsEventandfollowsthissyntax:
GfsOutput{}filename%d%f%ld
ThefirstpartofthelineGfsOutput{}definestheGfsEventpartofGfsOutputandfollowsthesyntaxabove.Inthe
remainderofthistutorial,Iwillusethefollowingnotationtoexpressthisinheritanceofsyntax:
[GfsEvent]filename%d%f%ld
toavoidrepeatingthewholethingforeveryderivedobjects.
Thesecondpartfilename%d%f%ldspecifieswheretooutputthings.The%d,%fand%ldcharactersareformatting
stringswhichfollowtheClanguagesyntaxandwillbereplacedeverytimetheeventtakesplaceaccordingto:
%d
%f
%ld

integerreplacedwiththecurrentprocessnumber(usedwhenrunningtheparallelversionofGerris).
floatingpointnumberreplacedwiththecurrentphysicaltime.
(long)integerreplacedwiththecurrenttimestepnumber.

Ofcourse,youarefreenottospecifyanyofthese,inwhichcasetheoutputwilljustbeappendedtothesamefileevery
timetheeventtakesplace.Therearealsotwofilenameswhichhaveaspecialmeaning:stdoutandstderr,forthe
standardoutputandstandarderroroftheshellrespectively.
Wenowaddthefollowingtooursimulationfile:
12GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=50}
GfsRefine6
GfsInit{}{
U=(0.5rand()/(double)RAND_MAX)
V=(0.5rand()/(double)RAND_MAX)
}
GfsOutputTime{istep=10}stdout
GfsOutputProjectionStats{istep=10}stdout
}
GfsBox{}
11right
11top
Thefirstlineweaddedtellstheprogramtooutputinformationaboutthetimeevery10timestepsonthestandardoutput.
Thesecondlineoutputsstatisticsabouttheprojectionpartofthealgorithm.
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

6/20

12/1/2015

Gerristutorial

Youcannowrunthecodelikethis:
%gerris2Dvorticity.gfs
andyoushouldgetanoutputinyourconsolelookinglikethis(youcanstoptheprogramusingCtrlC):
step:0t:0.00000000dt:0.000000e+00
MACprojectionbeforeafterrate
niter:0
residual.bias:0.000e+000.000e+00
residual.first:0.000e+000.000e+000.0
residual.second:0.000e+000.000e+000.0
residual.infty:0.000e+000.000e+000.0
Approximateprojection
niter:0
residual.bias:0.000e+000.000e+00
residual.first:1.050e141.050e140.0
residual.second:1.612e141.612e140.0
residual.infty:7.105e147.105e140.0
step:10t:0.02190704dt:2.801016e03
MACprojectionbeforeafterrate
niter:5
residual.bias:3.053e161.403e16
residual.first:3.365e+012.949e0516.3
residual.second:4.274e+014.676e0515.6
residual.infty:1.954e+023.285e0414.3
Approximateprojection
niter:5
residual.bias:9.714e172.874e16
residual.first:3.322e+012.548e0516.7
residual.second:4.250e+014.062e0516.0
residual.infty:1.880e+023.380e0414.1
step:20t:0.05278371dt:3.531551e03
MACprojectionbeforeafterrate
niter:5
...
Thelinesstartingwithstep:arewrittenbyGfsOutputTime.Theygivethetimestepnumber,correspondingphysical
timeandthetimestepusedforthepreviousiteration.
TheotherlinesarewrittenbyGfsOutputProjectionStatsandgiveyouanideaofthedivergenceerrorsand
convergencerateofthetwoprojectionsteps(MACandapproximate)performedduringthepreviousiteration.Thevarious
normsoftheresidualofthesolutionofthePoissonequationaregivenbeforeandaftertheprojectionstep.Therate
columngivestheaverageamountbywhichthedivergenceisreducedbyeachiterationofthemultigridsolver.
Well,numbersaregreatbutwhataboutsomeimages?Whatwewanttodo,forexample,isoutputsomegraphical
representationofagivenscalarfield.In2D,asimplewaytodothatistocreateanimagewhereeachpixeliscoloured
accordingtothelocalvalueofthescalar.Gerrisprovidesanobjecttodojustthat:GfsOutputPPMwhichwillcreatea
PPM(PortablePixMap)image.Thisobjectisderivedfromamoregeneralclassusedtodealwithscalarfields:
GfsOutputScalarfollowingthissyntax:
[GfsOutput]{v=Umin=1max=2.5}
whereasbeforethesquarebracketsexpressinheritancefromtheparentclass.Thevidentifierspecifieswhatscalarfield
wearedealingwith,oneof:
U,V(andWin3D)
:componentsofthevelocity.
P
C

:pressure.
:passivetracer.

Vorticity
:vorticity(normofthevorticityvectorin3D).
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

7/20

12/1/2015

Gerristutorial

Velocity
:normofthevelocity.
Theminandmaxvaluesspecifytheminimumandmaximumvaluesthisscalarcantake.Iftheyarenotgiven,theyare
computedeverytimetheeventtakesplace.
Wecannowusethisinoursimulationfile:
12GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=50}
GfsRefine6
GfsInit{}{
U=(0.5rand()/(double)RAND_MAX)
V=(0.5rand()/(double)RAND_MAX)
}
GfsOutputTime{istep=10}stdout
GfsOutputProjectionStats{istep=10}stdout
GfsOutputPPM{step=1}vorticity%4.1f.ppm{v=Vorticity}
}
GfsBox{}
11right
11top
Thecodewilloutputevery1timeunitsaPPMimagerepresentingthevorticityfield.Theresultwillbewritteninfiles
named:vorticity00.0.ppm,vorticity01.0.ppm(ifthe%4.1fthingisnotfamiliar,consultaCbookortry%man
3printf).
Ifyoureruntheprogramusingthisnewsimulationfile,youwillgetanumberofPPMfiles(51tobeprecise)youcan
thenvisualisewithanyimageeditingorviewingtool.IwouldrecommendtheverygoodImageMagicktoolbox.Ifyourun
aLinuxbox,thesetoolsareverylikelytobealreadyinstalledonyoursystem.Trytypingthisinyourworkingdirectory:
%display*.ppm
Ifitworks,youshouldseeasmall(64x64)imagerepresentingtheinitialvorticityfield.Ifyouclickonit,amenuwill
appear.SelectFileNextandlookattheevolutionofthevorticityfieldwithtime(youcanalsousethespacebarand
backspacekeytochangebackandforth).Youmightalsowanttotrytheanimate*.ppmcommand.Readtheman
pagesofImageMagickifyouwanttoknowmore.NotethatyoucanusethesetoolsalsowhileGerrisisrunning(and
creatingnewimages).Withabitofpatienceyouwillgettheimageonfigure2att=18(resolutionhasbeenincreasedto
128128).

Figure2:Vorticityfieldfortheinitialrandomvorticityproblematt=18.

Beforewecarryon,wearegoingtomaketwomodificationstothesimulationfile.Firstofall,itisnotreallyhandyto
generateonefileforeveryimagegenerated.ImageMagick(andmostotherprograms)candealwithmultiplePPMimages
containedwithinthesamefile.Secondly,inthesequenceofimageswegenerate,agivenvalueofthevorticitydoesnot
alwayscorrespondtothesamecolour(becausetheminimumandmaximumvaluesofthevorticitycanvaryintime).We
canfixthatlikethis:
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

8/20

12/1/2015

Gerristutorial

12GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=50}
GfsRefine6
GfsInit{}{
U=(0.5rand()/(double)RAND_MAX)
V=(0.5rand()/(double)RAND_MAX)
}
GfsOutputTime{istep=10}stdout
GfsOutputProjectionStats{istep=10}stdout
GfsOutputScalarStats{istep=10}stdout{v=Vorticity}
GfsOutputPPM{step=0.1}vorticity.ppm{
v=Vorticity
min=10
max=10
}
}
GfsBox{}
11right
11top
Wehavenowspecifiedfixedboundsforthevorticity(usingtheminandmaxidentifiers).EachPPMimagewillbe
appendedtothesamefile:vorticity.ppm.
HowdidIchoosetheminimumandmaximumvaluesforthevorticity?ThelineGfsOutputScalarStats{istep=10
}stdout{v=Vorticity},writestheminimum,average,standarddeviationandmaximumvaluesofthevorticity.
Byrerunningthesimulationandlookingatthesevaluesitiseasytofindasuitablerange.

3Amorecomplexexamplewithsolidboundaries
Inthissectionwewillseehowtosetupasimulationfortheflowpastasolidbody(ahalfcylinder)inanarrowchannel.
Whiledoingthatwewillalsoencounternewwaysofdisplayingsimulationresults.

3.1Domaingeometryandboundaryconditions
Whatwewantisanarrowchannel(41forexample).Fromthepreviousexample,weknowthatwecanbuilditlikethis:
43GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=0}
}
GfsBox{}
GfsBox{}
GfsBox{}
GfsBox{}
12right
23right
34right
i.e.fourboxes,box1connectedtobox2horizontally(totheright),box2connectedtobox3horizontallyandbox3
connectedtobox4horizontally.Box1iscenteredontheoriginandisofsizeone.Alltheotherboxesarepositioned
accordingly.Wenowhaveour41rectangulardomain.

3.1.1Boundaryconditions
Whataboutboundaryconditions?BydefaultGerrisassumesthatboundariesaresolidwallswithslipconditionsforthe
velocity(i.e.thetangentialstressonthewalliszero).Forthemomentwethenhavedefinedarectangularboxclosedon
allsidesbysolidwalls.
Whatwereallywantistospecifyaninputvelocityontheleftsideoftheboxandsomesortofoutputconditiononthe
rightside.Wecandothatlikethis:
43GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=0}
}
GfsBox{left=GfsBoundaryInflowConstant1}
GfsBox{}
GfsBox{}
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

9/20

12/1/2015

Gerristutorial

GfsBox{right=GfsBoundaryOutflow}
12right
23right
34right
Thewholeleftsideofthefirst(leftmost)boxisnowdefinedtobeaGfsBoundaryInflowConstantobjectandthewhole
rightsideofthelast(rightmost)boxaGfsBoundaryOutflowobject.Again,boundaryconditionsobjectsareallderived
fromtheGfsBoundaryobjectand,asinitialconditions,newobjectscanbeeasilywrittenbytheuser(seealsosection
4.1).
WeseethatGfsBoundaryInflowConstanttakesoneargumentwhichisthevalueofthe(constant)normalvelocity
appliedtothisboundary.Alltheothervariables(pressure,tracerconcentrationetc...)followazerogradientcondition.
GfsBoundaryOutflowimplementsasimpleoutflowboundaryconditionwherethepressureissettozeroaswellasthe
gradientofallotherquantities.

3.1.2Solidboundaries
Wenowhaveanemptywindtunnelwithaconstantinletvelocityofnormunity.Gerriscandealwitharbitrarilycomplex
solidboundariesembeddedinthequad/octreemesh.ThegeometryofthesolidboundariesisdescribedusingGTS
triangulatedsurfaces.In2D,using3Dtriangulatedsurfacesseemsoverkill,as2Dcurveswouldbeenough.However,
Gerrisbeingbotha2Dand3Dcodeitdealswith2Dsolidboundariesexactlyaswith3Dones,evenifthesimulationis
doneonlyona2Dcrosssection.
Creating3Dpolygonalsurfacesisnotaneasyjobandisclearlyoutsidethescopeofthistutorial.Thereareanumberof
utilitiesyoucanusetodothat,includingbigcommercialCADpackages.Ingeneral,onceyouhavecreatedapolygonal
surfacewithoneofthesetoolsitshouldberelativelyeasytoconvertittothefileformatusedbyGTS.Inparticular,most
CADpackagescanexporttotheSTL(stereolithography)formatwhichiseasilyconvertedtotheGTSfileformatusing
thestl2gtsutilitywhichcomeswiththelibrary.
Thistutorialcomes(handily)withonesuchfile:halfcylinder.gts.Youcanvisualisethesurfaceitdescribesusinga
programcalledGeomview.Todothis,youfirstneedtoconverttheGTSfiletoaformatGeomviewunderstands.Thiscan
bedoneusingthegts2ooglutilitylikethis:
%gts2oogl<halfcylinder.gts>halfcylinder.oogl
(OOGListhefileformatusedbyGeomview).gts2ooglhasanumberofoptions.Youcanhaveashortexplanationof
whattheydobytyping:
%gts2ooglh
Ifyounowstartgeomviewlikethis:
%geomviewhalfcylinder.oogl
andplayaroundwiththepan/rotate/zoomfunctionsofGeomview(readthemanualfordetails),youshouldseesomething
liketheimageonfigure3.

Figure3:Geomviewrepresentationofhalfcylinder.gts

http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

10/20

12/1/2015

Gerristutorial

Youcannoticethatthisisaproper3Dobject,evenifweareonlygoingtosimulatetheflowina2Dcrosssection.Itis
alsoimportantthattheobjectistallenoughsothatitspanstheentireheightofthe2Ddomain,asifweweregoingto
simulatetheflowarounditinaproper3Dchannelwithasquarecrosssection.Theorientationofthesurfaceisalso
importanttodefinewhatisinside(thesolid)andwhatisoutside(thefluid).
Wecannowinsertthisobjectinthesimulationdomainlikethis:
43GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=0}
GfsSolidhalfcylinder.gts
}
GfsBox{left=GfsBoundaryInflowConstant1}
GfsBox{}
GfsBox{}
GfsBox{right=GfsBoundaryOutflow}
12right
23right
34right
addwhatmeshrefinementwewantandafewthingstooutput:
43GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=9}
GfsRefine6
GfsSolidhalfcylinder.gts
GfsInit{}{U=1}
GfsOutputBoundaries{}boundaries
GfsOutputTime{step=0.02}stdout
GfsOutputProjectionStats{step=0.02}stdout
GfsOutputPPM{step=0.02}vorticity.ppm{
min=100max=100v=Vorticity
}
GfsOutputTiming{start=end}stdout
}
GfsBox{left=GfsBoundaryInflowConstant1}
GfsBox{}
GfsBox{}
GfsBox{right=GfsBoundaryOutflow}
12right
23right
34right
IhaveaddedanewGfsOutputobjectwehaventseenyet:GfsOutputTiming.Thisobjectwritesasummaryofthetime
takenbyvariouspartsofthesolver.Youmightalsohavenoticedtheunusualstart=endbitthisjustspecifiesthat
thiseventwillonlyhappenonceattheendofthesimulation.
AnothernewoutputobjectisGfsOutputBoundaries.Thisobjectwritesageometricalsummary(inOOGL/Geomview
format)ofthemeshused,includingboundaryconditions,solidboundariesandsoon.
Wealsoinitialisethevelocityfieldonthewholedomaintoaconstantvalue(1,0,0).Wecouldhaveleftthevelocityfield
toitsdefaultvalueof(0,0,0)but,giventhatweimposeinflowboundaryconditions,itwouldhavemeantthattheinitial
velocitywouldhavebeenstronglydivergent.Gerrisalwaysstartsasimulationbyaprojectionstep(tofixproblemslike
this)butitisalwaysagoodideatostartwiththebestpossiblevelocityfield.
Wecannowrunthecode:
%gerris2Dhalfcylinder.gfs
Itisgoingtotakeawhiletocomplete,butrememberthatyoucanlookatfileswhiletheyarebeinggenerated.Thefirst
filewhichwillbegeneratedisboundaries.IfyouloaditinGeomview,youshouldgetsomethinglikefigure4(you
probablywanttodisableautomaticnormalizationinGeomviewbyselectingInspectAppearanceNormalizeNone).

http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

11/20

12/1/2015

Gerristutorial

Figure4:Representationofboundaryconditionsandsolidboundaries

Theblacklinesrepresenttheboundariesbetweensolidcellsandfluidcells.Ifyouzoominonthehalfcylinder,youwill
seethatitisrepresentedbylinesfollowingthegrid(itislegolooking).Thisdoesnotmeanthatthereal(i.e.
computational)solidboundaryisalsolegolookingbecausefluidcellscanbecutbythesolidboundaries,inwhichcase
thealgorithmproperlytakesintoaccountthecorrespondingcellgeometry.
EachGfsBoundaryobjectiscolourcoded.Fromthecoloursinthepictureweseethatwehaveindeedaninflow
boundaryconditionontheleftside(blue)andanoutflowboundaryconditionontherightside(green).
Youcanalsoloadinthefullhalfcylindergeometrywecreatedbefore:halfcylinder.ooglorvisualisethePPMfiles
usinganimateanddisplayasinthepreviousexample.Bytheway,ausefulfeatureofdisplayisthatyoucanzoom
inbyclickingonthemiddlebuttonintheimagebeingdisplayed.

3.2Savingthewholesimulation
Hmm,thissimulationistakingquiteawhileWhatifwewanttostopthesimulation,makesomemodificationstothe
simulationfileandrestartwhereweleftfrom?Orequivalently,savethewholesimulationatregularintervalsforlatter
postprocessing?
YoucandothisusingtheGfsOutputSimulationobject.Likethisforexample:
GfsOutputSimulation{step=0.1}halfcylinder%3.1f.gfs{
variables=U,V,P
}
wherevariablesdefineswhichvariablesyouwanttosave.Bydefaultallthevariablesaresaved.
Ifyounowrerunthesimulation,youwillgetanewfileevery0.1timeunits.Thisfileisavalidsimulationfile(likehalf
cylinder.gfs)andyoucanuseitdirectlytorestartthesimulationfromthispointonward.Ifyoueditit,youwillseethat
thegeneralstructureisthesameasusualbutforfiveprettybigchunksofdata.
ThefirstchunkstartswithGfsSolidandisjustthedatacontainedinhalfcylinder.gtsbutthistimeembedded
directlyintothesimulationfile.Thegoalthereistohavefullyselfcontainedsimulationsfileswhichyoucanjustmove
aroundwithouthavingtokeeptrackoftwentydifferentfiles.
ThefourotherchunksareeachassociatedwithaGfsBoxandcontainboththetopologyofthecorrespondingcelltreebut
alsotheassociatedphysicaldata,solidboundarydefinitionsetc...
Youcanofcourseeditthisfile,addnewoutputsandsoonandrestartthesimulationfromwhereyouleftit.

3.3Visualisation
3.3.1GfsView
GfsViewisatoolwrittenspecificallytovisualiseGerrissimulationfiles.Itisstillyoungbutfullyusablebothfor2Dand
3Dsimulations.Itsmainadvantageoverotheroptionsandthereasonforitsexistenceisthatitmakesfulluseofthe
adaptivenatureoftheoctreerepresentationatthevisualisationlevel.TheoctreestructureisusedwithinGfsViewto
dynamicallyselecttheappropriatelevelofrefinementdependingontheviewpoint,zoomandrenderingspeed.Itisalso
usedtoefficientlycomputecomplexgeometricalentitiessuchasisosurfacesorcutplanes.
ThemoreclassicalviewerssuchasopenDXorMayaViaredesignedforeitherregularCartesiangridsorfully
unstructuredmeshesanddonottakeadvantageoftheoctreerepresentation(worsestill,theoctreerepresentationfirst
needstobeconvertedtoCartesianorfullyunstructuredmeshesbeforebeingimportedintotheseprograms).
ToinstallGfsView,youneedtohavetheGtk+toolkitinstalledonyoursystem.IfyouarerunningaLinuxmachine,Gtk+
ismostprobablyalreadyinstalled.YouwillalsoneedtheGtkGlExtOpenGLextensiontoGtk+.
IfyouarerunningaDebianbasedsystem,youcaninstallthesepackagesusing
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

12/20

12/1/2015

Gerristutorial

%aptgetinstalllibgtkglext1dev
IfyouthendownloadarecentversionofGfsViewfromtheGerriswebsite(eitheranofficialreleaseorasnapshot)anddo
thenowclassical:
%gunzipgfsview.tar.gz
%tarxvfgfsview.tar
%cdgfsview
%./configureprefix=/home/joe/local
%make
%makeinstall
youwillbeabletostartGfsViewusing:
%gfsview2Dhalfcylinder0.5.gfs
NotethatyoucanalsoinstallthemostrecentGfsViewversionusingdarcsand
http://gfs.sourceforge.net/darcs/gfsview/gfsviewmainlineassourcerepository(youwillalsoneedtoinstall
Gerristhisway,seesection??fordetails).
ClickingonLinear,VectorsandSolidinthetoolbarandchangingthevectorlengthbyeditingthepropertiesofthe
Vectorsobject(selecttheobjectthenchooseEditProperties)youshouldbeabletogetsomethinglookinglikefigure
5.Youcanpanbydraggingtherightmousebutton,zoombydraggingthemiddlebuttonandrotatebydraggingtheleft
button.

Figure5:ScreenshotofaGfsViewsession.

http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

13/20

12/1/2015

Gerristutorial

Whilebynomeanscomplete,youcanalreadydomanythingswithGfsView.Ihopeitisfairlyuserfriendlysojustplay
withitanddiscoverforyourself.

3.3.2Somepostprocessingusinggfs2oogl
Gerriscomeswithautilitycalledgfs2ooglwhichconvertssimulationfilestovariousrepresentationsinOOGLformat.
Wearejustgoingtolookattwotypesofrepresentationsgfs2ooglcando:scalarfieldcrosssectionsandvectorfields.
Firstofall,youcanaccessasmallsummaryoftheoptionsofgfs2ooglbytyping:
%gfs2oogl2Dh
Bydefaultgfs2ooglwillgeneratethesameoutputasGfsOutputBoundarieslikethis:
%gfs2oogl2D<halfcylinder0.1.gfs>boundaries.oogl
TogenerateanOOGLrepresentationofascalarfield(acolouredsquareforeachdiscretisationcell)dothis:
%gfs2oogl2DSz0cVorticity<halfcylinder0.5.gfs>squares.oogl
whichtellsgfs2oogltodoacrosssectionforz=0(z0)representedbysquares(S)andcoloredaccordingtothe
localvorticity(cVorticity).Togenerateavectorfieldrepresentingthevelocitytry:
%gfs2oogl2DV2z0<halfcylinder0.5.gfs>vectors.oogl
whereV2specifiesthatthemaximumlengthofthevectoristwicethedimensionofthesmallestcellinthedomain.
IfyounowloadallthesefilesinGeomviewanddoabitofpanningandzoomingaround(andpossiblytunethingslike
faceshading)youshouldgetanimagelookinglikefigure6.

Figure6:Scalarandvectorrepresentationgeneratedusinggfs2oogl.

3.4Usingdynamicadaptivemeshrefinement
Forthemomentoursimulationisnotverywellresolved.WecouldalwayschangetheGfsRefine6linetosomething
biggerbutitwouldnotmakereallygooduseofthequadtreeapproachusedinGerris.Acodeusingasimpleregular
Cartesiangridapproachwouldbefasterandwouldproducethesameresults.Insteadwearegoingtousedynamic
adaptivemeshrefinement,wherethequadtreestructureofthediscretisationisusedtoadaptivelyfollowthesmall
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

14/20

12/1/2015

Gerristutorial

structuresoftheflow,thusconcentratingthecomputationaleffortontheareawhereitismostneeded.
Thisisdoneusingyetanotherobjectclass:GfsAdapt,alsoderivedfromGfsEvent.Variouscriteriacanbeusedto
determinewhererefinementisneeded.Inpractice,eachcriteriumwillbedefinedthroughadifferentobjectderivedfrom
GfsAdapt.IfseveralGfsAdaptobjectsarespecifiedinthesamesimulationfile,refinementwilloccurwheneveratleast
oneofthecriteriaisverified.
Forthisfirstexample,wewilluseasimplecriteriumbasedonthelocalvalueofthevorticity.Acellwillberefined
whenever

|v|x
max|v|

>,

wherexisthesizeofthecellandisauserdefinedthresholdwhichcanbeinterpretedasthemaximumangular
deviation(causedbythelocalvorticity)ofaparticletravelingatspeedmax|v|acrossthecell.Thiscriteriumis
implementedbytheGfsAdaptVorticityobject.
ThegeneralsyntaxforanGfsAdaptobjectis:
[GfsEvent]{mincells=1maxcells=100000minlevel=1maxlevel=10cmax=1e2}
wheremincellsspecifiestheminimumnumberofcellsinthedomain,maxcellsthemaximumnumberofcells,
minlevelthelevelbelowwhichitisnotpossibletocoarsenacell,maxlevelthelevelabovewhichitisnotpossibleto
refineacellandcmaxthemaximumcellcost.Thedefaultvaluesare0forminlevelandmincellsandinfinitefor
maxlevelandmaxcells.Animportantpointisthat,forthemoment,itisnotpossibletodynamicallyrefinesolid
boundaries.Asimplesolutiontothisrestrictionistoalwaysrefinethesolidboundarywiththemaximumresolutionatthe
startofthesimulationandtorestricttherefinementusingthemaxlevelidentifierinGfsAdapt.
Whathappensifthemaximumnumberofcellsisreached?Therefinementalgorithmwillkeepthenumberofcellsfixed
butwillminimizethemaximumcostoverallthecells.Thiscanbeusedforexampletorunaconstantsizesimulation
wherethecellsareoptimallydistributedacrossthesimulationdomain.Thiswouldbedonebysettingmaxcellstothe
desirednumberandcmaxtozero.
Followingthiswecanmodifyoursimulationfile:
43GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=9}
GfsRefine7
GfsSolidhalfcylinder.gts
GfsInit{}{U=1}
#GfsOutputBoundaries{}boundaries
GfsAdaptVorticity{istep=1}{maxlevel=7cmax=1e2}
GfsOutputTime{step=0.02}stdout
GfsOutputBalance{step=0.02}stdout
GfsOutputProjectionStats{step=0.02}stdout
GfsOutputPPM{step=0.02}vorticity.ppm{
min=100max=100v=Vorticity
}
GfsOutputSimulation{step=0.1}halfcylinder%3.1f.gfs{
variables=U,V,P
}
GfsOutputTiming{start=end}stdout
}
GfsBox{left=GfsBoundaryInflowConstant1}
GfsBox{}
GfsBox{}
GfsBox{right=GfsBoundaryOutflow}
12right
23right
34right
Wehaveaddedtwolinesandcommentedout(using#)thelineoutputtingtheboundaries(wedontneedthatanymore,
wehavethesimulationfiles).
ThefirstlineweaddedsaysthatwewanttorefinedynamicallythemeshthroughtheGfsAdaptVorticityobjectapplied
everytimestep(istep=1).Theparameter(cmax)issetto102.
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

15/20

12/1/2015

Gerristutorial

ThesecondlineweaddedisanewGfsOutputobjectwhichdisplaysthebalanceofthedomainsizesacrossthe
differentprocesses(whenGerrisisraninparallel).Wewillusethistomonitorhowthenumberofcellsevolveswithtime
asthesimulationrefinesorcoarsensthemeshaccordingtoourvorticitycriterium.
Wecannowrunthisnewsimulation.Iftheprevioussimulationdidnotcompleteyet,dontbeafraidtoabortit(CtrlC),
thisoneisgoingtobebetter(andfaster).
%gerris2Dhalfcylinder.gfs
IfwenowlookatthebalancesummarywrittenbyGfsOutputBalance,weseethatinitially(step:0)thetotalnumberof
cells(onalllevels)is86966,whichcorrespondstoaconstantresolutionof42727=512128.Atstep10thenumber
ofcellsisdownto990withacorrespondingincreaseincomputationalspeed.Ifwenowlookatthefirstsimulationfilewe
saved,using:
%gfs2oogl2D<halfcylinder0.1.gfs>boundaries
%gfs2oogl2DSz0cVorticity<halfcylinder0.1.gfs>squares.oogl
weobtainfigure7showingnotonlythedomainboundariesasusual,butalsotheboundaries(thinblacklines)between
differentlevelsofrefinement.

Figure7:Dynamicadaptivemeshrefinementt=0.1

Weseethatthemeshisveryrefinedaroundthesolidandaroundthetwovorticesdevelopingatthetrailingedgeand
verycoarse(onecellperboxonly)onthedownstreampartofthedomain.Ifyouarenotsurewhatthesethinblacklines
represent,justswitchontheedgerepresentationinGeomview(usingtheInspectAppearancemenu).Youwillgeta
picturelookinglikefigure8,showingallthecellsusedforthediscretisation.

http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

16/20

12/1/2015

Gerristutorial

Figure8:Dynamicadaptivemeshrefinementt=0.1.Detailofthecells.

Asthesimulationgoeson,youcanseethenumberofcellsinthedomainincreaseasthetrailingvorticesdevelop.With
abitofpatienceyouwillgettofigure9showingthefullydevelopedVonKarmanvortexstreetwithpatchesofincreased
resolutionfollowingeachvortex.Evenwhentheflowisfullydevelopedusingadaptivemeshrefinementstillsavesa
factorof~6intimeandmemoryuse.Theadvantageofadaptivemeshrefinementisevenmoreobviousinsituations
whereitisnecessarytouseverylargedomainstoavoidanycontaminationofthesolutionbytheboundaryconditions.

Figure9:Dynamicadaptivemeshrefinementt=9.

Youshouldalsotrytoanimatevorticity.ppmwhichbynowshouldgiveyouaniceanimationofthedevelopingtrailing
vorticesbecomingunstableandgeneratingtheVonKarmanstreet.IfImageMagickisproperlyinstalledonyoursystem
youcanalsotry:
%convertvorticity.ppmvorticity.mpg
whichwillproduceamuchsmallerMPEGvideofile,suitablefordistributionthroughthenetwork.

4Goingfurther
4.1Moreonboundaryconditions
UptonowwehaveonlydealtwithprepackagedboundaryconditionssuchasGfsBoundaryInflowConstantand
GfsBoundaryOutflow.Whatifyouneedmorespecificboundaryconditions?
Formostpracticalproblems,boundaryconditionscanbereducedtotwomaincategories:Dirichletboundaryconditions
forwhichthevalueofthevariableissetandNeumannboundaryconditionsforwhichthevalueofthederivativeofthe
variableisset.Aswehaveseenearlier,thedefaultboundaryconditioninGerrisisDirichlet(zero)forthenormal
componentsofthevelocityandNeumann(zero)forallothervariables.
LetussaythatwewanttoimposeaPoiseuille(parabolic)profileratherthanaconstantinflowvelocityforthehalf
cylinderproblemi.e.wewantaDirichletboundaryconditiononthenormalcomponentofthevelocity(U)withanimposed
parabolicprofile.ThiscaneasilybedoneinGerrislikethis:
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

17/20

12/1/2015

Gerristutorial

...
GfsBox{left=GfsBoundary{
GfsBcDirichletU{return1.4.*y*y;}
GfsBcDirichletV0
}
}
GfsBox{}
GfsBox{}
GfsBox{right=GfsBoundaryOutflow}
...
SimilarlyaNeumannboundaryconditiononvariableXwoulduseGfsBcNeumannX...

4.2Addingtracers
Inthehalfcylinderexample,itwouldbenicetobeabletovisualisetheflowusingforexampleapassivetracerinjected
attheinlet.Thisisverysimple,justmodifythehalfcylinder.gfsparameterfilelikethis:
43GfsSimulationGfsBoxGfsGEdge{}{
GfsTime{end=9}
GfsRefine7
GfsSolidhalfcylinder.gts
GfsVariableTracer{}T
...
GfsOutputPPM{step=0.02}tracer.ppm{
min=0max=1v=T
}
GfsOutputSimulation{step=0.1}halfcylinder%3.1f.gfs{
variables=U,V,P,T
}
...
}
GfsBox{left=GfsBoundary{
GfsBcDirichletU1
GfsBcDirichletV0
GfsBcDirichletT{returny>0.?1.:0.;}
}
}
...
whichwillinjecttracerTattheinletonlyintheupperhalfofthechannel.
Theadaptiverefinementalgorithmshoudalsotakeyourtracerintoaccount.Trythis
...
GfsAdaptVorticity{istep=1}{maxlevel=7cmax=1e2}
GfsAdaptGradient{istep=1}{maxlevel=7cmax=1e2}T
...
whichwilladaptusingboththegradientoftracerTandthevorticity.
Youcanhaveanynumberoftracersyouwant,theyaredynamicallyallocated.

4.3Addingdiffusionterms
Uptonow,wehaveonlyconsideredinviscid,incompressibleflows.Withoutgoingintothedetails,thistypeofproblems
requirethesolutionoftwomainsubproblems:solvingaPoissonequationforthepressureandanadvectionequationfor
themomentumandtracerswiththecorrespondingboundaryconditions.
Gerriscanalsosolveathirdclassofsubproblems:diffusionequations.DiffusionequationsaresimilartoPoisson
equations(theybothinvolveLaplacianoperators)andcanbesolvedefficientlyusingthesamemultigridsolverweusefor
thepressure.
Inpracticeaddingdiffusiontoagiventracerisassimpleasadding:

http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

18/20

12/1/2015

Gerristutorial

...
GfsSourceDiffusion{}T0.01
...
totheparameterfile,where0.01isthevalueofthediffusioncoefficient.

4.3.1Boundaryconditionsfordiffusionterms
Whatifwewanttomodifythetracerexampleabovesothatnowthehalfcylinderitselfisa(diffusive)sourceoftracer
ratherthantheinlet?Weneedtobeabletoimposethisboundaryconditionontheembeddedsolidsurface.On
embeddedsolids,thedefaultboundaryconditionsforthediffusionequationisNeumann(zeroflux)fortracersand
Dirichlet(noslip)forthevelocitycomponents.Tochangethatuse
...
GfsVariableTracerT
GfsSourceDiffusion{}T0.001
GfsSurfaceBcTDirichlet1
...
andchangetheinletboundaryconditionbackto
...
GfsBox{left=GfsBoundary{
GfsBcDirichletU1
GfsBcDirichletV0
}
}
...

4.4Outputs
4.5Boundaryconditions

5RunningGerrisinparallel
6Learningmore
WhilethistutorialshouldgiveyouagoodoverviewofGerris,itisbynomeansacompletedescription.Tolearnmoreyou
shouldfirstconsulttheGerrisFrequentlyAskedQuestionsandtheGerrisobjecthierarchywhichdescribeseachobject
andthecorrespondingfileparametersinmoredetail.
YoushouldalsohavealookattheGerrisExamplespageforexamplesofhowtouseGerrisforarangeofproblems.The
parameterfilesarecrosslinkedwiththereferencemanual.
AnothersourceofmoreadvancedexamplesistheGerristestsuite.
Ifthingsarestillunclearyoucanaskforhelponthegfsusersmailinglist.Pleasenotethatyoufirstneedtosubscribe
tothelisttobeabletopostmessages.

7Doyouwanttohelp?
TheideabehindGerrisandotherfreesoftwareprojectsisthattransparency,freeexchangeofinformationand
cooperationbenefitindividualsbutalsosocietyasawhole.Ifyouareascientist,youknowthatthesesameprinciples
arealsokeystotheefficiencyofScience.
HelpingwithGerrisdevelopmentcanbedoneinvariouswaysandasidefromgivingyouthisaltruistic,warmfuzzyfeeling
ofhelpingotherswillalsobenefityoudirectly.Afewconcretesimplewaysofhelpingare(inapproximateorderof
difficulty):
Usethecode,commentontheproblemsyoufind,whatyoulike,dontlikeaboutit.
ShareyourresultswithotherGerrisusers,writeawebpageabouttheproblemyousolvedusingGerrisetc
IfyoupublishpapersusingGerris,sendmethereference.Itisveryusefultobeabletoshowevidenceofwider
usagewhenseekingcontinuedfundingfortheproject.
Also,ifGerriscapabilitiesarecentraltoyourarticlefeelfreetoaskmetobeacoauthoronyourpaper
http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

19/20

12/1/2015

Gerristutorial

HavealookattheGerrisinternals(writeyourownmodules)andsharethemwithus.
ThinkofwaystoextendGerrisforyourownproblems,implementthemandsharethemwithus(youcancounton
myandotherdevelopershelp).
ThisdocumentwastranslatedfromLATEXbyHEVEA.

http://gfs.sourceforge.net/tutorial/tutorial/tutorial1.html

20/20

You might also like