27 #ifndef EWOMS_QUADRATURE_GEOMETRIES_HH 28 #define EWOMS_QUADRATURE_GEOMETRIES_HH 30 #include <dune/common/fmatrix.hh> 31 #include <dune/common/fvector.hh> 32 #include <dune/geometry/type.hh> 42 template <
class Scalar,
unsigned dim>
46 enum { numCorners = (1 << dim) };
48 using LocalPosition = Dune::FieldVector<Scalar, dim>;
49 using GlobalPosition = Dune::FieldVector<Scalar, dim>;
51 Dune::GeometryType type()
const 52 {
return Dune::GeometryType((1 << dim) - 1, dim); }
54 template <
class CornerContainer>
55 void setCorners(
const CornerContainer& corners, std::size_t nCorners)
57 for (std::size_t cornerIdx = 0; cornerIdx < nCorners; ++cornerIdx) {
58 for (
unsigned j = 0; j < dim; ++j) {
59 corners_[cornerIdx][j] = corners[cornerIdx][j];
64 for (std::size_t cornerIdx = 0; cornerIdx < nCorners; ++cornerIdx) {
65 center_ += corners_[cornerIdx];
68 center_ /=
static_cast<Scalar
>(nCorners);
81 GlobalPosition
global(
const LocalPosition& localPos)
const 83 GlobalPosition globalPos(0.0);
85 for (
unsigned cornerIdx = 0; cornerIdx < numCorners; ++cornerIdx) {
97 void jacobian(Dune::FieldMatrix<Scalar, dim, dim>& jac,
98 const LocalPosition& localPos)
const 101 for (
unsigned cornerIdx = 0; cornerIdx < numCorners; ++cornerIdx) {
102 for (
unsigned k = 0; k < dim; ++k) {
103 Scalar dWeight_dk = (cornerIdx & (1 << k)) ? 1 : -1;
104 for (
unsigned j = 0; j < dim; ++j) {
106 if (cornerIdx & (1 << j)) {
107 dWeight_dk *= localPos[j];
110 dWeight_dk *= 1 - localPos[j];
115 jac[k].axpy(dWeight_dk, corners_[cornerIdx]);
127 Dune::FieldMatrix<Scalar, dim, dim> jac;
129 return jac.determinant();
135 const GlobalPosition&
corner(
unsigned cornerIdx)
const 136 {
return corners_[cornerIdx]; }
142 Scalar
cornerWeight(
const LocalPosition& localPos,
unsigned cornerIdx)
const 147 for (
unsigned j = 0; j < dim; ++j) {
148 weight *= (cornerIdx & (1 << j)) ? localPos[j] : (1 - localPos[j]);
155 std::array<GlobalPosition, numCorners> corners_{};
156 GlobalPosition center_;
161 #endif // EWOMS_QUADRATURE_GEOMETRY_HH Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
const GlobalPosition & corner(unsigned cornerIdx) const
Return the position of the corner with a given index.
Definition: quadraturegeometries.hh:135
Quadrature geometry for quadrilaterals.
Definition: quadraturegeometries.hh:43
GlobalPosition global(const LocalPosition &localPos) const
Convert a local coordinate into a global one.
Definition: quadraturegeometries.hh:81
const GlobalPosition & center() const
Returns the center of weight of the polyhedron.
Definition: quadraturegeometries.hh:75
Scalar cornerWeight(const LocalPosition &localPos, unsigned cornerIdx) const
Return the weight of an individual corner for the local to global mapping.
Definition: quadraturegeometries.hh:142
Scalar integrationElement(const LocalPosition &localPos) const
Return the determinant of the Jacobian of the mapping from local to global coordinates at a given loc...
Definition: quadraturegeometries.hh:125
void jacobian(Dune::FieldMatrix< Scalar, dim, dim > &jac, const LocalPosition &localPos) const
Returns the Jacobian matrix of the local to global mapping at a given local position.
Definition: quadraturegeometries.hh:97