From: Martin Kronbichler Date: Fri, 11 Dec 2009 16:33:04 +0000 (+0000) Subject: Simplify one more function with the internal extract_dofs_by_component function. X-Git-Tag: v8.0.0~6738 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16af9964c3783ed3267548d705157c4c924056cf;p=dealii.git Simplify one more function with the internal extract_dofs_by_component function. git-svn-id: https://svn.dealii.org/trunk@20238 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/dofs/dof_tools.cc b/deal.II/deal.II/source/dofs/dof_tools.cc index 645de5e5dc..dfbac365bf 100644 --- a/deal.II/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/deal.II/source/dofs/dof_tools.cc @@ -2896,97 +2896,6 @@ DoFTools::make_hanging_node_constraints (const DH &dof_handler, -template -void DoFTools::distribute_cell_to_dof_vector ( - const DH &dof_handler, - const Vector &cell_data, - Vector &dof_data, - const unsigned int component) -{ - const Triangulation &tria = dof_handler.get_tria(); - - Assert (cell_data.size()==tria.n_active_cells(), - ExcWrongSize (cell_data.size(), tria.n_active_cells())); - Assert (dof_data.size()==dof_handler.n_dofs(), - ExcWrongSize (dof_data.size(), dof_handler.n_dofs())); - Assert (component < n_components(dof_handler), - ExcInvalidComponent(component, n_components(dof_handler))); - Assert (fe_is_primitive(dof_handler) == true, - ExcFENotPrimitive()); - - // store a flag whether we should care - // about different components. this is - // just a simplification, we could ask - // for this at every single place - // equally well - const bool consider_components = (n_components(dof_handler) != 1); - - // zero out the components that we - // will touch - if (consider_components == false) - dof_data = 0; - else - { - std::vector component_dofs (dof_handler.n_dofs()); - std::vector component_mask (dof_handler.get_fe().n_components(), - false); - component_mask[component] = true; - DoFTools::extract_dofs (dof_handler, component_mask, component_dofs); - - for (unsigned int i=0; i touch_count (dof_handler.n_dofs(), 0); - - typename DH::active_cell_iterator cell = dof_handler.begin_active(), - endc = dof_handler.end(); - std::vector dof_indices; - dof_indices.reserve (max_dofs_per_cell(dof_handler)); - - for (unsigned int present_cell = 0; cell!=endc; ++cell, ++present_cell) - { - const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; - dof_indices.resize (dofs_per_cell); - cell->get_dof_indices (dof_indices); - - for (unsigned int i=0; iget_fe().system_to_component_index(i).first == component)) - { - // sum up contribution of the - // present_cell to this dof - dof_data(dof_indices[i]) += cell_data(present_cell); - // note that we added another - // summand - ++touch_count[dof_indices[i]]; - } - } - - // compute the mean value on all the - // dofs by dividing with the number - // of summands. - for (unsigned int i=0; i +void DoFTools::distribute_cell_to_dof_vector ( + const DH &dof_handler, + const Vector &cell_data, + Vector &dof_data, + const unsigned int component) +{ + const Triangulation &tria = dof_handler.get_tria(); + + Assert (cell_data.size()==tria.n_active_cells(), + ExcWrongSize (cell_data.size(), tria.n_active_cells())); + Assert (dof_data.size()==dof_handler.n_dofs(), + ExcWrongSize (dof_data.size(), dof_handler.n_dofs())); + Assert (component < n_components(dof_handler), + ExcInvalidComponent(component, n_components(dof_handler))); + Assert (fe_is_primitive(dof_handler) == true, + ExcFENotPrimitive()); + + // store a flag whether we should care + // about different components. this is + // just a simplification, we could ask + // for this at every single place + // equally well + const bool consider_components = (n_components(dof_handler) != 1); + + // zero out the components that we + // will touch + if (consider_components == false) + dof_data = 0; + else + { + std::vector component_dofs (dof_handler.n_dofs()); + std::vector component_mask (dof_handler.get_fe().n_components(), + false); + component_mask[component] = true; + internal::extract_dofs_by_component (dof_handler, component_mask, + false, component_dofs); + + for (unsigned int i=0; i(component)) + dof_data(i) = 0; + } + + // count how often we have added a value + // in the sum for each dof + std::vector touch_count (dof_handler.n_dofs(), 0); + + typename DH::active_cell_iterator cell = dof_handler.begin_active(), + endc = dof_handler.end(); + std::vector dof_indices; + dof_indices.reserve (max_dofs_per_cell(dof_handler)); + + for (unsigned int present_cell = 0; cell!=endc; ++cell, ++present_cell) + { + const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; + dof_indices.resize (dofs_per_cell); + cell->get_dof_indices (dof_indices); + + for (unsigned int i=0; iget_fe().system_to_component_index(i).first == component)) + { + // sum up contribution of the + // present_cell to this dof + dof_data(dof_indices[i]) += cell_data(present_cell); + // note that we added another + // summand + ++touch_count[dof_indices[i]]; + } + } + + // compute the mean value on all the + // dofs by dividing with the number + // of summands. + for (unsigned int i=0; i void DoFTools::extract_dofs (