gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
approximationError.cpp
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #include "approximationError.h"
7 #include "MElement.h"
8 
10 {
11  std::vector<double> VALS(element->getNumVertices());
12 
13  for(std::size_t i = 0; i < element->getNumVertices(); i++) {
14  MVertex *v = element->getVertex(i);
15  VALS[i] = f(v->x(), v->y(), v->z());
16  }
17 
18  int npts;
19  IntPt *pts;
20  element->getIntegrationPoints(2 * element->getPolynomialOrder() + 2, &npts,
21  &pts);
22  double errSqr = 0.0;
23  for(int k = 0; k < npts; k++) {
24  const double u = pts[k].pt[0];
25  const double v = pts[k].pt[1];
26  const double w = pts[k].pt[2];
27  SPoint3 p;
28  element->pnt(u, v, w, p);
29  const double Jac = element->getJacobianDeterminant(u, v, w);
30  const double C = element->interpolate(&VALS[0], u, v, w);
31  const double F = f(p.x(), p.y(), p.z());
32  errSqr += pts[k].weight * Jac * std::pow(C - F, 2);
33  }
34  return std::sqrt(errSqr);
35 }
F
#define F
Definition: DefaultOptions.h:23
MVertex
Definition: MVertex.h:24
MVertex::z
double z() const
Definition: MVertex.h:62
approximationError
double approximationError(simpleFunction< double > &f, MElement *element)
Definition: approximationError.cpp:9
SPoint3
Definition: SPoint3.h:14
LegendrePolynomials::f
void f(int n, double u, double *val)
Definition: orthogonalBasis.cpp:77
IntPt::pt
double pt[3]
Definition: GaussIntegration.h:13
approximationError.h
SPoint3::x
double x(void) const
Definition: SPoint3.h:125
IntPt::weight
double weight
Definition: GaussIntegration.h:14
simpleFunction< double >
SPoint3::y
double y(void) const
Definition: SPoint3.h:127
MElement
Definition: MElement.h:30
element
Definition: shapeFunctions.h:12
IntPt
Definition: GaussIntegration.h:12
MElement.h
SPoint3::z
double z(void) const
Definition: SPoint3.h:129
MVertex::y
double y() const
Definition: MVertex.h:61
element::interpolate
double interpolate(double val[], double u, double v, double w, int stride=1)
Definition: shapeFunctions.h:155
MVertex::x
double x() const
Definition: MVertex.h:60