Problem 1313

Summary: tessellated solid inside error due to wrong dimension of tolerance
Product: Geant4 Reporter: Gong Ding <gdiso>
Component: geometry/solidsAssignee: tatiana.nikitina
Status: RESOLVED WORKSFORME    
Severity: minor    
Priority: P5    
Version: 9.5   
Hardware: All   
OS: All   

Description Gong Ding 2012-05-12 07:36:17 CEST
For a small (~um) tessellated solid, the Inside function sometimes gives undetermined result.

I spend some time to debug and find the problem is caused by G4TriangularFacet Intersect function.

Here is the code:

  G4double d       = E[0].dot(DD);
  G4double e       = E[1].dot(DD);
  G4double s       = b*e - c*d;
  G4double t       = b*d - a*e;

  G4double sTolerance = (std::fabs(b)+ std::fabs(c) + std::fabs(d)
                       + std::fabs(e)) *kCarTolerance;
  G4double tTolerance = (std::fabs(a)+ std::fabs(b) + std::fabs(d)
                       + std::fabs(e)) *kCarTolerance;
  G4double detTolerance = (std::fabs(a)+ std::fabs(c)
                       + 2*std::fabs(b) ) *kCarTolerance;

  if (s < -sTolerance || t < -tTolerance || ( s+t - det ) > detTolerance)   

both a/b/c/d/e has the dimension of L^2, as a result, s and t should have the dimension as L^4. However, the sTolerance / tTolerance / detTolerance  only ~ L^3.

I guess  sTolerance / tTolerance / detTolerance should be changed to

  G4double sTolerance = (std::fabs(b)+ std::fabs(c) + std::fabs(d)
                       + std::fabs(e)) *kCarTolerance*kCarTolerance;
  G4double tTolerance = (std::fabs(a)+ std::fabs(b) + std::fabs(d)
                       + std::fabs(e)) *kCarTolerance*kCarTolerance;
  G4double detTolerance = (std::fabs(a)+ std::fabs(c)
                       + 2*std::fabs(b) ) *kCarTolerance*kCarTolerance;
Comment 1 tatiana.nikitina 2012-06-07 08:28:58 CEST
Dear Gong Ding,

Could you send us more information about the solid or a source code were error happens. It will help to understand the problem.

Thank you,

Best Regards,

Tatiana.