Smooted Patcle Hydodynamcs Applcaton Example Alan Hec Noembe 9, 010
Fluds Nae-Stokes equatons Smooted Patcle Hydodynamcs Smooted Patcle Hydodynamcs Noembe 010
Fluds Lquds, e.g. wate Gasses, e.g. a Plasmas 3 Smooted Patcle Hydodynamcs Noembe 010
Fluds Descbed by (ncompessble) Nae-Stokes equatons g p t ( ) 0 Den by gaty g, pessue and elocty Flud flows fom g pessue to low pessue Vscosty µ detemnes flud stckness Low scosty: a, wate Hg scosty: oney, mud p 4 Smooted Patcle Hydodynamcs Noembe 010
Fluds 5 Smooted Patcle Hydodynamcs Noembe 010
Fluds Nae-Stokes equatons Smooted Patcle Hydodynamcs 6 Smooted Patcle Hydodynamcs Noembe 010
7 Smooted Patcle Hydodynamcs Noembe 010 Incompessble Nae-Stokes equatons - densty, p pessue (scalas) g gaty, elocty (ectos) conecte acceleaton p = k( - 0 ) estng densty 0 p g t 0 ) ( z p y p x p p,, z y x z z y y x x,, (mass contnuty),,, z y x x x x x z y x
Incompessble Nae-Stokes equatons t g p Mass contnuty equaton: ( ) 0 x x y y z z 0 Mass contnuty wll be satsfed tally by usng a patcle fomulaton, snce eac patcle as constant mass and patcles ae nete ceated no destoyed 8 Smooted Patcle Hydodynamcs Noembe 010
Incompessble Nae-Stokes equatons t g p Te mateal deate s te deate along a pat wt elocty. To smulate wt patcles take te mateal deate D g p Dt Fo a sngle patcle d dt g 1 p 9 Smooted Patcle Hydodynamcs Noembe 010
Incompessble Nae-Stokes equatons Te Nae-Stokes equatons ae senste to scale, so we smulate tem at 0.004x scale elate to te pyscal enonment. 10 Smooted Patcle Hydodynamcs Noembe 010
Fluds Nae-Stokes equatons Smooted Patcle Hydodynamcs 11 Smooted Patcle Hydodynamcs Noembe 010
1 Smooted Patcle Hydodynamcs Noembe 010 Smooted Patcle Hydodynamcs [Monagan 199] ntoduced smootng kenels W And appoxmatons to tems of te N-S equatons m mass, poston, - adus ), ( ) ( ), ( ) ( ) ( W A d W A A b b b W m ), ( ), ( W p p m p ), ( W m
13 Smooted Patcle Hydodynamcs Noembe 010 Smooted Patcle Hydodynamcs Oe tme te lteatue as coneged on tese W: w = 0 at dstance w sums to 1 oe spee of adus ) ( 3 64 315 ), ( 9 b W b b b b b W 45 ), ( 6 b W b 6 45 ), (
14 Smooted Patcle Hydodynamcs Noembe 010 Smooted Patcle Hydodynamcs Fom Nae-Stokes to SPH: p g dt d 1 m b ) ( 3 64 315 9 b b b p p m p 45 6 b m 6 45 ) ( (1) () (3) (4)
Fluds Nae-Stokes equatons Smooted Patcle Hydodynamcs 15 Smooted Patcle Hydodynamcs Noembe 010
Numecal algotm: densty = equaton (). pessue p = k( - 0) pessue gadent = equaton (3). scous tem = equaton (4). acceleaton = equaton (1). numecally ntegate elocty, poston. p 16 Smooted Patcle Hydodynamcs Noembe 010
A naïe algotm computes nteactons among all patcles Ges coect esult because W= 0 fo patcles beyond te nteacton adus But ts as complexty O(n^) Need an algotm tat only computes nteactons among patcles tat ae wtn te nteacton adus 17 Smooted Patcle Hydodynamcs Noembe 010
A bette algotm pattons space nto local egons Dde nto oxels of sze on a sde Eac patcle can only nteact wt patcles n te same oxel, and n mmedately adacent oxels Total seac olume = xx oxels Fute efnement: compute nteactons wt a lmted numbe m of patcles m = 3 woks well 18 Smooted Patcle Hydodynamcs Noembe 010
Te fnal algotm: Oganze patcles nto oxels Compute spatal ndex fom oxel to patcles Fo eey patcle Examne local egon of xx oxels Compute nteactons wt 3 patcles 19 Smooted Patcle Hydodynamcs Noembe 010
Inteop allows a buffe to be saed between OpenCL and a gapcs subsystem. Ts aods an expense ound tp to ost memoy Ts s cucal fo g pefomance applcatons Due to lmts of tme we dd not mplement nteop n te gapcs code, owee we wll sow you te OpenCL ntalzaton fo nteop fo efeence. 0 Smooted Patcle Hydodynamcs Noembe 010
To nteop wt dx10 nclude cl_d3d10. and defne USE_DX_INTEROP #defne USE_DX_INTEROP #f defned( APPLE ) defned( MACOSX) #nclude <OpenCL/cl.pp> #nclude <OpenCL/cl_d3d10.> #else #nclude <CL/cl.pp> #nclude <CL/cl_d3d10.> #endf 1 Smooted Patcle Hydodynamcs Noembe 010
To nteop wt dx10 ntalze te OpenCL context: cl_context_popetes *cpops; cpops = new cl_context_popetes[ 6 ]; cpops[ 0 ] = CL_CONTEXT_D3D10_DEVICE_KHR; cpops[ 1 ] = (ntpt_t) DXUTGetD3D10Dece(); cpops[ ] = CL_CONTEXT_PLATFORM; cpops[ 3 ] = (cl_context_popetes)(platfomlst[0])(); cpops[ 4 ] = cpops[ 5 ] = 0; context = cl::context( CL_DEVICE_TYPE_GPU, cpops, NULL, NULL, &e); Smooted Patcle Hydodynamcs Noembe 010
Buffes poston, elocty, acceleaton float4 patcleindex unt sotedposton, sotedvelocty float4 gdcellindex, gdcellindexfxedup - unt Kenels aspatcles, sot, sotpostpass ndexx, ndexpostpass fndnegbos computedenstypessue, computeacceleaton, ntegate 3 Smooted Patcle Hydodynamcs Noembe 010
Te fnal algotm: Oganze patcles nto oxels aspatcles, sot, sotpostpass Compute spatal ndex fom oxel to patcles ndexx, ndexpostpass Fo eey patcle Examne local egon of xx oxels fndnegbos Compute nteactons wt 3 patcles computedenstypessue, computeacceleaton, ntegate 4 Smooted Patcle Hydodynamcs Noembe 010
Oganze patcles nto oxels: global_d(0)=patcle d aspatcles: computes a scala oxel d fom poston Voxel sze x stoes oxel d n poston.w; wtes {oxel d,global_d(0)} to patcleindex sot: sots patcleindex by oxel d adxsot woks only on GPU, use qsot on CPU sotpostpass: ewte poston,elocty nto sotedposton,sotedvelocty accodng to ode of patcleindex 5 Smooted Patcle Hydodynamcs Noembe 010
Compute spatal ndex fom oxel to patcles: global_d(0) = oxel d ndexx: computes gdcellindex(), ndex nto sotedposton of fst patcle n oxel Bnay seac n sotedposton fo lowest patcle d Leae -1 fo empty oxels ndexpostpass: Flls n ndex fo empty oxels gdcellindex( ) = gdcellindex( +1 ) fo empty, +1 nonempty 6 Smooted Patcle Hydodynamcs Noembe 010
Examne local egon of xx oxels: fndnegbos: Locates patcle n one cone of xx oxel set Seaces up to 8 oxels untl 3 negbos ae found Retans only negbos wtn nteacton adus Wtn eac oxel seac s andomzed Necessay to elmnate basng atfacts Specfcally, compute andom offset wtn oxel, ten poceed sequentally Altenate sequental dectons accodng to odd/eenness of patcle 7 Smooted Patcle Hydodynamcs Noembe 010
Compute nteactons wt 3 patcles: computedenstypessue: Equaton () followed by p = k( - 0 ) computeacceleaton: Equatons (3), (4), (1) ntegate: Sem-mplct Eule ntegaton = + dt a, poston = poston + dt Bounday condtons peent patcle escape 8 Smooted Patcle Hydodynamcs Noembe 010
Summay Fluds Goened by pessue, elocty Nae-Stokes equatons Incompessble equatons, mateal deate Smooted Patcle Hydodynamcs Smootng kenel appoxmatons Appoxmate, p, Oganze nto oxels, ceate oxel ndex, compute equatons (), (3), (4), (1), ntegate 9 Smooted Patcle Hydodynamcs Noembe 010
Questons and Answes Vst te OpenCL Zone on deelope.amd.com ttp://deelope.amd.com/zones/openclzone/ Tutoals, deelope gudes, and moe OpenCL Pogammng Webnas page ncludes: Scedule of upcomng webnas On-demand esons of ts and past webnas Slde decks of ts and past webnas Souce code fo Smooted Patcle Hydodynamcs webna 30 Smooted Patcle Hydodynamcs Noembe 010
Tademak Attbuton AMD, te AMD Aow logo and combnatons teeof ae tademaks of Adanced Mco Deces, Inc. n te Unted States and/o ote usdctons. Ote names used n ts pesentaton ae fo dentfcaton puposes only and may be tademaks of te especte ownes. 009 Adanced Mco Deces, Inc. All gts eseed. 31 Smooted Patcle Hydodynamcs Noembe 010