Problem 1943 - Infinite loop for overlap checking in placements for elliptical tube and boolean
Summary: Infinite loop for overlap checking in placements for elliptical tube and boolean
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: geometry (show other problems)
Version: 10.3
Hardware: Apple Mac OS X
: P4 major
Assignee: Evgueni.Tcherniaev
URL:
Depends on:
Blocks:
 
Reported: 2017-02-21 11:26 CET by Laurie Nevay
Modified: 2017-02-22 11:07 CET (History)
1 user (show)

See Also:


Attachments
Edited B1 example to reproduce the problem (48.35 KB, application/zip)
2017-02-21 11:26 CET, Laurie Nevay
Details
Screenshot of elliptical geometry as shown in our framework (540.35 KB, image/png)
2017-02-21 11:27 CET, Laurie Nevay
Details
Time profiler screenshot showing time in G4BooleanSolid::GetPointOnSurface (448.70 KB, image/png)
2017-02-21 11:28 CET, Laurie Nevay
Details

Note You need to log in before you can comment on or make changes to this problem.
Description Laurie Nevay 2017-02-21 11:26:39 CET
Created attachment 441 [details]
Edited B1 example to reproduce the problem

In Geant4.10.3 we see infinite loops on overlap checking with lots of solids. The overlap checking never finishes and never reports any warnings.  This makes Geant4.10.3 unusable for us.  We see no overlaps with the exact same geometry in earlier version of Geant4 and experience no tracking problems.

We have a framework that makes Geant4 models of accelerators (BDSIM) and we have factories that produce various shapes of beam pipe (circular, elliptical, rectangular etc).  These are composed of straight sections with angled faces.

We have a nightly ctest test suite running on ~300 tests that report no geometry problems in Geant4.10.0 -> Geant4.10.2.p03 - no overlaps.  This is long standing code that has worked fine and produced desired results.

I've edited the B1 example to reproduce the problem and attached it.  It should be run like

./exampleB1 exampleB1.in

Apart from the geometry, I made minor edits to the stepping action and primary generator by commenting out bits of code to exclude warnings from geometry specific look ups for scoring & coordinate generation.

I also attach a screenshot of a time profiler (xcode) showing the code spending all of its time in overlap checking and calling the random number generator for testing the solids.

The geometry consists of an elliptical container with angled faces.  Inside this are a 'vacuum' volume and a beam pipe volume.  The vacuum volume is a similar elliptical tube with angled faces that's just smaller.  The beam pipe is a subtraction of two elliptical tubes (to make a hollow elliptical tube) that is then intersected with a cut tubs to give the angled faces.  The vacuum volume and beam pipe are placed inside the 'container' with is in turn placed in the world.

I also attach a screenshot of roughly what this type of geometry would look like in our application.

We see this particularly with G4EllipticalTube + G4IntersectionSolid or G4SubtractionSolid.  But also with the same setup but with G4Box used instead of G4EllipticalTube.
Comment 1 Laurie Nevay 2017-02-21 11:27:45 CET
Created attachment 442 [details]
Screenshot of elliptical geometry as shown in our framework
Comment 2 Laurie Nevay 2017-02-21 11:28:43 CET
Created attachment 443 [details]
Time profiler screenshot showing time in G4BooleanSolid::GetPointOnSurface
Comment 3 Evgueni.Tcherniaev 2017-02-22 11:07:02 CET
Thank you for reporting the problem. In reality there is no infinite loop in your test, it is just very slow. On my computer userDetector->Construct() takes 10 mins:

/run/initialize
userDetector->Construct() start.
Placing vacuum in container
Checking overlaps for volume beampipe_vacuum_pv ... OK!
Placing beam pipe in container
Checking overlaps for volume beampipe_beampipe_pv ... OK!
Placing container in world
Checking overlaps for volume beampipe_container_pv ... OK!
=== Timer: User=593.42s Real=602.26s Sys=2.06s

The reason is inefficient implementation of G4CutTubs::GetSurfaceArea().
After correction the test runs much faster:

=== Timer: User=0.42s Real=0.43s Sys=0s

Corrected G4CutTubs is already available in the	repository and will be included in the next patch.