40 unsigned int degree_sum=0;
47 for(i_dim=0; i_dim <
dim; i_dim++) {
48 if (degree_sum < degree) {
53 degree_sum-=pows[i_dim];
57 if (i_dim == dim)
break;
64 unsigned int comp_index
72 for (
unsigned int j=0; j<this->
space_dim_; j++)
73 v *= pow(point[j], (
int)
powers[i][j]);
81 unsigned int comp_index
89 for (
unsigned int j=0; j<this->
space_dim_; j++)
92 if (
powers[i][j] == 0)
continue;
94 for (
unsigned int k=0; k<this->
space_dim_; k++)
96 grad[j] *= pow(p[k], (
int) (k==j?
powers[i][k]-1:
powers[i][k]));
112 template<
unsigned int dim>
121 this->dofs_.push_back(
Dof(
dim, 0, coords, { 1 },
Value));
131 arma::uvec ubc = arma::zeros<arma::uvec>(
dim+1);
148 while (ubc[c] == 0) c++;
150 if (c ==
dim) finish =
true;
160 for (
auto ubc : uvbc)
167 arma::uvec nonzeros = find(ubc);
169 arma::vec coords = arma::conv_to<arma::vec>::from(ubc);
174 unsigned int n_face_idx = -1;
175 switch (
dim-zeros.first) {
189 this->dofs_.push_back(
Dof(nonzeros.size()-1, n_face_idx, coords, { 1 },
Value));
197 template<
unsigned int dim>
225 template<
unsigned int dim>
230 for (
unsigned int i=0; i<this->
dofs_.size(); i++)
231 this->
dofs_[i].dim = dim;
243 template<
unsigned int dim>
255 arma::vec::fixed<dim> sp;
256 for (
unsigned int sid=0; sid<RefElement<dim>::n_sides; ++sid)
259 for (
unsigned int i=0; i<RefElement<dim>::n_nodes_per_side; ++i)
263 arma::vec::fixed<dim+1> bsp;
264 bsp.subvec(1,dim) = sp;
265 bsp[0] = 1. - arma::sum(sp);
277 template<
unsigned int dim>
289 arma::vec::fixed<dim> sp;
290 for (
unsigned int sid=0; sid<RefElement<dim>::n_sides; ++sid)
293 for (
unsigned int i=0; i<RefElement<dim>::n_nodes_per_side; ++i)
297 arma::vec::fixed<dim+1> bsp;
298 bsp.subvec(1,dim) = sp;
299 bsp[0] = 1. - arma::sum(sp);
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.
FE_P_disc(unsigned int degree)
Constructor.
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.
std::vector< Dof > dofs_
Set of degrees of freedom (functionals) defining the FE.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
unsigned int dim() const override
Dimension of function space (number of basis functions).
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.
FE_P(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...
std::shared_ptr< FunctionSpace > function_space_
Function space defining the FE.
void setup_components()
Initialize vectors with information about components of basis functions.
Conforming Lagrangean finite element on dim dimensional simplex.
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).
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
Crouzeix-Raviart finite element on dim dimensional simplex.
const unsigned int degree_
Max. degree of polynomials.