Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unified Solids Marek Gayer, John Apostolakis, Gabriele Cosmo, Andrei Gheata, Jean-Marie Guyader, Tatiana Nikitina CERN PH/SFT The 17 th Geant4 Collaboration.

Similar presentations


Presentation on theme: "Unified Solids Marek Gayer, John Apostolakis, Gabriele Cosmo, Andrei Gheata, Jean-Marie Guyader, Tatiana Nikitina CERN PH/SFT The 17 th Geant4 Collaboration."— Presentation transcript:

1 Unified Solids Marek Gayer, John Apostolakis, Gabriele Cosmo, Andrei Gheata, Jean-Marie Guyader, Tatiana Nikitina CERN PH/SFT The 17 th Geant4 Collaboration Meeting, Chartres, France, September 10-14, 2012

2 Motivations for a common solids library Optimize and guarantee better long-term maintenance of Root and Gean4 solids libraries o A rough estimation indicates that about 70-80% of code investment for the geometry modeler concerns solids, to guarantee the required precision and efficiency in a huge variety of combinations Create a single library of high quality implementations o Starting from what exists today in Geant4 and Root o Adopt a single type for each shape o Create a new Multi-Union solid o Make high quality, much faster Tessellated Solid o Aims to replace solid libraries in Geant4 and Root o Allowing to reach complete conformance to GDML solids schema Create extensive testing suite Marek Gayer - Unified Solids9/11/20122

3 Navigation functionality and library services for each solid Performance critical methods: o Location of point either inside, outside or on surface o Shortest distance to surface for outside points o Shortest distance to surface for inside points o Distance to surface for inside points with given direction o Distance to surface for outside points with given direction o Normal vector for closest surface from given point Additional methods: Bounding Box, Capacity, Volume, Generating points on surface/edge/inside of solid, creating mesh / polyhedra for visualization Marek Gayer - Unified Solids9/11/20123

4 Notes Build system for USolids and it’s tests = Cmake. Works both on Linux and Windows Marek Gayer - Unified Solids9/11/20124

5 Topics presented next: Testing suite New Multi Union Solid Tessellated Solid made fast Marek Gayer - Unified Solids9/11/20125

6 Testing Suite Solid Batch Test Optical Escape Data analysis and performance (SBT DAP) Specialized tests (e.g. quick performance scalability test for multi-union) Marek Gayer - Unified Solids9/11/20126

7 Optical Escape Test Optical photons are generated inside a solid Repeatedly bounce on the reflecting inner surface Particles must not escape the solid Marek Gayer - Unified Solids9/11/20127

8 Solids Batch Test (SBT) Points and vectors test o Generating groups of inside, outside and surface points o Testing all distance methods with numerous checks E.g. for each inside random point p, SafetyFromInside(p) must be > 0 Voxels (boxes) tests o Randomly sized voxels with random inside points Scriptable application, creates logs Extendible C++ framework o Allowing easy addition of new tests Marek Gayer - Unified Solids9/11/20128

9 Data Analysis and Performance (DAP) Marek Gayer - Unified Solids9/11/20129

10 DAP features Extension of the SBT framework Centred around testing Unified Solids together with existing Geant4 and Root solids Performance and values their differences from different codes can be compared Tests with pre-calculated, randomly generated sets of points and vectors Constrain: aim to reach similar or better performance in each method The core part of Unified Solids testing Two phases o Sampling phase (generation of data sets, implemented as C++ app.) o Support for batch scripting Detailed configuration of conditions in the tests Invoking several tests sequentially o Analysis phase (data post-processing, implemented as MATLAB scripts) Portable: Windows, Linux, Mac Marek Gayer - Unified Solids9/11/201210

11 DAP - DAP - Sampling phase Marek Gayer - Unified Solids9/11/201211

12 DAP - A DAP - Analysis phase Visualization of scalar and vector data sets and shapes Visual analysis of differences Graphs with comparison of performance and scalability Inspection of values and differences of data sets Marek Gayer - Unified Solids9/11/201212

