20#ifndef OPM_FACEQUADRATURE_HEADER_INCLUDED
21#define OPM_FACEQUADRATURE_HEADER_INCLUDED
23#include <opm/grid/utility/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.");
98 int numQuadPts()
const
111 void quadPtCoord(
const int index,
double* coord)
const
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]);
147 double quadPtWeight(
const int index)
const
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;
Main OPM-Core grid data structure along with helper functions for construction, destruction and readi...
A class providing numerical quadrature for faces.
Definition: FaceQuadrature.hpp:83
FieldVector< T, 3 > cross(const FieldVector< T, 3 > &a, const FieldVector< T, 3 > &b)
Definition: Volumes.hpp:58
Holds the implementation of the CpGrid as a pimple.
Definition: CellQuadrature.hpp:29
Data structure for an unstructured grid, unstructured meaning that any cell may have an arbitrary num...
Definition: UnstructuredGrid.h:99
int * face_nodes
Contains for each face, the indices of its adjacent nodes.
Definition: UnstructuredGrid.h:121
int * face_nodepos
For a face f, face_nodepos[f] contains the starting index for f's nodes in the face_nodes array.
Definition: UnstructuredGrid.h:127
double * face_areas
Exact or approximate face areas.
Definition: UnstructuredGrid.h:173
double * face_centroids
Exact or approximate face centroids, stored consecutively for each face.
Definition: UnstructuredGrid.h:168
int dimensions
The topological and geometrical dimensionality of the grid.
Definition: UnstructuredGrid.h:106
double * node_coordinates
Node coordinates, stored consecutively for each node.
Definition: UnstructuredGrid.h:160