Problem 2142 - A PhysicalVolume with more than two BorderSurface will not be writed to GDML file in correct way.
Summary: A PhysicalVolume with more than two BorderSurface will not be writed to GDML ...
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: persistency/gdml (show other problems)
Version: 10.5
Hardware: All Linux
: P4 minor
Assignee: Witold.Pokorski
URL:
: 2148 (view as problem list)
Depends on:
Blocks:
 
Reported: 2019-03-01 11:41 CET by Binbin Qi
Modified: 2019-04-12 15:29 CEST (History)
1 user (show)

See Also:


Attachments
Test file (2.72 KB, text/plain)
2019-04-11 13:12 CEST, Witold.Pokorski
Details
Test output (4.39 KB, text/plain)
2019-04-11 13:12 CEST, Witold.Pokorski
Details
A new GDML file which can reproduce my problem (2.74 KB, text/plain)
2019-04-11 14:35 CEST, Binbin Qi
Details

Note You need to log in before you can comment on or make changes to this problem.
Description Binbin Qi 2019-03-01 11:41:27 CET
When a PhysicalVolume has boundaries with multiple different PhysicalVolumes, you need to define multiple BorderSurfaces. However, the GDML write operation only write the first defined BorderSurface of each PhysicalVolume to the GDML file.

  For example, A PhysicalVolume called physicalVolumeA has boundaries with physicalVolumeB and physicalVolumeC, the code shows as bellow:

   new G4LogicalBorderSurface(“nameAB”, 
              physicalVolumeA, physicalVolumeB, opSurfaceAB);
   new G4LogicalBorderSurface(“nameAC”, 
              physicalVolumeA, physicalVolumeC, opSurfaceAC);

Then Only the BoderSurfaceAB is writed to GDML file, and the BorderSurfaceAC is ignored.

Suggested fix:
  343 const G4LogicalBorderSurface*
  344 G4GDMLWriteStructure::GetBorderSurface(const G4VPhysicalVolume* const pvol)
  345 {
  346   G4LogicalBorderSurface* surf = 0;
  347   G4int nsurf = G4LogicalBorderSurface::GetNumberOfBorderSurfaces();
  348   if (nsurf)
  349   {
  350     const G4LogicalBorderSurfaceTable* btable =
  351           G4LogicalBorderSurface::GetSurfaceTable();
  352     std::vector<G4LogicalBorderSurface*>::const_iterator pos;
  353     for (pos = btable->begin(); pos != btable->end(); pos++)
  354     {
  355       if (pvol == (*pos)->GetVolume1())  // just the first in the couple 
  356       {                                  // is enough
  357         surf = *pos; //break;
  358         BorderSurfaceCache(surf);  //add this code
  359       }
  360     }
  361   }
  362   return surf;
  363 }

  And in G4GDMLWriteStructure::TraverseVolumeTree(),make the following changes:

  546        //BorderSurfaceCache(GetBorderSurface(physvol));
  547        GetBorderSurface(physvol);
Comment 1 Gabriele Cosmo 2019-03-13 09:41:17 CET
*** Problem 2148 has been marked as a duplicate of this problem. ***
Comment 2 Witold.Pokorski 2019-04-11 13:12:16 CEST
Created attachment 562 [details]
Test file
Comment 3 Witold.Pokorski 2019-04-11 13:12:56 CEST
Created attachment 563 [details]
Test output
Comment 4 Witold.Pokorski 2019-04-11 13:15:59 CEST
Hi,

I am a bit confused. I tried running example G01 (load_gdml executable, without your changes applied) with the GDML file attached opticalsurfaces2.gdml which, as far as I see, contains a volume with two boarder surfaces as you have described. When I write out the gdml file, I get what is in output_test.gdml which contains two border surfaces as expected.
Could you please provide a gdml file that I could use to reproduce your problem?

Cheers,
Witek
Comment 5 Binbin Qi 2019-04-11 14:34:52 CEST
Hi,

In opticalsurface2.gdml, two bordersurfaces are defined,but they are belong to different physicsvolume.

  <bordersurface name="bordersrf1" surfaceproperty="surf2" >
    <physvolref ref="pv1"/>
    <physvolref ref="pv2"/>
  </bordersurface> 

  <bordersurface name="bordersrf2" surfaceproperty="surf2" >
    <physvolref ref="pv2"/>
    <physvolref ref="pv3"/>
  </bordersurface>

If you use bellow code to reproduce my problem
  <bordersurface name="bordersrf1" surfaceproperty="surf2" >
    <physvolref ref="pv2"/>
    <physvolref ref="pv1"/> <!-- difference -->
  </bordersurface> 

  <bordersurface name="bordersrf2" surfaceproperty="surf2" >
    <physvolref ref="pv2"/>
    <physvolref ref="pv3"/>
  </bordersurface>
Comment 6 Binbin Qi 2019-04-11 14:35:37 CEST
Created attachment 564 [details]
A new GDML file which can reproduce my problem
Comment 7 Witold.Pokorski 2019-04-12 15:29:24 CEST
Yes, you are right. Thanks. Your fix is going in the patch release.
Comment 8 Witold.Pokorski 2019-04-12 15:29:42 CEST
Yes, you are right. Thanks. Your fix is going in the patch release.