From: Wolfgang Bangerth Date: Tue, 7 Apr 1998 14:42:00 +0000 (+0000) Subject: Use dVector instead of vector<...> and fix a serious bug. X-Git-Tag: v8.0.0~23100 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c52f3bdc845d4b7176f589536298b1cf4bc35b3;p=dealii.git Use dVector instead of vector<...> and fix a serious bug. git-svn-id: https://svn.dealii.org/trunk@154 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/dofs/dof_handler.cc b/deal.II/deal.II/source/dofs/dof_handler.cc index fa51a436f3..bbf555b741 100644 --- a/deal.II/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/deal.II/source/dofs/dof_handler.cc @@ -1466,10 +1466,10 @@ unsigned int DoFHandler<2>::max_transfer_entries (const unsigned int max_level_d template -void DoFHandler::distribute_cell_to_dof_vector (const vector &cell_data, - dVector &dof_data) const { - Assert (cell_data.size()==tria->n_active_cells(), - ExcWrongSize (cell_data.size(), tria->n_active_cells())); +void DoFHandler::distribute_cell_to_dof_vector (const dVector &cell_data, + dVector &dof_data) const { + Assert (cell_data.n()==tria->n_active_cells(), + ExcWrongSize (cell_data.n(), tria->n_active_cells())); // assign the right size to the output vector dof_data.reinit (n_dofs()); @@ -1491,7 +1491,7 @@ void DoFHandler::distribute_cell_to_dof_vector (const vector &cell_ { // sum up contribution of the // present_cell to this dof - dof_data(dof_indices[i]) += cell_data[present_cell]; + dof_data(dof_indices[i]) += cell_data(present_cell); // note that we added another // summand ++touch_count[dof_indices[i]]; diff --git a/deal.II/deal.II/source/numerics/base.cc b/deal.II/deal.II/source/numerics/base.cc index 69e88f9bfb..993c0e6156 100644 --- a/deal.II/deal.II/source/numerics/base.cc +++ b/deal.II/deal.II/source/numerics/base.cc @@ -6,6 +6,7 @@ #include #include #include +#include #include "../../../mia/control.h" #include "../../../mia/vectormemory.h" @@ -148,16 +149,15 @@ void ProblemBase::solve () { template void ProblemBase::integrate_difference (const Function &exact_solution, - vector &difference, + dVector &difference, const Quadrature &q, const FiniteElement &fe, const NormType &norm) const { Assert ((tria!=0) && (dof_handler!=0), ExcNoTriaSelected()); Assert (fe == dof_handler->get_selected_fe(), ExcInvalidFE()); - difference.erase (difference.begin(), difference.end()); - difference.reserve (tria->n_cells()); - + difference.reinit (tria->n_active_cells()); + FEValues::UpdateStruct update_flags; update_flags.q_points = true; update_flags.jacobians = true; @@ -176,7 +176,7 @@ void ProblemBase::integrate_difference (const Function &exact_sol endc = dof_handler->end(); Triangulation::active_cell_iterator tria_cell = dof_handler->get_tria().begin_active(); - for (; cell != endc; ++cell, ++tria_cell) + for (unsigned int index=0; cell != endc; ++cell, ++tria_cell, ++index) { double diff=0; // initialize for this cell @@ -209,6 +209,7 @@ void ProblemBase::integrate_difference (const Function &exact_sol // and assign that to the vector // \psi. const unsigned int n_dofs = fe.total_dofs; + const unsigned int n_q_points = q.n_quadrature_points; const dFMatrix & shape_values = fe_values.get_shape_values(); vector dof_values; cell->get_dof_values (solution, dof_values); @@ -221,7 +222,7 @@ void ProblemBase::integrate_difference (const Function &exact_sol psi); // then subtract finite element // solution - for (unsigned int j=0; j::integrate_difference (const Function &exact_sol // append result of this cell // to the end of the vector - difference.push_back (diff); + difference(index) = diff; }; };