From 0cca4c10041377158de873f39857aff193375b4f Mon Sep 17 00:00:00 2001 From: Andreas Lauser <and@poware.org> Date: Mon, 29 Aug 2011 13:02:40 +0000 Subject: [PATCH] box local residual: choose epsilon more intelligently we now take the geometric mean of the numerical precision of the underlying floating point type and 1. for standard 64 bit double values this does not change anything (the base epsilon stays 1e-8), but for higher or lower resolution scalars, the value is now "always right". probably. git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@6550 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- dumux/boxmodels/common/boxlocaljacobian.hh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dumux/boxmodels/common/boxlocaljacobian.hh b/dumux/boxmodels/common/boxlocaljacobian.hh index 41d4bfbe07..9ccf1ffed8 100644 --- a/dumux/boxmodels/common/boxlocaljacobian.hh +++ b/dumux/boxmodels/common/boxlocaljacobian.hh @@ -284,8 +284,18 @@ public: Scalar numericEpsilon(int scvIdx, int pvIdx) const { + // define the base epsilon as the geometric mean of 1 and the + // resolution of the scalar type. E.g. for standard 64 bit + // floating point values, the resolution is about 10^-16 and + // the base epsilon is thus approximately 10^-8. + static const Scalar baseEps + = Dumux::geometricMean<Scalar>(std::numeric_limits<Scalar>::epsilon(), + 1.0); + + // the epsilon value used for the numeric differentiation is + // now scaled by the absolute value of the primary variable... Scalar pv = this->curVolVars_[scvIdx].primaryVar(pvIdx); - return 1e-9*(std::abs(pv) + 1); + return baseEps*(std::abs(pv) + 1); } protected: -- GitLab