From: kronbichler Date: Mon, 5 Jan 2009 16:03:01 +0000 (+0000) Subject: Corrected the make_mass_function that had a bug when assembling together with right... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=486a6196e83446babe21f963d1eab175b73996b0;p=dealii-svn.git Corrected the make_mass_function that had a bug when assembling together with right hand side functions. git-svn-id: https://svn.dealii.org/trunk@18072 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/numerics/matrices.cc b/deal.II/deal.II/source/numerics/matrices.cc index 2cbff4aa3e..3c650dbe09 100644 --- a/deal.II/deal.II/source/numerics/matrices.cc +++ b/deal.II/deal.II/source/numerics/matrices.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -160,16 +160,17 @@ void MatrixCreator::create_mass_matrix_1 (const Mapping &ma for (unsigned int i=0; i &ma const unsigned int component_i= fe.system_to_component_index(i).first; for (unsigned int j=0; j &ma { const double v = fe_values.shape_value(i,point); for (unsigned int j=0; j &ma // transfer everything into the // global object mutex.acquire (); - if (fe.is_primitive ()) - { - for (unsigned int i=0; i &mapping const DoFHandler &dof, const Quadrature &q, SparseMatrix &matrix, - const Function &rhs, + const Function &rhs, Vector &rhs_vector, const Function * const coefficient, const IteratorRange > range, @@ -385,49 +370,71 @@ MatrixCreator::create_mass_matrix_2 (const Mapping &mapping Assert(coefficient == 0 || coefficient->n_components==1 || coefficient->n_components==n_components, ExcComponentMismatch()); + Assert (rhs.n_components == 1 || + rhs.n_components == n_components,ExcComponentMismatch()); + Assert (rhs_vector.size() == dof.n_dofs(), + ExcDimensionMismatch(rhs_vector.size(), dof.n_dofs())); FullMatrix cell_matrix (dofs_per_cell, dofs_per_cell); Vector local_rhs (dofs_per_cell); - std::vector rhs_values (fe_values.n_quadrature_points); std::vector coefficient_values (n_q_points); std::vector > coefficient_vector_values (n_q_points, - Vector (n_components)); - + Vector (n_components)); + std::vector rhs_values(n_q_points); + std::vector > rhs_vector_values(n_q_points, + Vector (n_components)); + std::vector dof_indices (dofs_per_cell); - + typename DoFHandler::active_cell_iterator cell = range.first; + for (; cell!=range.second; ++cell) { fe_values.reinit (cell); - + cell_matrix = 0; local_rhs = 0; cell->get_dof_indices (dof_indices); - - rhs.value_list (fe_values.get_quadrature_points(), rhs_values); - + + // value_list for one component rhs, + // vector_value_list otherwise + if (rhs.n_components==1) + rhs.value_list (fe_values.get_quadrature_points(), rhs_values); + else + rhs.vector_value_list (fe_values.get_quadrature_points(), + rhs_vector_values); + + // Case with coefficient if (coefficient != 0) { - if (coefficient->n_components==1) + if (coefficient->n_components == 1) { + // Version for variable coefficient with 1 component coefficient->value_list (fe_values.get_quadrature_points(), coefficient_values); for (unsigned int point=0; point &mapping { coefficient->vector_value_list (fe_values.get_quadrature_points(), coefficient_vector_values); + if (fe.is_primitive ()) + { + // Version for variable coefficient with multiple components + for (unsigned int point=0; point