Problem 1313 - tessellated solid inside error due to wrong dimension of tolerance
Summary: tessellated solid inside error due to wrong dimension of tolerance
Status: RESOLVED WORKSFORME
Alias: None
Product: Geant4
Classification: Unclassified
Component: geometry/solids (show other problems)
Version: 9.5
Hardware: All All
: P5 minor
Assignee: tatiana.nikitina
URL:
Depends on:
Blocks:
 
Reported: 2012-05-12 07:36 CEST by Gong Ding
Modified: 2012-07-10 08:58 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
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.