• No se han encontrado resultados

A new isosurface extraction method on arbitrary grids

N/A
N/A
Protected

Academic year: 2023

Share "A new isosurface extraction method on arbitrary grids"

Copied!
30
0
0

Texto completo

(1)

Dept.deIngenieríaMecánica,MaterialesyFabricación,ETSII,UniversidadPolitécnicadeCartagena,E-30202Cartagena,Spain bDept.deMecánica,ETSII,UNED,E-28040Madrid,Spain

a rt i c l e i nf o a b s t ra c t

Articlehistory:

Availableonline21July2021

Keywords:

Volumeoffluidmethod Interfacereconstruction Isosurfaceextraction Non-convexpolyhedra Unstructuredirregulargrids Signeddistance

Thedevelopmentofinterface-capturingmethods(suchaslevel-set,phase-fieldorvolume offluid(VOF) methods)forarbitrary3Dgridshasfurtherhighlightedtheneed formore accurateandefficientinterfacereconstructionprocedures.Inthiswork,weproposeanew method for the extraction ofisosurfaces onarbitrary polyhedra that can be used with advantageforthispurpose.Theisosurfaceisextractedfromvolumefractionsbyageneral polygontracingprocedure,whichisvalidforconvexornon-convexgeometries,evenwith non-planarfaces.Theproposed method,whichcanbeconsideredasanextensionofthe marching cubes technique,producesconsistent resultseven for ambiguoussituationsin polyhedraofarbitraryshape.Toshow thereproducibilityoftheresultspresentedinthis work,weprovidetheopensourcelibraryisoap,whichhasbeendevelopedtoimplement theproposedmethodandincludestestprogramstodemonstratethesuccessfulextraction ofisosurfacesonseveralgridswithpolyhedralcellsofdifferenttypes.Wepresentresults obtainednot onlyforisosurfaceextractionfromdiscretevolumefractionsresultingfrom avolume offluidmethod,butalsofrom datasets obtainedfromimplicit mathematical functions and signed distances to scanned surfaces. The improvement provided by the proposedmethodfortheextractionofisosurfacesinarbitrarygridswillalsobeveryuseful inotherfields,suchasCFDvisualizationormedicalimaging.

