Skip to content

Commit

Permalink
Merge Pull Request #4700 from trilinos/Trilinos/tempus-fix-divide-by-…
Browse files Browse the repository at this point in the history
…zero-3698

Automatically Merged using Trilinos Pull Request AutoTester
PR Title: Tempus: Fix Divide by Zero
PR Author: ccober6
  • Loading branch information
trilinos-autotester authored Mar 26, 2019
2 parents 022d09d + a739ab8 commit 9330de5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/tempus/src/Tempus_StepperImplicit_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ void StepperImplicit<Scalar>::setInitialConditions(

this->evaluateImplicitODE(f, x, xDot, time, p);

Scalar reldiff = Thyra::norm(*f)/Thyra::norm(*x);
Scalar normX = Thyra::norm(*x);
Scalar reldiff = Scalar(0.0);
if (normX == Scalar(0.0)) reldiff = Thyra::norm(*f);
else reldiff = Thyra::norm(*f)/normX;

Scalar eps = Scalar(100.0)*std::abs(Teuchos::ScalarTraits<Scalar>::eps());
if (reldiff > eps) {
RCP<Teuchos::FancyOStream> out = this->getOStream();
Expand Down

0 comments on commit 9330de5

Please sign in to comment.