20 #ifndef OPM_FACEQUADRATURE_HEADER_INCLUDED
21 #define OPM_FACEQUADRATURE_HEADER_INCLUDED
23 #include <opm/common/ErrorMacros.hpp>
35 inline void cross(
const double* a,
const double* b,
double* res)
37 res[0] = a[1]*b[2] - a[2]*b[1];
38 res[1] = a[2]*b[0] - a[0]*b[2];
39 res[2] = a[0]*b[1] - a[1]*b[0];
44 inline double triangleArea3d(
const double* p0,
48 double a[3] = { p1[0] - p0[0], p1[1] - p0[1], p1[2] - p0[2] };
49 double b[3] = { p2[0] - p0[0], p2[1] - p0[1], p2[2] - p0[2] };
52 return 0.5*std::sqrt(cr[0]*cr[0] + cr[1]*cr[1] + cr[2]*cr[2]);
88 : grid_(grid), face_(face), degree_(degree)
91 OPM_THROW(std::runtime_error,
"FaceQuadrature only implemented for up to 3 dimensions.");
94 OPM_THROW(std::runtime_error,
"FaceQuadrature exact for polynomial degrees > 2 not implemented.");
115 if (degree_ < 2 || dim < 2) {
116 std::copy(fc, fc + dim, coord);
125 const double* pa[3] = { nc + dim*fnodes[0], fc, nc + dim*fnodes[1] };
126 std::copy(pa[index], pa[index] + dim, coord);
132 const int node0 = fnodes[index];
133 const int node1 = fnodes[(index + 1)%nn];
134 for (
int dd = 0; dd < dim; ++dd) {
135 coord[dd] = 0.5*(nc[dim*node0 + dd] + nc[dim*node1 + dd]);
140 const int node = fnodes[index - nn];
141 for (
int dd = 0; dd < dim; ++dd) {
142 coord[dd] = 0.5*(nc[dim*node + dd] + fc[dd]);
155 const double simpsonw[3] = { 1.0/6.0, 4.0/6.0, 1.0/6.0 };
156 return grid_.
face_areas[face_]*simpsonw[index];
165 const int node0 = fnodes[index];
166 const int node1 = fnodes[(index + 1)%nn];
167 const double area = triangleArea3d(nc + dim*node1, nc + dim*node0, fc);
172 const int node0 = fnodes[(index - 1) % nn];
173 const int node1 = fnodes[index - nn];
174 const int node2 = fnodes[(index + 1) % nn];
175 const double area0 = triangleArea3d(nc + dim*node1, nc + dim*node0, fc);
176 const double area1 = triangleArea3d(nc + dim*node2, nc + dim*node1, fc);
177 return (area0 + area1) / 3.0;
189 #endif // OPM_FACEQUADRATURE_HEADER_INCLUDED
Definition: FaceQuadrature.hpp:82
Definition: AnisotropicEikonal.hpp:43
int numQuadPts() const
Definition: FaceQuadrature.hpp:98
int * face_nodes
Definition: grid.h:121
double quadPtWeight(const int index) const
Definition: FaceQuadrature.hpp:147
const double area
Definition: Units.hpp:149
double * face_areas
Definition: grid.h:173
double * face_centroids
Definition: grid.h:168
int dimensions
Definition: grid.h:106
FaceQuadrature(const UnstructuredGrid &grid, const int face, const int degree)
Definition: FaceQuadrature.hpp:85
double * node_coordinates
Definition: grid.h:160
const UnstructuredGrid & grid
Definition: ColumnExtract.hpp:31
int * face_nodepos
Definition: grid.h:127
void quadPtCoord(const int index, double *coord) const
Definition: FaceQuadrature.hpp:111