29 unsigned int n_comp = 0;
30 for (
auto fs : fs_vector)
31 n_comp += fs->n_components();
39 ASSERT(fs_vector.size() > 0);
40 unsigned int space_dim = fs_vector[0]->space_dim();
41 for (
auto fs : fs_vector)
42 ASSERT(fs->space_dim() == space_dim).error(
"FunctionSpace space_dim mismatch.");
53 unsigned int fe_index = 0;
54 unsigned int comp_offset = 0;
55 for (
auto fs : fs_vector)
57 for (
unsigned int i=0; i<fs->dim(); i++)
62 comp_offset += fs->n_components();
69 unsigned int comp)
const
71 ASSERT(i <
dim_).error(
"Index of basis function is out of range.");
85 const unsigned int comp)
const
87 ASSERT(i <
dim_).error(
"Index of basis function is out of range.");
101 template<
unsigned int dim>
104 ASSERT_EQ(fe->n_components(), 1).error(
"FEVectorContravariant and FEVectorPiola can only be created from scalar FE.");
106 .error(
"This constructor can be used only for FEVectorContravariant or FEVectorPiola.");
114 template<
unsigned int dim>
118 .error(
"This constructor can be used only for FEVector, FETensor or FEMixedSystem.");
120 .error(
"FEVector and FETensor can only be created from scalar FE.");
128 template<
unsigned int dim>
133 fe_.push_back(fe_object);
139 template<
unsigned int dim>
142 unsigned int fe_index = 0;
143 unsigned int comp_offset = 0;
152 scalar_components_.push_back(comp_offset);
157 vector_components_.push_back(comp_offset);
160 tensor_components_.push_back(comp_offset);
168 comp_offset += fe->n_components();
169 fs_vector.push_back(shared_ptr<FunctionSpace>(fe->function_space_));
172 this->function_space_ = make_shared<FESystemFunctionSpace>(fs_vector);
174 double dof_index = 0;
178 for (
unsigned int i=0; i<fe->n_dofs(); i++)
180 arma::vec coefs(this->function_space_->n_components());
181 coefs.subvec(comp_offset, comp_offset+fe->dof(i).coefs.size()-1) = fe->dof(i).coefs;
182 this->dofs_.push_back(
Dof(fe->dof(i).dim, fe->dof(i).n_face_idx, fe->dof(i).coords, coefs, fe->dof(i).type));
185 comp_offset += fe->n_components();
203 for (
uint i=0; i<fe->n_dofs(); ++i)
206 for (
unsigned int c=0; c<fe->n_components(); c++)\
207 nonzeros[comp_offset+c] = fe->get_nonzero_components(i)[c];
208 this->nonzero_components_.push_back(nonzeros);
211 comp_offset += fe->n_components();
215 compute_node_matrix();
221 template<
unsigned int dim>
inline
227 f |= fe->update_each(flags);
232 template<
unsigned int dim>
236 for (
unsigned int i = 0; i < fe_.size(); i++)
238 auto fe_points = fe_[i]->dof_points();
239 points.insert(points.end(), fe_points.begin(), fe_points.end());
245 template<
unsigned int dim>
251 this->node_matrix.resize(this->dofs_.size(), this->dofs_.size());
253 unsigned int offset = 0;
254 for (
unsigned int i = 0; i < fe_.size(); i++)
256 this->node_matrix.submat(offset, offset, offset+fe_[i]->n_dofs()-1, offset+fe_[i]->n_dofs()-1)
257 = fe_[i]->node_matrix;
259 offset += fe_[i]->n_dofs();
266 template<
unsigned int dim>
272 for (
unsigned int i=0; i<fs->dof_indices().size(); i++)
274 if (fs->dof_indices()[i].fe_index == fe_index)
275 fe_dof_indices.push_back(i);
278 return fe_dof_indices;
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
FESystemFunctionSpace(const std::vector< std::shared_ptr< FunctionSpace > > &fs_vector)
Constructor.
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.
std::vector< std::shared_ptr< FunctionSpace > > fs_
Function spaces that are put together.
unsigned int dim_
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.
std::vector< DofComponentData > dof_indices_
Indices of basis functions relative to the sub-spaces.
Compound finite element on dim dimensional simplex.
void compute_node_matrix() override
Initializes the node_matrix for computing the coefficients of the shape functions in the raw basis of...
std::vector< unsigned int > fe_dofs(unsigned int fe_index)
Return dof indices belonging to given sub-FE.
virtual std::vector< arma::vec::fixed< dim+1 > > dof_points() const
UpdateFlags update_each(UpdateFlags flags) override
Decides which additional quantities have to be computed for each cell.
FESystem(std::shared_ptr< FiniteElement< dim > > fe, FEType t)
Constructor for FEVectorContravariant and FEVectorPiola.
void initialize()
Initialization of the internal structures from the vector of base FE.
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
void init(bool primitive=true, FEType type=FEScalar)
Clears all internal structures.
unsigned int n_components() const
Getter for number of components.
unsigned int space_dim() const
Getter for space dimension.
unsigned int count_components(const vector< shared_ptr< FunctionSpace > > &fs_vector)
unsigned int check_spacedim(const vector< shared_ptr< FunctionSpace > > &fs_vector)
Class FESystem for compound finite elements.
Global macros to enhance readability and debugging, general constants.
Basic definitions of numerical quadrature rules.
UpdateFlags
Enum type UpdateFlags indicates which quantities are to be recomputed on each finite element cell.