diff --git a/dune/gfe/realtuple.hh b/dune/gfe/realtuple.hh index e8b5420b480920b2de1ac54619ab3f0ac26ffadb..5921c9ea932aa34d6e24ae7d862d7eae5f98329c 100644 --- a/dune/gfe/realtuple.hh +++ b/dune/gfe/realtuple.hh @@ -94,6 +94,19 @@ public: return (a.data_ - b.data_).two_norm(); } +#if ADOLC_ADOUBLE_H + /** \brief Geodesic distance squared between two points + + Simply the Euclidean distance squared */ + static adouble distanceSquared(const RealTuple<double,N>& a, const RealTuple<adouble,N>& b) { + adouble result(0.0); + for (int i=0; i<N; i++) + result += (a.globalCoordinates()[i] - b.globalCoordinates()[i]) * (a.globalCoordinates()[i] - b.globalCoordinates()[i]); + return result; + } +#endif + + /** \brief Compute the gradient of the squared distance function keeping the first argument fixed Unlike the distance itself the squared distance is differentiable at zero