5#ifndef DUNE_LOCALFUNCTIONS_ENRICHED_CUBEQ1BUBBLE_LOCALBASIS_HH
6#define DUNE_LOCALFUNCTIONS_ENRICHED_CUBEQ1BUBBLE_LOCALBASIS_HH
16#include <dune/localfunctions/common/localbasis.hh>
34 template<
class D,
class R,
int dim>
48 static constexpr int dimension = dim;
49 static constexpr int numVertices =
power(2, dim);
52 static constexpr int scaling =
power(2, 2*dim);
59 static constexpr std::size_t
size () noexcept
69 for (
int i = 0; i < numVertices; ++i) {
71 for (
int j = 0; j < dimension; ++j) {
73 out[i] *= (i & (1<<j)) ? x[j] : 1-x[j];
78 for (
int j = 0; j < dimension; ++j) {
79 out.back() *= (1-x[j]) * x[j];
89 for (
int i = 0; i < numVertices; ++i) {
91 for (
int j = 0; j < dimension; ++j) {
94 out[i][0][j] = (i & (1<<j)) ? 1 : -1;
96 for (
int k = 0; k < dimension; ++k) {
99 out[i][0][j] *= (i & (1<<k)) ? x[k] : 1-x[k];
104 for (
int j = 0; j < dimension; ++j) {
105 out.
back()[0][j] = scaling;
106 for (
int k = 0; k < dimension; ++k)
107 out.back()[0][j] *= (j == k) ? (1-2*x[k]) : (1-x[k])*x[k];
112 static constexpr void partial (
const std::array<unsigned int, dim>&
order,
114 std::vector<RangeType>& out)
116 unsigned int totalOrder = 0;
117 for (
int i = 0; i < dimension; ++i)
118 totalOrder +=
order[i];
120 switch (totalOrder) {
127 for (
int i = 0; i < dimension; ++i)
131 throw std::invalid_argument(
"Direction of partial derivative not found!");
134 for (
int i = 0; i < numVertices; ++i) {
137 out[i] = (i & (1<<d)) ? 1 : -1;
139 for (
int j = 0; j < dimension; ++j) {
142 out[i] *= (i & (1<<j)) ? x[j] : 1-x[j];
146 out.
back() = scaling;
147 for (
int k = 0; k < dimension; ++k)
148 out.back() *= (d == k) ? (1-2*x[k]) : (1-x[k])*x[k];
152 throw std::runtime_error(
"Desired derivative order is not implemented");
157 static constexpr unsigned int order () noexcept
Q1 basis in dim-d enriched by an (order 2) element bubble function.
Definition: localbasis.hh:36
static constexpr std::size_t size() noexcept
Returns number of shape functions.
Definition: localbasis.hh:59
static constexpr void partial(const std::array< unsigned int, dim > &order, const DomainType &x, std::vector< RangeType > &out)
Evaluate partial derivatives of all shape functions.
Definition: localbasis.hh:112
static constexpr unsigned int order() noexcept
Returns maximal polynomial order of the basis functions.
Definition: localbasis.hh:157
static constexpr void evaluateJacobian(const DomainType &x, std::vector< JacobianType > &out)
Evaluate Jacobian of all shape functions.
Definition: localbasis.hh:84
static constexpr void evaluateFunction(const DomainType &x, std::vector< RangeType > &out)
Evaluate all shape functions.
Definition: localbasis.hh:65
Interpolation into the CubeQ1BubbleLocalBasis.
Definition: localinterpolation.hh:34
constexpr value_type & back()
return reference to last element
Definition: densevector.hh:319
A dense n x m matrix.
Definition: fmatrix.hh:117
vector space out of a tensor product of fields.
Definition: fvector.hh:97
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
Some useful basic math stuff.
Dune namespace.
Definition: alignedallocator.hh:13
constexpr Base power(Base m, Exponent p)
Power method for integer exponents.
Definition: math.hh:75
Type traits for LocalBasisVirtualInterface.
Definition: localbasis.hh:35