From: bangerth Date: Wed, 20 Sep 2006 04:12:10 +0000 (+0000) Subject: Cache the subface matrices for the simple case. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f4c32ca3a4c4e499b30e22e96cd397709d5e917;p=dealii-svn.git Cache the subface matrices for the simple case. git-svn-id: https://svn.dealii.org/trunk@13932 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/dofs/dof_tools.cc b/deal.II/deal.II/source/dofs/dof_tools.cc index d6d7d778c0..091e7719ea 100644 --- a/deal.II/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/deal.II/source/dofs/dof_tools.cc @@ -1579,8 +1579,9 @@ namespace internal { if (matrix == 0) { - matrix = new FullMatrix (fe2.dofs_per_face, - fe1.dofs_per_face); + matrix = boost::shared_ptr > + (new FullMatrix (fe2.dofs_per_face, + fe1.dofs_per_face)); fe1.get_face_interpolation_matrix (fe2, *matrix); } @@ -1601,8 +1602,9 @@ namespace internal { if (matrix == 0) { - matrix = new FullMatrix (fe2.dofs_per_face, - fe1.dofs_per_face); + matrix = boost::shared_ptr > + (new FullMatrix (fe2.dofs_per_face, + fe1.dofs_per_face)); fe1.get_subface_interpolation_matrix (fe2, subface, *matrix); @@ -1631,6 +1633,31 @@ namespace internal { static const bool value = false; }; + + + /** + * A function that returns how + * many different finite + * elements a dof handler + * uses. This is one for non-hp + * DoFHandlers and + * dof_handler.get_fe().size() + * for the hp-versions. + */ + template + unsigned int + n_finite_elements (const ::hp::DoFHandler &dof_handler) + { + return dof_handler.get_fe().size(); + } + + + template + unsigned int + n_finite_elements (const DH &) + { + return 1; + } @@ -2156,7 +2183,21 @@ namespace internal std::vector dofs_on_mother; std::vector dofs_on_children; - FullMatrix constraint_matrix; + // caches for the face and + // subface interpolation + // matrices between different + // (or the same) finite + // elements. we compute them + // only once, namely the first + // time they are needed, and + // then just reuse them + Table<2,boost::shared_ptr > > + face_interpolation_matrices (n_finite_elements (dof_handler), + n_finite_elements (dof_handler)); + Table<3,boost::shared_ptr > > + subface_interpolation_matrices (n_finite_elements (dof_handler), + n_finite_elements (dof_handler), + GeometryInfo::subfaces_per_face); // loop over all faces; only on // face there can be constraints. @@ -2331,11 +2372,12 @@ namespace internal // properties of a // finite element onto // that mesh - constraint_matrix.reinit (n_dofs_on_children, - n_dofs_on_mother); - cell->get_fe() - .get_subface_interpolation_matrix (subface->get_fe(subface_fe_index), - c, constraint_matrix); + assert_existence_of_subface_matrix + (cell->get_fe(), + subface->get_fe(subface_fe_index), + c, + subface_interpolation_matrices + [cell->active_fe_index()][subface_fe_index][c]); // Add constraints to global constraint // matrix. @@ -2348,7 +2390,8 @@ namespace internal filter_constraints (dofs_on_mother, dofs_on_children, - constraint_matrix, + *(subface_interpolation_matrices + [cell->active_fe_index()][subface_fe_index][c]), constraints); }