Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // class G4BrentLocator implementation << 26 // $Id: G4BrentLocator.cc,v 1.5 2008/12/11 10:13:41 tnikitin Exp $ >> 27 // GEANT4 tag $Name: geant4-09-02 $ >> 28 // >> 29 // Class G4BrentLocator implementation 27 // 30 // 28 // 27.10.08 - Tatiana Nikitina. 31 // 27.10.08 - Tatiana Nikitina. 29 // 04.10.11 - John Apostolakis, revised conver << 30 // ------------------------------------------- 32 // --------------------------------------------------------------------------- 31 33 32 #include <iomanip> << 33 << 34 #include "G4BrentLocator.hh" 34 #include "G4BrentLocator.hh" 35 #include "G4ios.hh" 35 #include "G4ios.hh" >> 36 #include <iomanip> 36 37 37 G4BrentLocator::G4BrentLocator(G4Navigator *th 38 G4BrentLocator::G4BrentLocator(G4Navigator *theNavigator) 38 : G4VIntersectionLocator(theNavigator) << 39 : G4VIntersectionLocator(theNavigator) 39 { 40 { 40 // In case of too slow progress in finding I 41 // In case of too slow progress in finding Intersection Point 41 // intermediates Points on the Track must be 42 // intermediates Points on the Track must be stored. 42 // Initialise the array of Pointers [max_dep 43 // Initialise the array of Pointers [max_depth+1] to do this 43 44 44 G4ThreeVector zeroV(0.0,0.0,0.0); 45 G4ThreeVector zeroV(0.0,0.0,0.0); 45 for (auto & idepth : ptrInterMedFT) << 46 for (G4int idepth=0; idepth<max_depth+1; idepth++ ) 46 { 47 { 47 idepth = new G4FieldTrack( zeroV, zeroV, 0 << 48 ptrInterMedFT[ idepth ] = new G4FieldTrack( zeroV, zeroV, 0., 0., 0., 0.); 48 } 49 } >> 50 >> 51 // Counters for Locator >> 52 >> 53 // Counter for Maximum Number Of Trial before Intersection Found >> 54 // >> 55 maxNumberOfStepsForIntersection=0; >> 56 >> 57 // Counter for Number Of Calls to ReIntegrationEndPoint Method >> 58 // >> 59 maxNumberOfCallsToReIntegration=0; >> 60 maxNumberOfCallsToReIntegration_depth=0; 49 } 61 } 50 62 51 G4BrentLocator::~G4BrentLocator() 63 G4BrentLocator::~G4BrentLocator() 52 { 64 { 53 for (auto & idepth : ptrInterMedFT) << 65 for ( G4int idepth=0; idepth<max_depth+1; idepth++) >> 66 { >> 67 delete ptrInterMedFT[idepth]; >> 68 } >> 69 #ifdef G4DEBUG_FIELD >> 70 if(fVerboseLevel>0) 54 { 71 { 55 delete idepth; << 72 G4cout << "G4BrentLocator::Location with Max Number of Steps=" >> 73 << maxNumberOfStepsForIntersection<<G4endl; >> 74 G4cout << "G4BrentLocator::ReIntegrateEndPoint was called " >> 75 << maxNumberOfCallsToReIntegration >> 76 << " times and for depth algorithm " >> 77 << maxNumberOfCallsToReIntegration_depth << " times." << G4endl; 56 } 78 } >> 79 #endif 57 } 80 } 58 81 59 // ------------------------------------------- 82 // -------------------------------------------------------------------------- 60 // G4bool G4PropagatorInField::LocateIntersect 83 // G4bool G4PropagatorInField::LocateIntersectionPoint( 61 // const G4FieldTrack& CurveStart 84 // const G4FieldTrack& CurveStartPointVelocity, // A 62 // const G4FieldTrack& CurveEndPo 85 // const G4FieldTrack& CurveEndPointVelocity, // B 63 // const G4ThreeVector& TrialPoint 86 // const G4ThreeVector& TrialPoint, // E 64 // G4FieldTrack& Intersecte 87 // G4FieldTrack& IntersectedOrRecalculated // Output 65 // G4bool& recalculat 88 // G4bool& recalculated) // Out 66 // ------------------------------------------- 89 // -------------------------------------------------------------------------- 67 // 90 // 68 // Function that returns the intersection of t 91 // Function that returns the intersection of the true path with the surface 69 // of the current volume (either the external 92 // of the current volume (either the external one or the inner one with one 70 // of the daughters: 93 // of the daughters: 71 // 94 // 72 // A = Initial point 95 // A = Initial point 73 // B = another point 96 // B = another point 74 // 97 // 75 // Both A and B are assumed to be on the true 98 // Both A and B are assumed to be on the true path: 76 // 99 // 77 // E is the first point of intersection of 100 // E is the first point of intersection of the chord AB with 78 // a volume other than A (on the surface 101 // a volume other than A (on the surface of A or of a daughter) 79 // 102 // 80 // Convention of Use : 103 // Convention of Use : 81 // i) If it returns "true", then Intersect 104 // i) If it returns "true", then IntersectionPointVelocity is set 82 // to the approximate intersection poin 105 // to the approximate intersection point. 83 // ii) If it returns "false", no intersecti 106 // ii) If it returns "false", no intersection was found. 84 // The validity of IntersectedOrRecalcu 107 // The validity of IntersectedOrRecalculated depends on 'recalculated' 85 // a) if latter is false, then Intersec 108 // a) if latter is false, then IntersectedOrRecalculated is invalid. 86 // b) if latter is true, then Intersec 109 // b) if latter is true, then IntersectedOrRecalculated is 87 // the new endpoint, due to a re-int 110 // the new endpoint, due to a re-integration. 88 // ------------------------------------------- 111 // -------------------------------------------------------------------------- 89 // NOTE: implementation taken from G4Propagato 112 // NOTE: implementation taken from G4PropagatorInField 90 // New second order locator is added 113 // New second order locator is added 91 // 114 // 92 G4bool G4BrentLocator::EstimateIntersectionPoi 115 G4bool G4BrentLocator::EstimateIntersectionPoint( 93 const G4FieldTrack& CurveStart 116 const G4FieldTrack& CurveStartPointVelocity, // A 94 const G4FieldTrack& CurveEndPo 117 const G4FieldTrack& CurveEndPointVelocity, // B 95 const G4ThreeVector& TrialPoint 118 const G4ThreeVector& TrialPoint, // E 96 G4FieldTrack& Intersecte 119 G4FieldTrack& IntersectedOrRecalculatedFT, // Output 97 G4bool& recalculat 120 G4bool& recalculatedEndPoint, // Out 98 G4double& fPreviousS 121 G4double& fPreviousSafety, // In/Out 99 G4ThreeVector& fPreviousS 122 G4ThreeVector& fPreviousSftOrigin) // In/Out 100 123 101 { 124 { 102 // Find Intersection Point ( A, B, E ) of t 125 // Find Intersection Point ( A, B, E ) of true path AB - start at E. 103 126 104 G4bool found_approximate_intersection = fals 127 G4bool found_approximate_intersection = false; 105 G4bool there_is_no_intersection = fals 128 G4bool there_is_no_intersection = false; 106 129 107 G4FieldTrack CurrentA_PointVelocity = Curve 130 G4FieldTrack CurrentA_PointVelocity = CurveStartPointVelocity; 108 G4FieldTrack CurrentB_PointVelocity = Curve 131 G4FieldTrack CurrentB_PointVelocity = CurveEndPointVelocity; 109 G4ThreeVector CurrentE_Point = TrialPoint; 132 G4ThreeVector CurrentE_Point = TrialPoint; 110 G4bool validNormalAtE = false; << 111 G4ThreeVector NormalAtEntry; << 112 << 113 G4FieldTrack ApproxIntersecPointV(CurveEndP 133 G4FieldTrack ApproxIntersecPointV(CurveEndPointVelocity); // FT-Def-Construct 114 G4double NewSafety = 0.0; 134 G4double NewSafety = 0.0; 115 G4bool last_AF_intersection = false; 135 G4bool last_AF_intersection = false; 116 136 117 // G4bool final_section= true; // Shows whe 137 // G4bool final_section= true; // Shows whether current section is last 118 // (i.e. B=f 138 // (i.e. B=full end) 119 G4bool first_section = true; 139 G4bool first_section = true; 120 recalculatedEndPoint = false; 140 recalculatedEndPoint = false; 121 141 122 G4bool restoredFullEndpoint = false; 142 G4bool restoredFullEndpoint = false; 123 143 124 G4long oldprc; // cout, cerr precision << 125 G4int substep_no = 0; 144 G4int substep_no = 0; 126 145 127 // Limits for substep number 146 // Limits for substep number 128 // 147 // 129 const G4int max_substeps= 10000; // Test 148 const G4int max_substeps= 10000; // Test 120 (old value 100 ) 130 const G4int warn_substeps= 1000; // 149 const G4int warn_substeps= 1000; // 100 131 150 132 // Statistics for substeps 151 // Statistics for substeps 133 // 152 // 134 static G4ThreadLocal G4int max_no_seen= -1; << 153 static G4int max_no_seen= -1; 135 << 154 static G4int trigger_substepno_print= warn_substeps - 20 ; 136 // Counter for restarting Bintermed << 137 // << 138 G4int restartB = 0; << 139 155 140 //------------------------------------------ 156 //-------------------------------------------------------------------------- 141 // Algorithm for the case if progress in fo 157 // Algorithm for the case if progress in founding intersection is too slow. 142 // Process is defined too slow if after N=p 158 // Process is defined too slow if after N=param_substeps advances on the 143 // path, it will be only 'fraction_done' of 159 // path, it will be only 'fraction_done' of the total length. 144 // In this case the remaining length is div 160 // In this case the remaining length is divided in two half and 145 // the loop is restarted for each half. 161 // the loop is restarted for each half. 146 // If progress is still too slow, the divis 162 // If progress is still too slow, the division in two halfs continue 147 // until 'max_depth'. 163 // until 'max_depth'. 148 //------------------------------------------ 164 //-------------------------------------------------------------------------- 149 165 150 const G4int param_substeps = 50; // Test val << 166 const G4int param_substeps=100; // Test value for the maximum number 151 // of subst << 167 // of substeps 152 const G4double fraction_done = 0.3; << 168 const G4double fraction_done=0.3; 153 169 154 G4bool Second_half = false; // First hal 170 G4bool Second_half = false; // First half or second half of divided step 155 171 156 NormalAtEntry = GetSurfaceNormal(CurrentE_Po << 157 << 158 // We need to know this for the 'final_secti 172 // We need to know this for the 'final_section': 159 // real 'final_section' or first half 'final 173 // real 'final_section' or first half 'final_section' 160 // In algorithm it is considered that the 'S 174 // In algorithm it is considered that the 'Second_half' is true 161 // and it becomes false only if we are in th 175 // and it becomes false only if we are in the first-half of level 162 // depthness or if we are in the first secti 176 // depthness or if we are in the first section 163 177 164 G4int depth = 0; // Depth counts how many su << 178 G4int depth=0; // Depth counts how many subdivisions of initial step made 165 179 166 #ifdef G4DEBUG_FIELD 180 #ifdef G4DEBUG_FIELD 167 const G4double tolerance = 1.0e-8; << 181 static G4double tolerance= 1.0e-8; 168 G4ThreeVector StartPosition = CurveStartPoi << 182 G4ThreeVector StartPosition= CurveStartPointVelocity.GetPosition(); 169 if( (TrialPoint - StartPosition).mag() < tol << 183 if( (TrialPoint - StartPosition).mag() < tolerance * mm ) 170 { 184 { >> 185 G4cerr << "WARNING - G4BrentLocator::EstimateIntersectionPoint()" >> 186 << G4endl >> 187 << " Intermediate F point is on top of starting point A." >> 188 << G4endl; 171 G4Exception("G4BrentLocator::EstimateInte 189 G4Exception("G4BrentLocator::EstimateIntersectionPoint()", 172 "GeomNav1002", JustWarning, << 190 "IntersectionPointIsAtStart", JustWarning, 173 "Intersection point F is exac 191 "Intersection point F is exactly at start point A." ); 174 } 192 } 175 #endif 193 #endif 176 194 177 // Intermediates Points on the Track = Subdi 195 // Intermediates Points on the Track = Subdivided Points must be stored. 178 // Give the initial values to 'InterMedFt' 196 // Give the initial values to 'InterMedFt' 179 // Important is 'ptrInterMedFT[0]', it saves 197 // Important is 'ptrInterMedFT[0]', it saves the 'EndCurvePoint' 180 // 198 // 181 *ptrInterMedFT[0] = CurveEndPointVelocity; 199 *ptrInterMedFT[0] = CurveEndPointVelocity; 182 for (auto idepth=1; idepth<max_depth+1; ++id << 200 for (G4int idepth=1; idepth<max_depth+1; idepth++ ) 183 { 201 { 184 *ptrInterMedFT[idepth] = CurveStartPointVe << 202 *ptrInterMedFT[idepth]=CurveStartPointVelocity; 185 } 203 } 186 204 187 //Final_section boolean store 205 //Final_section boolean store 188 G4bool fin_section_depth[max_depth]; 206 G4bool fin_section_depth[max_depth]; 189 for (bool & idepth : fin_section_depth) << 207 for (G4int idepth=0; idepth<max_depth; idepth++ ) 190 { 208 { 191 idepth = true; << 209 fin_section_depth[idepth]=true; 192 } 210 } 193 211 194 // 'SubStartPoint' is needed to calculate th 212 // 'SubStartPoint' is needed to calculate the length of the divided step 195 // 213 // 196 G4FieldTrack SubStart_PointVelocity = CurveS 214 G4FieldTrack SubStart_PointVelocity = CurveStartPointVelocity; 197 215 198 do // Loop checking, 07.10.2016, J.Apostol << 216 do 199 { 217 { 200 G4int substep_no_p = 0; 218 G4int substep_no_p = 0; 201 G4bool sub_final_section = false; // the s 219 G4bool sub_final_section = false; // the same as final_section, 202 // but f 220 // but for 'sub_section' 203 SubStart_PointVelocity = CurrentA_PointVel 221 SubStart_PointVelocity = CurrentA_PointVelocity; 204 << 222 do // REPEAT param 205 do // Loop checking, 07.10.2016, J.Apost << 223 { 206 { // REPEAT param << 207 G4ThreeVector Point_A = CurrentA_PointVe 224 G4ThreeVector Point_A = CurrentA_PointVelocity.GetPosition(); 208 G4ThreeVector Point_B = CurrentB_PointVe 225 G4ThreeVector Point_B = CurrentB_PointVelocity.GetPosition(); 209 226 210 // F = a point on true AB path close to 227 // F = a point on true AB path close to point E 211 // (the closest if possible) 228 // (the closest if possible) 212 // 229 // 213 if(substep_no_p==0) 230 if(substep_no_p==0) 214 { 231 { 215 ApproxIntersecPointV = GetChordFinderF 232 ApproxIntersecPointV = GetChordFinderFor() 216 ->ApproxCurvePo 233 ->ApproxCurvePointV( CurrentA_PointVelocity, 217 234 CurrentB_PointVelocity, 218 235 CurrentE_Point, 219 236 GetEpsilonStepFor()); 220 // The above method is the key & mo 237 // The above method is the key & most intuitive part ... 221 } 238 } 222 #ifdef G4DEBUG_FIELD 239 #ifdef G4DEBUG_FIELD 223 if( ApproxIntersecPointV.GetCurveLength( 240 if( ApproxIntersecPointV.GetCurveLength() > 224 CurrentB_PointVelocity.GetCurveLengt 241 CurrentB_PointVelocity.GetCurveLength() * (1.0 + tolerance) ) 225 { 242 { >> 243 G4cerr << "ERROR - G4BrentLocator::EstimateIntersectionPoint()" >> 244 << G4endl >> 245 << " Intermediate F point is more advanced than" >> 246 << " endpoint B." << G4endl; 226 G4Exception("G4BrentLocator::EstimateI 247 G4Exception("G4BrentLocator::EstimateIntersectionPoint()", 227 "GeomNav0003", FatalExcept << 248 "IntermediatePointConfusion", FatalException, 228 "Intermediate F point is p 249 "Intermediate F point is past end B point" ); 229 } 250 } 230 #endif 251 #endif 231 252 232 G4ThreeVector CurrentF_Point = ApproxInt << 253 G4ThreeVector CurrentF_Point= ApproxIntersecPointV.GetPosition(); 233 254 234 // First check whether EF is small - the 255 // First check whether EF is small - then F is a good approx. point 235 // Calculate the length and direction of 256 // Calculate the length and direction of the chord AF 236 // 257 // 237 G4ThreeVector ChordEF_Vector = CurrentF 258 G4ThreeVector ChordEF_Vector = CurrentF_Point - CurrentE_Point; 238 G4ThreeVector NewMomentumDir = ApproxIn << 239 G4double MomDir_dot_Norm = NewMome << 240 << 241 #ifdef G4DEBUG_FIELD << 242 G4ThreeVector ChordAB = Point_B - Point << 243 259 244 G4VIntersectionLocator::ReportTrialStep( << 260 if ( ChordEF_Vector.mag2() <= sqr(GetDeltaIntersectionFor()) ) 245 ChordEF_Vector, NewMomentumDir, << 246 #endif << 247 << 248 G4bool adequate_angle; << 249 adequate_angle = ( MomDir_dot_Norm >= 0 << 250 || (! validNormalAtE ); << 251 G4double EF_dist2 = ChordEF_Vector.mag2( << 252 if ( ( EF_dist2 <= sqr(fiDeltaIntersecti << 253 || ( EF_dist2 <= kCarTolerance*kCarTol << 254 { 261 { 255 found_approximate_intersection = true; 262 found_approximate_intersection = true; 256 263 257 // Create the "point" return value 264 // Create the "point" return value 258 // 265 // 259 IntersectedOrRecalculatedFT = ApproxIn 266 IntersectedOrRecalculatedFT = ApproxIntersecPointV; 260 IntersectedOrRecalculatedFT.SetPositio 267 IntersectedOrRecalculatedFT.SetPosition( CurrentE_Point ); 261 268 262 if ( GetAdjustementOfFoundIntersection 269 if ( GetAdjustementOfFoundIntersection() ) 263 { 270 { 264 // Try to Get Correction of Intersec 271 // Try to Get Correction of IntersectionPoint using SurfaceNormal() 265 // 272 // 266 G4ThreeVector IP; 273 G4ThreeVector IP; 267 G4ThreeVector MomentumDir=ApproxInte 274 G4ThreeVector MomentumDir=ApproxIntersecPointV.GetMomentumDirection(); 268 G4bool goodCorrection = AdjustmentOf 275 G4bool goodCorrection = AdjustmentOfFoundIntersection( Point_A, 269 CurrentE_P 276 CurrentE_Point, CurrentF_Point, MomentumDir, 270 last_AF_in 277 last_AF_intersection, IP, NewSafety, 271 fPreviousS 278 fPreviousSafety, fPreviousSftOrigin ); 272 if ( goodCorrection ) 279 if ( goodCorrection ) 273 { 280 { 274 IntersectedOrRecalculatedFT = Appr 281 IntersectedOrRecalculatedFT = ApproxIntersecPointV; 275 IntersectedOrRecalculatedFT.SetPos 282 IntersectedOrRecalculatedFT.SetPosition(IP); 276 } 283 } 277 } 284 } 278 285 279 // Note: in order to return a point on 286 // Note: in order to return a point on the boundary, 280 // we must return E. But it is F 287 // we must return E. But it is F on the curve. 281 // So we must "cheat": we are us 288 // So we must "cheat": we are using the position at point E 282 // and the velocity at point F ! 289 // and the velocity at point F !!! 283 // 290 // 284 // This must limit the length we can a 291 // This must limit the length we can allow for displacement! 285 } 292 } 286 else // E is NOT close enough to the cu 293 else // E is NOT close enough to the curve (ie point F) 287 { 294 { 288 // Check whether any volumes are encou 295 // Check whether any volumes are encountered by the chord AF 289 // ----------------------------------- 296 // --------------------------------------------------------- 290 // First relocate to restore any Voxel 297 // First relocate to restore any Voxel etc information 291 // in the Navigator before calling Com 298 // in the Navigator before calling ComputeStep() 292 // 299 // 293 GetNavigatorFor()->LocateGlobalPointWi 300 GetNavigatorFor()->LocateGlobalPointWithinVolume( Point_A ); 294 301 295 G4ThreeVector PointG; // Candidate i 302 G4ThreeVector PointG; // Candidate intersection point 296 G4double stepLengthAF; 303 G4double stepLengthAF; 297 G4bool usedNavigatorAF = false; << 298 G4bool Intersects_AF = IntersectChord( 304 G4bool Intersects_AF = IntersectChord( Point_A, CurrentF_Point, 299 305 NewSafety,fPreviousSafety, 300 306 fPreviousSftOrigin, 301 307 stepLengthAF, 302 << 308 PointG ); 303 << 304 last_AF_intersection = Intersects_AF; 309 last_AF_intersection = Intersects_AF; 305 if( Intersects_AF ) 310 if( Intersects_AF ) 306 { 311 { 307 // G is our new Candidate for the in 312 // G is our new Candidate for the intersection point. 308 // It replaces "E" and we will repe 313 // It replaces "E" and we will repeat the test to see if 309 // it is a good enough approximate p 314 // it is a good enough approximate point for us. 310 // B <- F 315 // B <- F 311 // E <- G 316 // E <- G 312 // 317 // 313 G4FieldTrack EndPoint = ApproxInters 318 G4FieldTrack EndPoint = ApproxIntersecPointV; 314 ApproxIntersecPointV = GetChordFinde 319 ApproxIntersecPointV = GetChordFinderFor()->ApproxCurvePointS( 315 CurrentA_Poin 320 CurrentA_PointVelocity, CurrentB_PointVelocity, 316 EndPoint,Curr 321 EndPoint,CurrentE_Point, CurrentF_Point,PointG, 317 true, GetEpsi 322 true, GetEpsilonStepFor() ); 318 CurrentB_PointVelocity = EndPoint; 323 CurrentB_PointVelocity = EndPoint; 319 CurrentE_Point = PointG; 324 CurrentE_Point = PointG; 320 << 321 // Need to recalculate the Exit Norm << 322 // Know that a call was made to Navi << 323 // IntersectChord above. << 324 // << 325 G4bool validNormalLast; << 326 NormalAtEntry = GetSurfaceNormal( P << 327 validNormalAtE = validNormalLast; << 328 325 329 // By moving point B, must take care 326 // By moving point B, must take care if current 330 // AF has no intersection to try cur 327 // AF has no intersection to try current FB!! 331 // 328 // 332 fin_section_depth[depth] = false; 329 fin_section_depth[depth] = false; 333 #ifdef G4VERBOSE 330 #ifdef G4VERBOSE 334 if( fVerboseLevel > 3 ) 331 if( fVerboseLevel > 3 ) 335 { 332 { 336 G4cout << "G4PiF::LI> Investigatin 333 G4cout << "G4PiF::LI> Investigating intermediate point" 337 << " at s=" << ApproxInters 334 << " at s=" << ApproxIntersecPointV.GetCurveLength() 338 << " on way to full s=" 335 << " on way to full s=" 339 << CurveEndPointVelocity.Ge 336 << CurveEndPointVelocity.GetCurveLength() << G4endl; 340 } 337 } 341 #endif 338 #endif 342 } 339 } 343 else // not Intersects_AF 340 else // not Intersects_AF 344 { 341 { 345 // In this case: 342 // In this case: 346 // There is NO intersection of AF wi 343 // There is NO intersection of AF with a volume boundary. 347 // We must continue the search in th 344 // We must continue the search in the segment FB! 348 // 345 // 349 GetNavigatorFor()->LocateGlobalPoint 346 GetNavigatorFor()->LocateGlobalPointWithinVolume( CurrentF_Point ); 350 347 351 G4double stepLengthFB; 348 G4double stepLengthFB; 352 G4ThreeVector PointH; 349 G4ThreeVector PointH; 353 G4bool usedNavigatorFB = false; << 354 350 355 // Check whether any volumes are enc 351 // Check whether any volumes are encountered by the chord FB 356 // --------------------------------- 352 // --------------------------------------------------------- 357 353 358 G4bool Intersects_FB = IntersectChor 354 G4bool Intersects_FB = IntersectChord( CurrentF_Point, Point_B, 359 355 NewSafety,fPreviousSafety, 360 356 fPreviousSftOrigin, 361 357 stepLengthFB, 362 << 358 PointH ); 363 << 364 if( Intersects_FB ) 359 if( Intersects_FB ) 365 { 360 { 366 // There is an intersection of FB 361 // There is an intersection of FB with a volume boundary 367 // H <- First Intersection of Chor 362 // H <- First Intersection of Chord FB 368 363 369 // H is our new Candidate for the 364 // H is our new Candidate for the intersection point. 370 // It replaces "E" and we will re 365 // It replaces "E" and we will repeat the test to see if 371 // it is a good enough approximate 366 // it is a good enough approximate point for us. 372 367 373 // Note that F must be in volume v 368 // Note that F must be in volume volA (the same as A) 374 // (otherwise AF would meet a volu 369 // (otherwise AF would meet a volume boundary!) 375 // A <- F 370 // A <- F 376 // E <- H 371 // E <- H 377 // 372 // 378 G4FieldTrack InterMed = ApproxInte << 373 CurrentA_PointVelocity = ApproxIntersecPointV; 379 ApproxIntersecPointV = GetChordFin 374 ApproxIntersecPointV = GetChordFinderFor()->ApproxCurvePointS( 380 CurrentA_PointVeloci 375 CurrentA_PointVelocity,CurrentB_PointVelocity, 381 InterMed,CurrentE_Po << 376 CurrentA_PointVelocity,CurrentE_Point,Point_A,PointH, 382 false,GetEpsilonStep 377 false,GetEpsilonStepFor()); 383 CurrentA_PointVelocity = InterMed; << 384 CurrentE_Point = PointH; 378 CurrentE_Point = PointH; 385 << 386 // Need to recalculate the Exit No << 387 // << 388 G4bool validNormalLast; << 389 NormalAtEntry = GetSurfaceNormal( << 390 validNormalAtE = validNormalLast; << 391 } 379 } 392 else // not Intersects_FB 380 else // not Intersects_FB 393 { 381 { 394 // There is NO intersection of FB 382 // There is NO intersection of FB with a volume boundary 395 383 396 if( fin_section_depth[depth] ) 384 if( fin_section_depth[depth] ) 397 { 385 { 398 // If B is the original endpoint 386 // If B is the original endpoint, this means that whatever 399 // volume(s) intersected the ori 387 // volume(s) intersected the original chord, none touch the 400 // smaller chords we have used. 388 // smaller chords we have used. 401 // The value of 'IntersectedOrRe 389 // The value of 'IntersectedOrRecalculatedFT' returned is 402 // likely not valid 390 // likely not valid 403 391 404 // Check on real final_section o 392 // Check on real final_section or SubEndSection 405 // 393 // 406 if( ((Second_half)&&(depth==0)) 394 if( ((Second_half)&&(depth==0)) || (first_section) ) 407 { 395 { 408 there_is_no_intersection = tru 396 there_is_no_intersection = true; // real final_section 409 } 397 } 410 else 398 else 411 { 399 { 412 // end of subsection, not real 400 // end of subsection, not real final section 413 // exit from the and go to the 401 // exit from the and go to the depth-1 level 414 402 415 substep_no_p = param_substeps+ 403 substep_no_p = param_substeps+2; // exit from the loop 416 404 417 // but 'Second_half' is still 405 // but 'Second_half' is still true because we need to find 418 // the 'CurrentE_point' for th 406 // the 'CurrentE_point' for the next loop 419 // 407 // 420 Second_half = true; 408 Second_half = true; 421 sub_final_section = true; 409 sub_final_section = true; 422 } 410 } 423 } 411 } 424 else 412 else 425 { 413 { 426 if( depth==0 ) << 414 if(depth==0) 427 { 415 { 428 // We must restore the origina 416 // We must restore the original endpoint 429 // 417 // 430 CurrentA_PointVelocity = Curre 418 CurrentA_PointVelocity = CurrentB_PointVelocity; // Got to B 431 CurrentB_PointVelocity = Curve 419 CurrentB_PointVelocity = CurveEndPointVelocity; 432 SubStart_PointVelocity = Curre 420 SubStart_PointVelocity = CurrentA_PointVelocity; 433 ApproxIntersecPointV = GetChor << 434 ->ApproxCurvePo << 435 << 436 << 437 << 438 << 439 restoredFullEndpoint = true; 421 restoredFullEndpoint = true; 440 ++restartB; // counter << 441 } 422 } 442 else 423 else 443 { 424 { 444 // We must restore the depth e 425 // We must restore the depth endpoint 445 // 426 // 446 CurrentA_PointVelocity = Curre 427 CurrentA_PointVelocity = CurrentB_PointVelocity; // Got to B 447 CurrentB_PointVelocity = *ptr 428 CurrentB_PointVelocity = *ptrInterMedFT[depth]; 448 SubStart_PointVelocity = Curre 429 SubStart_PointVelocity = CurrentA_PointVelocity; 449 ApproxIntersecPointV = GetChor << 450 ->ApproxCurvePo << 451 << 452 << 453 << 454 restoredFullEndpoint = true; 430 restoredFullEndpoint = true; 455 ++restartB; // counter << 456 } 431 } 457 } 432 } 458 } // Endif (Intersects_FB) 433 } // Endif (Intersects_FB) 459 } // Endif (Intersects_AF) 434 } // Endif (Intersects_AF) 460 435 461 // Ensure that the new endpoints are n 436 // Ensure that the new endpoints are not further apart in space 462 // than on the curve due to different 437 // than on the curve due to different errors in the integration 463 // 438 // 464 G4double linDistSq, curveDist; 439 G4double linDistSq, curveDist; 465 linDistSq = ( CurrentB_PointVelocity.G 440 linDistSq = ( CurrentB_PointVelocity.GetPosition() 466 - CurrentA_PointVelocity.G 441 - CurrentA_PointVelocity.GetPosition() ).mag2(); 467 curveDist = CurrentB_PointVelocity.Get 442 curveDist = CurrentB_PointVelocity.GetCurveLength() 468 - CurrentA_PointVelocity.G 443 - CurrentA_PointVelocity.GetCurveLength(); 469 444 470 // Change this condition for very stri 445 // Change this condition for very strict parameters of propagation 471 // 446 // 472 if( curveDist*curveDist*(1+2* GetEpsil 447 if( curveDist*curveDist*(1+2* GetEpsilonStepFor()) < linDistSq ) 473 { 448 { 474 // Re-integrate to obtain a new B 449 // Re-integrate to obtain a new B 475 // 450 // 476 G4FieldTrack newEndPointFT= 451 G4FieldTrack newEndPointFT= 477 ReEstimateEndpoint( CurrentA 452 ReEstimateEndpoint( CurrentA_PointVelocity, 478 CurrentB 453 CurrentB_PointVelocity, 479 linDistS 454 linDistSq, // to avoid recalculation 480 curveDis 455 curveDist ); 481 G4FieldTrack oldPointVelB = CurrentB 456 G4FieldTrack oldPointVelB = CurrentB_PointVelocity; 482 CurrentB_PointVelocity = newEndPoint 457 CurrentB_PointVelocity = newEndPointFT; 483 458 484 if ( (fin_section_depth[depth]) 459 if ( (fin_section_depth[depth]) // real final section 485 &&( first_section || ((Second_ha 460 &&( first_section || ((Second_half)&&(depth==0)) ) ) 486 { 461 { 487 recalculatedEndPoint = true; 462 recalculatedEndPoint = true; 488 IntersectedOrRecalculatedFT = newE 463 IntersectedOrRecalculatedFT = newEndPointFT; 489 // So that we can return it, if 464 // So that we can return it, if it is the endpoint! 490 } 465 } 491 } 466 } 492 if( curveDist < 0.0 ) 467 if( curveDist < 0.0 ) 493 { 468 { >> 469 G4cerr << "ERROR - G4BrentLocator::EstimateIntersectionPoint()" >> 470 << G4endl >> 471 << " Error in advancing propagation." << G4endl; 494 fVerboseLevel = 5; // Print out a ma 472 fVerboseLevel = 5; // Print out a maximum of information 495 printStatus( CurrentA_PointVelocity, 473 printStatus( CurrentA_PointVelocity, CurrentB_PointVelocity, 496 -1.0, NewSafety, subst 474 -1.0, NewSafety, substep_no ); 497 std::ostringstream message; << 475 G4cerr << " Point A (start) is " << CurrentA_PointVelocity 498 message << "Error in advancing propa << 476 << G4endl; 499 << " Error in advanci << 477 G4cerr << " Point B (end) is " << CurrentB_PointVelocity 500 << " Point A (start) << 478 << G4endl; 501 << G4endl << 479 G4cerr << " Curve distance is " << curveDist << G4endl; 502 << " Point B (end) << 480 G4cerr << G4endl 503 << G4endl << 481 << "The final curve point is not further along" 504 << " Curve distance i << 482 << " than the original!" << G4endl; 505 << G4endl << 506 << "The final curve point is << 507 << " than the original!" << << 508 483 509 if( recalculatedEndPoint ) 484 if( recalculatedEndPoint ) 510 { 485 { 511 message << "Recalculation of EndPo << 486 G4cerr << "Recalculation of EndPoint was called with fEpsStep= " 512 << GetEpsilonStepFor() << << 487 << GetEpsilonStepFor() << G4endl; 513 } 488 } 514 oldprc = G4cerr.precision(20); << 489 G4cerr.precision(20); 515 message << " Point A (Curve start) << 490 G4cerr << " Point A (Curve start) is " << CurveStartPointVelocity 516 << G4endl << 491 << G4endl; 517 << " Point B (Curve end) << 492 G4cerr << " Point B (Curve end) is " << CurveEndPointVelocity 518 << G4endl << 493 << G4endl; 519 << " Point A (Current start) << 494 G4cerr << " Point A (Current start) is " << CurrentA_PointVelocity 520 << G4endl << 495 << G4endl; 521 << " Point B (Current end) << 496 G4cerr << " Point B (Current end) is " << CurrentB_PointVelocity 522 << G4endl << 497 << G4endl; 523 << " Point S (Sub start) << 498 G4cerr << " Point S (Sub start) is " << SubStart_PointVelocity 524 << G4endl << 499 << G4endl; 525 << " Point E (Trial Point) << 500 G4cerr << " Point E (Trial Point) is " << CurrentE_Point 526 << G4endl << 501 << G4endl; 527 << " Old Point F(Intersectio << 502 G4cerr << " Point F (Intersection) is " << ApproxIntersecPointV 528 << G4endl << 503 << G4endl; 529 << " New Point F(Intersectio << 504 G4cerr << " LocateIntersection parameters are : Substep no= " 530 << G4endl << 505 << substep_no << G4endl; 531 << " LocateIntersecti << 506 G4cerr << " Substep depth no= "<< substep_no_p << " Depth= " 532 << substep_no << G4endl << 507 << depth << G4endl; 533 << " Substep depth no << 534 << depth << G4endl << 535 << " Restarted no= "< << 536 << GetEpsilonStepFor() <<" D << 537 << GetDeltaIntersectionFor() << 538 G4cerr.precision( oldprc ); << 539 508 540 G4Exception("G4BrentLocator::Estimat 509 G4Exception("G4BrentLocator::EstimateIntersectionPoint()", 541 "GeomNav0003", FatalExce << 510 "FatalError", FatalException, >> 511 "Error in advancing propagation."); 542 } 512 } 543 513 544 if( restoredFullEndpoint ) << 514 if(restoredFullEndpoint) 545 { 515 { 546 fin_section_depth[depth] = restoredF 516 fin_section_depth[depth] = restoredFullEndpoint; 547 restoredFullEndpoint = false; 517 restoredFullEndpoint = false; 548 } 518 } 549 } // EndIf ( E is close enough to the cu 519 } // EndIf ( E is close enough to the curve, ie point F. ) 550 // tests ChordAF_Vector.mag() <= maxim 520 // tests ChordAF_Vector.mag() <= maximum_lateral_displacement 551 521 552 #ifdef G4DEBUG_LOCATE_INTERSECTION 522 #ifdef G4DEBUG_LOCATE_INTERSECTION 553 G4int trigger_substepno_print= warn_subs << 554 << 555 if( substep_no >= trigger_substepno_prin 523 if( substep_no >= trigger_substepno_print ) 556 { 524 { 557 G4cout << "Difficulty in converging in 525 G4cout << "Difficulty in converging in " 558 << "G4BrentLocator::EstimateInt 526 << "G4BrentLocator::EstimateIntersectionPoint()" 559 << G4endl 527 << G4endl 560 << " Substep no = " << subst 528 << " Substep no = " << substep_no << G4endl; 561 if( substep_no == trigger_substepno_pr 529 if( substep_no == trigger_substepno_print ) 562 { 530 { 563 printStatus( CurveStartPointVelocity 531 printStatus( CurveStartPointVelocity, CurveEndPointVelocity, 564 -1.0, NewSafety, 0); 532 -1.0, NewSafety, 0); 565 } 533 } 566 G4cout << " State of point A: "; 534 G4cout << " State of point A: "; 567 printStatus( CurrentA_PointVelocity, C 535 printStatus( CurrentA_PointVelocity, CurrentA_PointVelocity, 568 -1.0, NewSafety, substep_ 536 -1.0, NewSafety, substep_no-1, 0); 569 G4cout << " State of point B: "; 537 G4cout << " State of point B: "; 570 printStatus( CurrentA_PointVelocity, C 538 printStatus( CurrentA_PointVelocity, CurrentB_PointVelocity, 571 -1.0, NewSafety, substep_ 539 -1.0, NewSafety, substep_no); 572 } 540 } 573 #endif 541 #endif 574 ++substep_no; << 542 substep_no++; 575 ++substep_no_p; << 543 substep_no_p++; 576 544 577 } while ( ( ! found_approximate_intersect 545 } while ( ( ! found_approximate_intersection ) 578 && ( ! there_is_no_intersection ) 546 && ( ! there_is_no_intersection ) 579 && ( substep_no_p <= param_substep 547 && ( substep_no_p <= param_substeps) ); // UNTIL found or 580 548 // failed param substep 581 first_section = false; 549 first_section = false; 582 550 583 if( (!found_approximate_intersection) && ( 551 if( (!found_approximate_intersection) && (!there_is_no_intersection) ) 584 { 552 { 585 G4double did_len = std::abs( CurrentA_Po 553 G4double did_len = std::abs( CurrentA_PointVelocity.GetCurveLength() 586 - SubStart_PointVelocit 554 - SubStart_PointVelocity.GetCurveLength()); 587 G4double all_len = std::abs( CurrentB_Po 555 G4double all_len = std::abs( CurrentB_PointVelocity.GetCurveLength() 588 - SubStart_PointVelocit 556 - SubStart_PointVelocity.GetCurveLength()); 589 557 590 G4double stepLengthAB; 558 G4double stepLengthAB; 591 G4ThreeVector PointGe; 559 G4ThreeVector PointGe; 592 560 593 // Check if progress is too slow and if 561 // Check if progress is too slow and if it possible to go deeper, 594 // then halve the step if so 562 // then halve the step if so 595 // 563 // 596 if ( ( did_len < fraction_done*all_len ) 564 if ( ( did_len < fraction_done*all_len ) 597 && (depth < max_depth) && (!sub_final_ << 565 && (depth<max_depth) && (!sub_final_section) ) 598 { 566 { 599 Second_half=false; 567 Second_half=false; 600 ++depth; << 568 depth++; 601 569 602 G4double Sub_len = (all_len-did_len)/( 570 G4double Sub_len = (all_len-did_len)/(2.); 603 G4FieldTrack start = CurrentA_PointVel 571 G4FieldTrack start = CurrentA_PointVelocity; 604 auto integrDriver = << 572 G4MagInt_Driver* integrDriver = 605 GetChordFinderFor()-> 573 GetChordFinderFor()->GetIntegrationDriver(); 606 integrDriver->AccurateAdvance(start, S 574 integrDriver->AccurateAdvance(start, Sub_len, GetEpsilonStepFor()); 607 *ptrInterMedFT[depth] = start; 575 *ptrInterMedFT[depth] = start; 608 CurrentB_PointVelocity = *ptrInterMedF 576 CurrentB_PointVelocity = *ptrInterMedFT[depth]; 609 577 610 // Adjust 'SubStartPoint' to calculate 578 // Adjust 'SubStartPoint' to calculate the 'did_length' in next loop 611 // 579 // 612 SubStart_PointVelocity = CurrentA_Poin 580 SubStart_PointVelocity = CurrentA_PointVelocity; 613 581 614 // Find new trial intersection point n 582 // Find new trial intersection point needed at start of the loop 615 // 583 // 616 G4ThreeVector Point_A = CurrentA_Point 584 G4ThreeVector Point_A = CurrentA_PointVelocity.GetPosition(); 617 G4ThreeVector SubE_point = CurrentB_Po 585 G4ThreeVector SubE_point = CurrentB_PointVelocity.GetPosition(); 618 586 619 GetNavigatorFor()->LocateGlobalPointWi 587 GetNavigatorFor()->LocateGlobalPointWithinVolume(Point_A); 620 G4bool Intersects_AB = IntersectChord( 588 G4bool Intersects_AB = IntersectChord(Point_A, SubE_point, 621 589 NewSafety, fPreviousSafety, 622 590 fPreviousSftOrigin,stepLengthAB, 623 591 PointGe); 624 if( Intersects_AB ) 592 if( Intersects_AB ) 625 { 593 { 626 last_AF_intersection = Intersects_AB 594 last_AF_intersection = Intersects_AB; 627 CurrentE_Point = PointGe; 595 CurrentE_Point = PointGe; 628 fin_section_depth[depth] = true; << 596 fin_section_depth[depth]=true; 629 << 630 // Need to recalculate the Exit Norm << 631 // << 632 G4bool validNormalAB; << 633 NormalAtEntry = GetSurfaceNormal( Po << 634 validNormalAtE = validNormalAB; << 635 } 597 } 636 else 598 else 637 { 599 { 638 // No intersection found for first p 600 // No intersection found for first part of curve 639 // (CurrentA,InterMedPoint[depth]). 601 // (CurrentA,InterMedPoint[depth]). Go to the second part 640 // 602 // 641 Second_half = true; 603 Second_half = true; 642 } 604 } 643 } // if did_len 605 } // if did_len 644 606 645 if( (Second_half)&&(depth!=0) ) 607 if( (Second_half)&&(depth!=0) ) 646 { 608 { 647 // Second part of curve (InterMed[dept 609 // Second part of curve (InterMed[depth],Intermed[depth-1]) ) 648 // On the depth-1 level normally we ar 610 // On the depth-1 level normally we are on the 'second_half' 649 611 650 Second_half = true; 612 Second_half = true; 651 613 652 // Find new trial intersection point 614 // Find new trial intersection point needed at start of the loop 653 // 615 // 654 SubStart_PointVelocity = *ptrInterMedF 616 SubStart_PointVelocity = *ptrInterMedFT[depth]; 655 CurrentA_PointVelocity = *ptrInterMedF 617 CurrentA_PointVelocity = *ptrInterMedFT[depth]; 656 CurrentB_PointVelocity = *ptrInterMedF 618 CurrentB_PointVelocity = *ptrInterMedFT[depth-1]; 657 // Ensure that the new endpoints are 619 // Ensure that the new endpoints are not further apart in space 658 // than on the curve due to different 620 // than on the curve due to different errors in the integration 659 // 621 // 660 G4double linDistSq, curveDist; 622 G4double linDistSq, curveDist; 661 linDistSq = ( CurrentB_PointVelocity.G 623 linDistSq = ( CurrentB_PointVelocity.GetPosition() 662 - CurrentA_PointVelocity.G 624 - CurrentA_PointVelocity.GetPosition() ).mag2(); 663 curveDist = CurrentB_PointVelocity.Get 625 curveDist = CurrentB_PointVelocity.GetCurveLength() 664 - CurrentA_PointVelocity.G 626 - CurrentA_PointVelocity.GetCurveLength(); 665 if( curveDist*curveDist*(1+2*GetEpsilo 627 if( curveDist*curveDist*(1+2*GetEpsilonStepFor() ) < linDistSq ) 666 { 628 { 667 // Re-integrate to obtain a new B 629 // Re-integrate to obtain a new B 668 // 630 // 669 G4FieldTrack newEndPointFT = << 631 G4FieldTrack newEndPointFT= 670 ReEstimateEndpoint( CurrentA 632 ReEstimateEndpoint( CurrentA_PointVelocity, 671 CurrentB 633 CurrentB_PointVelocity, 672 linDistS 634 linDistSq, // to avoid recalculation 673 curveDis 635 curveDist ); 674 G4FieldTrack oldPointVelB = CurrentB 636 G4FieldTrack oldPointVelB = CurrentB_PointVelocity; 675 CurrentB_PointVelocity = newEndPoint 637 CurrentB_PointVelocity = newEndPointFT; 676 if ( depth==1 ) << 638 if (depth==1) 677 { 639 { 678 recalculatedEndPoint = true; 640 recalculatedEndPoint = true; 679 IntersectedOrRecalculatedFT = newE 641 IntersectedOrRecalculatedFT = newEndPointFT; 680 // So that we can return it, if it 642 // So that we can return it, if it is the endpoint! 681 } 643 } 682 } 644 } 683 645 684 646 685 G4ThreeVector Point_A = CurrentA_Po 647 G4ThreeVector Point_A = CurrentA_PointVelocity.GetPosition(); 686 G4ThreeVector SubE_point = CurrentB_Po 648 G4ThreeVector SubE_point = CurrentB_PointVelocity.GetPosition(); 687 GetNavigatorFor()->LocateGlobalPointWi 649 GetNavigatorFor()->LocateGlobalPointWithinVolume(Point_A); 688 G4bool Intersects_AB = IntersectChord( 650 G4bool Intersects_AB = IntersectChord(Point_A, SubE_point, NewSafety, 689 651 fPreviousSafety, 690 652 fPreviousSftOrigin,stepLengthAB, PointGe); 691 if( Intersects_AB ) 653 if( Intersects_AB ) 692 { 654 { 693 last_AF_intersection = Intersects_AB 655 last_AF_intersection = Intersects_AB; 694 CurrentE_Point = PointGe; 656 CurrentE_Point = PointGe; 695 << 696 G4bool validNormalAB; << 697 NormalAtEntry = GetSurfaceNormal( P << 698 validNormalAtE = validNormalAB; << 699 } 657 } 700 658 701 depth--; 659 depth--; 702 fin_section_depth[depth]=true; 660 fin_section_depth[depth]=true; 703 } 661 } 704 } // if(!found_aproximate_intersection) 662 } // if(!found_aproximate_intersection) 705 663 706 } while ( ( ! found_approximate_intersection 664 } while ( ( ! found_approximate_intersection ) 707 && ( ! there_is_no_intersection ) 665 && ( ! there_is_no_intersection ) 708 && ( substep_no <= max_substeps) ) 666 && ( substep_no <= max_substeps) ); // UNTIL found or failed 709 667 710 if( substep_no > max_no_seen ) 668 if( substep_no > max_no_seen ) 711 { 669 { 712 max_no_seen = substep_no; 670 max_no_seen = substep_no; 713 #ifdef G4DEBUG_LOCATE_INTERSECTION << 714 if( max_no_seen > warn_substeps ) 671 if( max_no_seen > warn_substeps ) 715 { 672 { 716 trigger_substepno_print = max_no_seen-20 673 trigger_substepno_print = max_no_seen-20; // Want to see last 20 steps 717 } << 674 } 718 #endif << 719 } 675 } 720 676 721 if( ( substep_no >= max_substeps) 677 if( ( substep_no >= max_substeps) 722 && !there_is_no_intersection 678 && !there_is_no_intersection 723 && !found_approximate_intersection ) 679 && !found_approximate_intersection ) 724 { 680 { 725 G4cout << "ERROR - G4BrentLocator::Estimat << 681 G4cerr << "WARNING - G4BrentLocator::EstimateIntersectionPoint()" 726 << " Start and end-point of << 682 << G4endl >> 683 << " Convergence is requiring too many substeps: " >> 684 << substep_no << G4endl; >> 685 G4cerr << " Abandoning effort to intersect. " << G4endl; >> 686 G4cerr << " Information on start & current step follows in cout." >> 687 << G4endl; >> 688 G4cout << "WARNING - G4BrentLocator::EstimateIntersectionPoint()" >> 689 << G4endl >> 690 << " Convergence is requiring too many substeps: " >> 691 << substep_no << G4endl; >> 692 G4cout << " Found intersection = " >> 693 << found_approximate_intersection << G4endl >> 694 << " Intersection exists = " >> 695 << !there_is_no_intersection << G4endl; >> 696 G4cout << " Start and Endpoint of Requested Step:" << G4endl; 727 printStatus( CurveStartPointVelocity, Curv 697 printStatus( CurveStartPointVelocity, CurveEndPointVelocity, 728 -1.0, NewSafety, 0); 698 -1.0, NewSafety, 0); 729 G4cout << " Start and end-point of << 699 G4cout << G4endl; >> 700 G4cout << " 'Bracketing' starting and endpoint of current Sub-Step" >> 701 << G4endl; 730 printStatus( CurrentA_PointVelocity, Curre 702 printStatus( CurrentA_PointVelocity, CurrentA_PointVelocity, 731 -1.0, NewSafety, substep_no-1 703 -1.0, NewSafety, substep_no-1); 732 printStatus( CurrentA_PointVelocity, Curre 704 printStatus( CurrentA_PointVelocity, CurrentB_PointVelocity, 733 -1.0, NewSafety, substep_no); 705 -1.0, NewSafety, substep_no); 734 std::ostringstream message; << 706 G4cout << G4endl; 735 message << "Too many substeps!" << G4endl << 707 G4cout.precision( 10 ); 736 << " Convergence is requi << 737 << substep_no << G4endl << 738 << " Abandoning effort to << 739 << " Found intersection = << 740 << found_approximate_intersection << 741 << " Intersection exists << 742 << !there_is_no_intersection << G4 << 743 oldprc = G4cout.precision( 10 ); << 744 G4double done_len = CurrentA_PointVelocity 708 G4double done_len = CurrentA_PointVelocity.GetCurveLength(); 745 G4double full_len = CurveEndPointVelocity. 709 G4double full_len = CurveEndPointVelocity.GetCurveLength(); 746 message << " Undertaken only length << 710 G4cout << "ERROR - G4BrentLocator::EstimateIntersectionPoint()" 747 << " out of " << full_len << " req << 711 << G4endl 748 << " Remaining length = " < << 712 << " Undertaken only length: " << done_len 749 G4cout.precision( oldprc ); << 713 << " out of " << full_len << " required." << G4endl; >> 714 G4cout << " Remaining length = " << full_len - done_len << G4endl; 750 715 751 G4Exception("G4BrentLocator::EstimateInter 716 G4Exception("G4BrentLocator::EstimateIntersectionPoint()", 752 "GeomNav0003", FatalException, << 717 "UnableToLocateIntersection", FatalException, >> 718 "Too many substeps while trying to locate intersection."); 753 } 719 } 754 else if( substep_no >= warn_substeps ) 720 else if( substep_no >= warn_substeps ) 755 { 721 { 756 oldprc = G4cout.precision( 10 ); << 722 G4int oldprc= G4cout.precision( 10 ); 757 std::ostringstream message; << 723 G4cout << "WARNING - G4BrentLocator::EstimateIntersectionPoint()" 758 message << "Many substeps while trying to << 724 << G4endl 759 << G4endl << 725 << " Undertaken length: " 760 << " Undertaken length: " << 726 << CurrentB_PointVelocity.GetCurveLength(); 761 << CurrentB_PointVelocity.GetCurve << 727 G4cout << " - Needed: " << substep_no << " substeps." << G4endl 762 << " - Needed: " << substep_no << << 728 << " Warning level = " << warn_substeps 763 << " Warning level = " << << 729 << " and maximum substeps = " << max_substeps << G4endl; 764 << " and maximum substeps = " << m << 765 G4Exception("G4BrentLocator::EstimateInter 730 G4Exception("G4BrentLocator::EstimateIntersectionPoint()", 766 "GeomNav1002", JustWarning, me << 731 "DifficultyToLocateIntersection", JustWarning, >> 732 "Many substeps while trying to locate intersection."); 767 G4cout.precision( oldprc ); 733 G4cout.precision( oldprc ); 768 } 734 } 769 return !there_is_no_intersection; // Succe 735 return !there_is_no_intersection; // Success or failure 770 } 736 } 771 737