From a7858b7281e5fdc4649e8f18d5f8bed48bd933ca Mon Sep 17 00:00:00 2001 From: cvs Date: Wed, 13 Oct 1999 08:28:19 +0000 Subject: [PATCH] Some changes and checks about vector values elements. git-svn-id: https://svn.dealii.org/trunk@1766 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/numerics/matrices.h | 13 +++ deal.II/deal.II/source/numerics/matrices.cc | 104 ++++++++++++++++---- 2 files changed, 100 insertions(+), 17 deletions(-) diff --git a/deal.II/deal.II/include/numerics/matrices.h b/deal.II/deal.II/include/numerics/matrices.h index fb22ee3962..5e5b691b85 100644 --- a/deal.II/deal.II/include/numerics/matrices.h +++ b/deal.II/deal.II/include/numerics/matrices.h @@ -66,6 +66,14 @@ * way using quadrature sets up the full matrix, i.e. with the * cross coupling of shape functions belonging to different subelements. * + * If the finite element for which the mass matrix is to be built + * has more than one component, the resulting matrix will not + * couple the different components. It will furthermore accept + * a single coefficient through the #Function# parameter for all + * components. If you want different coefficients for the different + * parameters, you need to call the respective function accepting + * a #VectorFunction# argument. + * * \item #create_laplace_matrix#: there are two versions of this; the * one which takes the #Function# object creates * $a_{ij} = \int_\Omega a(x) \nabla\phi_i(x) \nabla\phi_j(x) dx$, @@ -307,6 +315,11 @@ class MatrixCreator static void create_interpolation_matrix(const FiniteElement &high, const FiniteElement &low, FullMatrix& result); + + /** + * Exception + */ + DeclException0 (ExcInvalidFE); }; diff --git a/deal.II/deal.II/source/numerics/matrices.cc b/deal.II/deal.II/source/numerics/matrices.cc index d3834cd23e..edbd3f1f2a 100644 --- a/deal.II/deal.II/source/numerics/matrices.cc +++ b/deal.II/deal.II/source/numerics/matrices.cc @@ -141,6 +141,10 @@ void MatrixCreator::create_boundary_mass_matrix (const DoFHandler & const unsigned int dofs_per_cell = fe.total_dofs, dofs_per_face = fe.dofs_per_face; + + const unsigned int n_components = fe.n_components; + Assert (n_components == 1, ExcNotImplemented()); + FullMatrix cell_matrix(dofs_per_cell, dofs_per_cell); Vector cell_vector(dofs_per_cell); @@ -318,6 +322,9 @@ void MatrixCreator::create_laplace_matrix (const DoFHandler &dof, const Quadrature &q, SparseMatrix &matrix, const Function * const a) { + const unsigned int n_components = dof.get_fe().n_components; + Assert ((n_components==1) || (a==0), ExcNotImplemented()); + Vector dummy; // no entries, should give an error if accessed UpdateFlags update_flags = UpdateFlags(update_gradients | update_JxW_values); @@ -382,6 +389,9 @@ void MatrixCreator::create_laplace_matrix (const DoFHandler &dof, Vector &rhs_vector, const Function * const a) { + const unsigned int n_components = dof.get_fe().n_components; + Assert ((n_components==1) || (a==0), ExcNotImplemented()); + UpdateFlags update_flags = UpdateFlags(update_q_points | update_gradients | update_JxW_values); @@ -567,6 +577,8 @@ void MassMatrix::assemble (FullMatrix &cell_matrix, const typename DoFHandler::cell_iterator &) const { const unsigned int total_dofs = fe_values.total_dofs, n_q_points = fe_values.n_quadrature_points; + const FiniteElement &fe = fe_values.get_fe(); + const unsigned int n_components = fe.n_components; Assert (cell_matrix.n() == total_dofs, Equation::ExcWrongSize(cell_matrix.n(), total_dofs)); @@ -586,19 +598,31 @@ void MassMatrix::assemble (FullMatrix &cell_matrix, coefficient_values); for (unsigned int i=0; i::assemble (FullMatrix &cell_matrix, const unsigned int total_dofs = fe_values.total_dofs, n_q_points = fe_values.n_quadrature_points; + const FiniteElement &fe = fe_values.get_fe(); + const unsigned int n_components = fe.n_components; + // for system elements: need + // VectorFunction for rhs + Assert (n_components==1, ExcNotImplemented()); + Assert (cell_matrix.n() == total_dofs, Equation::ExcWrongSize(cell_matrix.n(), total_dofs)); Assert (cell_matrix.m() == total_dofs, @@ -671,6 +701,12 @@ void MassMatrix::assemble (Vector &rhs, const unsigned int total_dofs = fe_values.total_dofs, n_q_points = fe_values.n_quadrature_points; + const FiniteElement &fe = fe_values.get_fe(); + const unsigned int n_components = fe.n_components; + + // for system elements: need + // VectorFunction for rhs + Assert (n_components==1, ExcNotImplemented()); Assert (rhs.size() == total_dofs, Equation::ExcWrongSize(rhs.size(), total_dofs)); @@ -710,6 +746,12 @@ void LaplaceMatrix::assemble (FullMatrix &cell_matrix, const unsigned int total_dofs = fe_values.total_dofs, n_q_points = fe_values.n_quadrature_points; + const FiniteElement &fe = fe_values.get_fe(); + const unsigned int n_components = fe.n_components; + + // for system elements: need + // VectorFunction for rhs + Assert (n_components==1, ExcNotImplemented()); Assert (cell_matrix.n() == total_dofs, Equation::ExcWrongSize(cell_matrix.n(), total_dofs)); @@ -770,6 +812,13 @@ void LaplaceMatrix::assemble (FullMatrix &cell_matrix, const unsigned int total_dofs = fe_values.total_dofs, n_q_points = fe_values.n_quadrature_points; + const FiniteElement &fe = fe_values.get_fe(); + const unsigned int n_components = fe.n_components; + + // for system elements: need + // VectorFunction for coefficient + Assert ((n_components==1) || (coefficient==0), ExcNotImplemented()); + Assert (cell_matrix.n() == total_dofs, Equation::ExcWrongSize(cell_matrix.n(), total_dofs)); Assert (cell_matrix.m() == total_dofs, @@ -794,12 +843,18 @@ void LaplaceMatrix::assemble (FullMatrix &cell_matrix, coefficient_values[point]; } else - for (unsigned int point=0; point::assemble (Vector &rhs, const unsigned int total_dofs = fe_values.total_dofs, n_q_points = fe_values.n_quadrature_points; + const FiniteElement &fe = fe_values.get_fe(); + const unsigned int n_components = fe.n_components; + + // for system elements: need + // VectorFunction for rhs + Assert (n_components==1, ExcNotImplemented()); Assert (rhs.size() == total_dofs, Equation::ExcWrongSize(rhs.size(), total_dofs)); @@ -828,13 +889,18 @@ void LaplaceMatrix::assemble (Vector &rhs, rhs(i) += values(i,point) * rhs_values[point] * weights[point]; -} +}; + + template void MatrixCreator::create_interpolation_matrix(const FiniteElement &high, const FiniteElement &low, FullMatrix& result) { + Assert (high.n_components == low.n_components, + ExcInvalidFE()); + result.reinit (low.total_dofs, high.total_dofs); vector > unit_support_points (high.total_dofs); @@ -842,7 +908,11 @@ MatrixCreator::create_interpolation_matrix(const FiniteElement &high, for (unsigned int i=0; i