9 #ifndef Tempus_Stepper_ErrorNorm_impl_hpp 10 #define Tempus_Stepper_ErrorNorm_impl_hpp 12 #include "Teuchos_ScalarTraitsDecl.hpp" 13 #include "Thyra_DefaultSerialDenseLinearOpWithSolve_decl.hpp" 14 #include "Thyra_MultiVectorStdOps_decl.hpp" 15 #include "Thyra_VectorSpaceBase_decl.hpp" 16 #include "Thyra_VectorStdOps_decl.hpp" 19 template<
class Scalar>
23 template<
class Scalar>
25 relTol_(relTol), abssTol_(absTol)
28 template<
class Scalar>
34 if (errorWeightVector_ == Teuchos::null)
35 errorWeightVector_ = Thyra::createMember(x->space());
37 if (u_ == Teuchos::null)
38 u_ = Thyra::createMember(x->space());
40 if (uNext_ == Teuchos::null)
41 uNext_ = Thyra::createMember(x->space());
44 Thyra::abs(*x, u_.ptr());
45 Thyra::abs(*xNext, uNext_.ptr());
46 Thyra::pair_wise_max_update(relTol_, *u_, uNext_.ptr());
47 Thyra::add_scalar(abssTol_, uNext_.ptr());
49 Thyra::assign(errorWeightVector_.ptr(), Teuchos::ScalarTraits<Scalar>::zero());
50 Thyra::ele_wise_divide(Teuchos::as<Scalar>(1.0), *err, *uNext_, errorWeightVector_.ptr());
52 const auto space_dim = err->space()->dim();
53 Scalar err_norm = std::abs( Thyra::norm(*errorWeightVector_) / space_dim);
58 template<
class Scalar>
62 if (scratchVector_ == Teuchos::null)
63 scratchVector_ = Thyra::createMember(x->space());
65 Thyra::assign(scratchVector_.ptr(), *x);
66 Thyra::abs(*x, scratchVector_.ptr());
67 Thyra::Vt_S(scratchVector_.ptr(), relTol_);
68 Thyra::Vp_S(scratchVector_.ptr(), abssTol_);
69 Thyra::ele_wise_divide(Teuchos::as<Scalar>(1.0), *x, *scratchVector_, scratchVector_.ptr());
70 Scalar err = Thyra::norm_inf(*scratchVector_);
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)
Scalar errorNorm(const Teuchos::RCP< const Thyra::VectorBase< Scalar >> &x)