template <int dim, int spacedim>
-Table<2,bool>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
FiniteElement<dim,spacedim>::get_constant_modes () const
{
Assert (false, ExcNotImplemented());
- return Table<2,bool>(this->n_components(), this->dofs_per_cell);
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >
+ (Table<2,bool>(this->n_components(), this->dofs_per_cell),
+ std::vector<unsigned int>(this->n_components()));
}
template <int dim, int spacedim>
-Table<2,bool>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
FE_DGP<dim,spacedim>::get_constant_modes () const
{
Table<2,bool> constant_modes(1, this->dofs_per_cell);
constant_modes(0,0) = true;
- return constant_modes;
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >
+ (constant_modes, std::vector<unsigned int>(1, 0));
}
template <int dim, int spacedim>
-Table<2,bool>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
FE_DGQ<dim,spacedim>::get_constant_modes () const
{
Table<2,bool> constant_modes(1, this->dofs_per_cell);
- for (unsigned int i=0; i<this->dofs_per_cell; ++i)
- constant_modes(0,i) = true;
- return constant_modes;
+ constant_modes.fill(true);
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >
+ (constant_modes, std::vector<unsigned int>(1, 0));
}
template <int dim, int spacedim>
-Table<2,bool>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
FE_FaceQ<dim,spacedim>::get_constant_modes () const
{
Table<2,bool> constant_modes(1, this->dofs_per_cell);
for (unsigned int i=0; i<this->dofs_per_cell; ++i)
constant_modes(0,i) = true;
- return constant_modes;
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >
+ (constant_modes, std::vector<unsigned int>(1, 0));
}
template <int spacedim>
-Table<2,bool>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
FE_FaceQ<1,spacedim>::get_constant_modes () const
{
Table<2,bool> constant_modes(1, this->dofs_per_cell);
for (unsigned int i=0; i<this->dofs_per_cell; ++i)
constant_modes(0,i) = true;
- return constant_modes;
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >
+ (constant_modes, std::vector<unsigned int>(1,0));
}
template <int dim, int spacedim>
-Table<2,bool>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
FE_FaceP<dim,spacedim>::get_constant_modes () const
{
Table<2,bool> constant_modes(1, this->dofs_per_cell);
for (unsigned int face=0; face<GeometryInfo<dim>::faces_per_cell; ++face)
constant_modes(0, face*this->dofs_per_face) = true;
- return constant_modes;
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >
+ (constant_modes, std::vector<unsigned int>(1, 0));
}
template <int dim>
-Table<2,bool>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
FE_Nedelec<dim>::get_constant_modes() const
{
Table<2,bool> constant_modes(dim, this->dofs_per_cell);
for (unsigned int d=0; d<dim; ++d)
for (unsigned int i=0; i<this->dofs_per_cell; ++i)
constant_modes(d,i) = true;
- return constant_modes;
+ std::vector<unsigned int> components;
+ for (unsigned int d=0; d<dim; ++d)
+ components.push_back(d);
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >
+ (constant_modes, components);
}
template <typename POLY, int dim, int spacedim>
-Table<2,bool>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
FE_Q_Base<POLY,dim,spacedim>::get_constant_modes () const
{
Table<2,bool> constant_modes(1, this->dofs_per_cell);
- // leave out last component
- for (unsigned int i=0; i<Utilities::fixed_power<dim>(this->degree+1); ++i)
- constant_modes(0, i) = true;
- return constant_modes;
+ // FE_Q_DG0 should not use this function...
+ AssertDimension(this->dofs_per_cell, Utilities::fixed_power<dim>(this->degree+1));
+ constant_modes.fill(true);
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >
+ (constant_modes, std::vector<unsigned int>(1, 0));
}
}
+
+template <int dim, int spacedim>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
+FE_Q_DG0<dim,spacedim>::get_constant_modes () const
+{
+ Table<2,bool> constant_modes(2, this->dofs_per_cell);
+
+ // 1 represented by FE_Q part
+ for (unsigned int i=0; i<this->dofs_per_cell-1; ++i)
+ constant_modes(0, i) = true;
+
+ // 1 represented by DG0 part
+ constant_modes(1, this->dofs_per_cell-1) = true;
+
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >
+ (constant_modes, std::vector<unsigned int> (2, 0));
+}
+
+
+
// explicit instantiations
#include "fe_q_dg0.inst"
template <int dim>
-Table<2,bool>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
FE_Q_Hierarchical<dim>::get_constant_modes () const
{
Table<2,bool> constant_modes(1, this->dofs_per_cell);
constant_modes(0,i) = true;
for (unsigned int i=GeometryInfo<dim>::vertices_per_cell; i<this->dofs_per_cell; ++i)
constant_modes(0,i) = false;
- return constant_modes;
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >
+ (constant_modes, std::vector<unsigned int>(1, 0));
}
template <int dim>
-Table<2,bool>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
FE_RaviartThomas<dim>::get_constant_modes() const
{
Table<2,bool> constant_modes(dim, this->dofs_per_cell);
for (unsigned int d=0; d<dim; ++d)
for (unsigned int i=0; i<this->dofs_per_cell; ++i)
constant_modes(d,i) = true;
- return constant_modes;
+ std::vector<unsigned int> components;
+ for (unsigned int d=0; d<dim; ++d)
+ components.push_back(d);
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >
+ (constant_modes, components);
}
template <int dim, int spacedim>
-Table<2,bool>
+std::pair<Table<2,bool>, std::vector<unsigned int> >
FESystem<dim,spacedim>::get_constant_modes () const
{
+ // Note that this->n_components() is actually only an estimate of how many
+ // constant modes we will need. There might be more than one such mode
+ // (e.g. FE_Q_DG0).
Table<2,bool> constant_modes(this->n_components(), this->dofs_per_cell);
- unsigned int comp=0;
+ std::vector<unsigned int> components;
for (unsigned int i=0; i<base_elements.size(); ++i)
{
- Table<2,bool> base_table = base_elements[i].first->get_constant_modes();
- const unsigned int n_base_components = base_elements[i].first->n_components();
+ std::pair<Table<2,bool>, std::vector<unsigned int> >
+ base_table = base_elements[i].first->get_constant_modes();
+ AssertDimension(base_table.first.n_rows(), base_table.second.size());
+ const unsigned int element_multiplicity = this->element_multiplicity(i);
+
+ // there might be more than one constant mode for some scalar elements,
+ // so make sure the table actually fits: Create a new table with more
+ // rows
+ const unsigned int comp = components.size();
+ if (constant_modes.n_rows() < comp+base_table.first.n_rows()*element_multiplicity)
+ {
+ Table<2,bool> new_constant_modes(comp+base_table.first.n_rows()*
+ element_multiplicity,
+ constant_modes.n_cols());
+ std::copy(&constant_modes(0,0), &constant_modes(0,0)+this->dofs_per_cell*comp,
+ &new_constant_modes(0,0));
+ constant_modes.swap(new_constant_modes);
+ }
+
+ // next, fill the constant modes from the individual components as well
+ // as the component numbers corresponding to the constant mode rows
for (unsigned int k=0; k<this->dofs_per_cell; ++k)
{
std::pair<std::pair<unsigned int,unsigned int>, unsigned int> ind
= this->system_to_base_index(k);
if (ind.first.first == i)
- for (unsigned int c=0; c<base_table.n_rows(); ++c)
- constant_modes(comp+ind.first.second*n_base_components+c,k)
- = base_table(c,ind.second);
+ for (unsigned int c=0; c<base_table.first.n_rows(); ++c)
+ constant_modes(comp+ind.first.second*base_table.first.n_rows()+c,k)
+ = base_table.first(c,ind.second);
}
- comp += n_base_components * base_elements[i].second;
+ for (unsigned int r=0; r<element_multiplicity; ++r)
+ for (unsigned int c=0; c<base_table.second.size(); ++c)
+ components.push_back(comp+r*this->base_elements[i].first->n_components()
+ +base_table.second[c]);
}
- AssertDimension(comp, this->n_components());
- return constant_modes;
+ AssertDimension(components.size(), constant_modes.n_rows());
+ return std::pair<Table<2,bool>, std::vector<unsigned int> >(constant_modes,
+ components);
}