n_fine_dofs = fine_grid.n_dofs();
// local numbers of dofs
- const unsigned int coarse_dofs_per_cell = coarse_fe.dofs_per_cell,
- fine_dofs_per_cell = fine_fe.dofs_per_cell;
+ const unsigned int fine_dofs_per_cell = fine_fe.dofs_per_cell;
// alias the number of dofs per
// cell belonging to the
// to true if this is an
// interesting dof. finally count
// how many true's there
- vector<bool> dof_is_interesting (fine_grid.n_dofs(), false);
+ vector<bool> dof_is_interesting (fine_grid.n_dofs(), false);
vector<unsigned int> local_dof_indices (fine_fe.dofs_per_cell);
for (DoFHandler<dim>::active_cell_iterator cell=fine_grid.begin_active();
};
n_parameters_on_fine_grid = count (dof_is_interesting.begin(),
- dof_is_interesting.end(),
- true);
+ dof_is_interesting.end(),
+ true);
};
+ // get an array in which we store
+ // which dof on the coarse grid is
+ // a parameter and which is not
+ vector<bool> coarse_dof_is_parameter (coarse_grid.n_dofs());
+ if (true)
+ {
+ vector<bool> mask (coarse_grid.get_fe().n_components(),
+ false);
+ mask[coarse_component] = true;
+ extract_dofs (coarse_grid, mask, coarse_dof_is_parameter);
+ };
+
+
// store the weights with which a dof
// on the parameter grid contributes
// set up this mapping
if (true)
{
- // list of local dof numbers
- // belonging to the parameter
- // part of the FE on the fine grid
- vector<unsigned int> parameter_dofs;
- for (unsigned int i=0; i<coarse_dofs_per_cell; ++i)
- parameter_dofs.push_back(fine_fe.component_to_system_index(coarse_component,i));
-
vector<unsigned int> local_dof_indices(fine_fe.dofs_per_cell);
unsigned int next_free_index=0;
for (typename DoFHandler<dim>::active_cell_iterator cell=fine_grid.begin_active();
Assert (next_free_index == n_parameters_on_fine_grid,
ExcInternalError());
};
-
+
// for each cell on the parameter grid:
// find out which degrees of freedom on the
coarse_to_fine_grid_map, parameter_dofs,
weight_mapping, weights);
-
// ok, now we have all weights for each
// dof on the fine grid. if in debug
// mode lets see if everything went smooth,
// possibly others)
vector<int> representants(weights.m(), -1);
for (unsigned int parameter_dof=0; parameter_dof<weights.m(); ++parameter_dof)
- {
- unsigned int column=0;
- for (; column<weights.n(); ++column)
- if (weights(parameter_dof,column) == 1)
- break;
- Assert (column < weights.n(), ExcInternalError());
-
- // now we know in which column of
- // weights the representant is, but
- // we don't know its global index. get
- // it using the inverse operation of
- // the weight_mapping
- unsigned int global_dof=0;
- for (; global_dof<weight_mapping.size(); ++global_dof)
- if (weight_mapping[global_dof] == static_cast<int>(column))
- break;
- Assert (global_dof < weight_mapping.size(), ExcInternalError());
-
- // now enter the representants global
- // index into our list
- representants[parameter_dof] = global_dof;
- };
+ if (coarse_dof_is_parameter[parameter_dof] == true)
+ {
+ unsigned int column=0;
+ for (; column<weights.n(); ++column)
+ if (weights(parameter_dof,column) == 1)
+ break;
+ Assert (column < weights.n(), ExcInternalError());
+
+ // now we know in which column of
+ // weights the representant is, but
+ // we don't know its global index. get
+ // it using the inverse operation of
+ // the weight_mapping
+ unsigned int global_dof=0;
+ for (; global_dof<weight_mapping.size(); ++global_dof)
+ if (weight_mapping[global_dof] == static_cast<int>(column))
+ break;
+ Assert (global_dof < weight_mapping.size(), ExcInternalError());
+
+ // now enter the representants global
+ // index into our list
+ representants[parameter_dof] = global_dof;
+ }
+ else
+ {
+ // consistency check: if this
+ // is no parameter dof on the
+ // coarse grid, then the
+ // respective row must be
+ // empty!
+ for (unsigned int col=0; col<weights.n(); ++col)
+ Assert (weights(parameter_dof,col) == 0, ExcInternalError());
+ };
+
// note for people that want to
if ((weights(first_used_row,weight_mapping[global_dof]) == 1) &&
(representants[first_used_row] == static_cast<int>(global_dof)))
- // dof unconstrained
+ // dof unconstrained or
+ // constrained to itself
+ // (in case this cell is
+ // mapped to itself, rather
+ // than to children of
+ // itself)
continue;
// otherwise enter all constraints
cell_intervals = Threads::split_range<active_cell_iterator> (coarse_grid.begin_active(),
coarse_grid.end(),
multithread_info.n_default_threads);
-
+
Threads::ThreadManager thread_manager;
for (unsigned int i=0; i<multithread_info.n_default_threads; ++i)
Threads::spawn (thread_manager,
// aliases to the finite elements
// used by the dof handlers:
const FiniteElement<dim> &coarse_fe = coarse_grid.get_fe();
-
+
// for each cell on the parameter grid:
// find out which degrees of freedom on the
// fine grid correspond in which way to
// loop over all dofs on this
// cell and check whether they
// are interesting for us
- for (unsigned int local_parameter_dof=0;
- local_parameter_dof<coarse_fe.dofs_per_cell;
- ++local_parameter_dof)
- if (coarse_fe.system_to_component_index(local_parameter_dof).first
+ for (unsigned int local_dof=0;
+ local_dof<coarse_fe.dofs_per_cell;
+ ++local_dof)
+ if (coarse_fe.system_to_component_index(local_dof).first
==
coarse_component)
{
+ // the how-many-th
+ // parameter is this on
+ // this cell?
+ const unsigned int local_parameter_dof
+ = coarse_fe.system_to_component_index(local_dof).second;
+
global_parameter_representation.clear ();
// distribute the representation of
// zero
if (global_parameter_representation(i) != 0)
{
- const unsigned int wi = parameter_dof_indices[local_parameter_dof],
+ const unsigned int wi = parameter_dof_indices[local_dof],
wj = weight_mapping[i];
weights(wi,wj) = global_parameter_representation(i);
};
#if deal_II_dimension < 3
-template <>
-unsigned int Triangulation<1>::n_hexs () const {
+template <int dim>
+unsigned int Triangulation<dim>::n_hexs () const
+{
Assert (false, ExcFunctionNotUseful());
return 0;
};
-template <>
-unsigned int Triangulation<1>::n_hexs (const unsigned int) const {
- Assert (false, ExcFunctionNotUseful());
- return 0;
-};
-
-template <>
-unsigned int Triangulation<1>::n_active_hexs () const {
+template <int dim>
+unsigned int Triangulation<dim>::n_hexs (const unsigned int) const
+{
Assert (false, ExcFunctionNotUseful());
return 0;
};
-template <>
-unsigned int Triangulation<1>::n_active_hexs (const unsigned int) const {
- Assert (false, ExcFunctionNotUseful());
- return 0;
-};
-
-template <>
-unsigned int Triangulation<2>::n_hexs () const {
+template <int dim>
+unsigned int Triangulation<dim>::n_active_hexs () const
+{
Assert (false, ExcFunctionNotUseful());
return 0;
};
-template <>
-unsigned int Triangulation<2>::n_hexs (const unsigned int) const {
- Assert (false, ExcFunctionNotUseful());
- return 0;
-};
-
-template <>
-unsigned int Triangulation<2>::n_active_hexs () const {
+template <int dim>
+unsigned int Triangulation<dim>::n_active_hexs (const unsigned int) const
+{
Assert (false, ExcFunctionNotUseful());
return 0;
};
-template <>
-unsigned int Triangulation<2>::n_active_hexs (const unsigned int) const {
- Assert (false, ExcFunctionNotUseful());
- return 0;
-};
-
-#endif
+#else
template <int dim>
-unsigned int Triangulation<dim>::n_hexs () const {
+unsigned int Triangulation<dim>::n_hexs () const
+{
return number_cache.n_hexes;
};
+
template <int dim>
-unsigned int Triangulation<dim>::n_hexs (const unsigned int level) const {
+unsigned int Triangulation<dim>::n_hexs (const unsigned int level) const
+{
Assert (level < number_cache.n_hexes_level.size(),
ExcIndexRange (level, 0, number_cache.n_hexes_level.size()));
};
+
template <int dim>
-unsigned int Triangulation<dim>::n_active_hexs () const {
+unsigned int Triangulation<dim>::n_active_hexs () const
+{
return number_cache.n_active_hexes;
};
+
template <int dim>
-unsigned int Triangulation<dim>::n_active_hexs (const unsigned int level) const {
+unsigned int Triangulation<dim>::n_active_hexs (const unsigned int level) const
+{
Assert (level < number_cache.n_hexes_level.size(),
ExcIndexRange (level, 0, number_cache.n_hexes_level.size()));
};
+#endif
+
+
template <int dim>
-unsigned int Triangulation<dim>::n_levels () const {
+unsigned int Triangulation<dim>::n_levels () const
+{
if (levels.size() == 0)
return 0;
// check whether there are