10 #ifndef Tempus_Stepper_ErrorNorm_impl_hpp
11 #define Tempus_Stepper_ErrorNorm_impl_hpp
14 #include "Thyra_DefaultSerialDenseLinearOpWithSolve_decl.hpp"
15 #include "Thyra_MultiVectorStdOps_decl.hpp"
16 #include "Thyra_VectorSpaceBase_decl.hpp"
17 #include "Thyra_VectorStdOps_decl.hpp"
23 template <
class Scalar>
25 : relTol_(1.0e-4), abssTol_(1.0e-4)
29 template <
class Scalar>
32 : relTol_(relTol), abssTol_(absTol)
36 template <
class Scalar>
42 if (errorWeightVector_ == Teuchos::null)
43 errorWeightVector_ = Thyra::createMember(x->space());
45 if (u_ == Teuchos::null) u_ = Thyra::createMember(x->space());
47 if (uNext_ == Teuchos::null) uNext_ = Thyra::createMember(x->space());
50 Thyra::abs(*x, u_.ptr());
51 Thyra::abs(*xNext, uNext_.ptr());
52 Thyra::pair_wise_max_update(relTol_, *u_, uNext_.ptr());
54 Thyra::add_scalar(abssTol_, uNext_.ptr());
57 Scalar absTol = Thyra::norm_2(*uNext_) * numericalTol<Scalar>();
58 if (
approxZero(absTol)) absTol = numericalTol<Scalar>();
59 Thyra::add_scalar(absTol, uNext_.ptr());
62 Thyra::assign(errorWeightVector_.ptr(),
64 Thyra::ele_wise_divide(Teuchos::as<Scalar>(1.0), *err, *uNext_,
65 errorWeightVector_.ptr());
67 const auto space_dim = err->space()->dim();
68 Scalar err_norm = std::abs(Thyra::norm(*errorWeightVector_) / space_dim);
72 template <
class Scalar>
76 if (scratchVector_ == Teuchos::null)
77 scratchVector_ = Thyra::createMember(x->space());
79 Thyra::assign(scratchVector_.ptr(), *x);
80 Thyra::abs(*x, scratchVector_.ptr());
81 Thyra::Vt_S(scratchVector_.ptr(), relTol_);
83 Thyra::Vp_S(scratchVector_.ptr(), abssTol_);
86 Scalar absTol = Thyra::norm_2(*scratchVector_) * numericalTol<Scalar>();
87 if (
approxZero(absTol)) absTol = numericalTol<Scalar>();
88 Thyra::add_scalar(absTol, scratchVector_.ptr());
90 Thyra::ele_wise_divide(Teuchos::as<Scalar>(1.0), *x, *scratchVector_,
91 scratchVector_.ptr());
92 Scalar err = Thyra::norm_inf(*scratchVector_);
Stepper_ErrorNorm()
Default Constructor.
Scalar computeWRMSNorm(const Teuchos::RCP< const Thyra::VectorBase< Scalar >> &x, const Teuchos::RCP< const Thyra::VectorBase< Scalar >> &xNext, const Teuchos::RCP< const Thyra::VectorBase< Scalar >> &err)
Compute the weigthed root mean square norm.
bool approxZero(Scalar value, Scalar tol=Teuchos::ScalarTraits< Scalar >::sfmin())
Test if value is approximately zero within tolerance.
Scalar errorNorm(const Teuchos::RCP< const Thyra::VectorBase< Scalar >> &x)
Compute the error Norm.