From ab9d71550078c2f5bb0a249064fe1cb2ee5f41da Mon Sep 17 00:00:00 2001 From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be> Date: Sun, 26 Oct 2014 14:02:57 +0000 Subject: [PATCH] added missing files --- Numeric/approximationError.cpp | 26 ++++++++++++++++++++++++++ Numeric/approximationError.h | 10 ++++++++++ 2 files changed, 36 insertions(+) create mode 100644 Numeric/approximationError.cpp create mode 100644 Numeric/approximationError.h diff --git a/Numeric/approximationError.cpp b/Numeric/approximationError.cpp new file mode 100644 index 0000000000..407aaa5d5c --- /dev/null +++ b/Numeric/approximationError.cpp @@ -0,0 +1,26 @@ +#include "approximationError.h" +#include "MElement.h" +double approximationError (simpleFunction<double> &f, MElement *e) +{ + double VALS [e->getNumVertices()]; + for (int i=0;i<e->getNumVertices();i++){ + MVertex *v = e->getVertex(i); + VALS[i] = f(v->x(),v->y(),v->z()); + } + int npts; IntPt *pts; + e->getIntegrationPoints (2*e->getPolynomialOrder() + 2 , &npts, &pts); + double errSqr = 0.0; + for (int k=0;k<npts;k++){ + const double u = pts[k].pt[0]; + const double v = pts[k].pt[1]; + const double w = pts[k].pt[2]; + SPoint3 p; e->pnt(u, v, w, p); + const double Jac = e->getJacobianDeterminant(u,v,w); + const double C = e->interpolate(VALS,u,v,w); + const double F = f(p.x(),p.y(),p.z()); + const double DIFF = C-F; + errSqr += pts[k].weight * Jac * (DIFF*DIFF); + } + return sqrt(errSqr); +} + diff --git a/Numeric/approximationError.h b/Numeric/approximationError.h new file mode 100644 index 0000000000..53caed4437 --- /dev/null +++ b/Numeric/approximationError.h @@ -0,0 +1,10 @@ +#ifndef _APPROXIMATION_ERROR_ +#define _APPROXIMATION_ERROR_ +#include <map> +#include "simpleFunction.h" +class MElement; +// computes E such as +// E^2 = \int_e [C_e(f) - f]^2 de +// where C_e(f) is clement's interpolation operator of f on e +double approximationError (simpleFunction<double> &f, MElement *e) ; +#endif -- GitLab