* than the total number of
* degrees of freedom.
*
+ * This behavior can be switched
+ * off by the optional parameter
+ * <tt>vector_valued_once</tt>. If
+ * this is <tt>true</tt>, the
+ * number of components of a
+ * nonprimitive vector valued
+ * element is collected only in
+ * the first component. All other
+ * components will have a count
+ * of zero.
+ *
* The additional optional
* argument @p target_component
* allows for a re-sorting and
static void
count_dofs_per_component (const DoFHandler<dim>& dof_handler,
std::vector<unsigned int>& dofs_per_component,
+ const bool vector_valued_once = false,
std::vector<unsigned int> target_component
=std::vector<unsigned int>());
DoFTools::count_dofs_per_component (
const DoFHandler<dim>& dof_handler,
std::vector<unsigned int>& dofs_per_component,
+ bool only_once,
std::vector<unsigned int> target_component)
{
- const unsigned int n_components = dof_handler.get_fe().n_components();
+ const FiniteElement<dim>& fe = dof_handler.get_fe();
+ const unsigned int n_components = fe.n_components();
dofs_per_component.resize (n_components);
std::fill (dofs_per_component.begin(), dofs_per_component.end(), 0U);
{
dofs_per_component[0] = dof_handler.n_dofs();
return;
- };
-
+ }
+
+
// otherwise determine the number
// of dofs in each component
// separately. do so in parallel
threads.join_all ();
// next count what we got
- for (unsigned int i=0; i<n_components; ++i)
- dofs_per_component[target_component[i]]
- += std::count(dofs_in_component[i].begin(),
- dofs_in_component[i].end(),
- true);
-
+ unsigned int component = 0;
+ for (unsigned int b=0;b<fe.n_base_elements();++b)
+ {
+ const FiniteElement<dim>& base = fe.base_element(b);
+ // Dimension of base element
+ unsigned int d = base.n_components();
+
+ for (unsigned int m=0;m<fe.element_multiplicity(b);++m)
+ {
+ for (unsigned int dd=0;dd<d;++dd)
+ {
+ if (base.is_primitive() || (!only_once || dd==0))
+ dofs_per_component[target_component[component]]
+ += std::count(dofs_in_component[component].begin(),
+ dofs_in_component[component].end(),
+ true);
+ ++component;
+ }
+ }
+ }
+
// finally sanity check. this is
// only valid if the finite element
// is actually primitive, so
void
DoFTools::count_dofs_per_component<deal_II_dimension> (
const DoFHandler<deal_II_dimension>&,
- std::vector<unsigned int>&, std::vector<unsigned int>);
+ std::vector<unsigned int>&, bool, std::vector<unsigned int>);
template
void
component_start.resize(target_component.size());
DoFTools::
count_dofs_per_component (static_cast<const DoFHandler<dim>&>(mg_dof),
- component_start, target_component);
+ component_start, true, target_component);
unsigned int k=0;
for (unsigned int i=0;i<component_start.size();++i)
// $Id$
// Version: $Name$
//
-// Copyright (C) 2003, 2004 by the deal.II authors
+// Copyright (C) 2003, 2004, 2005 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
deallog << ' ' << dofs_per_component[i];
deallog << std::endl;
+ DoFTools::count_dofs_per_component (dof_handler,
+ dofs_per_component, true);
+
+ for (unsigned int i=0;i<n_components;++i)
+ deallog << ' ' << dofs_per_component[i];
+ deallog << std::endl;
+
if (n_components>1)
{
std::vector<unsigned int> target_component(n_components,0U);
DoFTools::count_dofs_per_component (dof_handler,
dofs_per_component,
+ false,
+ target_component);
+ for (unsigned int i=0;i<n_components;++i)
+ deallog << ' ' << dofs_per_component[i];
+ deallog << std::endl;
+
+ DoFTools::count_dofs_per_component (dof_handler,
+ dofs_per_component,
+ true,
target_component);
for (unsigned int i=0;i<n_components;++i)
deallog << ' ' << dofs_per_component[i];
DoFTools::count_dofs_per_component (dof_handler,
dofs_per_component,
+ false,
+ target_component);
+ for (unsigned int i=0;i<n_components;++i)
+ deallog << ' ' << dofs_per_component[i];
+ deallog << std::endl;
+ DoFTools::count_dofs_per_component (dof_handler,
+ dofs_per_component,
+ true,
target_component);
for (unsigned int i=0;i<n_components;++i)
deallog << ' ' << dofs_per_component[i];
#include <fe/fe_dgq.h>
#include <fe/fe_dgp.h>
#include <fe/fe_nedelec.h>
+#include <fe/fe_raviart_thomas.h>
#include <fe/fe_system.h>
#include <fstream>
CHECK(Nedelec, 1, 2);
CHECK(Nedelec, 1, 3);
-
+ CHECK(RaviartThomas, 0, 2);
+ CHECK(RaviartThomas, 1, 2);
+ CHECK(RaviartThomas, 2, 2);
+
+ CHECK(RaviartThomasNodal, 0, 2);
+ CHECK(RaviartThomasNodal, 1, 2);
+ CHECK(RaviartThomasNodal, 2, 2);
+ CHECK(RaviartThomasNodal, 0, 3);
+ CHECK(RaviartThomasNodal, 1, 3);
+ CHECK(RaviartThomasNodal, 2, 3);
+
CHECK_SYS1(FE_Q<1>(1), 3,1);
CHECK_SYS1(FE_DGQ<1>(2),2,1);
CHECK_SYS1(FE_DGP<1>(3),1,1);
mgdof.distribute_dofs(fe);
DoFRenumbering::component_wise(mgdof, target_component);
vector<unsigned int> ndofs(fe.n_components());
- DoFTools::count_dofs_per_component(mgdof, ndofs, target_component);
+ DoFTools::count_dofs_per_component(mgdof, ndofs, true, target_component);
for (unsigned int l=0;l<tr.n_levels();++l)
DoFRenumbering::component_wise(mgdof, l, mg_target_component);