]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Allow the create_* functions to be called with nullptr coefficients 4762/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 10 Aug 2017 06:00:28 +0000 (08:00 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Thu, 10 Aug 2017 15:38:41 +0000 (17:38 +0200)
include/deal.II/numerics/matrix_creator.templates.h
include/deal.II/numerics/matrix_tools.h
tests/numerics/create_laplace_matrix_constraints_01.cc
tests/numerics/create_laplace_matrix_constraints_02.cc
tests/numerics/create_laplace_matrix_constraints_02b.cc
tests/numerics/create_mass_matrix_constraints_01.cc
tests/numerics/create_mass_matrix_constraints_02.cc
tests/numerics/create_mass_matrix_constraints_02b.cc

index b3c56d19ae46478aaaf91012075843a51f95074f..4c1fd44d2cd457ec05860b30ce8e6b24f2aa3b91 100644 (file)
@@ -671,7 +671,7 @@ namespace MatrixCreator
                            const DoFHandler<dim,spacedim>    &dof,
                            const Quadrature<dim>    &q,
                            SparseMatrix<number>     &matrix,
-                           const Function<spacedim,number> *const coefficient,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const coefficient,
                            const ConstraintMatrix   &constraints)
   {
     Assert (matrix.m() == dof.n_dofs(),
@@ -712,7 +712,7 @@ namespace MatrixCreator
   void create_mass_matrix (const DoFHandler<dim,spacedim>    &dof,
                            const Quadrature<dim>    &q,
                            SparseMatrix<number>     &matrix,
-                           const Function<spacedim,number> *const coefficient,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const coefficient,
                            const ConstraintMatrix   &constraints)
   {
     create_mass_matrix(StaticMappingQ1<dim,spacedim>::mapping, dof,
@@ -728,7 +728,7 @@ namespace MatrixCreator
                            SparseMatrix<number>     &matrix,
                            const Function<spacedim,number>      &rhs,
                            Vector<number>           &rhs_vector,
-                           const Function<spacedim,number> *const coefficient,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const coefficient,
                            const ConstraintMatrix   &constraints)
   {
     Assert (matrix.m() == dof.n_dofs(),
@@ -770,7 +770,7 @@ namespace MatrixCreator
                            SparseMatrix<number>     &matrix,
                            const Function<spacedim,number>      &rhs,
                            Vector<number>           &rhs_vector,
-                           const Function<spacedim,number> *const coefficient,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const coefficient,
                            const ConstraintMatrix   &constraints)
   {
     create_mass_matrix(StaticMappingQ1<dim,spacedim>::mapping,
@@ -785,7 +785,7 @@ namespace MatrixCreator
                            const hp::DoFHandler<dim,spacedim>    &dof,
                            const hp::QCollection<dim>    &q,
                            SparseMatrix<number>     &matrix,
-                           const Function<spacedim,number> *const coefficient,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const coefficient,
                            const ConstraintMatrix   &constraints)
   {
     Assert (matrix.m() == dof.n_dofs(),
@@ -822,7 +822,7 @@ namespace MatrixCreator
   void create_mass_matrix (const hp::DoFHandler<dim,spacedim> &dof,
                            const hp::QCollection<dim> &q,
                            SparseMatrix<number>     &matrix,
-                           const Function<spacedim,number> *const coefficient,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const coefficient,
                            const ConstraintMatrix   &constraints)
   {
     create_mass_matrix(hp::StaticMappingQ1<dim,spacedim>::mapping_collection,
@@ -838,7 +838,7 @@ namespace MatrixCreator
                            SparseMatrix<number>     &matrix,
                            const Function<spacedim,number>      &rhs,
                            Vector<number>           &rhs_vector,
-                           const Function<spacedim,number> *const coefficient,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const coefficient,
                            const ConstraintMatrix   &constraints)
   {
     Assert (matrix.m() == dof.n_dofs(),
@@ -877,7 +877,7 @@ namespace MatrixCreator
                            SparseMatrix<number>     &matrix,
                            const Function<spacedim,number> &rhs,
                            Vector<number>           &rhs_vector,
-                           const Function<spacedim,number> *const coefficient,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const coefficient,
                            const ConstraintMatrix   &constraints)
   {
     create_mass_matrix(hp::StaticMappingQ1<dim,spacedim>::mapping_collection, dof, q,
@@ -1198,7 +1198,7 @@ namespace MatrixCreator
                                const std::map<types::boundary_id, const Function<spacedim,number>*> &boundary_functions,
                                Vector<number>            &rhs_vector,
                                std::vector<types::global_dof_index> &dof_to_boundary_mapping,
-                               const Function<spacedim,number> *const coefficient,
+                               const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const coefficient,
                                std::vector<unsigned int> component_mapping)
   {
     // what would that be in 1d? the
@@ -1597,7 +1597,7 @@ namespace MatrixCreator
                                     const std::map<types::boundary_id, const Function<spacedim,number>*> &rhs,
                                     Vector<number>            &rhs_vector,
                                     std::vector<types::global_dof_index> &dof_to_boundary_mapping,
-                                    const Function<spacedim,number> *const a,
+                                    const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a,
                                     std::vector<unsigned int> component_mapping)
   {
     create_boundary_mass_matrix(StaticMappingQ1<dim,spacedim>::mapping, dof, q,
@@ -1615,7 +1615,7 @@ namespace MatrixCreator
                                const std::map<types::boundary_id, const Function<spacedim,number>*> &boundary_functions,
                                Vector<number>            &rhs_vector,
                                std::vector<types::global_dof_index> &dof_to_boundary_mapping,
-                               const Function<spacedim,number> *const coefficient,
+                               const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const coefficient,
                                std::vector<unsigned int> component_mapping)
   {
     // what would that be in 1d? the
@@ -1684,7 +1684,7 @@ namespace MatrixCreator
                                     const std::map<types::boundary_id, const Function<spacedim,number>*> &rhs,
                                     Vector<number>            &rhs_vector,
                                     std::vector<types::global_dof_index> &dof_to_boundary_mapping,
-                                    const Function<spacedim,number> *const a,
+                                    const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a,
                                     std::vector<unsigned int> component_mapping)
   {
     create_boundary_mass_matrix(hp::StaticMappingQ1<dim,spacedim>::mapping_collection, dof, q,
@@ -1698,7 +1698,7 @@ namespace MatrixCreator
                               const DoFHandler<dim,spacedim>    &dof,
                               const Quadrature<dim>    &q,
                               SparseMatrix<double>     &matrix,
-                              const Function<spacedim> *const coefficient,
+                              const Function<std::integral_constant<int, spacedim>::value> *const coefficient,
                               const ConstraintMatrix   &constraints)
   {
     Assert (matrix.m() == dof.n_dofs(),
@@ -1740,7 +1740,7 @@ namespace MatrixCreator
   void create_laplace_matrix (const DoFHandler<dim,spacedim>    &dof,
                               const Quadrature<dim>    &q,
                               SparseMatrix<double>     &matrix,
-                              const Function<spacedim> *const coefficient,
+                              const Function<std::integral_constant<int, spacedim>::value> *const coefficient,
                               const ConstraintMatrix &constraints)
   {
     create_laplace_matrix(StaticMappingQ1<dim,spacedim>::mapping,
@@ -1756,7 +1756,7 @@ namespace MatrixCreator
                               SparseMatrix<double>     &matrix,
                               const Function<spacedim>      &rhs,
                               Vector<double>           &rhs_vector,
-                              const Function<spacedim> *const coefficient,
+                              const Function<std::integral_constant<int, spacedim>::value> *const coefficient,
                               const ConstraintMatrix   &constraints)
   {
     Assert (matrix.m() == dof.n_dofs(),
@@ -1800,7 +1800,7 @@ namespace MatrixCreator
                               SparseMatrix<double>     &matrix,
                               const Function<spacedim>      &rhs,
                               Vector<double>           &rhs_vector,
-                              const Function<spacedim> *const coefficient,
+                              const Function<std::integral_constant<int, spacedim>::value> *const coefficient,
                               const ConstraintMatrix &constraints)
   {
     create_laplace_matrix(StaticMappingQ1<dim,spacedim>::mapping, dof, q,
@@ -1814,7 +1814,7 @@ namespace MatrixCreator
                               const hp::DoFHandler<dim,spacedim>    &dof,
                               const hp::QCollection<dim>    &q,
                               SparseMatrix<double>     &matrix,
-                              const Function<spacedim> *const coefficient,
+                              const Function<std::integral_constant<int, spacedim>::value> *const coefficient,
                               const ConstraintMatrix   &constraints)
   {
     Assert (matrix.m() == dof.n_dofs(),
@@ -1853,7 +1853,7 @@ namespace MatrixCreator
   void create_laplace_matrix (const hp::DoFHandler<dim,spacedim>    &dof,
                               const hp::QCollection<dim>    &q,
                               SparseMatrix<double>     &matrix,
-                              const Function<spacedim> *const coefficient,
+                              const Function<std::integral_constant<int, spacedim>::value> *const coefficient,
                               const ConstraintMatrix &constraints)
   {
     create_laplace_matrix(hp::StaticMappingQ1<dim,spacedim>::mapping_collection, dof, q,
@@ -1869,7 +1869,7 @@ namespace MatrixCreator
                               SparseMatrix<double>     &matrix,
                               const Function<spacedim>      &rhs,
                               Vector<double>           &rhs_vector,
-                              const Function<spacedim> *const coefficient,
+                              const Function<std::integral_constant<int, spacedim>::value> *const coefficient,
                               const ConstraintMatrix   &constraints)
   {
     Assert (matrix.m() == dof.n_dofs(),
@@ -1910,7 +1910,7 @@ namespace MatrixCreator
                               SparseMatrix<double>     &matrix,
                               const Function<spacedim>      &rhs,
                               Vector<double>           &rhs_vector,
-                              const Function<spacedim> *const coefficient,
+                              const Function<std::integral_constant<int, spacedim>::value> *const coefficient,
                               const ConstraintMatrix &constraints)
   {
     create_laplace_matrix(hp::StaticMappingQ1<dim,spacedim>::mapping_collection, dof, q,
index a2377cbd4a4941b60065dd8cb26530d62696f483..070502d158d33253df3624112dc5384e36c4d605 100644 (file)
@@ -237,7 +237,7 @@ namespace MatrixCreator
                            const DoFHandler<dim,spacedim>    &dof,
                            const Quadrature<dim>    &q,
                            SparseMatrix<number>     &matrix,
-                           const Function<spacedim,number> *const a = nullptr,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a = nullptr,
                            const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -248,7 +248,7 @@ namespace MatrixCreator
   void create_mass_matrix (const DoFHandler<dim,spacedim>    &dof,
                            const Quadrature<dim>    &q,
                            SparseMatrix<number>     &matrix,
-                           const Function<spacedim,number> *const a = nullptr,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a = nullptr,
                            const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -274,7 +274,7 @@ namespace MatrixCreator
                            SparseMatrix<number>     &matrix,
                            const Function<spacedim,number> &rhs,
                            Vector<number>           &rhs_vector,
-                           const Function<spacedim,number> *const a = nullptr,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a = nullptr,
                            const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -287,7 +287,7 @@ namespace MatrixCreator
                            SparseMatrix<number>     &matrix,
                            const Function<spacedim,number> &rhs,
                            Vector<number>           &rhs_vector,
-                           const Function<spacedim,number> *const a = 0,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a = nullptr,
                            const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -298,7 +298,7 @@ namespace MatrixCreator
                            const hp::DoFHandler<dim,spacedim>    &dof,
                            const hp::QCollection<dim>    &q,
                            SparseMatrix<number>     &matrix,
-                           const Function<spacedim,number> *const a = nullptr,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a = nullptr,
                            const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -308,7 +308,7 @@ namespace MatrixCreator
   void create_mass_matrix (const hp::DoFHandler<dim,spacedim>    &dof,
                            const hp::QCollection<dim>    &q,
                            SparseMatrix<number>     &matrix,
-                           const Function<spacedim,number> *const a = 0,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a = nullptr,
                            const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -321,7 +321,7 @@ namespace MatrixCreator
                            SparseMatrix<number>     &matrix,
                            const Function<spacedim,number> &rhs,
                            Vector<number>           &rhs_vector,
-                           const Function<spacedim,number> *const a = nullptr,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a = nullptr,
                            const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -333,7 +333,7 @@ namespace MatrixCreator
                            SparseMatrix<number>     &matrix,
                            const Function<spacedim,number> &rhs,
                            Vector<number>           &rhs_vector,
-                           const Function<spacedim,number> *const a = 0,
+                           const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a = nullptr,
                            const ConstraintMatrix   &constraints = ConstraintMatrix());
 
 
@@ -367,7 +367,7 @@ namespace MatrixCreator
                                     const std::map<types::boundary_id, const Function<spacedim,number>*> &boundary_functions,
                                     Vector<number>           &rhs_vector,
                                     std::vector<types::global_dof_index> &dof_to_boundary_mapping,
-                                    const Function<spacedim,number> *const weight = 0,
+                                    const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const weight = nullptr,
                                     std::vector<unsigned int> component_mapping = std::vector<unsigned int>());
 
 
@@ -382,7 +382,7 @@ namespace MatrixCreator
                                     const std::map<types::boundary_id, const Function<spacedim,number>*> &boundary_functions,
                                     Vector<number>           &rhs_vector,
                                     std::vector<types::global_dof_index> &dof_to_boundary_mapping,
-                                    const Function<spacedim,number> *const a = 0,
+                                    const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a = nullptr,
                                     std::vector<unsigned int> component_mapping = std::vector<unsigned int>());
 
   /**
@@ -396,7 +396,7 @@ namespace MatrixCreator
                                     const std::map<types::boundary_id, const Function<spacedim,number>*> &boundary_functions,
                                     Vector<number>           &rhs_vector,
                                     std::vector<types::global_dof_index> &dof_to_boundary_mapping,
-                                    const Function<spacedim,number> *const a = 0,
+                                    const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a = nullptr,
                                     std::vector<unsigned int> component_mapping = std::vector<unsigned int>());
 
   /**
@@ -409,7 +409,7 @@ namespace MatrixCreator
                                     const std::map<types::boundary_id, const Function<spacedim,number>*> &boundary_functions,
                                     Vector<number>           &rhs_vector,
                                     std::vector<types::global_dof_index> &dof_to_boundary_mapping,
-                                    const Function<spacedim,number> *const a = 0,
+                                    const Function<std::integral_constant<int, spacedim>::value, typename identity<number>::type> *const a = nullptr,
                                     std::vector<unsigned int> component_mapping = std::vector<unsigned int>());
 
   /**
@@ -433,7 +433,7 @@ namespace MatrixCreator
                               const DoFHandler<dim,spacedim> &dof,
                               const Quadrature<dim>    &q,
                               SparseMatrix<double>     &matrix,
-                              const Function<spacedim> *const a = nullptr,
+                              const Function<std::integral_constant<int, spacedim>::value> *const a = nullptr,
                               const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -444,7 +444,7 @@ namespace MatrixCreator
   void create_laplace_matrix (const DoFHandler<dim,spacedim> &dof,
                               const Quadrature<dim>    &q,
                               SparseMatrix<double>     &matrix,
-                              const Function<spacedim> *const a = nullptr,
+                              const Function<std::integral_constant<int, spacedim>::value> *const a = nullptr,
                               const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -469,7 +469,7 @@ namespace MatrixCreator
                               SparseMatrix<double>     &matrix,
                               const Function<spacedim> &rhs,
                               Vector<double>           &rhs_vector,
-                              const Function<spacedim> *const a = nullptr,
+                              const Function<std::integral_constant<int, spacedim>::value> *const a = nullptr,
                               const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -482,7 +482,7 @@ namespace MatrixCreator
                               SparseMatrix<double>     &matrix,
                               const Function<spacedim> &rhs,
                               Vector<double>           &rhs_vector,
-                              const Function<spacedim> *const a = nullptr,
+                              const Function<std::integral_constant<int, spacedim>::value> *const a = nullptr,
                               const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -494,7 +494,7 @@ namespace MatrixCreator
                               const hp::DoFHandler<dim,spacedim> &dof,
                               const hp::QCollection<dim>    &q,
                               SparseMatrix<double>     &matrix,
-                              const Function<spacedim> *const a = nullptr,
+                              const Function<std::integral_constant<int, spacedim>::value> *const a = nullptr,
                               const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -505,7 +505,7 @@ namespace MatrixCreator
   void create_laplace_matrix (const hp::DoFHandler<dim,spacedim> &dof,
                               const hp::QCollection<dim>    &q,
                               SparseMatrix<double>     &matrix,
-                              const Function<spacedim> *const a = nullptr,
+                              const Function<std::integral_constant<int, spacedim>::value> *const a = nullptr,
                               const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -519,7 +519,7 @@ namespace MatrixCreator
                               SparseMatrix<double>     &matrix,
                               const Function<spacedim>      &rhs,
                               Vector<double>           &rhs_vector,
-                              const Function<spacedim> *const a = nullptr,
+                              const Function<std::integral_constant<int, spacedim>::value> *const a = nullptr,
                               const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
@@ -532,7 +532,7 @@ namespace MatrixCreator
                               SparseMatrix<double>     &matrix,
                               const Function<spacedim>      &rhs,
                               Vector<double>           &rhs_vector,
-                              const Function<spacedim> *const a = nullptr,
+                              const Function<std::integral_constant<int, spacedim>::value> *const a = nullptr,
                               const ConstraintMatrix   &constraints = ConstraintMatrix());
 
   /**
index 7174673bc82e82664fce1c585d77a8a3cc5a51b4..419cbad0c65d2fb95d184973ef95500058a9bfd0 100644 (file)
@@ -104,9 +104,8 @@ check ()
                          rhs_function, rhs_ref);
   constraints.condense(matrix_ref, rhs_ref);
 
-  const Function<dim> *const dummy = nullptr;
   MatrixTools::create_laplace_matrix (mapping, dof, quadrature, matrix,
-                                      rhs_function, rhs, dummy, constraints);
+                                      rhs_function, rhs, nullptr, constraints);
 
   // compute reference: need to cancel constrained entries as these will in
   // general get different values
index 2faf7d23b7a1bf0b2bf43c38b7860441a6601749..e7710f6d30e382484465c54a021f58fd65d688c1 100644 (file)
@@ -108,9 +108,8 @@ check ()
                          rhs_function, rhs_ref);
   constraints.condense(matrix_ref, rhs_ref);
 
-  const Function<dim> *const dummy = nullptr;
   MatrixTools::create_laplace_matrix (mapping, dof, quadrature, matrix,
-                                      rhs_function, rhs, dummy, constraints);
+                                      rhs_function, rhs, nullptr, constraints);
 
   // compute reference: need to cancel constrained entries as these will in
   // general get different values
index a2b2de1c93a8a035f0922094e8fd0447e867f641..cac865044b4e859823f72dae8c73537411e4a2ae 100644 (file)
@@ -104,9 +104,8 @@ check ()
                          quadrature, matrix_ref);
   constraints.condense(matrix_ref);
 
-  const Function<dim> *const dummy = nullptr;
   MatrixTools::create_laplace_matrix (mapping, dof, quadrature, matrix,
-                                      dummy, constraints);
+                                      nullptr, constraints);
 
   // compute reference: need to cancel constrained entries as these will in
   // general get different values
index eb904bf6a68db9cd134ce9666ece562e508f521c..3fb936e83fe1dd8fe6f37cff91fe83507e97907d 100644 (file)
@@ -104,9 +104,8 @@ check ()
                       rhs_function, rhs_ref);
   constraints.condense(matrix_ref, rhs_ref);
 
-  const Function<dim> *const dummy = nullptr;
   MatrixTools::create_mass_matrix (mapping, dof, quadrature, matrix,
-                                   rhs_function, rhs, dummy, constraints);
+                                   rhs_function, rhs, nullptr, constraints);
 
   // compute reference: need to cancel constrained entries as these will in
   // general get different values
index 4063c2066464bd01cd06f68a3249f3898aebae3a..92140878a3b59606cbcd9f167711a87082a8f196 100644 (file)
@@ -108,9 +108,8 @@ check ()
                       rhs_function, rhs_ref);
   constraints.condense(matrix_ref, rhs_ref);
 
-  const Function<dim> *const dummy = nullptr;
   MatrixTools::create_mass_matrix (mapping, dof, quadrature, matrix,
-                                   rhs_function, rhs, dummy, constraints);
+                                   rhs_function, rhs, nullptr, constraints);
 
   // compute reference: need to cancel constrained entries as these will in
   // general get different values
index b9985b73c6bd7e1f4541cc1d2968edebeb87b798..385309be7163507fd4a1781f16d7fd3075348c02 100644 (file)
@@ -104,9 +104,8 @@ check ()
                       quadrature, matrix_ref);
   constraints.condense(matrix_ref);
 
-  const Function<dim> *const dummy = nullptr;
   MatrixTools::create_mass_matrix (mapping, dof, quadrature, matrix,
-                                   dummy, constraints);
+                                   nullptr, constraints);
 
   // compute reference: need to cancel constrained entries as these will in
   // general get different values

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.