@@ -125,12 +125,18 @@ bool Foam::minimizationScheme::convergedXScale
125125 const scalarList & s
126126) const
127127{
128- forAll (xErrors_ , i )
128+ forAll (xAbsErrors_ , i )
129129 {
130- xErrors_ [i ] = mag (errors [i ]);
131- xRelErrors_ [i ] = xErrors_ [i ]/stabilise (mag (s [i ]), small );
130+ xAbsErrors_ [i ] = mag (errors [i ]);
131+ xRelErrors_ [i ] = xAbsErrors_ [i ]/stabilise (mag (s [i ]), small );
132132 }
133- return checkConvergence (xErrors_ , xRelErrors_ , xTolerances_ , xRelTolerances_ );
133+ return checkConvergence
134+ (
135+ xAbsErrors_ ,
136+ xRelErrors_ ,
137+ xAbsTolerances_ ,
138+ xRelTolerances_
139+ );
134140}
135141
136142
@@ -141,14 +147,14 @@ bool Foam::minimizationScheme::convergedXScale
141147 const label cmpt
142148) const
143149{
144- xErrors_ [cmpt ] = mag (error );
145- xRelErrors_ [cmpt ] = xErrors_ [cmpt ]/stabilise (mag (s ), small );
150+ xAbsErrors_ [cmpt ] = mag (error );
151+ xRelErrors_ [cmpt ] = xAbsErrors_ [cmpt ]/stabilise (mag (s ), small );
146152
147153 return checkConvergence
148154 (
149- xErrors_ [cmpt ],
155+ xAbsErrors_ [cmpt ],
150156 xRelErrors_ [cmpt ],
151- xTolerances_ [cmpt ],
157+ xAbsTolerances_ [cmpt ],
152158 xRelTolerances_ [cmpt ]
153159 );
154160}
@@ -160,13 +166,19 @@ bool Foam::minimizationScheme::convergedX
160166 const scalarList & x2
161167) const
162168{
163- forAll (xErrors_ , i )
169+ forAll (xAbsErrors_ , i )
164170 {
165- xErrors_ [i ] = mag (x2 [i ] - x1 [i ]);
171+ xAbsErrors_ [i ] = mag (x2 [i ] - x1 [i ]);
166172 xRelErrors_ [i ] =
167- xErrors_ [i ]/stabilise (min (mag (x1 [i ]), mag (x2 [i ])), small );
173+ xAbsErrors_ [i ]/stabilise (min (mag (x1 [i ]), mag (x2 [i ])), small );
168174 }
169- return checkConvergence (xErrors_ , xRelErrors_ , xTolerances_ , xRelTolerances_ );
175+ return checkConvergence
176+ (
177+ xAbsErrors_ ,
178+ xRelErrors_ ,
179+ xAbsTolerances_ ,
180+ xRelTolerances_
181+ );
170182}
171183
172184
@@ -177,15 +189,15 @@ bool Foam::minimizationScheme::convergedX
177189 const label cmpt
178190) const
179191{
180- xErrors_ [cmpt ] = mag (x2 - x1 );
192+ xAbsErrors_ [cmpt ] = mag (x2 - x1 );
181193 xRelErrors_ [cmpt ] =
182- xErrors_ [cmpt ]/stabilise (min (mag (x1 ), mag (x2 )), small );
194+ xAbsErrors_ [cmpt ]/stabilise (min (mag (x1 ), mag (x2 )), small );
183195
184196 return checkConvergence
185197 (
186- xErrors_ [cmpt ],
198+ xAbsErrors_ [cmpt ],
187199 xRelErrors_ [cmpt ],
188- xTolerances_ [cmpt ],
200+ xAbsTolerances_ [cmpt ],
189201 xRelTolerances_ [cmpt ]
190202 );
191203}
@@ -197,10 +209,16 @@ bool Foam::minimizationScheme::convergedYScale
197209 const scalar s
198210) const
199211{
200- yError_ = mag (error );
201- yRelError_ = yError_ /stabilise (mag (s ), small );
212+ yAbsError_ = mag (error );
213+ yRelError_ = yAbsError_ /stabilise (mag (s ), small );
202214
203- return checkConvergence (yError_ , yRelError_ , yTolerance_ , yRelTolerance_ );
215+ return checkConvergence
216+ (
217+ yAbsError_ ,
218+ yRelError_ ,
219+ yAbsTolerance_ ,
220+ yRelTolerance_
221+ );
204222}
205223
206224
@@ -210,10 +228,16 @@ bool Foam::minimizationScheme::convergedY
210228 const scalar y2
211229) const
212230{
213- yError_ = mag (y2 - y1 );
231+ yAbsError_ = mag (y2 - y1 );
214232 yRelError_ =
215- yError_ /stabilise (min (mag (y1 ), mag (y2 )), small );
216- return checkConvergence (yError_ , yRelError_ , yTolerance_ , yRelTolerance_ );
233+ yAbsError_ /stabilise (min (mag (y1 ), mag (y2 )), small );
234+ return checkConvergence
235+ (
236+ yAbsError_ ,
237+ yRelError_ ,
238+ yAbsTolerance_ ,
239+ yRelTolerance_
240+ );
217241}
218242
219243
@@ -268,18 +292,18 @@ void Foam::minimizationScheme::printStepInformation
268292{
269293 if (debug > 2 )
270294 {
271- if (xErrors_ .size () > 1 )
295+ if (xAbsErrors_ .size () > 1 )
272296 {
273297 Info << "Step: " << stepi_ << ":" << endl ;
274298 if (checkX_ )
275299 {
276300 Info << " Errors (abs/rel): "
277- << xErrors_ << ", " << xRelErrors_ << endl ;
301+ << xAbsErrors_ << ", " << xRelErrors_ << endl ;
278302 }
279303 if (checkY_ )
280304 {
281305 Info << " Deltas (abs/rel): "
282- << yError_ << ", " << yRelError_ << endl ;
306+ << yAbsError_ << ", " << yRelError_ << endl ;
283307 }
284308 Info << " Values: " << vals << endl ;
285309 }
@@ -289,12 +313,12 @@ void Foam::minimizationScheme::printStepInformation
289313 if (checkX_ )
290314 {
291315 Info << " Error (abs/rel): "
292- << xErrors_ [0 ] << ", " << xRelErrors_ [0 ] << endl ;
316+ << xAbsErrors_ [0 ] << ", " << xRelErrors_ [0 ] << endl ;
293317 }
294318 if (checkY_ )
295319 {
296320 Info << " Delta (abs/rel): "
297- << yError_ << ", " << yRelError_ << endl ;
321+ << yAbsError_ << ", " << yRelError_ << endl ;
298322 }
299323 Info << " Value: " << vals [0 ] << endl ;
300324 }
@@ -328,17 +352,17 @@ void Foam::minimizationScheme::printFinalInformation
328352 << "Did not converge in "
329353 << stepi_ << " iterations" << endl ;
330354 }
331- if (xErrors_ .size () > 1 )
355+ if (xAbsErrors_ .size () > 1 )
332356 {
333357 if (checkX_ )
334358 {
335359 Info << " Final errors (abs/rel): "
336- << xErrors_ << ", " << xRelErrors_ << endl ;
360+ << xAbsErrors_ << ", " << xRelErrors_ << endl ;
337361 }
338362 if (checkY_ )
339363 {
340364 Info << " Final deltas (abs, rel): "
341- << yError_ << ", " << yRelError_ << endl ;
365+ << yAbsError_ << ", " << yRelError_ << endl ;
342366 }
343367 Info << " Values: " << vals << endl ;
344368 }
@@ -347,12 +371,12 @@ void Foam::minimizationScheme::printFinalInformation
347371 if (checkX_ )
348372 {
349373 Info << " Final error (abs/rel): "
350- << xErrors_ [0 ] << ", " << xRelErrors_ [0 ] << endl ;
374+ << xAbsErrors_ [0 ] << ", " << xRelErrors_ [0 ] << endl ;
351375 }
352376 if (checkY_ )
353377 {
354378 Info << " Final delta (abs, rel): "
355- << yError_ << ", " << yRelError_ << endl ;
379+ << yAbsError_ << ", " << yRelError_ << endl ;
356380 }
357381 Info << " Value: " << vals [0 ] << endl ;
358382 }
@@ -443,19 +467,15 @@ Foam::minimizationScheme::minimizationScheme
443467:
444468 dict_ (dict ),
445469 eqns_ (eqns ),
446- xTolerances_
470+ xAbsTolerances_
447471 (
448- dict .lookupOrDefaultBackwardsCompatible
472+ dict .lookupOrDefault
449473 (
450- { "xTolerances" , "tolerances" } ,
474+ "xAbsTolerances" ,
451475 scalarList
452476 (
453477 eqns_ .nVar (),
454- dict .lookupOrDefaultBackwardsCompatible
455- (
456- {"xTolerance" , "tolerance" },
457- 1e-6
458- )
478+ dict .lookupOrDefault ("xAbsTolerance" , small )
459479 )
460480 )
461481 ),
@@ -469,34 +489,21 @@ Foam::minimizationScheme::minimizationScheme
469489 eqns_ .nVar (),
470490 dict .lookupOrDefaultBackwardsCompatible
471491 (
472- {"xRelTolerance" , "relTolerance " },
492+ {"xRelTolerance" , "tolerance " },
473493 1e-6
474494 )
475495 )
476496 )
477497 ),
478- yTolerance_
479- (
480- dict .lookupOrDefaultBackwardsCompatible
481- (
482- {"yTolerance" , "tolerance" },
483- 1e-6
484- )
485- ),
486- yRelTolerance_
487- (
488- dict .lookupOrDefaultBackwardsCompatible
489- (
490- {"yRelTolerance" , "tolerance" },
491- 1e-6
492- )
493- ),
498+ yAbsTolerance_ (dict .lookupOrDefault ("yAbsTolerance" , small )),
499+ yRelTolerance_ (dict .lookupOrDefault ("yRelTolerance" , 1e-6 )),
500+
494501 minSteps_ (dict .lookupOrDefault < scalar > ("minIter" , 0 )),
495502 maxSteps_ (dict .lookupOrDefault < scalar > ("maxIter" , 100 )),
496503 stepi_ (0 ),
497- xErrors_ (eqns .nVar (), great ),
504+ xAbsErrors_ (eqns .nVar (), great ),
498505 xRelErrors_ (eqns .nVar (), great ),
499- yError_ (great ),
506+ yAbsError_ (great ),
500507 yRelError_ (great ),
501508 nSamples_
502509 (
@@ -527,16 +534,16 @@ Foam::minimizationScheme::minimizationScheme
527534:
528535 dict_ (solver .dict_ ),
529536 eqns_ (eqns ),
530- xTolerances_ (solver .xTolerances_ ),
537+ xAbsTolerances_ (solver .xAbsTolerances_ ),
531538 xRelTolerances_ (solver .xRelTolerances_ ),
532- yTolerance_ (solver .yTolerance_ ),
539+ yAbsTolerance_ (solver .yAbsTolerance_ ),
533540 yRelTolerance_ (solver .yRelTolerance_ ),
534541 minSteps_ (solver .minSteps_ ),
535542 maxSteps_ (solver .maxSteps_ ),
536543 stepi_ (0 ),
537- xErrors_ (eqns .nVar (), great ),
544+ xAbsErrors_ (eqns .nVar (), great ),
538545 xRelErrors_ (eqns .nVar (), great ),
539- yError_ (great ),
546+ yAbsError_ (great ),
540547 yRelError_ (great ),
541548 nSamples_ (solver .nSamples_ ),
542549 normalize_ (solver .normalize_ ),
@@ -633,14 +640,14 @@ bool Foam::minimizationScheme::converged() const
633640 {
634641 c =
635642 c
636- || max (xErrors_ - xTolerances_ ) <= 0.0
643+ || max (xAbsErrors_ - xAbsTolerances_ ) <= 0.0
637644 || max (xRelErrors_ - xRelTolerances_ ) <= 0.0 ;
638645 }
639646 if (checkY_ )
640647 {
641648 c =
642649 c
643- || (yError_ - yTolerance_ <= 0.0 )
650+ || (yAbsError_ - yAbsTolerance_ <= 0.0 )
644651 || (yRelError_ - yRelTolerance_ <= 0.0 );
645652 }
646653 return c ;
0 commit comments