90 : fDefaultDeltaChord(0.25 * mm)
91{
92
93
94 constexpr G4int nVar6 = 6;
95
96 fDeltaChord = fDefaultDeltaChord;
97
98
99
100 G4bool useFSALstepper= (stepperDriverId == 1);
101 G4bool useTemplatedStepper= (stepperDriverId == 2);
102 G4bool useRegularStepper = (stepperDriverId == 3);
103
104
105
106
107
109
110 using TemplatedStepperType =
112 const char* TemplatedStepperName =
113 "G4TDormandPrince745 (templated Dormand-Prince45, aka DoPri5): 5th/4th Order 7-stage embedded";
114
115 using RegularStepperType =
117
118
119
120
121
122 const char* RegularStepperName =
123 "G4DormandPrince745 (aka DOPRI5): 5th/4th Order 7-stage embedded";
124
125
126
128
129 const char* NewFSALStepperName =
130 "G4RK574FEq1> FSAL 4th/5th order 7-stage 'Equilibrium-type' #1.";
131
132#ifdef G4DEBUG_FIELD
133 static G4bool verboseDebug =
true;
134 if( verboseDebug )
135 {
136 G4cout <<
"G4ChordFinder 2nd Constructor called. " <<
G4endl;
138 <<
" - min step = " << stepMinimum <<
G4endl
139 << " - stepper ptr provided : "
140 << ( pItsStepper==
nullptr ?
" no " :
" yes " ) <<
G4endl;
141 if( pItsStepper==nullptr )
142 G4cout <<
" - stepper/driver Id = " << stepperDriverId <<
" i.e. "
143 << " useFSAL = " << useFSALstepper
144 << " , useTemplated = " << useTemplatedStepper
145 << " , useRegular = " << useRegularStepper
146 << " , useFSAL = " << useFSALstepper
148 }
149#endif
150
151
152
154 fEquation = pEquation;
155
156
157
158
159
160 G4bool errorInStepperCreation =
false;
161
162 std::ostringstream message;
163
164 if( pItsStepper != nullptr )
165 {
166 if( gVerboseCtor )
167 G4cout <<
" G4ChordFinder: Creating G4IntegrationDriver<G4MagIntegratorStepper> with "
168 << " stepMinimum = " << stepMinimum
169 <<
" numVar= " << pItsStepper->GetNumberOfVariables() <<
G4endl;
170
172 stepMinimum, pItsStepper, pItsStepper->GetNumberOfVariables());
173
174
175
176
177
178
179 }
180 else if ( useTemplatedStepper )
181 {
182 if( gVerboseCtor )
183 G4cout <<
" G4ChordFinder: Creating Templated Stepper of type> "
184 << TemplatedStepperName <<
G4endl;
185
186 auto templatedStepper = new TemplatedStepperType(pEquation);
187
188
189
190
191 fRegularStepperOwned = templatedStepper;
192 if( templatedStepper == nullptr )
193 {
194 message <<
"Templated Stepper instantiation FAILED." <<
G4endl;
195 message << "G4ChordFinder: Attempted to instantiate "
196 << TemplatedStepperName <<
" type stepper " <<
G4endl;
197 errorInStepperCreation = true;
198 }
199 else
200 {
202 stepMinimum, templatedStepper, nVar6 );
203 if( gVerboseCtor )
204 G4cout <<
" G4ChordFinder: Using G4IntegrationDriver. " <<
G4endl;
205 }
206
207 }
208 else if ( useRegularStepper )
209 {
210 auto regularStepper = new RegularStepperType(pEquation);
211
212 fRegularStepperOwned = regularStepper;
213
214 if( gVerboseCtor )
215 G4cout <<
" G4ChordFinder: Creating Driver for regular stepper.";
216
217 if( regularStepper == nullptr )
218 {
219 message <<
"Regular Stepper instantiation FAILED." <<
G4endl;
220 message << "G4ChordFinder: Attempted to instantiate "
221 << RegularStepperName <<
" type stepper " <<
G4endl;
222 errorInStepperCreation = true;
223 }
224 else
225 {
227 if( dp5 ) {
229 stepMinimum, dp5, nVar6 );
230 if( gVerboseCtor )
231 G4cout <<
" Using InterpolationDriver<DoPri5> " <<
G4endl;
232 } else {
234 stepMinimum, regularStepper, nVar6 );
235 if( gVerboseCtor )
236 G4cout <<
" Using IntegrationDriver<DoPri5> " <<
G4endl;
237 }
238 }
239 }
240 else if ( !useFSALstepper )
241 {
243
244
245 fRegularStepperOwned = regularStepper;
246
247 {
250
251 fLongStepper = std::unique_ptr<G4HelixHeum>(
new G4HelixHeum(pEquation));
252
254 std::unique_ptr<SmallStepDriver>(new SmallStepDriver(stepMinimum,
255 regularStepper, regularStepper->GetNumberOfVariables())),
256 std::unique_ptr<LargeStepDriver>(new LargeStepDriver(stepMinimum,
257 fLongStepper.get(), regularStepper->GetNumberOfVariables())) );
258
259 if( fIntgrDriver == nullptr)
260 {
261 message << "Using G4BFieldIntegrationDriver with "
262 << RegularStepperName <<
" type stepper " <<
G4endl;
263 message <<
"Driver instantiation FAILED." <<
G4endl;
266 }
267 }
268 }
269 else
270 {
271 auto fsalStepper= new NewFsalStepperType(pEquation);
272
273 fNewFSALStepperOwned = fsalStepper;
274
275 if( fsalStepper == nullptr )
276 {
277 message <<
"Stepper instantiation FAILED." <<
G4endl;
278 message << "Attempted to instantiate "
279 << NewFSALStepperName <<
" type stepper " <<
G4endl;
282 errorInStepperCreation = true;
283 }
284 else
285 {
286 fIntgrDriver = new
288 fsalStepper->GetNumberOfVariables() );
289
290
291 if( fIntgrDriver == nullptr )
292 {
293 message << "Using G4FSALIntegrationDriver with stepper type: "
294 << NewFSALStepperName <<
G4endl;
295 message <<
"Integration Driver instantiation FAILED." <<
G4endl;
298 }
299 }
300 }
301
302
303
304
305
306
307
308
309
310
311
312 if( errorInStepperCreation || (fIntgrDriver == nullptr ))
313 {
314 std::ostringstream errmsg;
315
316 if( errorInStepperCreation )
317 {
318 errmsg <<
"ERROR> Failure to create Stepper object." <<
G4endl
319 <<
" --------------------------------" <<
G4endl;
320 }
321 if (fIntgrDriver == nullptr )
322 {
323 errmsg << "ERROR> Failure to create Integration-Driver object."
325 << " -------------------------------------------"
327 }
328 const std::string BoolName[2]= { "False", "True" };
329 errmsg <<
" Configuration: (constructor arguments) " <<
G4endl
330 <<
" provided Stepper = " << pItsStepper <<
G4endl
331 << " stepper/driver Id = " << stepperDriverId << " i.e. "
332 << " useTemplated = " << BoolName[useTemplatedStepper]
333 << " useRegular = " << BoolName[useRegularStepper]
334 << " useFSAL = " << BoolName[useFSALstepper]
335 << " using combo BField Driver = " <<
336 BoolName[ ! (useFSALstepper||useTemplatedStepper
337 || useRegularStepper ) ]
339 errmsg << message.str();
340 errmsg << "Aborting.";
341 G4Exception(
"G4ChordFinder::G4ChordFinder() - constructor 2",
343 }
344
345 assert( ( pItsStepper != nullptr )
346 || ( fRegularStepperOwned != nullptr )
347 || ( fNewFSALStepperOwned != nullptr )
348 );
349 assert( fIntgrDriver != nullptr );
350}
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)