|Message: Re: Segmentation fault after material re-use||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)|
Hi Marek, This looks "interesting" indeed... At this point, I would guess this is not much due to re-using a same material, which is perfectly legal, but I would suspect a nasty effect of the "inline const" method of the G4LogicalVolume GetMaterial() method, probably compiler related, and/or some confusion of the kernel because the world volume is being contructed, but not yet handled by the kernel (to which it is passed to, at the end of the Construct() method). In itself, your code is not wrong to me. I would suggest: - to fix (hopefully) your problem : start by having a "worldMaterial" pointer that you pass to all the volumes which should have this same material - you submit a but report. Please indicate your configuration (Geant4 version, OS, compiler, compiler version, etc...) at this might have relation to these. Please provide the stack trace as well. Cheers, Marc On 10/18/2013 05:33 PM, Marek Szuba wrote: > *** Discussion title: Geometry > > Hello, > > I have built very simple Geant4 geometry consisting of an aluminium box > with mylar windows in two walls and filled, for the time being, the same > material as the world volume. In the code it looks roughly like this: > > G4NistManager* nist = G4NistManager::Instance(); > > /* World volume */ > G4Material* air = nist->FindOrBuildMaterial("G4_AIR"); > G4VSolid* worldSolid = new G4Box("World", 6*m, 2*m, 20*m); > G4LogicalVolume* logicalWorld = new G4LogicalVolume(worldSolid, air, "World"); > new PVPlacement(NULL, G4ThreeVector(), logicalWorld, "World", NULL, false, 0, true); > > /* Box part 1 - solid aluminium */ > G4Material* boxWalls = nist->FindOrBuildMaterial("G4_Al"); > G4VSolid* boxSolid = new G4Box("Box", 270*cm, 49*cm, 180*cm); > G4LogicalVolume* boxLV = new G4LogicalVolume(boxSolid, boxWalls, "Box"); > new PVPlacement(NULL, G4ThreeVector(0., 0., 300*cm), boxLV, "Box", logicalWorld, false, 0, true); > > /* Box part 2 - gaps in walls, same material as surroundings */ > G4VSolid* windowGapSolid = new G4Box("Box window gap", 270*cm - 1*cm, 49*cm - 1*cm, 1*mm); > G4LogicalVolume* windowGapLV = new G4LogicalVolume(windowGapSolid, logicalWorld->GetMaterial(), "Box window gap"); > new PVPlacement(NULL, G4ThreeVector(0., 0., -(180*cm - 1*mm)), windowGapLV, "Box window gap upstream", boxLV, false, 0, true); > new PVPlacement(NULL, G4ThreeVector(0., 0., +(180*cm - 1*mm)), windowGapLV, "Box window gap downstream", boxLV, false, 1, true); > > /* Box part 3 - gas inside it. At the moment the box is leaky i.e. is filled with same material as surroundings. */ > G4Material* gasInBox = logicalWorld->GetMaterial(); > G4VSolid* boxGasSolid = new G4Box("Box gas", 270*cm - 2*mm, 49*cm - 2*mm, 180*cm - 2*mm); > G4LogicalVolume* boxGasLV = new G4LogicalVolume(boxGasSolid, gasInBox, "Box gas"); > new PVPlacement(NULL, G4ThreeVector(), boxGasLV, "Box gas", boxLV, false, 0, true); > > /* Box part 4 - mylar foil in windows */ > G4Material* mylar = nist->FindOrBuildMaterial("G4_MYLAR"); > G4VSolid* windowFoilSolid = new G4Box("Box window foil", 270*cm - 2*mm, 49*cm - 2*mm, 0.05*mm); > G4LogicalVolume* windowFoilLV = new G4LogicalVolume(windowFoilSolid, mylar, "Box window foil"); > new PVPlacement(NULL, G4ThreeVector(0., 0., -(180*cm - 2*mm - 0.05*mm)), windowFoilLV, "Box window foil upstream", boxGasLV, false, 0, true); > new PVPlacement(NULL, G4ThreeVector(0., 0., +(180*cm - 2*mm - 0.05*mm)), windowFoilLV, "Box window foil downstream", boxGasLV, false, 1, true); > > Now, if I stop detector construction after part 2 everything works fine > even though I do re-use world material for window gaps. If however I > include part 3 in the process, initialisation of Geant aborts with a > segmentation fault and the following stack trace: > > [...snipped irrelevant bit...] > #5 > #6 AddMaterial (aMaterial=0x7f5d00000005, this=0x25cc890) at /path/to/geant4.9.6.p02/source/geometry/management/src/G4Region.cc:422 > #7 G4Region::ScanVolumeTree (this=this > entry=0x25cc890, lv=0x3f88500, region=region > entry=true) at /path/to/geant.9.6.p02/source/geometry/management/src/G4Region.cc:129 > #8 0x00007f5dee979c01 in G4Region::ScanVolumeTree (this=this > entry=0x25cc890, lv=0x2e29000, region=region > entry=true) at /path/to/geant4.9.6.p02/source/geometry/management/src/G4Region.cc:215 > #9 0x00007f5dee97b4fe in G4Region::AddRootLogicalVolume (this=0x25cc890, lv=lv > entry=0x2e29000) at /path/to/geant4.9.6.p02/source/geometry/management/src/G4Region.cc:243 > #10 0x00007f5df14bab3a in G4RunManagerKernel::DefineWorldVolume (this=0x253c8e0, worldVol=, topologyIsChanged=topologyIsChanged > entry=false) at /path/to/geant4.9.6.p02/source/run/src/G4RunManagerKernel.cc:220 > #11 0x00007f5df14b41b6 in G4RunManager::InitializeGeometry (this=0x253d000) at /path/to/geant4.9.6.p02/source/run/src/G4RunManager.cc:388 > #12 0x00007f5df14b3ed1 in G4RunManager::Initialize (this=0x253d000) at /path/to/geant4.9.6.p02/source/run/src/G4RunManager.cc:373 > [...snipped irrelevant bit...] > > The error also happens if I stop construction after creating boxGasLV - > i.e. not only is there no foil in windows but even the gas volume itself > doesn't get placed inside the box. To make things even more interesting, > if instead of setting gasInBox to logicalWorld->GetMaterial() I invoke > nist->FindOrBuildMaterial("G4_AIR") again, the error vanishes - only to > appear again as a result of creation of windowFoilLV . > > Having spent the larger part of today going over my code both visually > and with gdb, I had to eventually admit defeat and ask my question here. > Thank you in advance for any hints which will help me fix this issue! If > you need any more information, just let me know. All the best, > -- > MS > ------------------------------------------------------------- > Visit this GEANT4 at hypernews.slac.stanford.edu message (to reply or unsubscribe) at: > http://hypernews.slac.stanford.edu/HyperNews/geant4/get/geometry/1302.html
|Inline Depth:||Outline Depth:||Add message:|