27 template<
unsigned int dim,
unsigned int spacedim>
30 OLD_ASSERT(fe->is_primitive(),
"FE vector or tensor can olny by created from primitive FE.");
33 t ==
FEType::FETensor,
"This constructor can be used only for vectors or tensors.");
46 template<
unsigned int dim,
unsigned int spacedim>
55 template<
unsigned int dim,
unsigned int spacedim>
60 fe_.push_back(fe_object);
66 template<
unsigned int dim,
unsigned int spacedim>
69 unsigned int fe_index = 0;
70 unsigned int comp_offset = 0;
76 n_components_ += fe->n_components();
81 scalar_components_.push_back(comp_offset);
85 vector_components_.push_back(comp_offset);
92 for (
int i=0; i<fe->n_dofs(); ++i)
96 comp_offset += fe->n_components();
103 for (
unsigned int i=0; i<fe->n_dofs(); i++)
105 arma::vec coefs(n_components_);
106 coefs.subvec(comp_offset, comp_offset+fe->dof(i).coefs.size()-1) = fe->dof(i).coefs;
107 this->dofs_.push_back(
Dof(fe->dof(i).dim, fe->dof(i).n_face_idx, fe->dof(i).coords, coefs, fe->dof(i).type));
110 comp_offset += fe->n_components();
128 for (
int i=0; i<fe->n_dofs(); ++i)
131 for (
unsigned int c=0; c<fe->n_components(); c++)\
132 nonzeros[comp_offset+c] = fe->get_nonzero_components(fe_dof_indices_[dof_index].basis_index)[c];
133 this->nonzero_components_.push_back(nonzeros);
136 comp_offset += fe->n_components();
140 compute_node_matrix();
145 template<
unsigned int dim,
unsigned int spacedim>
147 const arma::vec::fixed<dim> &p,
148 const unsigned int comp)
const 150 OLD_ASSERT(i <= this->dofs_.size(),
"Index of basis function is out of range.");
153 int l_comp = comp-fe_dof_indices_[i].component_offset;
154 OLD_ASSERT(l_comp >= 0 && l_comp < fe_[fe_dof_indices_[i].fe_index]->n_components(),
155 "Index of component is out of range.");
157 return fe_[fe_dof_indices_[i].fe_index]->basis_value(fe_dof_indices_[i].basis_index, p, l_comp);
160 template<
unsigned int dim,
unsigned int spacedim>
162 const arma::vec::fixed<dim> &p,
163 const unsigned int comp)
const 165 OLD_ASSERT(i <= this->dofs_.size(),
"Index of basis function is out of range.");
168 int l_comp = comp-fe_dof_indices_[i].component_offset;
169 OLD_ASSERT(l_comp >= 0 && l_comp < fe_[fe_dof_indices_[i].fe_index]->n_components(),
170 "Index of component is out of range.");
172 return fe_[fe_dof_indices_[i].fe_index]->basis_grad(fe_dof_indices_[i].basis_index, p, l_comp);
176 template<
unsigned int dim,
unsigned int spacedim>
inline 182 f |= fe->update_each(flags);
188 template<
unsigned int dim,
unsigned int spacedim>
194 this->node_matrix.resize(this->dofs_.size(), this->dofs_.size());
196 unsigned int offset = 0;
197 for (
unsigned int i = 0; i < fe_.size(); i++)
199 this->node_matrix.submat(offset, offset, offset+fe_[i]->n_dofs()-1, offset+fe_[i]->n_dofs()-1)
200 = fe_[i]->node_matrix;
202 offset += fe_[i]->n_dofs();
207 template<
unsigned int dim,
unsigned int spacedim>
215 fe_data.push_back(fe->initialize(q));
220 unsigned int comp_offset = 0;
221 unsigned int dof_offset = 0;
222 for (
unsigned int f=0; f<fe_.size(); f++)
225 for (
unsigned int i=0; i<q.
size(); i++)
226 for (
unsigned int n=0; n<fe_[f]->n_dofs(); n++)
227 data->
ref_shape_values[i][dof_offset+n].subvec(comp_offset,comp_offset+fe_[f]->n_components()-1) = fe_data[f]->ref_shape_values[i][n];
228 comp_offset += fe_[f]->n_components();
229 dof_offset += fe_[f]->n_dofs();
237 for (
unsigned int f=0; f<fe_.size(); f++)
239 for (
unsigned int i=0; i<q.
size(); i++)
240 for (
unsigned int n=0; n<fe_[f]->n_dofs(); n++)
241 data->
ref_shape_grads[i][dof_offset+n].submat(0,comp_offset,dim-1,comp_offset+fe_[f]->n_components()-1) = fe_data[f]->ref_shape_grads[i][n];
242 comp_offset += fe_[f]->n_components();
243 dof_offset += fe_[f]->n_dofs();
246 for (
auto d : fe_data)
delete d;
252 template<
unsigned int dim,
unsigned int spacedim>
inline 264 for (
unsigned int k=0; k<q.
size(); k++)
265 for (
unsigned int i=0; i<fv_data.
shape_values[0].size(); i++)
266 shape_gradients[k][i].zeros();
268 unsigned int comp_offset = 0;
269 unsigned int dof_offset = 0;
270 unsigned int shape_offset = 0;
271 for (
unsigned int f=0; f<fe_.size(); f++)
281 for (
unsigned int i=0; i<q.
size(); i++)
282 for (
unsigned int n=0; n<fe_[f]->n_dofs(); n++)
289 for (
unsigned int i=0; i<q.
size(); i++)
290 for (
unsigned int n=0; n<fe_[f]->n_dofs(); n++)
299 fe_[f]->fill_fe_values(q, d, sub_fv_data);
304 for (
unsigned int i=0; i<q.
size(); i++)
305 for (
unsigned int n=0; n<fe_[f]->n_dofs(); n++)
306 for (
unsigned int c=0; c<fe_[f]->n_components(); c++)
307 fv_data.
shape_values[i][shape_offset+n_components_*n+comp_offset+c] = sub_fv_data.
shape_values[i][n*fe_[f]->n_components()+c];
312 for (
unsigned int i=0; i<q.
size(); i++)
313 for (
unsigned int n=0; n<fe_[f]->n_dofs(); n++)
314 for (
unsigned int c=0; c<fe_[f]->n_components(); c++)
318 dof_offset += fe_[f]->n_dofs();
319 comp_offset += fe_[f]->n_components();
320 shape_offset += fe_[f]->n_dofs()*n_components_;
UpdateFlags
Enum type UpdateFlags indicates which quantities are to be recomputed on each finite element cell...
void init(bool primitive=true, FEType type=FEScalar)
Clears all internal structures.
void compute_node_matrix() override
Initializes the node_matrix for computing the coefficients of the shape functions in the raw basis of...
void fill_fe_values(const Quadrature< dim > &q, FEInternalData &data, FEValuesData< dim, spacedim > &fv_data) override
Computes the shape function values and gradients on the actual cell and fills the FEValues structure...
std::vector< arma::mat::fixed< dim, spacedim > > inverse_jacobians
Inverse Jacobians at the quadrature points.
UpdateFlags update_flags
Flags that indicate which finite element quantities are to be computed.
Class FESystem for compound finite elements.
void initialize()
Initialization of the internal structures from the vector of base FE.
void allocate(unsigned int size, UpdateFlags flags, unsigned n_comp)
Resize the data arrays.
Base class for quadrature rules on simplices in arbitrary dimensions.
UpdateFlags update_each(UpdateFlags flags) override
Decides which additional quantities have to be computed for each cell.
Global macros to enhance readability and debugging, general constants.
std::vector< arma::mat::fixed< spacedim, dim > > jacobians
Jacobians of the mapping at the quadrature points.
FESystem(std::shared_ptr< FiniteElement< dim, spacedim > > fe, FEType t)
Constructor. FESystem for vector or tensor created from a scalar FE.
Compound finite element on dim dimensional simplex.
arma::vec::fixed< dim > basis_grad(const unsigned int i, const arma::vec::fixed< dim > &p, const unsigned int comp) const override
The vector variant of basis_grad must be implemented but need not be used.
Basic definitions of numerical quadrature rules.
Shape function gradients.
double basis_value(const unsigned int i, const arma::vec::fixed< dim > &p, const unsigned int comp) const override
The vector variant of basis_value must be implemented but need not be used.
std::vector< std::vector< arma::mat > > ref_shape_grads
Precomputed gradients of basis functions at the quadrature points.
Class FEValuesData holds the arrays of data computed by Mapping and FiniteElement.
const unsigned int size() const
Returns number of quadrature points.
std::vector< std::vector< double > > shape_values
Shape functions evaluated at the quadrature points.
std::vector< double > determinants
Determinants of Jacobians at quadrature points.
Structure for storing the precomputed finite element data.
std::vector< std::vector< arma::vec > > ref_shape_values
Precomputed values of basis functions at the quadrature points.
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
std::vector< std::vector< arma::vec::fixed< spacedim > > > shape_gradients
Gradients of shape functions evaluated at the quadrature points.