* The data is first the global
* index, then the level index.
*/
- std::vector<std::map<unsigned int, unsigned int> >
+ std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
copy_indices;
/**
dst = 0;
for (unsigned int level=0;level<mg_dof_handler.get_tria().n_levels();++level)
{
- typedef std::map<unsigned int, unsigned int>::const_iterator IT;
+ typedef std::vector<std::pair<unsigned int, unsigned int> >::const_iterator IT;
for (IT i= copy_indices[level].begin();
i != copy_indices[level].end();++i)
dst(i->first) = src[level](i->second);
// functions
for (unsigned int level=0;level<mg_dof_handler.get_tria().n_levels();++level)
{
- typedef std::map<unsigned int, unsigned int>::const_iterator IT;
+ typedef std::vector<std::pair<unsigned int, unsigned int> >::const_iterator IT;
for (IT i= copy_indices[level].begin();
i != copy_indices[level].end();++i)
dst(i->first) += src[level](i->second);
* The data is first the global
* index, then the level index.
*/
- std::vector<std::map<unsigned int, unsigned int> >
+ std::vector<std::vector<std::pair<unsigned int, unsigned int> > >
copy_to_and_from_indices;
/**
do_copy_from_mg (mg_dof_handler, dst, src);
if (constraints != 0)
{
- //If we were given constraints
- //apply them to the dst that goes
+ //If we were given constraints
+ //apply them to the dst that goes
//back now to the linear solver.
//Since constraints are globally
//defined create a global vector here
- //and copy dst to the right component,
- //apply the constraints then and copy
+ //and copy dst to the right component,
+ //apply the constraints then and copy
//the block back to dst.
- const unsigned int n_blocks =
+ const unsigned int n_blocks =
*std::max_element(target_component.begin(), target_component.end()) + 1;
std::vector<unsigned int> dofs_per_block (n_blocks);
DoFTools::count_dofs_per_block (mg_dof_handler, dofs_per_block, target_component);
for (; level_cell != endc; ++level_cell)
{
const unsigned int level = level_cell->level();
- typedef std::map<unsigned int, unsigned int>::const_iterator IT;
+ typedef std::vector<std::pair<unsigned int, unsigned int> >::const_iterator IT;
for (IT i=copy_to_and_from_indices[level].begin();
i != copy_to_and_from_indices[level].end(); ++i)
dst(i->first) = src[level](i->second);
for (; level_cell != endc; ++level_cell)
{
const unsigned int level = level_cell->level();
- typedef std::map<unsigned int, unsigned int>::const_iterator IT;
+ typedef std::vector<std::pair<unsigned int, unsigned int> >::const_iterator IT;
for (IT i=copy_to_and_from_indices[level].begin();
i != copy_to_and_from_indices[level].end(); ++i)
dst(i->first) += src[level](i->second);
for (unsigned int level=mg_dof_handler.get_tria().n_levels(); level!=0;)
{
--level;
+ Vector<number> &dst_level = dst[level];
- typedef std::map<unsigned int, unsigned int>::const_iterator IT;
- for (IT i=copy_to_and_from_indices[level].begin();
- i != copy_to_and_from_indices[level].end(); ++i)
- dst[level](i->second) = src(i->first);
+ typedef std::vector<std::pair<unsigned int, unsigned int> >::const_iterator IT;
+ for (IT i=copy_to_and_from_indices[level].begin();
+ i != copy_to_and_from_indices[level].end(); ++i)
+ dst_level(i->second) = src(i->first);
// for that part of the level
// which is further refined:
// get the defect by
// restriction of the defect on
// one level higher
- if(!first)
- restrict_and_add (level+1, dst[level], dst[level+1]);
- first = false;
+ if(!first)
+ restrict_and_add (level+1, dst[level], dst[level+1]);
+ first = false;
}
}
interface_dofs[l].resize(mg_dof.n_dofs(l));
MGTools::extract_inner_interface_dofs(mg_dof, interface_dofs);
+ // use a temporary vector to create the
+ // relation between global and level dofs
+ std::vector<unsigned int> temp_copy_indices;
std::vector<unsigned int> global_dof_indices (fe.dofs_per_cell);
std::vector<unsigned int> level_dof_indices (fe.dofs_per_cell);
for (int level=dof.get_tria().n_levels()-1; level>=0; --level)
const typename MGDoFHandler<dim,spacedim>::active_cell_iterator
level_end = mg_dof.end_active(level);
+ temp_copy_indices.resize (0);
+ temp_copy_indices.resize (mg_dof.n_dofs(level), numbers::invalid_unsigned_int);
+
// Compute coarse level right hand side
// by restricting from fine level.
for (; level_cell!=level_end; ++level_cell)
= mg_component_start[level][mg_target_component[component]];
const unsigned int global_start
= component_start[target_component[component]];
- copy_to_and_from_indices[level].insert(
- std::make_pair(global_dof_indices[i] - global_start
- /*- component_start[target_component[selected_component]]*/,
- level_dof_indices[i]-level_start));
+ temp_copy_indices[level_dof_indices[i]-level_start] =
+ global_dof_indices[i]-global_start;
deallog << "global " << global_dof_indices[i]
- component_start[target_component[selected_component]] <<
" lokal " << level_dof_indices[i]-level_start << std::endl;
}
}
}
+
+ // write indices from vector into the map from
+ // global to level dofs
+ const unsigned int n_active_dofs =
+ std::count_if (temp_copy_indices.begin(), temp_copy_indices.end(),
+ std::bind2nd(std::not_equal_to<unsigned int>(),
+ numbers::invalid_unsigned_int));
+ copy_to_and_from_indices[level].resize (n_active_dofs);
+ unsigned int counter = 0;
+ for (unsigned int i=0; i<temp_copy_indices.size(); ++i)
+ if (temp_copy_indices[i] != numbers::invalid_unsigned_int)
+ copy_to_and_from_indices[level][counter++] =
+ std::make_pair<unsigned int,unsigned int> (temp_copy_indices[i], i);
+ Assert (counter == n_active_dofs, ExcInternalError());
}
}
for (unsigned int level=mg_dof_handler.get_tria().n_levels();level != 0;)
{
--level;
-// VECTOR& dst_level = dst[level];
+ VECTOR& dst_level = dst[level];
- typedef std::map<unsigned int, unsigned int>::const_iterator IT;
+ typedef std::vector<std::pair<unsigned int, unsigned int> >::const_iterator IT;
for (IT i= copy_indices[level].begin();
i != copy_indices[level].end();++i)
- dst[level](i->second) = src(i->first);
+ dst_level(i->second) = src(i->first);
// For non-DG: degrees of
// freedom in the refinement
MGTools::extract_inner_interface_dofs (mg_dof, interface_dofs);
copy_indices.resize(n_levels);
-// std::vector<unsigned int> temp_copy_indices;
+ std::vector<unsigned int> temp_copy_indices;
std::vector<unsigned int> global_dof_indices (dofs_per_cell);
std::vector<unsigned int> level_dof_indices (dofs_per_cell);
for (int level=mg_dof.get_tria().n_levels()-1; level>=0; --level)
const typename MGDoFHandler<dim,spacedim>::active_cell_iterator
level_end = mg_dof.end_active(level);
-// temp_copy_indices.resize (0);
-// temp_copy_indices.resize (mg_dof.n_dofs(level), numbers::invalid_unsigned_int);
+ temp_copy_indices.resize (0);
+ temp_copy_indices.resize (mg_dof.n_dofs(level), numbers::invalid_unsigned_int);
// Compute coarse level right hand side
// by restricting from fine level.
for (unsigned int i=0; i<dofs_per_cell; ++i)
{
- if(!interface_dofs[level][level_dof_indices[i]])
- copy_indices[level].insert(
- std::make_pair(global_dof_indices[i], level_dof_indices[i]));
-// temp_copy_indices[level_dof_indices[i]] = global_dof_indices[i];
-// if(!interface_dofs[level][level_dof_indices[i]])
-// temp_copy_indices[level_dof_indices[i]] = global_dof_indices[i];
+ if(!interface_dofs[level][level_dof_indices[i]])
+ temp_copy_indices[level_dof_indices[i]] = global_dof_indices[i];
}
}
// copy_indices object. Then, insert the pairs
// of global index and level index into
// copy_indices.
-// const unsigned int n_active_dofs =
-// std::count_if (temp_copy_indices.begin(), temp_copy_indices.end(),
-// std::bind2nd(std::not_equal_to<unsigned int>(),
-// numbers::invalid_unsigned_int));
-// copy_indices[level].resize (n_active_dofs);
-// unsigned int counter = 0;
-// for (unsigned int i=0; i<temp_copy_indices.size(); ++i)
-// if (temp_copy_indices[i] != numbers::invalid_unsigned_int)
-// copy_indices[level][counter++] =
-// std::make_pair<unsigned int,unsigned int> (temp_copy_indices[i], i);
-// Assert (counter == n_active_dofs, ExcInternalError());
+ const unsigned int n_active_dofs =
+ std::count_if (temp_copy_indices.begin(), temp_copy_indices.end(),
+ std::bind2nd(std::not_equal_to<unsigned int>(),
+ numbers::invalid_unsigned_int));
+ copy_indices[level].resize (n_active_dofs);
+ unsigned int counter = 0;
+ for (unsigned int i=0; i<temp_copy_indices.size(); ++i)
+ if (temp_copy_indices[i] != numbers::invalid_unsigned_int)
+ copy_indices[level][counter++] =
+ std::make_pair<unsigned int,unsigned int> (temp_copy_indices[i], i);
+ Assert (counter == n_active_dofs, ExcInternalError());
}
}