From 1f44c4aff3f3845cf812c53b8d030c029c22a20f Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 29 Jun 2006 12:11:27 +0000 Subject: [PATCH] put these auxiliary functions into a reasonable place instead of duplicating them git-svn-id: https://svn.dealii.org/trunk@13311 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/dofs/dof_tools.h | 185 ++++++++++++++++++ .../include/numerics/vectors.templates.h | 10 +- deal.II/deal.II/source/dofs/dof_tools.cc | 95 --------- deal.II/deal.II/source/numerics/vectors.cc | 54 ----- 4 files changed, 190 insertions(+), 154 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_tools.h b/deal.II/deal.II/include/dofs/dof_tools.h index c264a55a95..6de8092e5c 100644 --- a/deal.II/deal.II/include/dofs/dof_tools.h +++ b/deal.II/deal.II/include/dofs/dof_tools.h @@ -196,6 +196,110 @@ class DoFTools */ nonzero }; + + /** + * @name Auxiliary functions + * @{ + */ + /** + * Maximal number of degrees of + * freedom on a cell. This is + * just + * FiniteElementData::dofs_per_cell, + * but allows for a common + * interface with hp::DoFHandler. + */ + template + static unsigned int + max_dofs_per_cell (const DoFHandler &dh); + + + /** + * Maximal number of degrees of + * freedom on a face. This is + * just + * FiniteElementData::dofs_per_face, + * but allows for a common + * interface with hp::DoFHandler. + */ + template + static unsigned int + max_dofs_per_face (const DoFHandler &dh); + + /** + * Maximal number of degrees of + * freedom on a vertex. This is + * just + * FiniteElementData::dofs_per_vertex, + * but allows for a common + * interface with hp::DoFHandler. + */ + template + static unsigned int + max_dofs_per_vertex (const DoFHandler &dh); + + /** + * Number of components in an + * hp-conforming way. + */ + template + static unsigned int + n_components (const DoFHandler &dh); + + /** + * Find out if a FiniteElement is + * primitive in an hp-conforming + * way. + */ + template + static unsigned int + fe_is_primitive (const DoFHandler &dh); + + /** + * Maximal number of degrees of + * freedom on a cell in an hp hierarchy. + */ + template + static unsigned int + max_dofs_per_cell (const hp::DoFHandler &dh); + + /** + * Maximal number of degrees of + * freedom on a face in an hp hierarchy. + */ + template + static unsigned int + max_dofs_per_face (const hp::DoFHandler &dh); + + /** + *Maximal number of degrees of + * freedom on a vertex in an hp hierarchy. + */ + template + static unsigned int + max_dofs_per_vertex (const hp::DoFHandler &dh); + + /** + * Number of components in an + * hp-conforming way. + */ + template + static unsigned int + n_components (const hp::DoFHandler &dh); + + /** + * Find out if an hp::FECollection is + * primitive in an hp-conforming + * way. + */ + template + static unsigned int + fe_is_primitive (const hp::DoFHandler &dh); + + /** + * @} + */ + /** * @name Sparsity Pattern Generation * @{ @@ -1644,6 +1748,87 @@ DoFTools::Coupling operator | (const DoFTools::Coupling c1, // ---------------------- inline and template functions -------------------- +template +inline unsigned int +DoFTools::max_dofs_per_cell (const DoFHandler &dh) +{ + return dh.get_fe().dofs_per_cell; +} + + +template +inline unsigned int +DoFTools::max_dofs_per_face (const DoFHandler &dh) +{ + return dh.get_fe().dofs_per_face; +} + + +template +inline unsigned int +DoFTools::max_dofs_per_vertex (const DoFHandler &dh) +{ + return dh.get_fe().dofs_per_vertex; +} + + +template +inline unsigned int +DoFTools::n_components (const DoFHandler &dh) +{ + return dh.get_fe().n_components(); +} + + + +template +inline unsigned int +DoFTools::fe_is_primitive (const DoFHandler &dh) +{ + return dh.get_fe().is_primitive(); +} + + +template +inline unsigned int +DoFTools::max_dofs_per_cell (const hp::DoFHandler &dh) +{ + return dh.get_fe().max_dofs_per_cell (); +} + + +template +inline unsigned int +DoFTools::max_dofs_per_face (const hp::DoFHandler &dh) +{ + return dh.get_fe().max_dofs_per_face (); +} + + +template +inline unsigned int +DoFTools::max_dofs_per_vertex (const hp::DoFHandler &dh) +{ + return dh.get_fe().max_dofs_per_vertex (); +} + + +template +inline unsigned int +DoFTools::n_components (const hp::DoFHandler &dh) +{ + return dh.get_fe()[0].n_components(); +} + + +template +inline unsigned int +DoFTools::fe_is_primitive (const hp::DoFHandler &dh) +{ + return dh.get_fe()[0].is_primitive(); +} + + template inline void diff --git a/deal.II/deal.II/include/numerics/vectors.templates.h b/deal.II/deal.II/include/numerics/vectors.templates.h index 67068eb5b8..33fdc7bca7 100644 --- a/deal.II/deal.II/include/numerics/vectors.templates.h +++ b/deal.II/deal.II/include/numerics/vectors.templates.h @@ -896,7 +896,7 @@ interpolate_boundary_values (const Mapping &mapping, Assert (function_map.find(255) == function_map.end(), ExcInvalidBoundaryIndicator()); - const unsigned int n_components = get_n_components(dof); + const unsigned int n_components = DoFTools::n_components(dof); const bool fe_is_system = (n_components != 1); for (typename FunctionMap::type::const_iterator i=function_map.begin(); @@ -915,11 +915,11 @@ interpolate_boundary_values (const Mapping &mapping, // field to store the indices std::vector face_dofs; - face_dofs.reserve (max_dofs_per_face(dof)); + face_dofs.reserve (DoFTools::max_dofs_per_face(dof)); std::fill (face_dofs.begin (), face_dofs.end (), DoFHandler::invalid_dof_index); std::vector > dof_locations; - dof_locations.reserve (max_dofs_per_face(dof)); + dof_locations.reserve (DoFTools::max_dofs_per_face(dof)); std::fill (dof_locations.begin(), dof_locations.end (), Point()); // array to store the values of @@ -930,8 +930,8 @@ interpolate_boundary_values (const Mapping &mapping, // respectively std::vector dof_values_scalar; std::vector > dof_values_system; - dof_values_scalar.reserve (max_dofs_per_face (dof)); - dof_values_system.reserve (max_dofs_per_face (dof)); + dof_values_scalar.reserve (DoFTools::max_dofs_per_face (dof)); + dof_values_system.reserve (DoFTools::max_dofs_per_face (dof)); typename DH::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); diff --git a/deal.II/deal.II/source/dofs/dof_tools.cc b/deal.II/deal.II/source/dofs/dof_tools.cc index 00a6d85ddf..7f2f251e39 100644 --- a/deal.II/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/deal.II/source/dofs/dof_tools.cc @@ -37,101 +37,6 @@ #include -namespace -{ - // Functions for the DoFHandler - template - unsigned int - max_dofs_per_cell (const DoFHandler &dh) - { - return dh.get_fe().dofs_per_cell; - } - - - - template - unsigned int - max_dofs_per_face (const DoFHandler &dh) - { - return dh.get_fe().dofs_per_face; - } - - - - template - unsigned int - max_dofs_per_vertex (const DoFHandler &dh) - { - return dh.get_fe().dofs_per_vertex; - } - - - - template - unsigned int - n_components (const DoFHandler &dh) - { - return dh.get_fe().n_components(); - } - - - - template - unsigned int - fe_is_primitive (const DoFHandler &dh) - { - return dh.get_fe().is_primitive(); - } - - // Functions for the hp::DoFHandler - template - unsigned int - max_dofs_per_cell (const hp::DoFHandler &dh) - { - return dh.get_fe().max_dofs_per_cell (); - } - - - - template - unsigned int - max_dofs_per_face (const hp::DoFHandler &dh) - { - return dh.get_fe().max_dofs_per_face (); - } - - - - template - unsigned int - max_dofs_per_vertex (const hp::DoFHandler &dh) - { - return dh.get_fe().max_dofs_per_vertex (); - } - - - - template - unsigned int - n_components (const hp::DoFHandler &dh) - { -//TODO:[?] Verify that this is really correct - return dh.get_fe()[0].n_components(); - } - - - - template - unsigned int - fe_is_primitive (const hp::DoFHandler &dh) - { -//TODO:[?] Verify that this is really correct - return dh.get_fe()[0].is_primitive(); - } -} - - - #if deal_II_dimension == 1 // Specialization for 1D diff --git a/deal.II/deal.II/source/numerics/vectors.cc b/deal.II/deal.II/source/numerics/vectors.cc index d5d5e6f3a3..0f3a57ab37 100644 --- a/deal.II/deal.II/source/numerics/vectors.cc +++ b/deal.II/deal.II/source/numerics/vectors.cc @@ -14,60 +14,6 @@ #include #include -namespace -{ - // Functions for the DoFHandler - template - unsigned int - max_dofs_per_cell (const DoFHandler &dh) - { - return dh.get_fe().dofs_per_cell; - } - - - template - unsigned int - max_dofs_per_face (const DoFHandler &dh) - { - return dh.get_fe().dofs_per_face; - } - - - template - unsigned int - get_n_components (const DoFHandler &dh) - { - return dh.get_fe().n_components(); - } - - - // Functions for the hp::DoFHandler - template - unsigned int - max_dofs_per_cell (const hp::DoFHandler &dh) - { - return dh.get_fe().max_dofs_per_cell (); - } - - - template - unsigned int - max_dofs_per_face (const hp::DoFHandler &dh) - { - return dh.get_fe().max_dofs_per_face (); - } - - - - template - unsigned int - get_n_components (const hp::DoFHandler &dh) - { - return dh.get_fe().n_components(); - } -} - - #include // explicit instantiations -- 2.39.5