13 Visualization of scalar and vector data sets Marek Gayer - Unified Solids9/11/201213

14 3D plots allowing to overview data sets Marek Gayer - Unified Solids9/11/201214

15 3D visualization of investigated shapes Marek Gayer - Unified Solids9/11/201215

16 Support for regions of data, focusing on sub-parts Marek Gayer - Unified Solids9/11/201216

17 Visual analysis of differences Marek Gayer - Unified Solids9/11/201217

18 Visual analysis of differences in 3D Marek Gayer - Unified Solids9/11/201218

19 Graphs with comparison of performance Marek Gayer - Unified Solids9/11/201219

20 Visualization of scalability performance for specific solids Marek Gayer - Unified Solids Number of z sections -> 9/11/201220

21 Inspection of values and differences of scalar and vector data sets Marek Gayer - Unified Solids9/11/201221

22 New Multi-Union solid Marek Gayer - Unified Solids9/11/201222

23 Boolean Union solids Marek Gayer - Unified Solids Existing CSG Boolean solids (Root and Geant4) represented as binary trees o To solve navigation requests, most of the solids composing a complex one have to be checked o Scalability is typically linear => low performance for solids composed of many parts Boolean Union solid: is composite of two solids, either primitive or Boolean [The pictures were produced by users of Wikipedia “Captain Sprite” and “Zottie” and are available under Creative Commons Attribution-Share Alike 3.0 Unported license ] 9/11/201223

24 Multi-Union solid We implemented a new solid as a union of many solids using voxelization technique to optimize the speed o 3D space partition for fast localization of components o Aiming for a log(n) scalability Useful also for several complex composites made of many solids with regular patterns Marek Gayer - Unified Solids9/11/201224

25 1. Create voxel space (2D simplification) Marek Gayer - Unified Solids x y 9/11/201225

26 2. Usage of bit masks for storing voxels Marek Gayer - Unified Solids9/11/201226

27 Scaling of Multi-Union vs. Boolean solid Marek Gayer - Unified Solids9/11/201227

28 Test union solids for scalability measurements Marek Gayer - Unified Solids9/11/201228

29 Test union solids for scalability measurements Marek Gayer - Unified Solids9/11/201229

30 Test union solids for scalability measurements Marek Gayer - Unified Solids9/11/201230

31 The most performance critical methods Marek Gayer - Unified Solids9/11/201231

32 Tessellated Solid made fast Marek Gayer - Unified Solids9/11/201232

33 Test case a mechanical part with ~1.100 faces – key-1.1k.gdml Marek Gayer - Unified Solids9/11/201233

34 Test case foil with ~2.500 faces – foil-2.5k.gdml Marek Gayer - Unified Solids9/11/201234

35 Test case foil ~164.000 faces for LHC experiment – foil-164k.gdml Marek Gayer - Unified Solids9/11/201235

36 Tessellated Solid notes The algorithms and datastructures were voxelized resulting in dramatical performance enhancement in the all most performance critical methods Also, G4TesselatedSolid had several weak parts of algorithm, used at initialization which had n 2 complexity. This sometimes caused very huge delays (e.g. in case of foil with 164k faces) We rewrote them to have n ∙ log n complexity Analysis for huge speedup of Normal, SafetyFromInside, SafetyFromOutside methods done, implementing now Analysis for lowering of ~33%+ of original memory requirements done, implementing now Very soon to be implemented for Geant4 9.6 as G4TesselatedSolid (without bridge) Marek Gayer - Unified Solids9/11/201236

37 Performance – 1.1k/SCL 5 with 10k voxels Speedup: 15x 1638x+ 19.4x 9.04x Marek Gayer - Unified Solids9/11/201237

38 Performance – 2.5k/SCL5 with 10k voxels Speedup: 33x 1000x+ 22x 23x Marek Gayer - Unified Solids9/11/201238

