|Message: Re: Complex object by chaining G4IntersectionSolid||Not Logged In (login)|
Click on the Forum title, e.g. on the "Forums by Category" page, to read a sequence of postings to the Forum and its threads all in one page. If you are only interested in one thread or the thread following a specific posting, click the thread or the posting, which takes you to a smaller page, which contains only the part you are interested in and may be easier to navigate.
Messages are "chained" if there are only replies at the first level, i.e. 1/1.html, 1/1/1.html etc. In case of "chained" messages the message number is replaced by the icon and there is no indentation.
Inline: Display the subject line only or also the text of the posting(s); for the choice "All" the "Outline" choices are switched off.
|1||0||1||no text / full text of posting|
|2||1||All||text for level 1 only / text for All postings|
Outline: Choose the depth of the posting thread, successive toggle controls provide increasing detail.
|1||2||1||2 levels / 1 level (original posting)|
|2||3||2||3 levels / 2 levels|
|3||3||All||3 levels / all levels (all postings)|
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:||Outline Depth:||Add message:|