bool at_refinement_edge (const unsigned int level,
const types::global_dof_index index) const;
- /**
- * Return the indices of dofs for each level that are subject to boundary
- * constraints.
- *
- * @deprecated: use get_boundary_indices(const unsigned int) instead.
- */
- const std::vector<std::set<types::global_dof_index> > &
- get_boundary_indices () const DEAL_II_DEPRECATED;
-
/**
* Return the indices of level dofs on the given level that are subject to
* Dirichlet boundary conditions (as set by the @p function_map parameter in
const IndexSet &
get_boundary_indices (const unsigned int level) const;
- /**
- * @deprecated Use at_refinement_edge() if possible, else
- * get_refinement_edge_indices(unsigned int).
- *
- * Return the indices of dofs for each level that lie on the refinement edge
- * (i.e. are on faces between cells of this level and cells on the level
- * below).
- */
- const std::vector<std::vector<bool> > &
- get_refinement_edge_indices () const DEAL_II_DEPRECATED;
/**
* Return the indices of dofs on the given level that lie on an refinement
- * edge (dofs on faces to neighbors that are coarser)
+ * edge (dofs on faces to neighbors that are coarser).
*/
const IndexSet &
get_refinement_edge_indices (unsigned int level) const;
- /**
- * @deprecated Use at_refinement_edge_boundary() if possible, else use
- * get_refinement_edge_boundary_indices().
- *
- * Return the indices of dofs for each level that are in the intersection of
- * the sets returned by get_boundary_indices() and
- * get_refinement_edge_indices().
- */
- const std::vector<std::vector<bool> > &
- get_refinement_edge_boundary_indices () const DEAL_II_DEPRECATED;
/**
- * @deprecated The function is_boundary_index() now returns false if no
- * boundary values are set.
- *
- * Return if boundary_indices need to be set or not.
+ * Return if Dirichlet boundary indices are set in initialize().
*/
- bool set_boundary_values () const DEAL_II_DEPRECATED;
+ bool have_boundary_indices () const;
private:
*/
std::vector<IndexSet> boundary_indices;
- /**
- * Old data structure that is only filled on demand from @p boundary_indices
- * for deprecated get_boundary_indices().
- */
- mutable std::vector<std::set<types::global_dof_index> > boundary_indices_old;
-
/**
* The degrees of freedom on a given level that live on the refinement edge
* between the level and cells on a coarser level.
*/
std::vector<IndexSet> refinement_edge_indices;
-
- /**
- * Old data structure that is only filled on demand for deprecated
- * get_refinement_edge_boundary_indices().
- */
- mutable std::vector<std::vector<bool> > refinement_edge_boundary_indices_old;
-
- /**
- * Old data structure that is only filled on demand for deprecated
- * get_refinement_edge_indices().
- */
- mutable std::vector<std::vector<bool> > refinement_edge_indices_old;
};
void
MGConstrainedDoFs::initialize(const DoFHandler<dim,spacedim> &dof)
{
- const unsigned int nlevels = dof.get_triangulation().n_global_levels();
+ boundary_indices.clear();
- boundary_indices.resize(nlevels);
+ const unsigned int nlevels = dof.get_triangulation().n_global_levels();
refinement_edge_indices.resize(nlevels);
- refinement_edge_indices_old.clear();
- refinement_edge_boundary_indices_old.clear();
for (unsigned int l=0; l<nlevels; ++l)
- {
- boundary_indices[l].clear();
-
- refinement_edge_indices[l] = IndexSet(dof.n_dofs(l));
- }
+ refinement_edge_indices[l] = IndexSet(dof.n_dofs(l));
MGTools::extract_inner_interface_dofs (dof, refinement_edge_indices);
}
{
initialize (dof);
+ // allocate an IndexSet for each global level. Contents will be
+ // overwritten inside make_boundary_list.
+ const unsigned int n_levels = dof.get_triangulation().n_global_levels();
+ boundary_indices.resize(n_levels);
+
MGTools::make_boundary_list (dof,
function_map,
boundary_indices,
void
MGConstrainedDoFs::clear()
{
- for (unsigned int l=0; l<boundary_indices.size(); ++l)
- boundary_indices[l].clear();
-
- for (unsigned int l=0; l<refinement_edge_indices.size(); ++l)
- refinement_edge_indices[l].clear();
-
- refinement_edge_indices_old.clear();
- refinement_edge_boundary_indices_old.clear();
- boundary_indices_old.clear();
+ boundary_indices.clear();
+ refinement_edge_indices.clear();
}
}
-inline
-const std::vector<std::set<types::global_dof_index> > &
-MGConstrainedDoFs::get_boundary_indices () const
-{
- if (boundary_indices_old.size()!=boundary_indices.size())
- {
- boundary_indices_old.resize(boundary_indices.size());
- for (unsigned int l=0; l<boundary_indices.size(); ++l)
- {
- std::vector<types::global_dof_index> tmp;
- boundary_indices[l].fill_index_vector(tmp);
- boundary_indices_old[l].insert(tmp.begin(), tmp.end());
- }
- }
- return boundary_indices_old;
-}
inline
}
-inline
-const std::vector<std::vector<bool> > &
-MGConstrainedDoFs::get_refinement_edge_indices () const
-{
- if (refinement_edge_indices_old.size()!=refinement_edge_indices.size())
- {
- unsigned int n_levels = refinement_edge_indices.size();
- refinement_edge_indices_old.resize(n_levels);
- for (unsigned int l=0; l<n_levels; ++l)
- {
- refinement_edge_indices_old[l].resize(refinement_edge_indices[l].size(), false);
- refinement_edge_indices[l].fill_binary_vector(refinement_edge_indices_old[l]);
- }
- }
-
- return refinement_edge_indices_old;
-}
inline
const IndexSet &
}
-inline
-const std::vector<std::vector<bool> > &
-MGConstrainedDoFs::get_refinement_edge_boundary_indices () const
-{
- if (refinement_edge_boundary_indices_old.size()==0)
- {
- unsigned int n_levels = refinement_edge_indices.size();
- refinement_edge_boundary_indices_old.resize(n_levels);
- for (unsigned int l=0; l<n_levels; ++l)
- {
- refinement_edge_boundary_indices_old[l].resize(refinement_edge_indices[l].size());
- for (IndexSet::ElementIterator it = refinement_edge_indices[l].begin();
- it != refinement_edge_indices[l].end();
- ++it)
- refinement_edge_boundary_indices_old[l][*it] = this->is_boundary_index(l, *it);
- }
- }
-
- return refinement_edge_boundary_indices_old;
-}
inline
bool
-MGConstrainedDoFs::set_boundary_values () const
+MGConstrainedDoFs::have_boundary_indices () const
{
- const bool boundary_values_need_to_be_set
- = boundary_indices.size()!=0;
- return boundary_values_need_to_be_set;
+ return boundary_indices.size()!=0;
}
// impose boundary conditions
// but only in the column of
// the prolongation matrix
- if (mg_constrained_dofs != 0)
- if (mg_constrained_dofs->set_boundary_values())
- {
- std::vector<types::global_dof_index> constrain_indices;
- std::vector<std::vector<bool> > constraints_per_block (n_blocks);
- for (int level=n_levels-2; level>=0; --level)
- {
- if (mg_constrained_dofs->get_boundary_indices()[level].size() == 0)
- continue;
-
- // need to delete all the columns in the
- // matrix that are on the boundary. to achieve
- // this, create an array as long as there are
- // matrix columns, and find which columns we
- // need to filter away.
- constrain_indices.resize (0);
- constrain_indices.resize (prolongation_matrices[level]->n(), 0);
- std::set<types::global_dof_index>::const_iterator dof
- = mg_constrained_dofs->get_boundary_indices()[level].begin(),
- endd = mg_constrained_dofs->get_boundary_indices()[level].end();
- for (; dof != endd; ++dof)
- constrain_indices[*dof] = 1;
-
- unsigned int index = 0;
- for (unsigned int block=0; block<n_blocks; ++block)
- {
- const types::global_dof_index n_dofs = prolongation_matrices[level]->block(block, block).m();
- constraints_per_block[block].resize(0);
- constraints_per_block[block].resize(n_dofs, 0);
- for (types::global_dof_index i=0; i<n_dofs; ++i, ++index)
- constraints_per_block[block][i] = (constrain_indices[index] == 1);
-
- for (types::global_dof_index i=0; i<n_dofs; ++i)
- {
- SparseMatrix<double>::iterator
- start_row = prolongation_matrices[level]->block(block, block).begin(i),
- end_row = prolongation_matrices[level]->block(block, block).end(i);
- for (; start_row != end_row; ++start_row)
- {
- if (constraints_per_block[block][start_row->column()])
- start_row->value() = 0.;
- }
- }
- }
- }
- }
+ if (mg_constrained_dofs != 0 && mg_constrained_dofs->have_boundary_indices())
+ {
+ std::vector<types::global_dof_index> constrain_indices;
+ std::vector<std::vector<bool> > constraints_per_block (n_blocks);
+ for (int level=n_levels-2; level>=0; --level)
+ {
+ if (mg_constrained_dofs->get_boundary_indices(level).n_elements() == 0)
+ continue;
+
+ // need to delete all the columns in the
+ // matrix that are on the boundary. to achieve
+ // this, create an array as long as there are
+ // matrix columns, and find which columns we
+ // need to filter away.
+ constrain_indices.resize (0);
+ constrain_indices.resize (prolongation_matrices[level]->n(), 0);
+ IndexSet::ElementIterator dof
+ = mg_constrained_dofs->get_boundary_indices(level).begin(),
+ endd = mg_constrained_dofs->get_boundary_indices(level).end();
+ for (; dof != endd; ++dof)
+ constrain_indices[*dof] = 1;
+
+ unsigned int index = 0;
+ for (unsigned int block=0; block<n_blocks; ++block)
+ {
+ const types::global_dof_index n_dofs = prolongation_matrices[level]->block(block, block).m();
+ constraints_per_block[block].resize(0);
+ constraints_per_block[block].resize(n_dofs, 0);
+ for (types::global_dof_index i=0; i<n_dofs; ++i, ++index)
+ constraints_per_block[block][i] = (constrain_indices[index] == 1);
+
+ for (types::global_dof_index i=0; i<n_dofs; ++i)
+ {
+ SparseMatrix<double>::iterator
+ start_row = prolongation_matrices[level]->block(block, block).begin(i),
+ end_row = prolongation_matrices[level]->block(block, block).end(i);
+ for (; start_row != end_row; ++start_row)
+ {
+ if (constraints_per_block[block][start_row->column()])
+ start_row->value() = 0.;
+ }
+ }
+ }
+ }
+ }
}
= mg_dof.get_fe().get_prolongation_matrix (child,
cell->refinement_case());
- if (mg_constrained_dofs != 0 && mg_constrained_dofs->set_boundary_values())
+ if (mg_constrained_dofs != 0 && mg_constrained_dofs->have_boundary_indices())
for (unsigned int j=0; j<dofs_per_cell; ++j)
if (mg_constrained_dofs->is_boundary_index(level, dof_indices_parent[j]))
for (unsigned int i=0; i<dofs_per_cell; ++i)
const Coefficient<dim> coefficient;
std::vector<double> coefficient_values (n_q_points);
- std::vector<std::vector<bool> > interface_dofs
- = mg_constrained_dofs.get_refinement_edge_indices ();
- std::vector<std::vector<bool> > boundary_interface_dofs
- = mg_constrained_dofs.get_refinement_edge_boundary_indices ();
-
std::vector<ConstraintMatrix> boundary_constraints (triangulation.n_levels());
ConstraintMatrix empty_constraints;
for (unsigned int level=0; level<triangulation.n_levels(); ++level)
{
- boundary_constraints[level].add_lines (interface_dofs[level]);
- boundary_constraints[level].add_lines (mg_constrained_dofs.get_boundary_indices()[level]);
+ boundary_constraints[level].add_lines (mg_constrained_dofs.get_refinement_edge_indices(level));
+ boundary_constraints[level].add_lines (mg_constrained_dofs.get_boundary_indices(level));
boundary_constraints[level].close ();
}
for (unsigned int i=0; i<dofs_per_cell; ++i)
for (unsigned int j=0; j<dofs_per_cell; ++j)
- if (interface_dofs[lvl][local_dof_indices[i]] // at_refinement_edge(i)
+ if (mg_constrained_dofs.at_refinement_edge(lvl, local_dof_indices[i])
&&
- !interface_dofs[lvl][local_dof_indices[j]] // !at_refinement_edge(j)
+ ! mg_constrained_dofs.at_refinement_edge(lvl, local_dof_indices[j])
&&
(
(!mg_constrained_dofs.is_boundary_index(lvl, local_dof_indices[i])
const Coefficient<dim> coefficient;
std::vector<double> coefficient_values (n_q_points);
- std::vector<std::vector<bool> > interface_dofs
- = mg_constrained_dofs.get_refinement_edge_indices ();
- std::vector<std::vector<bool> > boundary_interface_dofs
- = mg_constrained_dofs.get_refinement_edge_boundary_indices ();
-
std::vector<ConstraintMatrix> boundary_constraints (triangulation.n_levels());
std::vector<ConstraintMatrix> boundary_interface_constraints (triangulation.n_levels());
for (unsigned int level=0; level<triangulation.n_levels(); ++level)
{
- boundary_constraints[level].add_lines (interface_dofs[level]);
- boundary_constraints[level].add_lines (mg_constrained_dofs.get_boundary_indices()[level]);
+ boundary_constraints[level].add_lines (mg_constrained_dofs.get_refinement_edge_indices(level));
+ boundary_constraints[level].add_lines (mg_constrained_dofs.get_boundary_indices(level));
boundary_constraints[level].close ();
boundary_interface_constraints[level]
- .add_lines (boundary_interface_dofs[level]);
+ .add_lines (mg_constrained_dofs.get_refinement_edge_indices(level));
boundary_interface_constraints[level].close ();
}
for (unsigned int i=0; i<dofs_per_cell; ++i)
for (unsigned int j=0; j<dofs_per_cell; ++j)
- if ( !(interface_dofs[cell->level()][local_dof_indices[i]]==true &&
- interface_dofs[cell->level()][local_dof_indices[j]]==false))
+ if (
+ !mg_constrained_dofs.at_refinement_edge(cell->level(),
+ local_dof_indices[i])
+ || mg_constrained_dofs.at_refinement_edge(cell->level(),
+ local_dof_indices[j])
+ )
cell_matrix(i,j) = 0;
boundary_interface_constraints[cell->level()]
deallog << "get_boundary_indices:" << std::endl;
bi.print(deallog);
- {
- // check that refinement_edge_boundary_indices (deprecated) is really
- // the intersection of the sets above:
- IndexSet intersect = rei & bi;
- std::vector<bool> ref = mg_constrained_dofs.get_refinement_edge_boundary_indices()[level];
-
- unsigned int idx = 0;
- for (std::vector<bool>::iterator it = ref.begin(); it != ref.end(); ++it, ++idx)
- {
- if ((*it == true) != intersect.is_element(idx))
- deallog << "mismatch idx=" << idx << " "
- << (*it == true) << " " << intersect.is_element(idx) << std::endl;
- }
- }
-
-
IndexSet relevant;
DoFTools::extract_locally_relevant_level_dofs (dofh,
level,
const Coefficient<dim> coefficient;
std::vector<double> coefficient_values (n_q_points);
- std::vector<std::vector<bool> > interface_dofs
- = mg_constrained_dofs.get_refinement_edge_indices ();
- std::vector<std::vector<bool> > boundary_interface_dofs
- = mg_constrained_dofs.get_refinement_edge_boundary_indices ();
-
std::vector<ConstraintMatrix> boundary_constraints (triangulation.n_levels());
std::vector<ConstraintMatrix> boundary_interface_constraints (triangulation.n_levels());
for (unsigned int level=0; level<triangulation.n_levels(); ++level)
{
- boundary_constraints[level].add_lines (interface_dofs[level]);
- boundary_constraints[level].add_lines (mg_constrained_dofs.get_boundary_indices()[level]);
+ boundary_constraints[level].add_lines (mg_constrained_dofs.get_refinement_edge_indices(level));
+ boundary_constraints[level].add_lines (mg_constrained_dofs.get_boundary_indices(level));
boundary_constraints[level].close ();
+ IndexSet idx =
+ mg_constrained_dofs.get_refinement_edge_indices(level)
+ & mg_constrained_dofs.get_boundary_indices(level);
+
boundary_interface_constraints[level]
- .add_lines (boundary_interface_dofs[level]);
+ .add_lines (idx);
boundary_interface_constraints[level].close ();
}
for (unsigned int i=0; i<dofs_per_cell; ++i)
for (unsigned int j=0; j<dofs_per_cell; ++j)
- if ( !(interface_dofs[cell->level()][local_dof_indices[i]]==true &&
- interface_dofs[cell->level()][local_dof_indices[j]]==false))
+ if (
+ !mg_constrained_dofs.at_refinement_edge(cell->level(),
+ local_dof_indices[i])
+ || mg_constrained_dofs.at_refinement_edge(cell->level(),
+ local_dof_indices[j])
+ )
cell_matrix(i,j) = 0;
boundary_interface_constraints[cell->level()]
const Coefficient<dim> coefficient;
std::vector<double> coefficient_values (n_q_points);
- std::vector<std::vector<bool> > interface_dofs
- = mg_constrained_dofs.get_refinement_edge_indices ();
-
std::vector<ConstraintMatrix> boundary_constraints (triangulation.n_levels());
ConstraintMatrix empty_constraints;
for (unsigned int level=0; level<triangulation.n_levels(); ++level)
{
- boundary_constraints[level].add_lines (interface_dofs[level]);
- boundary_constraints[level].add_lines (mg_constrained_dofs.get_boundary_indices()[level]);
+ boundary_constraints[level].add_lines (mg_constrained_dofs.get_refinement_edge_indices(level));
+ boundary_constraints[level].add_lines (mg_constrained_dofs.get_boundary_indices(level));
boundary_constraints[level].close ();
}
for (unsigned int i=0; i<dofs_per_cell; ++i)
for (unsigned int j=0; j<dofs_per_cell; ++j)
- if (interface_dofs[lvl][local_dof_indices[i]] // at_refinement_edge(i)
+ if (mg_constrained_dofs.at_refinement_edge(lvl, local_dof_indices[i])
&&
- !interface_dofs[lvl][local_dof_indices[j]] // !at_refinement_edge(j)
+ ! mg_constrained_dofs.at_refinement_edge(lvl, local_dof_indices[j])
&&
(
(!mg_constrained_dofs.is_boundary_index(lvl, local_dof_indices[i])
const Coefficient<dim> coefficient;
std::vector<double> coefficient_values (n_q_points);
- std::vector<std::vector<bool> > interface_dofs
- = mg_constrained_dofs.get_refinement_edge_indices ();
-
std::vector<ConstraintMatrix> boundary_constraints (triangulation.n_levels());
ConstraintMatrix empty_constraints;
for (unsigned int level=0; level<triangulation.n_levels(); ++level)
{
- boundary_constraints[level].add_lines (interface_dofs[level]);
- boundary_constraints[level].add_lines (mg_constrained_dofs.get_boundary_indices()[level]);
+ boundary_constraints[level].add_lines (mg_constrained_dofs.get_refinement_edge_indices(level));
+ boundary_constraints[level].add_lines (mg_constrained_dofs.get_boundary_indices(level));
boundary_constraints[level].close ();
}
for (unsigned int i=0; i<dofs_per_cell; ++i)
for (unsigned int j=0; j<dofs_per_cell; ++j)
- if (interface_dofs[lvl][local_dof_indices[i]] // at_refinement_edge(i)
+ if (mg_constrained_dofs.at_refinement_edge(lvl, local_dof_indices[i])
&&
- !interface_dofs[lvl][local_dof_indices[j]] // !at_refinement_edge(j)
+ ! mg_constrained_dofs.at_refinement_edge(lvl, local_dof_indices[j])
&&
(
(!mg_constrained_dofs.is_boundary_index(lvl, local_dof_indices[i])