39 Performance – 164k/SCL5 with 10k voxels Speedup: 240x 1000x+ 133x 397x Marek Gayer - Unified Solids9/11/201239

40 Memory overhead requirements for voxelization Marek Gayer - Unified Solids Voxels / Casekey-1.1k.gdmlfoil-2.5k.gdmlfoil-164k.gdml 10001.6% 10.0004.5%4%3.9% 100.00016.5%12.2%8.7% 1.000.000101%| 593/1193kB60% | 1.1/1.8MB19.5% | 66/79MB 9/11/201240

41 In addition, G4TesselatedSolid memory requirements will be lessened by ~33% Each of tessel (can be millions) contains class G4VFacet Each of these facets self-contain between others these fields: string geometryType: “G4TriangularFacet” int nVertices = 3 double radiusSq // used only in constructor, as temp. variable std::vector used (2x), even in cases of triangle; but std::vector can take e.g. 16+ bytes even when is empty G4TessellatedGeometryAlgorithms *tGeomAlg Data fields are planned to be moved to inherited classes (also for the reason that quadrangular facet is currently implemented as two triangular facets). G4VFacet will be without data fields, only methods, becoming a real interface There are more things to improve there, we listed only some of most obvious things needed to be replaced 9/11/2012Marek Gayer - Unified Solids41

42 Tesselated Solid -TODO Autodetect optimal number of voxels, probably based on benchmarking of few random points with methods DistanceToIn/Out and Inside. Using already precalculated empty’s to do it quickly SafetyFromOutside / SafetyFromInside? Visualization data-structures routines were not ported Marek Gayer - Unified Solids9/11/201242

43 Status of work Types and USolid interface are defined Bridge classes defined and implemented for both Geant4 and Root Testing suite defined and deployed Implementation of Multi-Union as well as Tessellated solid performance optimized and nearly completed Started implementation of primitives: First implementation of Box, Orb (simple full sphere) and Trd (simple trapezoid) Currently implementing: Cone, Tube and their segment version Marek Gayer - Unified Solids9/11/201243

44 Future work Give priority to the most critical solids and those where room for improvement can be easily identified Systematically analyze and implement remaining solids in the new library Marek Gayer - Unified Solids9/11/201244

45 Thank you for your attention. ?????? Questions ? Marek Gayer - Unified Solids9/11/201245

46 BakS - Visualizing mesh in Matlab (sbtpolyhedra.m) function res = sbtpolyhedra(method) filenameVertices = [method 'Vertices.dat']; filenameTriangles = [method 'Triangles.dat']; filenameQuads = [method 'Quads.dat']; vertices = load(filenameVertices); quads = load(filenameQuads); triangles = load(filenameTriangles); hold on; h = patch('vertices',vertices,'faces',quads,'facecolor','c','edgecolor','b') ; % draw faces in blue alpha(h,.1); h = patch('vertices',vertices,'faces',triangles,'facecolor','c','edgecolor', 'b'); % draw faces in blue alpha(h,.1); view(3), grid on;% default view with grid end Marek Gayer - Unified Solids9/11/201246

47 BakS - Visualizing vectors of points in Matlab with color bar Key matlab commands: o colormap('default'); o scatter3 (points(:,1), points(:,2), points(:,3), pointsize, values, 'filled'); o colorbar; Scatter3 here uses table of points – each row consists of x, y, z than array of pointsize. But pointsize can be as well a numeric constant, which would be used for all points Marek Gayer - Unified Solids9/11/201247

48 BakS - Visualizing vectors with Matlab Marek Gayer - Unified Solids quiver3(x,y,z,u,v,w,color) ; x,y,z : array of points U,v,w: array of vector directions for corresponding point Color – colours used for vectors 9/11/201248


Download ppt "Unified Solids Marek Gayer, John Apostolakis, Gabriele Cosmo, Andrei Gheata, Jean-Marie Guyader, Tatiana Nikitina CERN PH/SFT The 17 th Geant4 Collaboration."

Similar presentations


Ads by Google