40 unsigned int degree_sum=0;
48 for(i_dim=0; i_dim <
dim; i_dim++) {
49 if (degree_sum < degree) {
54 degree_sum-=pows[i_dim];
58 if (i_dim == dim)
break;
64 const arma::vec &
point,
65 unsigned int comp_index
73 for (
unsigned int j=0; j<this->
space_dim_; j++)
74 v *= pow(point[j], (
int)
powers[i][j]);
82 unsigned int comp_index
90 for (
unsigned int j=0; j<this->
space_dim_; j++)
93 if (
powers[i][j] == 0)
continue;
95 for (
unsigned int k=0; k<this->
space_dim_; k++)
97 grad[j] *= pow(p[k], (
int) (k==j?
powers[i][k]-1:
powers[i][k]));
113 template<
unsigned int dim,
unsigned int spacedim>
121 arma::vec coords = arma::ones<arma::vec>(
dim+1)/(
dim+1);
122 this->dofs_.push_back(
Dof(
dim, 0, coords, { 1 },
Value));
132 arma::uvec ubc = arma::zeros<arma::uvec>(
dim+1);
149 while (ubc[c] == 0) c++;
151 if (c ==
dim-1) finish =
true;
161 for (
auto ubc : uvbc)
168 arma::uvec nonzeros = find(ubc);
170 arma::vec coords = arma::conv_to<arma::vec>::from(ubc);
175 unsigned int n_face_idx;
176 switch (
dim-zeros.first) {
190 this->dofs_.push_back(
Dof(nonzeros.size()-1, n_face_idx, coords, { 1 },
Value));
198 template<
unsigned int dim,
unsigned int spacedim>
226 template<
unsigned int dim,
unsigned int spacedim>
228 :
FE_P<dim,spacedim>(degree)
231 for (
unsigned int i=0; i<this->
dofs_.size(); i++)
232 this->
dofs_[i].dim = dim;
const arma::vec basis_grad(unsigned int basis_index, const arma::vec &point, unsigned int comp_index=0) const override
Gradient of the i th basis function at point point.
PolynomialSpace(unsigned int degree, unsigned int dim)
Constructor.
Space of polynomial functions.
std::vector< Dof > dofs_
Set of degrees of freedom (functionals) defining the FE.
const double basis_value(unsigned int basis_index, const arma::vec &point, unsigned int comp_index=0) const override
Value of the i th basis function at point point.
static std::pair< unsigned int, unsigned int > zeros_positions(const BaryPoint &barycentric, double tolerance=std::numeric_limits< double >::epsilon()*2)
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
std::vector< arma::uvec > powers
Coefficients of basis functions.
FE_P_disc(unsigned int degree)
Constructor.
virtual void compute_node_matrix()
Initializes the node_matrix for computing the coefficients of the shape functions in the raw basis of...
Definitions of basic Lagrangean finite elements with polynomial shape functions.
void setup_components()
Initialize vectors with information about components of basis functions.
FE_P(unsigned int degree)
Constructor.
Conforming Lagrangean finite element on dim dimensional simplex.
const unsigned int dim() const override
Dimension of function space (number of basis functions).
Class RefElement defines numbering of vertices, sides, calculation of normal vectors etc...
unsigned int space_dim_
Space dimension of function arguments (i.e. 1, 2 or 3).
FunctionSpace * function_space_
Function space defining the FE.
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
const unsigned int degree_
Max. degree of polynomials.