©2021TheAuthor(s).PublishedbyElsevierInc.Thisisanopenaccessarticleunderthe CCBY-NC-NDlicense(http://creativecommons.org/licenses/by-nc-nd/4.0/).

1. Introduction

Isosurface extractionisa procedureoftenused invariousapplications,such asdatavisualization andnumerousphys- ical andengineeringproblems(see, forexample,[1,2]).Itisincreasingly commontodevelop codescapable ofsimulating differentphysicalphenomena usingcomplexunstructuredgrids withcellswithoutanypredeterminedgeometric configu- ration.Thecomplexgeometryandtopologyofthistype ofgridsmakes extremelydifficulttheextractionofisosurfacesto visualizeorreconstructmaterialvolumes.ThisdifficultyalsoappearsinthesimulationofmultiphaseflowsusingVOF-type methodsandarbitraryconvexornon-convexgrids,whentryingtoreconstructtheinterfaceusingadvancedschemesbased on theextraction ofisosurfaces fromthe distribution ofthevolume fractionof fluid.Examples oftheseschemes can be found, for example, in [3–6]. López et al. [3] developed several piecewise linear interface calculation (PLIC) methods to representtheinterface inagivengridcellby aplane whosepositionisobtainedtomatchthefluidvolumecontainedin thecell andits orientationisobtainedbyaweighted-average procedure.Thisprocedureisbasedontriangulatedsurfaces

*

Correspondingauthor.

E-mailaddress:[email protected](J. López).

https://doi.org/10.1016/j.jcp.2021.110579

0021-9991/©2021TheAuthor(s).PublishedbyElsevierInc.ThisisanopenaccessarticleundertheCCBY-NC-NDlicense (http://creativecommons.org/licenses/by-nc-nd/4.0/).

(2)

Fig. 1. 2D example of an ambiguous situation produced in the isosurface extraction from discrete data.

constructedfromtheextractionofgenerallynon-planarisosurfaces correspondingto a0.5valueofthefluid volumefrac- tion distribution.In particular,the LLCIR(local level-contourinterface reconstruction) methodconstructsthe triangulated surface by joiningthevertices andcentroidofthe extractedisosurfaceinthe cell.The ELCIR(extendedlevel-contour in- terfacereconstruction)methodconstructsthetriangulatedsurfacebyjoiningthecentroidoftheisosurfaceextractedinthe cellwiththoseoftheisosurfacesextractedinadjacentcells.TheCLCIR(conservativelevel-contourinterfacereconstruction) methodtranslatestheabovementionedcentroidstothecorrespondingPLICgeometriccenters,andtheCLC-CBIR(conserva- tivelevel-contourcubic-Bézier-basedinterfacereconstruction)improvestheorientationobtainedfromtheCLCIRmethodby constructingacubic-Bézierpatchovereachtriangleofthetriangulatedsurface.Resultsobtainedusingthesereconstruction methods werepresentedin[3] forcubicgrids andresultsobtainedusingtheCLC-CBIRmethodwere presentedin[4] for gridswithdeformedhexahedralcells.Roenbyetal. [5] proposedanadvancedVOFmethod,referredtoasisoAdvector,based ontheextractionofisosurfacescorrespondingtoanon-fixedvalueofthefluidvolumefractionthatisadjustedineachcell to enforce volumeconservation withoutthe needfor PLICreconstructions. Later,Scheufler andRoenby [6] improved the isoAdvectormethodbyusingreconstructeddistancestoPLICinterfaces(isoAdvector-plicRDF).Resultsobtainedusingthese isosurface-basedmethods werepresented in[5,6] forgeneralgrids witharbitrarypolyhedral cells.Shin andJuric [7] also usedan isosurfaceextractiontechnique,referred toaslevelcontourreconstruction,whichenablesfront-trackingmethods torobustlymergeandbreakupinterfacesinthree-dimensionalflows(laterenhancements andapplicationscanbefoundin references[8–11]).

Thefollowingdescribestheproblemposedinthiswork anddiscussesthebackgroundtotheissue.Givenascalarfield φ: R3→ Randavalueφ∈ R,thegoalistoextracttheset{(x,y,z): φ(x,y,z)= φ},whichisusuallycalledanisosurface.

Thescalarfieldcanbegiven,forexample,byimplicitmathematicalfunctions,thresholdeddataobtainedbycomputerfluid dynamicssimulationsorbycomputertomography,whichisofparticularrelevanceinmedicalapplications,orunorganized pointsobtained,forexample,byscanningsystems(whichusuallyrequirescreatingadistancefunctionfromtheunorganized points).Inthiswork,withan approachthatcould alsobe usedinapplicationsotherthanthereconstruction ofinterfaces inVOFmethods,itwillbeassumedthat φisdefinedbydiscrete data,generallyintheformofexperimentalorcomputed volumetricdatasets, available onlyatthe cellvertices ofa grid.Therefore,the location oftheextractedisosurface points mustbeapproximatedbyinterpolation,andthereconstructedisosurfacecanberepresented,forexample,withlinearedges constructed by sequentially connecting the obtained isosurface points ordered by some tracing procedure. It should be mentionedthattheuseofdiscretedatamayintroduceambiguitieslikethatshownintheexampleofFig.1.Thesesituations canproduceinconsistenciesinisosurfaceextractionandcanbesolvedbyincreasingthenumberofsamplepoints.

Thereareseveralmethodsthatusepolygonstoreconstructisosurfacesfromdiscretedata;amongthem,the“marching cubes”algorithm,originallyintroduced byLorensenandCline [12] for3D medicaldatadisposedinacubicgrid,isone of thebestknown.Thisalgorithmcreatesatriangularsurface ofa givenφ level.Inanindividualcube thereare 28 different configurationsbasedontherelativevaluesoftheφ-sampleddataassignedtoits8verticeswithrespecttoφ.Theoriginal algorithm proposed in [12] usestwo different symmetriesto reduce the numberofdistinctive configurations to only14 (see Fig. 3 in[12]), whichare storedin a lookup table to speed up executionofthe algorithm. However, thisreduction introducesatopologicalinconsistencyinthevertexdatawhenatleastonefaceofthecubecontainstwooppositevertices, oneononesideoftheisosurface,andtheotherontheotherside(similartotheambiguoussituationshowninFig.1).This inconsistencyproduces isosurfacesthat mayhaveholesandmaynotbe a2-manifold (seetheexampleofFig. 2).Several effortshavebeenmadetoavoidthisinconsistencyandtoextendtheuseoftheoriginalmarchingcubesalgorithmtoother gridtypes(see,forexample,References[13–20]).

Manycodes,suchasOpenFOAM[21] orSTAR-CCM+[22],arecapableofsimulatingdifferentphysicalphenomenausing complexunstructuredgrids.However,isosurfaceextractiontovisualizeorreconstructmaterialvolumeshasnotbeensolved in a fully satisfactory way forsuch complex grids. The marching tetrahedraalgorithm, originally introduced by Doi and Koide [15], is one of the mostwidely used isosurface extraction algorithms to deal withinconsistencies. It can also be

(3)

Fig. 2. Inconsistencyoftheoriginalmarchingcubesalgorithm.Acombinationofcellswith(a)configuration3ofFig. 3in[12] and(b)thecomplementary symmetriccaseproduces(c)theholeobservedonthebottompicture.

applied tounstructuredgrids, althoughwiththeaddedcost ofan extrasteptodecompose complexpolyhedral cells into tetrahedra.Apromisingneuralnetwork-basedapproachtoefficientlyreconstructandvisualizeinterfacesusingsquare,cubic, triangularortetrahedralgridshasbeenrecentlyproposedbyAtaeietal. [23] inthecontextofVOFmethods.

In thiswork,we proposea method,described inSection 2,that avoidsthe abovementioned inconsistencies by using generalrulesthatdonotrelyonpredefinedconfigurationsandcanbeappliedtoanypolyhedralcell,eitherconvexornon- convex, evenwithnon-planar faces,withoutusing celldecompositions.Tothebest ofourknowledge,there isnosimilar published methodthat providesthisgeneralization. InSection3,differenttestsonseveralgrids are consideredtoextract polygonal isosurfaces from implicit mathematical functions, signed distances to a scanned surface, and volume fraction data obtained from a VOF scheme.Results obtained withan extension to arbitrarymeshes of the CLCIR methodbased on the proposed isosurface extraction methodwill be compared withthose obtained by other authors. The methodhas beenimplementedintheisoaplibrary,publiclyavailableintheMendeleyDatarepository[24],underthetermsofGPLv3 license[25].

2. Methodforisosurfaceextractiononarbitrarypolyhedralcells

The newmethod proposed in thiswork aims toefficiently andconsistently extract the isosurfacecorresponding to a value φ fromthe distributionofvaluesφip ofthescalarvariable φassignedtoevery vertexip ofan arbitrarypolyhedral cell.As alreadymentioned,theφip valuesmaybe obtained,forexample,fromimplicitfunctionsordiscrete datasuch as signeddistancesorvolumefractions,amongothersources.Theisosurfaceisapproximatedlocallyateachcellbyapolygonal surface,whichwillbereferredtoasanisopolygon,usingageneralpolygontracingprocedure.Theverticesoftheisopolygon willbecalledφ-vertices.Thefollowingadditionalconsiderationswillbemade:

theφ-verticesarelocatedatcelledgesconnectingcellverticeswithassignedφvaluesaboveandbelowφ,

(4)

Algorithm1Isosurfaceextraction.

1: Tagcellvertices

2: CalltoAlgorithm2toinserttheφ-vertices

3: CalltoAlgorithm3todefinetheisopolygonsbysequentiallyarrangingtheφ-vertexindices 4: Calculatethepositionvectorsxφoftheφ-verticesfrominterpolation

Table 1

Array IPVofindex ip assignedtoeveryvertexi offace boundary j ofthepolyhedraofFig.3.

Vertex index Face boundary j

i 1 2 3 4 5 6

Cube of Fig.3(a)

1 1 2 3 4 1 6

2 2 1 2 3 4 5

3 3 5 6 7 8 8

4 4 6 7 8 5 7

Non-convex pentapyramid of Fig.3(b)

1 1 1 2 3 4 5

2 5 2 3 4 5 1

3 4 6 6 6 6 6

4 3 − − − − −

5 2 − − − − −

atmost,oneφ-vertexisinsertedateachcelledge,and

theφ-verticesinsertedatcelledgesaresequentiallyjoinedbylinesegments,formingpolygonsthatmaybenon-planar.

TheextractedpolygonalsurfaceforthewholedomaincanbeusedintheimplementationofadvancedPLICschemesinVOF methods(examplesofsuchschemescanbefound,forexample,in[3]),butalsoforvisualizationwithconventionalgraphics- renderingtools,amongotherpurposes. Theconstructionofthepolygonalisosurfacemaybe followedbyadecomposition procedure toconverteach isopolygoninto triangles,butthisisbeyondthe scopeof thepresentwork. Inanycase, most visualizationapplicationscanhandlenon-planarpolygons,ascanbeseenintheresultspresentedinSection3.

Algorithm1performstheproposedisosurfaceextractionprocedure,whichbasicallyconsistsofthefollowingfoursteps:

(1) Thecellverticesaretaggedaccordingtotheirrelativeassignedvalueofφwithrespecttoφ. (2) Aφ-vertexisinsertedoneverycelledgeconnectingcellverticeswithdifferenttags.

(3) Theinserted φ-verticesare sequentiallyordered by apolygon tracing procedure.An anticlockwise orderischosen to sequentiallyconnectalltheφ-verticeswhentheisosurfaceisviewedfromtheoutsideoftheregionwithpositivescalar field(referencemediumwhosesurfaceisrepresented).Thisisthemostcomplexstepofthealgorithmandissomehow similartothecappingprocedurevalidforconvexornon-convexregionspresentedin[26].

(4) Theφ-verticesarefinallypositionedoncelledgesbyinterpolation.

Eachofthesestepsisdetailedinthenextfoursubsections.Thefollowingarrangementofvertices,similartothatused in[26], isconsideredforapolyhedralcell.Letusconsiderageneric (convexornon-convex)polyhedron withNIPV(j) verticeson eachfaceboundary j,eitherplanarornon-planar.Notethata facemaybedefinedbya simplepolygonwith holes,withitsnon-simplyconnectedinteriordelimitedbytwoormorefaceboundaries.Theverticesofeachfaceboundary are arranged sequentially, so that the vector joiningtwo consecutive vertices leavesthe face boundaryto the left when viewedfromoutsidethepolyhedron.Thevertexwithindexip,assignedtovertexi offaceboundary j,isstoredusingthe two-dimensionalarrayIPV(j,i)=ip.Thenotationusedinthedescriptionofthealgorithmsconsidersthattheverticesfor each faceboundaryareordered toforma closedloop.Moredetailsaboutthearrangementofverticesof canbefound in[26]. Asan example,Table1presentsthearrangement ofverticesinthecubeandnon-convexpentapyramid ofFig.3, showingtheindexip assignedtoevery vertexi offaceboundary j (xj,ixip).Foreaseofexplanation,manyexamplesof surfaceextractiononthesepolyhedrawillbepresentedbelowinthissection.Illustrativeexamplesoftheapplicationofthe algorithmtomorecomplexpolyhedralcellswillbepresentedthroughoutthepaper.

2.1. Cellvertextagging

Atevery cellvertexwithindexip,thearrayelementIA(ip)issetequalto1ifφip> φ,or0otherwise.From nowon, cellverticeswithassignedIAelementvaluesequalto1and0willbedepictedwith•andsymbols,respectively,asin Fig.4.

(5)

Fig. 3. Vertex coordinates of (a) a cube and (b) a non-convex pentagonal pyramid.

Fig. 4. Examples of vertex tagging for the cells shown in Fig.3.

(6)

Algorithm2Insertionoftheφ-vertexindices.

1: iφ=0

2: for faceboundaries j intersectedbytheisosurface do 3: i=0

4: for i=1 toNIPV(j)do

5: ip1= IPV(j,i)andip2= IPV(j,i+1) 6: ifIA(ip1)= IA(ip2)then

7: if edgedefinedbyip1andip2waspreviouslyvisited then 8: Identifythepreviouslyinsertedvertexwithindexiφ

9: else

10: Insertanewφ-vertex,withindexiφ=iφ+1

11: end if

12: i=i+1 andIPVINT(j,i)=iφ

13: ifIA(ip2)=1 thenIPVINT(j,i)ismarkedas“keyvertex”

14: end if

15: end for 16: NIPVINT(j)=i 17: end for

Fig. 5. Key(redcross)andprevious(bluecross)φ-verticesforj=2 (boundaryoftheshadedface)intheexampleofFig.6(a).Theisoedgesaredepictedin green.(Forinterpretationofthecolorsinthefigure(s),thereaderisreferredtothewebversionofthisarticle.)

2.2. φ-Vertexinsertion

Algorithm2insertsaφ-vertexateachcelledgeintersectedbytheisosurface.Toillustratetheproceduresusedhereand inthenextsection,theinsertedφ-verticesaredepictedwith×symbolsatthemiddleofthecorrespondingintersectedcell edges(thefinallocationoftheφ-verticeswillbeobtainedfromtheinterpolationproceduredescribedinSection2.4).Each oftheseintersectededgesisdefinedbythetwoverticesoftheedge,withdifferentIAelementvalues.Acellisconsidered tobeintersectedbytheisosurfaceifanyofitsedgesis.TheproceduregoesinsequentialorderovertheNIPV(j)vertices ofeachintersectedfaceboundary j (lines4-15inAlgorithm2) toobtainthearray IPVINT(j,i) thatstorestheindexiφ assignedtoeveryintersectededgeiof j (line12inAlgorithm2).ThearrayNIPVINT(j)storesthetotalnumberofedges ofthefaceboundary j intersectedbytheisosurface(line16inAlgorithm2). Notethateachintersectededgeissharedby two face boundaries, andindex iφ isincreasedby one only ifthe corresponding edge was not previously visitedin this sequentialprocedureoveralltheintersectedfaceboundaries(line10inAlgorithm2).Otherwise,theindexiφ identifiedin aprevious“visit”totheedge(line8inAlgorithm2)isassignedtothearrayIPVINT.

Oneveryintersectedfaceboundary,theinsertedφ-verticeswillbemarkedasfollows(seetheexampleinFig.5):

Aφ-vertexinserted atan intersectededgei,definedby verticeswithindicesip1= IPV(j,i)andip2= IPV(j,i+1), offaceboundary j willbemarkedasa“key φ-vertex”ifIA(ip2)=1 (line13inAlgorithm2;verticesdenotedbyred crosssymbolsintheexampleofFig.5).

If IPVINT(j,i) stores an indexcorresponding to a key φ-vertex inthe face boundary j, the edge joiningit to the previouslyinsertedφ-vertex,whoseindexisstoredasIPVINT(j,i1)(bluecrosssymbolsintheexampleofFig.5), is partofan isopolygon(each ofthegreen linesin theexample ofFig. 5).Note that theprevious φ-vertex ofindex IPVINT(j,i1) must be akey φ-vertex atthe other face boundaryof thecell that shares the celledge in which thisφ-vertex isinserted.Thearray IPVINTisconsideredtoformaclosedloop;thus, fori=1,IPVINT(j,i1)= IPVINT(j,NIPVINT(j)).

(7)

Fig. 6. ExamplesoftheapplicationoftheinsertionprocedureofAlgorithm2forthetwopolyhedraofFig.3.Symbolsanddenotecellverticeswith assignedIAelementvaluesequalto1and0,respectively,andsymbol×denotesφ-vertices(thesamenotationwillbeusedinotherfigures).

Table 2

ArrayIPVINTofindicesiφoftheverticesinsertedontheintersectedfacebound- ariesofthepolyhedraofFig.6.Thekeyφ-verticesinsertedoneveryfaceboundary areboundboxed.

Intersected edge Face boundary j

index i 1 2 3 4 5 6

Cube

1 1 1 2 6 7 4

2 2 3 5 7 3 6

34 − − − −

45 − − − −

Non-convex pentapyramid

1 1 4 3 2 1 5

2 2 5 6 6 7 7

3 3 − − − − −

4 4 − − − − −

Fig.6illustrates theapplicationofAlgorithm2tothepolyhedraofFig.3.Table2showstheresultingarrayIPVINTof indicesiφ,oftheverticesinsertedattheintersectedfaceboundariesofthepolyhedra(thekeyφ-verticesinsertedoneach faceboundaryarehighlightedinthetablebyabox).

2.3. φ-Vertexarrangement

Algorithm 3sequentially arranges all theindices ofthe inserted φ-vertices in anticlockwiseorder when viewedfrom outsidetheregionwithpositivescalarfield(fluidoranothermediumconsideredasreference),toformoneormoreclosed isopolygons.Theisopolygonsconstructedtoapproximatetheisosurfaceareidentifiedwithindexk.Thearray NIPVISO(k) is usedtostore thenumberof φ-verticeson each isopolygonk, andthetwo-dimensional array IPVISO(k,ik) isused to storeeveryφ-vertexindexiφassignedtovertexikofisopolygonk.

Theproposedvertexarrangementprocedureconsistsofthefollowingsteps:

1. Assigntheφ-vertexindexcorrespondingtothefirstvertexofisopolygonk (line2inAlgorithm3).

The first vertex (ik=1) of the first isopolygon (k=1) is assumedto be the first vertex (iφ=1) obtained in the insertionprocedureofSection2.2(line1inAlgorithm3).Note,however,thata differentchoicecould havebeenmade withnolossofgenerality.

2. Applythefollowingrecursiveprocedure(lines3-6inAlgorithm3):

2.i. For the φ-vertex index previously assigned to IPVISO(k,ik), find the intersected face boundary j for which IPVINT(j,i)= IPVISO(k,ik)isakeyφ-vertex(line3inAlgorithm3).

2.ii. Iftheprevious φ-vertexindexstoredatIPVINT(j,i1)isnotcoincidentwithIPVISO(k,1),increaseindexik byone,assignIPVINT(j,i1)toIPVISO(k,ik)andgoto2.i(lines4-6inAlgorithm3).

(8)

Algorithm3Arrangementoftheφ-vertices.

1: k=1 andiφ=1

2: ik=1 andIPVISO(k,ik)=iφ

3: Findj andiforwhichIPVINT(j,i)= IPVISO(k,ik)isa“keyφ-vertex”

4: ifIPVINT(j,i1)= IPVISO(k,1)then

5: ik=ik+1 andIPVISO(k,ik)= IPVINT(j,i1) 6: Goto line3

7: else

8: NIPVISO(k)=ik

9: if therearestillunassignedφ-vertices then 10: Pickanunassignedφ-vertexiφandk=k+1 11: Goto line2toconstructanewisosurfacek 12: end if

13: end if

3. If therearestillunassigned φ-vertices,pickoneofthem,increase indexk byone andgo toStep1toconstructanew isopolygon(lines9-12inAlgorithm3).

Figs. 7and8illustratethe sequenceofapplicationofAlgorithm 3totheexamples ofFigs. 4(a) and4(b),respectively.

Theedgeoftheisopolygonsaredepictedwiththickgreenlines.

ExamplesoftheconstructionofmultipleisopolygonsinpolyhedralcellscanbeseeninFigs.9(a)(fourisopolygons)and 9(b)(eightisopolygons).

2.4. Positioningtheφ-verticesbyinterpolation

Finally, theposition vectorsxφ ofthe φ-verticesare obtainedfrom thefollowing linearinterpolation (line 4 inAlgo- rithm1):

xφ

=

xip2

φ

ip2

−  φ φ

ip2

− φ

ip1



xip2

xip1



.

(1)

Note that, due to the useof strict inequalities (line 6 in Algorithm 2) to determine the φ values involved in Eq. (1), it isguaranteed that φip2 = φip1,and,therefore,thedivide byzeroissuenever occursandthe consistencyoftheisosurface extraction is maintained in cases where the isosurface coincides with a face, edge, or vertex of the cell. It should be mentioned that high-order interpolations based,for example,on the gradient ofφ could havebeen considered (see, for example,Reference[27]),butthiswillbethesubjectoffutureworks.

Fig.10showsthe resultingisopolygonsforthecells ofFig.3 andthe φ-node valuesindicated,which areobtainedby usingtheinterpolationofEq. (1) withφ=0 tocomputethepositionvectorsxφ.

2.5. Softwaredescription

Theimplementedalgorithmextracts,fromdiscretedata,isosurfacesonarbitrary,convexornon-convexpolyhedra,even withnon-planarfaceboundaries.Thesoftwarepackage[24] alsoincludesausermanualandroutinesforwritingthegeom- etry ofpolyhedraandisosurfaces inexternalfiles. Testsprograms areincludedtoextract isosurfaceson singlepolyhedral cellsandgridsofanytype,eitherfromimplicitmathematicalfunctionsordiscretedatasuchasvolumefractionsorsigned distancesto scannedsurfaces.Theimplementedroutinescan beusedin FORTRANandC,withCinterfaces.Tospeedup theoperationsperformedovergrids,theOpenMPapplicationprogramminginterfaceisused.

3. Resultsanddiscussion

A comparison in terms of consistency and computational efficiency between the proposed and the marching cubes algorithms is presented in Section 3.1. Results for isosurfaces constructed from implicit mathematical functions, signed distances toscannedsurfacesandvolumefractiondataobtainedfroma volumeoffluidscheme,usingseveralgrids with convexandnon-convexcells,arepresentedinSection 3.2.Theresultspresentedinthesesectionsarevisualized usingthe ParaViewprogram[28].

3.1. Comparisonbetweentheproposedalgorithmandthemarchingcubesalgorithm

Fig.11showstheisosurfacesextractedusingtheproposedmethodforthepre-definedcubiccellconfigurationsconsid- eredin[12]. Notethatthe resultsforambiguousconfigurations,likethoseshowninFig. 1, differfromthoseobtainedin [12].The inconsistencyobservedinFig.2whenusingtheoriginalmarchingcubesalgorithm[12] isproducedbecausethe

φ-verticeslyingontheisoedgesonanambiguouscellfaceareconnectedusingrulesthatmaybedifferentinthetwocells

(9)

Fig. 7. Constructionsequence(fromtoptobottomandfromlefttoright)oftheisopolygonfortheexampleofFig.4(a).Thecellfaceboundaryinvolvedin eachstepofthesequenceisdepictedgrayfilled.

that sharetheface.Note thatthe extractedisosurfaceseparatestheblack circlesontheleft cell inFig.2,buttheempty circlesontherightcell,producingaholeatthesharedface.Theproposedmethodavoidsthisinconsistencybecauseallthe faceboundariesaretreatedsystematically,usingthesamerulespresentedinAlgorithms2and3.Theextractedisopolygons obtainedusingtheproposedmethodalwaysseparatethecellverticeswithIAvaluesequaltozero,asshownintheexam- pleofFig.12.Bloomenthal [29],WyvillandJevans [30] orDelibasisetal. [31],amongothers,alsousedapolygontracing techniquetoavoidtheseinconsistencies,althoughonlyforcubiccells.

(10)

Fig. 8. Same isopolygon construction sequence as in Fig.7, but for the example of Fig.4(b).

Note that the proposed method relies on general rules which are able to extract isosurfaces on arbitrarypolyhedral cells, whilethe marchingcubestechnique isrestrictedto alistof standardconfigurations forcubiccells. Forcomparison purposes, Fig. 13 presents the isosurfaces of two tests described in [19], where the marching cube algorithm with an extendedmodifiedlookuptablewith21patternsisused.Theuseoflookuptablesinthemarchingcubesalgorithmspeeds up the surface extraction, making our more general algorithm to be, on average, 1.8 times slower (the testswere run for the algorithm in [19] and the proposed algorithm on an iMac Pro (2017) with a 2.3 GHz Intel Xeon W processor using the gcc compiler with -O3compilation option; a ×6 speedup is achieved forthe proposed algorithm using the -fopenmpcompilationoptionandalltheavailablethreads).However,ourmethodisnotconstrainedtousingagivencell geometry.Obviously,toacceleratetheCPU-timeandobtainacomputationalefficiencysimilartothatofthemarchingcubes algorithm,theφ-vertex connectivitycouldhavebeenpre-computedwiththeproposedmethodforeachofthepossible28 cubeconfigurationsandstoredinalookuptableforrapidaccess.Thesameappliesforothercelltypes.

(11)

Fig. 9. Examples of multiple isopolygons constructed on (a) a cubic cell and (b) a dodecahedral cell.

Fig. 10. Resulting isopolygons defined by the position vectors xφcomputed from the interpolation given by Eq. (1) withφ=0.

3.2. Applicationtoseveralgridtypes

Inthissection,thefollowinggridsinaunitdomainareused:

1. Structuredgridwithcubiccells(Fig.14(a)).

2. Unstructuredgridwithtetrahedralcells(Fig.14(b)),obtainedusingTetGen[32] (version1.5)bytyping tetgen option domain.poly

wherethecontentoffiledomain.polyisincludedinAppendixAandthevaluesofthe parameteroption,used to generatethegridswithdifferentresolutionsconsideredinthiswork,areshowninTable3.

3. Structuredgridwithnon-convexcells(Fig.14(c)),obtainedbydistortingcubiccellsasfollows.Eachoftheeightcorner verticesoftheinitialuniformcubicgridofcellsizeh is randomlymovedtothesurface ofaspherewithradius0.25h andcentered inthecorrespondingvertex. Eachface ofthe distortedcell,whichisgenerallynon-planar,istriangulated byjoiningits centerwithtwoconsecutiveverticesoftheface,resultinginanon-convexpolyhedronof14verticesand 24triangularfaces.

4. Unstructured grid withnon-convex irregular polyhedral cells (Fig. 14(d)), obtained withthe aid of TetGen [32] and OpenFOAM’stetgenToFoamandpolyDualMeshtools(see[21] forinformationonhowtousethesetools)bytyping

tetgen option domain.poly tetgenToFoam domain.1

polyDualMesh 75 -concaveMultiCells

(12)

Fig. 11. Results obtained with the proposed method for the 14 pre-defined cell configurations considered in [12].

It should be mentioned that the faces of these cells are generally non-planar. Forthe VOF simulation carried out in Section3.2.3,eachcellfacehasadditionallybeentriangulatedbyjoiningitsgeometriccenterwithtwoconsecutiveface vertices.

Theisosurfacesextractedfromφvaluesobtainedindifferentwaysarepresentedbelowforgridswithn 803 cells,inorder todemonstratetheversatilityoftheproposedalgorithm.

3.2.1. Scalarfieldgivenbyimplicitfunctions

Thescalarfieldφisdefinedateachcellvertexip bythefollowingimplicitfunctions:

φ

ip

=

0

.

3252

− (

xip

xc

)

2

− (

yip

yc

)

2

− (

zip

zc

)

2 (2)

(13)

Fig. 12. The proposed approach avoids the inconsistency of Fig.2.

Table 3

Detailsofthetetrahedralandnon-convexirregularpolyhedralgridsofdifferentresolutionsusedtoassesstheproposed methods.Thenumbersofgridverticesandfacesobtainedaftertriangulatingthefacesofthenon-convexirregularpoly- hedralgridsusedintheVOFsimulationareincludedinparenthesis.

Approx. tetgen Grid Grid Grid Avg. vertices Avg. faces

n1/3 option cells, n vertices faces per cell per cell

Tetrahedral grids

20 -pq1.2a0.00031k 7 923 1 831 16 907 4 4

32 -pq1.2a0.00007k 33 010 6 823 69 080 4 4

40 -pq1.2a0.000034k 63 988 12 400 132 550 4 4

64 -pq1.2a0.0000079k 261 051 47 201 534 515 4 4

80 -pq1.2a0.0000039k 513 711 89 902 1 046 584 4 4

128 -pq1.2a0.00000093k 2 094 575 351 874 4 239 540 4 4 160 -pq1.2a0.00000047k 4 138 041 687 618 8 360 839 4 4

Non-convex irregular polyhedral grids

20 -pq1.2a0.000056k 8 077 48 947 56 673 22.8 13.4

32 -pq1.2a0.000012k 32 887 201 401 233 551 23.6 13.8

(434 952) (1 201 904) (37.4) (70.8)

40 -pq1.2a0.0000056k 64 207 396 276 459 748 24.1 14.0

64 -pq1.2a0.00000127k 262 122 1 638 789 1 899 408 24.6 14.3 (3 538 197) (9 819 651) (38.9) (73.9) 80 -pq1.2a0.00000063k 510 961 3 210 090 3 719 548 24.8 14.4

(6 929 638) (19 247 250) (39.3) (74.5) 128 -pq1.2a0.000000147k 2 101 279 13 312 234 15 410 474 25.2 14.6

(28 722 708) (79 847 053) (39.7) (75.5) 160 -pq1.2a0.0000000745k 4 081 207 25 935 456 30 013 624 25.3 14.6

forasphere,

φ

ip

=

0

.

12



0

.

2

− 

(

xip

xc

)

2

+ (

yip

yc

)

2



1/2



2

− (

zip

zc

)

2 (3)

foratorus,

(14)

Fig. 13. Extractedisosurfacesobtainedfromthe2003volumetricdataprovidedbyMasalaetal. [19] fortwotests,usingagridwith1993cubiccells:(a)

‘visual’(φ=0.5)and(b)‘net’(φ=1.05)tests.

Fig. 14. Cell types: (a) cube, (b) tetrahedron, (c) distorted cube and (d) non-convex irregular polyhedron (note that this cell has non-planar faces).

φ

ip

=

1

x

ip

xc

0

.

4

2

y

ip

yc

0

.

3

2

z

ip

zc

0

.

2

2

(4) foranellipsoid,and

(15)

Fig. 15. Extractedisosurfacesofφ=0 forthesphereofEq. (2),obtainedusingthe(a)cubic,(b)tetrahedral,(c)distortedcubicand(d)non-convexirregular polyhedralgridswithn 803.

φ

ip

= − √

1

3

(

xip

xc

) − √

1

3

(

yip

yc

) − √

1

3

(

zip

zc

)

(5)

fora half-space,where xc=0.525, yc=0.464 and zc=0.516,andxip, yip and zip are thepositionvectorcoordinates of vertexip.

Figs. 15, 16 and17 show the extracted isosurfaces of φ=0 for the sphere of Eq. (2), the torus of Eq. (3) and the ellipsoidofEq. (4),respectively,obtainedusingthe(a)cubic,(b)tetrahedral,(c)distortedcubicand(d)non-convexirregular polyhedralgrids.

Toquantifytheaccuracyoftheisosurfaceextraction,theerrornorms EL

φ

=

max

 φ(

xφ

) 

(6) and

EL1

φ

=

φ(

xφ

)

Nφ (7)

areconsidered,wherethemaxoperatorandthesummationextendoveralltheNφ φ-vertices,andφ (xφ)isobtainedfrom Eqs. (2), (3), (4) or (5) by replacing xip, yip and zip withthe corresponding coordinates of each extracted φ-vertex xφ. The valuesoftheseerrornorms, alongwiththecorresponding convergenceorders,are shownin Tables4,5,6and7for the sphere,torus, ellipsoid andhalfspace, respectively. As expectedforthe linearlyapproximatedisosurface of Eq. (1) [33],itcanbeobservedfromthesetable,foranyofthegridsconsidered,asecond-orderconvergenceforthesphere,torus and ellipsoid,anderrors on the order ofthe machine precision for thehalf-space. The test programs supplied withthe software package use an interval-based approach to create the listof cells over which the algorithms presented in this work areapplied (i.e.,cellswithmaximumandminimumscalarvaluesgreater andlower,respectively, thanφ).The user couldincorporatemoresophisticatedsearchapproaches,suchasthosedescribed,forexample,in[34].Theexecutiontimes consumedto identifythesecells, ti, andextract the isosurfaceon them,tφ,havealsobeen includedinthe tables. Itcan beseen that,foraparticularcombinationofgridtypeandimplicitfunction,thevariationoftiandtφ withrespecttothe totalnumberofgridcells,n,andidentifiedcells,nφ,respectively,isroughlylinear(seetheexampleofFig.18).Theslopes of these variations decrease asthe number of threads used in the simulation executionincreases. Using the maximum

(16)

Fig. 16. Same results as in Fig.15, but for the torus of Eq. (3).

Fig. 17. Same results as in Fig.15, but for the ellipsoid of Eq. (4).

numberofthreadsallowedbytheprocessorusedforthistest,insteadofonlyone,theexecutioncanbespeedupinsome casesby afactorofaround10forti and20fortφ.Alsonotethat,asexpected, fora particularimplicitfunction andgrid sizen, theexecutiontimestendtoincrease asthegridcell complexityincreases(the highcomplexityofthe non-convex irregularpolyhedralgridsbecomesevidentfromthehighvaluesoftheaveragenumberofverticesandfacespercellshown inTable3).

The EL

φ valuesobtainedforφip=1− (xip4)2− (yip4)2− (zip4)2 inadomain 83 usinggrids withcubiccells ofsize h,are compareinFig. 19withthosereportedin[33] andobtainedwithsixdifferentisosurface extractioncodes:

(17)

1603 53030 2.13×105 2.0 5.48×106 2.0 22831 7247 Non-convex irregular polyhedral cells

203 555 4.50×104 1.13×104 309 273

403 2523 7.20×105 2.6 2.44×105 2.2 780 621 803 11033 2.18×105 1.7 5.70×106 2.1 5280 3275 1603 45263 5.60×106 2.0 1.38×106 2.0 78783 16057

Table 5

SameresultsasinTable4,butforthetorusofEq. (3).

n nφ ELφ O EφL1 O ti(μs) tφ(μs)

Cubic cells

203 460 6.25×104 3.52×104 315 226

403 1820 1.56×104 2.0 8.93×105 2.0 570 304 803 7296 3.91×105 2.0 2.13×105 2.1 2803 415 1603 29256 9.77×106 2.0 5.47×106 2.0 20326 1448 Tetrahedral cells

203 498 7.25×103 1.88×103 316 209

403 2264 2.21×103 1.7 4.73×104 2.0 489 247 803 9643 4.56×104 2.3 1.14×104 2.1 2540 493 1603 39439 1.22×104 1.9 2.79×105 2.0 20421 1884 Distorted cubic cells

203 468 1.27×103 2.80×104 292 220

403 1888 3.25×104 2.0 6.85×105 2.0 642 388 803 7856 8.29×105 2.0 1.69×105 2.0 2577 1200 1603 30779 2.17×105 1.9 4.27×106 2.0 22835 4521 Non-convex irregular polyhedral cells

203 335 2.90×104 8.23×105 290 251

403 1543 7.22×105 2.0 1.87×105 2.1 679 467 803 6435 1.91×105 1.9 4.43×106 2.1 5052 2019 1603 27053 4.98×106 1.9 1.06×106 2.1 81421 9710

vtkMarchingCubes[12],SnapMC[35],Macet[36],DualContouring[37],Afront[38] andDelIso[39].Asexpected,theEL φ valuesobtainedwiththeproposedmethodalmostcoincidewiththevtkMarchingCubesandSnapMCcodessincebothuse thesamelinearapproximationofEq. (1).AsmentionedinSection2.4,higher-orderinterpolationsmustbeusedtoobtained moreaccurateresults.

3.2.2. Scalarfieldgivenbysigneddistancestoscannedsurfaces

In this section, the scalar field φ is obtained from the scanned surface of two objects. The first corresponds to the well-knownStanfordbunny[40] andthesecondtoanautomobilepartavailableinourlaboratory.

The scannedStanford bunnyisavailable in[40] fordownloadinpolygon (PLY)format. Weused thefile composedby 35947 vertices and69451 triangles. The scalar field φ is assignedto each grid point fromits signed distance(negative inside the surface and positive outside) to the triangulated bunny surface. This signed distance is computed using the dist3droutinepresentedin[41,42].Fig.20showstheextractedisosurfacesofφ=0 forthefourgridtypesconsidered.

An aluminum alloy A413 automobile part (Fig. 21(a)) was scanned to provide a triangulated surface in PLY format composed of156229 vertices and312458 triangles (Fig. 21(b)). As inthe previous case, the scalar field φ at each grid pointisobtainedfromthesigneddistancetothetriangulatedsurface.Fig.22showstheextractedisosurfacesofφ=0 for

(18)

Fig. 18. Executiontimesti(toppicture)andtφ(bottompicture)asafunctionofn andnφ,respectively,forthesphereofEq. (2) andtetrahedralgridsof differentsizes.

Fig. 19. ErrorELφasafunctionofcellsize,h,obtainedforacubicgridandφip=1− (xip4)2− (yip4)2− (zip4)2,inadomainofsize83.Comparison oftheproposedmethodwithdifferentisosurfaceextractionmethods.

Referencias

Documento similar

In this paper, the new variational method proposed has been successfully applied to several initial value problems arising from chemical reactions composed of large systems of

The homotopy analysis method is a seminumerical scheme applied for the solution of the proposed model problem of heat transfer phenomena in a viscoelastic fluid through a

This test involves a perfored strip under tension, the stress field induces a fracture around the perforation because its tensions are greater there than in the rest of the domain.

In this paper a current sensorless control method of power factor correction for a boost converter based on pre-calculated duty cycle values is proposed, which is similar to

In this paper, we show how these invariant manifolds can be calculated, and used in a formally exact reaction rate calculation based on perturbation theory for any

In this paper, we have introduced a local method to re- duce Gaussian noise from colour images which is based on an eigenvector analysis of the colour samples in each

In this paper we analyze a finite element method applied to a continuous downscaling data assimilation algorithm for the numerical approximation of the two and three dimensional

This is due to the interaction between the Counters-Based traffic conditioner and the dual queuing scheme that makes all TCP connections to send approximately the same amount of