From 77374eeea2aa3751d6d6d104ab28e8894db0d5fa Mon Sep 17 00:00:00 2001 From: "daniel.arndt" Date: Wed, 20 Nov 2013 18:55:19 +0000 Subject: [PATCH] Finally fixed the bug in make_zero_boundary_constraints (Issue 154) git-svn-id: https://svn.dealii.org/trunk@31734 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/dofs/dof_tools_constraints.cc | 28 +++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/deal.II/source/dofs/dof_tools_constraints.cc b/deal.II/source/dofs/dof_tools_constraints.cc index acc7ba92b1..25c01c21cf 100644 --- a/deal.II/source/dofs/dof_tools_constraints.cc +++ b/deal.II/source/dofs/dof_tools_constraints.cc @@ -2854,22 +2854,32 @@ namespace DoFTools Assert (component_mask.n_selected_components(n_components) > 0, ComponentMask::ExcNoComponentSelected()); - // a field to store the indices + // a field to store the indices on the face std::vector face_dofs; face_dofs.reserve (max_dofs_per_face(dof)); + // a field to store the indices on the cell + std::vector cell_dofs; + cell_dofs.reserve (max_dofs_per_cell(dof)); typename DH::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); for (; cell!=endc; ++cell) - if (!cell->is_artificial()) + if (!cell->is_artificial() + && + cell->at_boundary ()) + { + const FiniteElement &fe = cell->get_fe(); + + // get global indices of dofs on the cell + cell_dofs.resize (fe.dofs_per_cell); + cell->get_dof_indices (cell_dofs); + for (unsigned int face_no = 0; face_no < GeometryInfo::faces_per_cell; ++face_no) { - const FiniteElement &fe = cell->get_fe(); - const typename DH::face_iterator face = cell->face(face_no); - + // if face is on the boundary and satisfies the correct // boundary id property if (face->at_boundary () @@ -2888,8 +2898,13 @@ namespace DoFTools { // Find out if a dof has a contribution in this // component, and if so, add it to the list + const std::vector::iterator it_index_on_cell + = std::find (cell_dofs.begin(), cell_dofs.end(), face_dofs[i]); + Assert (it_index_on_cell != cell_dofs.end(), ExcInvalidIterator()); + const unsigned int index_on_cell = std::distance(cell_dofs.begin(), + it_index_on_cell); const ComponentMask &nonzero_component_array - = cell->get_fe().get_nonzero_components (i); + = cell->get_fe().get_nonzero_components (index_on_cell); bool nonzero = false; for (unsigned int c=0; c