include/deal.II/numerics/matrices.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: matrices.h 25345 2012-03-31 08:37:04Z bangerth @f$
00003 //
00004 //    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012 by the deal.II authors
00005 //
00006 //    This file is subject to QPL and may not be  distributed
00007 //    without copyright and license information. Please refer
00008 //    to the file deal.II/doc/license.html for the  text  and
00009 //    further information on this license.
00010 //
00011 //---------------------------------------------------------------------------
00012 #ifndef __deal2__matrices_h
00013 #define __deal2__matrices_h
00014 
00015 
00016 #include <deal.II/base/config.h>
00017 #include <deal.II/base/exceptions.h>
00018 #include <deal.II/base/thread_management.h>
00019 #include <deal.II/dofs/function_map.h>
00020 
00021 #include <map>
00022 
00023 DEAL_II_NAMESPACE_OPEN
00024 
00025 
00026 // forward declarations
00027 template <int dim> class Quadrature;
00028 
00029 template<typename number> class Vector;
00030 template<typename number> class FullMatrix;
00031 template<typename number> class SparseMatrix;
00032 
00033 template <typename number> class BlockSparseMatrix;
00034 template <typename Number> class BlockVector;
00035 
00036 template <int dim, int spacedim> class Mapping;
00037 template <int dim, int spacedim> class DoFHandler;
00038 template <int dim, int spacedim> class MGDoFHandler;
00039 template <int dim, int spacedim> class FEValues;
00040 
00041 namespace hp
00042 {
00043   template <int> class QCollection;
00044   template <int, int> class MappingCollection;
00045   template <int, int> class DoFHandler;
00046 }
00047 
00048 
00049 #ifdef DEAL_II_USE_PETSC
00050 namespace PETScWrappers
00051 {
00052   class SparseMatrix;
00053   class Vector;
00054   namespace MPI
00055   {
00056     class SparseMatrix;
00057     class BlockSparseMatrix;
00058     class Vector;
00059     class BlockVector;
00060   }
00061 }
00062 #endif
00063 
00064 #ifdef DEAL_II_USE_TRILINOS
00065 namespace TrilinosWrappers
00066 {
00067   class SparseMatrix;
00068   class Vector;
00069   class BlockSparseMatrix;
00070   class BlockVector;
00071   namespace MPI
00072   {
00073     class Vector;
00074     class BlockVector;
00075   }
00076 }
00077 #endif
00078 
00079 
00210 namespace MatrixCreator
00211 {
00224   template <int dim, typename number, int spacedim>
00225   void create_mass_matrix (const Mapping<dim, spacedim>       &mapping,
00226                            const DoFHandler<dim,spacedim>    &dof,
00227                            const Quadrature<dim>    &q,
00228                            SparseMatrix<number>     &matrix,
00229                            const Function<spacedim> * const a = 0);
00230 
00236   template <int dim, typename number, int spacedim>
00237   void create_mass_matrix (const DoFHandler<dim,spacedim>    &dof,
00238                            const Quadrature<dim>    &q,
00239                            SparseMatrix<number>     &matrix,
00240                            const Function<spacedim> * const a = 0);
00241 
00255   template <int dim, typename number, int spacedim>
00256   void create_mass_matrix (const Mapping<dim, spacedim>       &mapping,
00257                            const DoFHandler<dim,spacedim>    &dof,
00258                            const Quadrature<dim>    &q,
00259                            SparseMatrix<number>     &matrix,
00260                            const Function<spacedim>      &rhs,
00261                            Vector<double>           &rhs_vector,
00262                            const Function<spacedim> * const a = 0);
00263 
00269   template <int dim, typename number, int spacedim>
00270   void create_mass_matrix (const DoFHandler<dim,spacedim>    &dof,
00271                            const Quadrature<dim>    &q,
00272                            SparseMatrix<number>     &matrix,
00273                            const Function<spacedim>      &rhs,
00274                            Vector<double>           &rhs_vector,
00275                            const Function<spacedim> * const a = 0);
00280   template <int dim, typename number, int spacedim>
00281   void create_mass_matrix (const hp::MappingCollection<dim,spacedim>       &mapping,
00282                            const hp::DoFHandler<dim,spacedim>    &dof,
00283                            const hp::QCollection<dim>    &q,
00284                            SparseMatrix<number>     &matrix,
00285                            const Function<spacedim> * const a = 0);
00286 
00291   template <int dim, typename number, int spacedim>
00292   void create_mass_matrix (const hp::DoFHandler<dim,spacedim>    &dof,
00293                            const hp::QCollection<dim>    &q,
00294                            SparseMatrix<number>     &matrix,
00295                            const Function<spacedim> * const a = 0);
00296 
00301   template <int dim, typename number, int spacedim>
00302   void create_mass_matrix (const hp::MappingCollection<dim,spacedim>       &mapping,
00303                            const hp::DoFHandler<dim,spacedim>    &dof,
00304                            const hp::QCollection<dim>    &q,
00305                            SparseMatrix<number>     &matrix,
00306                            const Function<spacedim>      &rhs,
00307                            Vector<double>           &rhs_vector,
00308                            const Function<spacedim> * const a = 0);
00309 
00314   template <int dim, typename number, int spacedim>
00315   void create_mass_matrix (const hp::DoFHandler<dim,spacedim>    &dof,
00316                            const hp::QCollection<dim>    &q,
00317                            SparseMatrix<number>     &matrix,
00318                            const Function<spacedim>      &rhs,
00319                            Vector<double>           &rhs_vector,
00320                            const Function<spacedim> * const a = 0);
00321 
00322 
00362   template <int dim, int spacedim>
00363 
00364   void create_boundary_mass_matrix (const Mapping<dim, spacedim>       &mapping,
00365                                     const DoFHandler<dim,spacedim>    &dof,
00366                                     const Quadrature<dim-1>  &q,
00367                                     SparseMatrix<double>     &matrix,
00368                                     const typename FunctionMap<spacedim>::type &boundary_functions,
00369                                     Vector<double>           &rhs_vector,
00370                                     std::vector<unsigned int>&dof_to_boundary_mapping,
00371                                     const Function<spacedim> * const weight = 0,
00372                                     std::vector<unsigned int> component_mapping = std::vector<unsigned int>());
00373 
00374 //                                    * Same function, but for 1d.
00375 //                                    */
00376 //
00377 //     void create_boundary_mass_matrix (const Mapping<1,1>       &mapping,
00378 //                                    const DoFHandler<1,1>    &dof,
00379 //                                    const Quadrature<0>    &q,
00380 //                                    SparseMatrix<double>   &matrix,
00381 //                                    const FunctionMap<1>::type &boundary_functions,
00382 //                                    Vector<double>         &rhs_vector,
00383 //                                    std::vector<unsigned int>&dof_to_boundary_mapping,
00384 //                                    const Function<1> * const a = 0);
00385 // //codimension 1
00386 //
00387 //     void create_boundary_mass_matrix (const Mapping<1,2>       &mapping,
00388 //                                    const DoFHandler<1,2>    &dof,
00389 //                                    const Quadrature<0>    &q,
00390 //                                    SparseMatrix<double>   &matrix,
00391 //                                    const FunctionMap<2>::type &boundary_functions,
00392 //                                    Vector<double>         &rhs_vector,
00393 //                                    std::vector<unsigned int>&dof_to_boundary_mapping,
00394 //                                    const Function<2> * const a = 0);
00395 
00396 
00397 
00404   template <int dim, int spacedim>
00405 
00406   void create_boundary_mass_matrix (const DoFHandler<dim,spacedim>    &dof,
00407                                     const Quadrature<dim-1>  &q,
00408                                     SparseMatrix<double>     &matrix,
00409                                     const typename FunctionMap<spacedim>::type        &boundary_functions,
00410                                     Vector<double>           &rhs_vector,
00411                                     std::vector<unsigned int>&dof_to_boundary_mapping,
00412                                     const Function<spacedim> * const a = 0,
00413                                     std::vector<unsigned int> component_mapping = std::vector<unsigned int>());
00414 
00419   template <int dim, int spacedim>
00420 
00421   void create_boundary_mass_matrix (const hp::MappingCollection<dim,spacedim>       &mapping,
00422                                     const hp::DoFHandler<dim,spacedim>    &dof,
00423                                     const hp::QCollection<dim-1>  &q,
00424                                     SparseMatrix<double>     &matrix,
00425                                     const typename FunctionMap<spacedim>::type &boundary_functions,
00426                                     Vector<double>           &rhs_vector,
00427                                     std::vector<unsigned int>&dof_to_boundary_mapping,
00428                                     const Function<spacedim> * const a = 0,
00429                                     std::vector<unsigned int> component_mapping = std::vector<unsigned int>());
00430 
00435 //
00436 //     void create_boundary_mass_matrix (const hp::MappingCollection<1,1>       &mapping,
00437 //                                    const hp::DoFHandler<1,1>    &dof,
00438 //                                    const hp::QCollection<0>    &q,
00439 //                                    SparseMatrix<double>   &matrix,
00440 //                                    const FunctionMap<1>::type &boundary_functions,
00441 //                                    Vector<double>         &rhs_vector,
00442 //                                    std::vector<unsigned int>&dof_to_boundary_mapping,
00443 //                                    const Function<1> * const a = 0);
00444 
00449   template <int dim, int spacedim>
00450 
00451   void create_boundary_mass_matrix (const hp::DoFHandler<dim,spacedim>    &dof,
00452                                     const hp::QCollection<dim-1>  &q,
00453                                     SparseMatrix<double>     &matrix,
00454                                     const typename FunctionMap<spacedim>::type        &boundary_functions,
00455                                     Vector<double>           &rhs_vector,
00456                                     std::vector<unsigned int>&dof_to_boundary_mapping,
00457                                     const Function<spacedim> * const a = 0,
00458                                     std::vector<unsigned int> component_mapping = std::vector<unsigned int>());
00459 
00473   template <int dim, int spacedim>
00474   void create_laplace_matrix (const Mapping<dim, spacedim>       &mapping,
00475                               const DoFHandler<dim,spacedim>    &dof,
00476                               const Quadrature<dim>    &q,
00477                               SparseMatrix<double>     &matrix,
00478                               const Function<spacedim> * const a = 0);
00479 
00486   template <int dim, int spacedim>
00487   void create_laplace_matrix (const DoFHandler<dim,spacedim>    &dof,
00488                               const Quadrature<dim>    &q,
00489                               SparseMatrix<double>     &matrix,
00490                               const Function<spacedim> * const a = 0);
00491 
00506   template <int dim, int spacedim>
00507   void create_laplace_matrix (const Mapping<dim, spacedim>       &mapping,
00508                               const DoFHandler<dim,spacedim>    &dof,
00509                               const Quadrature<dim>    &q,
00510                               SparseMatrix<double>     &matrix,
00511                               const Function<spacedim>      &rhs,
00512                               Vector<double>           &rhs_vector,
00513                               const Function<spacedim> * const a = 0);
00514 
00521   template <int dim, int spacedim>
00522   void create_laplace_matrix (const DoFHandler<dim,spacedim>    &dof,
00523                               const Quadrature<dim>    &q,
00524                               SparseMatrix<double>     &matrix,
00525                               const Function<spacedim>      &rhs,
00526                               Vector<double>           &rhs_vector,
00527                               const Function<spacedim> * const a = 0);
00528 
00534   template <int dim, int spacedim>
00535   void create_laplace_matrix (const hp::MappingCollection<dim,spacedim>       &mapping,
00536                               const hp::DoFHandler<dim,spacedim>    &dof,
00537                               const hp::QCollection<dim>    &q,
00538                               SparseMatrix<double>     &matrix,
00539                               const Function<spacedim> * const a = 0);
00540 
00546   template <int dim, int spacedim>
00547   void create_laplace_matrix (const hp::DoFHandler<dim,spacedim>    &dof,
00548                               const hp::QCollection<dim>    &q,
00549                               SparseMatrix<double>     &matrix,
00550                               const Function<spacedim> * const a = 0);
00551 
00557   template <int dim, int spacedim>
00558   void create_laplace_matrix (const hp::MappingCollection<dim,spacedim>       &mapping,
00559                               const hp::DoFHandler<dim,spacedim>    &dof,
00560                               const hp::QCollection<dim>    &q,
00561                               SparseMatrix<double>     &matrix,
00562                               const Function<spacedim>      &rhs,
00563                               Vector<double>           &rhs_vector,
00564                               const Function<spacedim> * const a = 0);
00565 
00571   template <int dim, int spacedim>
00572   void create_laplace_matrix (const hp::DoFHandler<dim,spacedim>    &dof,
00573                               const hp::QCollection<dim>    &q,
00574                               SparseMatrix<double>     &matrix,
00575                               const Function<spacedim>      &rhs,
00576                               Vector<double>           &rhs_vector,
00577                               const Function<spacedim> * const a = 0);
00578 
00582   DeclException0 (ExcComponentMismatch);
00583 }
00584 
00585 
00586 
00788 namespace MatrixTools
00789 {
00798   using namespace MatrixCreator;
00799 
00806   template <typename number>
00807   void
00808   apply_boundary_values (const std::map<unsigned int,double> &boundary_values,
00809                          SparseMatrix<number>  &matrix,
00810                          Vector<number>        &solution,
00811                          Vector<number>        &right_hand_side,
00812                          const bool             eliminate_columns = true);
00813 
00823   template <typename number>
00824   void
00825   apply_boundary_values (const std::map<unsigned int,double> &boundary_values,
00826                          BlockSparseMatrix<number>           &matrix,
00827                          BlockVector<number>                 &solution,
00828                          BlockVector<number>                 &right_hand_side,
00829                          const bool           eliminate_columns = true);
00830 
00831 #ifdef DEAL_II_USE_PETSC
00832 
00869   void
00870   apply_boundary_values (const std::map<unsigned int,double> &boundary_values,
00871                          PETScWrappers::SparseMatrix  &matrix,
00872                          PETScWrappers::Vector  &solution,
00873                          PETScWrappers::Vector  &right_hand_side,
00874                          const bool             eliminate_columns = true);
00875 
00880   void
00881   apply_boundary_values (const std::map<unsigned int,double> &boundary_values,
00882                          PETScWrappers::MPI::SparseMatrix  &matrix,
00883                          PETScWrappers::MPI::Vector  &solution,
00884                          PETScWrappers::MPI::Vector  &right_hand_side,
00885                          const bool             eliminate_columns = true);
00886 
00912   void
00913   apply_boundary_values (const std::map<unsigned int,double> &boundary_values,
00914                          PETScWrappers::MPI::SparseMatrix  &matrix,
00915                          PETScWrappers::Vector       &solution,
00916                          PETScWrappers::MPI::Vector  &right_hand_side,
00917                          const bool             eliminate_columns = true);
00918 
00922   void
00923   apply_boundary_values (const std::map<unsigned int,double>  &boundary_values,
00924                          PETScWrappers::MPI::BlockSparseMatrix  &matrix,
00925                          PETScWrappers::MPI::BlockVector        &solution,
00926                          PETScWrappers::MPI::BlockVector        &right_hand_side,
00927                          const bool       eliminate_columns = true);
00928 
00929 #endif
00930 
00931 #ifdef DEAL_II_USE_TRILINOS
00932 
00970   void
00971   apply_boundary_values (const std::map<unsigned int,double> &boundary_values,
00972                          TrilinosWrappers::SparseMatrix  &matrix,
00973                          TrilinosWrappers::Vector        &solution,
00974                          TrilinosWrappers::Vector        &right_hand_side,
00975                          const bool             eliminate_columns = true);
00976 
00982   void
00983   apply_boundary_values (const std::map<unsigned int,double> &boundary_values,
00984                          TrilinosWrappers::BlockSparseMatrix  &matrix,
00985                          TrilinosWrappers::BlockVector        &solution,
00986                          TrilinosWrappers::BlockVector        &right_hand_side,
00987                          const bool                eliminate_columns = true);
00988 
01025   void
01026   apply_boundary_values (const std::map<unsigned int,double> &boundary_values,
01027                          TrilinosWrappers::SparseMatrix  &matrix,
01028                          TrilinosWrappers::MPI::Vector   &solution,
01029                          TrilinosWrappers::MPI::Vector   &right_hand_side,
01030                          const bool             eliminate_columns = true);
01031 
01037   void
01038   apply_boundary_values (const std::map<unsigned int,double> &boundary_values,
01039                          TrilinosWrappers::BlockSparseMatrix  &matrix,
01040                          TrilinosWrappers::MPI::BlockVector   &solution,
01041                          TrilinosWrappers::MPI::BlockVector   &right_hand_side,
01042                          const bool                eliminate_columns = true);
01043 #endif
01044 
01081   void
01082   local_apply_boundary_values (const std::map<unsigned int,double> &boundary_values,
01083                                const std::vector<unsigned int> &local_dof_indices,
01084                                FullMatrix<double> &local_matrix,
01085                                Vector<double>     &local_rhs,
01086                                const bool          eliminate_columns);
01087 
01091   DeclException0 (ExcBlocksDontMatch);
01092 }
01093 
01094 
01095 
01096 DEAL_II_NAMESPACE_CLOSE
01097 
01098 #endif
01099 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Tue May 22 2012 12:06:02 by doxygen 1.7.3