Message: Re: Complex object by chaining G4IntersectionSolid Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: Complex object by chaining G4IntersectionSolid 

Forum: Geometry
Re: None Complex object by chaining G4IntersectionSolid (Francesc Massanes)
Date: Dec 29, 19:46
From: Michael H. Kelsey <Michael H. Kelsey>

On Sat, 29 Dec 2018 19:18:18 GMT, Francesc Massanes wrote:
> I am generating a complex solid by taking a G4Box and then removing a large
> set (60k+) of G4Tubs with different angles.
> 
> obj = new G4Box ...
> cylinder = new G4Tubs ...
> for ( int i = 0; i < 1<<16; ++i )
>     obj = new G4IntersectionSolid(obj, cylinder, M[i]);
> new G4Placement ....
[...]

What I've discovered is that that deep a chain of intersections can cause problems, either due to the depth of the calling stack, or due to cumulative rounding issues. I can't really "prove" this in the code, it's just an observation.

One way to improve this is to form a shallower union of the tubs, and then do a single subtraction of that union from the box. You're allowed to do this, even if the union is disjoint, so long as the union is never itself placed as a physical volume.

To make the "shallow union", there are two approaches: Make unions of pairs, then union pairs of those, and so on until you've built the whole set. With 60k objects, the nesting will be only 16 layers deep instead of 60,000 layers. Alternatively, if you're using "USOLIDS", you can use the G4MultiUnion class to form a single union out of a set of solids by repeatedly calling AddNode(solid, transform).

Once you've got your big union, just subtract it once from the G4Box. You "should" find that your geometry is better behaved.

Also, you mentioned that maybe you could split the box into pieces and do subtraction in the individual pieces. Are the different sub-boxes identical to one another? If so, then that's also a better choice: make the "unit cell" shape, and just place it multiple times into your world (or mother volume).

  -- Michael Kelsey

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 More: Re: Complex object by chaining G4IntersectionSolid   (Francesc Massanes - Dec 30, 08:45)
(_ Ok: Re: Complex object by chaining G4IntersectionSolid   (Francesc Massanes - Dec 31, 16:46)
 Add Message Add Message
to: "Re: Complex object by chaining G4IntersectionSolid"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]