From 63435c3c5a8c31c7b0365d2279a34660af149a53 Mon Sep 17 00:00:00 2001 From: kronbichler Date: Tue, 16 Nov 2010 13:50:47 +0000 Subject: [PATCH] Changed structure in dofs, hp, multigrid and numerics so that these directories are now dimension-independent. Some specializations for 1D could be removed by access to faces for 1D cells, but not all of them. The deal_II_dimension constant in .cc and .h files has been removed. git-svn-id: https://svn.dealii.org/trunk@22749 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/dofs/dof_tools.h | 11 - deal.II/include/deal.II/fe/fe_dgp.h | 4 - deal.II/include/deal.II/fe/fe_q.h | 3 - deal.II/include/deal.II/grid/grid_tools.h | 61 +- deal.II/include/deal.II/hp/dof_handler.h | 7 - .../deal.II/numerics/vectors.templates.h | 413 +++-- deal.II/source/Makefile | 4 +- ...k_info.all_dimensions.cc => block_info.cc} | 0 ...ssor.all_dimensions.cc => dof_accessor.cc} | 0 ...f_faces.all_dimensions.cc => dof_faces.cc} | 0 ...ndler.all_dimensions.cc => dof_handler.cc} | 0 deal.II/source/dofs/dof_handler_policy.cc | 22 +- .../source/dofs/dof_handler_policy.inst.in | 35 + ...levels.all_dimensions.cc => dof_levels.cc} | 0 ...jects.all_dimensions.cc => dof_objects.cc} | 0 deal.II/source/dofs/dof_renumbering.cc | 374 +--- deal.II/source/dofs/dof_renumbering.inst.in | 391 ++++ deal.II/source/dofs/dof_tools.cc | 1434 +-------------- deal.II/source/dofs/dof_tools.inst.in | 437 ++++- ...ache.all_dimensions.cc => number_cache.cc} | 0 deal.II/source/hp/dof_faces.cc | 12 +- deal.II/source/hp/dof_handler.cc | 111 +- deal.II/source/hp/dof_handler.inst.in | 24 + .../source/hp/dof_levels.all_dimensions.cc | 34 - deal.II/source/hp/dof_levels.cc | 16 +- ...jects.all_dimensions.cc => dof_objects.cc} | 0 deal.II/source/hp/fe_collection.cc | 21 +- deal.II/source/hp/fe_collection.inst.in | 24 + deal.II/source/hp/fe_values.cc | 139 +- deal.II/source/hp/fe_values.inst.in | 68 + deal.II/source/hp/mapping_collection.cc | 24 +- deal.II/source/hp/mapping_collection.inst.in | 26 + .../{mg_base.all_dimensions.cc => mg_base.cc} | 0 deal.II/source/multigrid/mg_dof_accessor.cc | 123 +- .../source/multigrid/mg_dof_accessor.inst.in | 140 ++ deal.II/source/multigrid/mg_dof_handler.cc | 119 +- .../source/multigrid/mg_dof_handler.inst.in | 125 ++ .../multigrid/mg_tools.all_dimensions.cc | 445 ----- deal.II/source/multigrid/mg_tools.cc | 589 +++++- deal.II/source/multigrid/mg_tools.inst.in | 110 ++ .../source/multigrid/mg_tools.pattern.in.h | 61 - deal.II/source/multigrid/mg_transfer_block.cc | 114 +- .../multigrid/mg_transfer_block.inst.in | 131 ++ .../source/multigrid/mg_transfer_component.cc | 81 +- .../multigrid/mg_transfer_component.inst.in | 97 + .../source/multigrid/mg_transfer_prebuilt.cc | 147 +- .../multigrid/mg_transfer_prebuilt.inst.in | 159 ++ ...ltigrid.all_dimensions.cc => multigrid.cc} | 2 + deal.II/source/numerics/data_out.inst.in | 4 +- deal.II/source/numerics/data_out_faces.cc | 7 +- .../source/numerics/data_out_faces.inst.in | 21 + deal.II/source/numerics/data_out_rotation.cc | 111 +- .../source/numerics/data_out_rotation.inst.in | 17 + deal.II/source/numerics/data_out_stack.cc | 20 +- .../source/numerics/data_out_stack.inst.in | 33 + deal.II/source/numerics/data_postprocessor.cc | 3 +- .../numerics/data_postprocessor.inst.in | 17 + .../numerics/derivative_approximation.cc | 307 +--- .../numerics/derivative_approximation.inst.in | 137 ++ deal.II/source/numerics/error_estimator.cc | 113 +- .../source/numerics/error_estimator.inst.in | 125 ++ .../source/numerics/fe_field_function.inst.in | 2 +- ...stogram.all_dimensions.cc => histogram.cc} | 0 .../numerics/matrices.all_dimensions.cc | 1179 ------------ deal.II/source/numerics/matrices.cc | 1618 ++++++++++++----- deal.II/source/numerics/matrices.inst.in | 450 +++++ ...orker.all_dimensions.cc => mesh_worker.cc} | 0 deal.II/source/numerics/mesh_worker_info.cc | 35 +- .../source/numerics/mesh_worker_info.inst.in | 48 + .../numerics/mesh_worker_vector_selector.cc | 6 - .../mesh_worker_vector_selector.inst.in | 17 +- deal.II/source/numerics/operator.inst.in | 2 +- .../source/numerics/point_value_history.cc | 4 +- .../numerics/point_value_history.inst.in | 9 +- deal.II/source/numerics/solution_transfer.cc | 41 +- .../source/numerics/solution_transfer.inst.in | 54 + .../numerics/time_dependent.all_dimensions.cc | 403 ---- deal.II/source/numerics/time_dependent.cc | 389 +++- .../source/numerics/time_dependent.inst.in | 23 + .../source/numerics/vectors.all_dimensions.cc | 47 - deal.II/source/numerics/vectors.cc | 447 +---- deal.II/source/numerics/vectors.inst.in | 422 ++++- 82 files changed, 5803 insertions(+), 6446 deletions(-) rename deal.II/source/dofs/{block_info.all_dimensions.cc => block_info.cc} (100%) rename deal.II/source/dofs/{dof_accessor.all_dimensions.cc => dof_accessor.cc} (100%) rename deal.II/source/dofs/{dof_faces.all_dimensions.cc => dof_faces.cc} (100%) rename deal.II/source/dofs/{dof_handler.all_dimensions.cc => dof_handler.cc} (100%) create mode 100644 deal.II/source/dofs/dof_handler_policy.inst.in rename deal.II/source/dofs/{dof_levels.all_dimensions.cc => dof_levels.cc} (100%) rename deal.II/source/dofs/{dof_objects.all_dimensions.cc => dof_objects.cc} (100%) create mode 100644 deal.II/source/dofs/dof_renumbering.inst.in rename deal.II/source/dofs/{number_cache.all_dimensions.cc => number_cache.cc} (100%) create mode 100644 deal.II/source/hp/dof_handler.inst.in delete mode 100644 deal.II/source/hp/dof_levels.all_dimensions.cc rename deal.II/source/hp/{dof_objects.all_dimensions.cc => dof_objects.cc} (100%) create mode 100644 deal.II/source/hp/fe_collection.inst.in create mode 100644 deal.II/source/hp/fe_values.inst.in create mode 100644 deal.II/source/hp/mapping_collection.inst.in rename deal.II/source/multigrid/{mg_base.all_dimensions.cc => mg_base.cc} (100%) create mode 100644 deal.II/source/multigrid/mg_dof_accessor.inst.in create mode 100644 deal.II/source/multigrid/mg_dof_handler.inst.in delete mode 100644 deal.II/source/multigrid/mg_tools.all_dimensions.cc create mode 100644 deal.II/source/multigrid/mg_tools.inst.in delete mode 100644 deal.II/source/multigrid/mg_tools.pattern.in.h create mode 100644 deal.II/source/multigrid/mg_transfer_block.inst.in create mode 100644 deal.II/source/multigrid/mg_transfer_component.inst.in create mode 100644 deal.II/source/multigrid/mg_transfer_prebuilt.inst.in rename deal.II/source/multigrid/{multigrid.all_dimensions.cc => multigrid.cc} (99%) create mode 100644 deal.II/source/numerics/data_out_faces.inst.in create mode 100644 deal.II/source/numerics/data_out_rotation.inst.in create mode 100644 deal.II/source/numerics/data_out_stack.inst.in create mode 100644 deal.II/source/numerics/data_postprocessor.inst.in create mode 100644 deal.II/source/numerics/derivative_approximation.inst.in create mode 100644 deal.II/source/numerics/error_estimator.inst.in rename deal.II/source/numerics/{histogram.all_dimensions.cc => histogram.cc} (100%) delete mode 100644 deal.II/source/numerics/matrices.all_dimensions.cc create mode 100644 deal.II/source/numerics/matrices.inst.in rename deal.II/source/numerics/{mesh_worker.all_dimensions.cc => mesh_worker.cc} (100%) create mode 100644 deal.II/source/numerics/mesh_worker_info.inst.in create mode 100644 deal.II/source/numerics/solution_transfer.inst.in delete mode 100644 deal.II/source/numerics/time_dependent.all_dimensions.cc create mode 100644 deal.II/source/numerics/time_dependent.inst.in delete mode 100644 deal.II/source/numerics/vectors.all_dimensions.cc diff --git a/deal.II/include/deal.II/dofs/dof_tools.h b/deal.II/include/deal.II/dofs/dof_tools.h index bfc15afb6c..39f8fde9ed 100644 --- a/deal.II/include/deal.II/dofs/dof_tools.h +++ b/deal.II/include/deal.II/dofs/dof_tools.h @@ -2132,17 +2132,6 @@ class DoFTools -/* ------------------------- explicit specializations -------------- */ - -#ifndef DOXYGEN - -template <> -void -DoFTools::map_dof_to_boundary_indices (const DoFHandler<1,1> &dof_handler, - std::vector &mapping); - -#endif - /* ------------------------- inline functions -------------- */ diff --git a/deal.II/include/deal.II/fe/fe_dgp.h b/deal.II/include/deal.II/fe/fe_dgp.h index cba751c274..fb1b378d2d 100644 --- a/deal.II/include/deal.II/fe/fe_dgp.h +++ b/deal.II/include/deal.II/fe/fe_dgp.h @@ -378,7 +378,6 @@ template <> const unsigned int FE_DGP<3>::Matrices::n_projection_matrices; //codimension 1 -#if deal_II_dimension != 3 template <> const double * const FE_DGP<1,2>::Matrices::projection_matrices[][GeometryInfo<1>::max_children_per_cell]; @@ -391,9 +390,6 @@ const double * const FE_DGP<2,3>::Matrices::projection_matrices[][GeometryInfo<2 template <> const unsigned int FE_DGP<2,3>::Matrices::n_projection_matrices; -#endif - - #endif #endif // DOXYGEN diff --git a/deal.II/include/deal.II/fe/fe_q.h b/deal.II/include/deal.II/fe/fe_q.h index 0903af3dd6..e88f9682ac 100644 --- a/deal.II/include/deal.II/fe/fe_q.h +++ b/deal.II/include/deal.II/fe/fe_q.h @@ -599,8 +599,6 @@ std::vector FE_Q<1>::face_lexicographic_to_hierarchic_numbering (const unsigned int); -#if deal_II_dimension != 3 - template <> void FE_Q<1,2>::initialize_unit_face_support_points (); @@ -608,7 +606,6 @@ template <> std::vector FE_Q<1,2>::face_lexicographic_to_hierarchic_numbering (const unsigned int); -#endif DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/include/deal.II/grid/grid_tools.h b/deal.II/include/deal.II/grid/grid_tools.h index 15237f9475..475fe7e471 100644 --- a/deal.II/include/deal.II/grid/grid_tools.h +++ b/deal.II/include/deal.II/grid/grid_tools.h @@ -930,67 +930,54 @@ GridTools::get_active_child_cells (const typename DH::cell_iterator& cell) -#if deal_II_dimension == 1 - template void GridTools::get_active_neighbors(const typename Container::active_cell_iterator &cell, std::vector &active_neighbors) { active_neighbors.clear (); - for (unsigned int n=0; n::faces_per_cell; ++n) + for (unsigned int n=0; n::faces_per_cell; ++n) if (! cell->at_boundary(n)) { + if (Container::dimension == 1) + { // check children of neighbor. note // that in 1d children of the neighbor // may be further refined. In 1d the // case is simple since we know what // children bound to the present cell - typename Container::cell_iterator - neighbor_child = cell->neighbor(n); - if (!neighbor_child->active()) - { - while (neighbor_child->has_children()) - neighbor_child = neighbor_child->child (n==0 ? 1 : 0); - - Assert (neighbor_child->neighbor(n==0 ? 1 : 0)==cell, - ExcInternalError()); + typename Container::cell_iterator + neighbor_child = cell->neighbor(n); + if (!neighbor_child->active()) + { + while (neighbor_child->has_children()) + neighbor_child = neighbor_child->child (n==0 ? 1 : 0); + + Assert (neighbor_child->neighbor(n==0 ? 1 : 0)==cell, + ExcInternalError()); + } + active_neighbors.push_back (neighbor_child); } - active_neighbors.push_back (neighbor_child); - } -} - -#else - -template -void -GridTools::get_active_neighbors(const typename Container::active_cell_iterator &cell, - std::vector &active_neighbors) -{ - active_neighbors.clear (); - for (unsigned int n=0; n::faces_per_cell; ++n) - if (! cell->at_boundary(n)) - { - if (cell->face(n)->has_children()) + else + { + if (cell->face(n)->has_children()) // this neighbor has children. find // out which border to the present // cell - for (unsigned int c=0; cface(n)->number_of_children(); ++c) - active_neighbors.push_back (cell->neighbor_child_on_subface(n,c)); - else - { + for (unsigned int c=0; cface(n)->number_of_children(); ++c) + active_neighbors.push_back (cell->neighbor_child_on_subface(n,c)); + else + { // the neighbor must be active // himself - Assert(cell->neighbor(n)->active(), ExcInternalError()); - active_neighbors.push_back(cell->neighbor(n)); + Assert(cell->neighbor(n)->active(), ExcInternalError()); + active_neighbors.push_back(cell->neighbor(n)); + } } } } -#endif - - // declaration of explicit specializations diff --git a/deal.II/include/deal.II/hp/dof_handler.h b/deal.II/include/deal.II/hp/dof_handler.h index b4264ae56e..8cbb832750 100644 --- a/deal.II/include/deal.II/hp/dof_handler.h +++ b/deal.II/include/deal.II/hp/dof_handler.h @@ -1311,15 +1311,8 @@ namespace hp - -/* -------------- declaration of explicit specializations ------------- */ - #ifndef DOXYGEN - template <> unsigned int DoFHandler<1>::n_boundary_dofs () const; - template <> unsigned int DoFHandler<1>::n_boundary_dofs (const FunctionMap &) const; - template <> unsigned int DoFHandler<1>::n_boundary_dofs (const std::set &) const; - /* ----------------------- Inline functions ---------------------------------- */ diff --git a/deal.II/include/deal.II/numerics/vectors.templates.h b/deal.II/include/deal.II/numerics/vectors.templates.h index b27f75adf4..6e2dabbf90 100644 --- a/deal.II/include/deal.II/numerics/vectors.templates.h +++ b/deal.II/include/deal.II/numerics/vectors.templates.h @@ -30,18 +30,19 @@ #include #include #include +#include #include -#include -#include #include +#include #include #include #include #include #include #include -#include #include +#include +#include #include #include #include @@ -318,12 +319,9 @@ namespace internal { namespace VectorTools { -#if deal_II_dimension == 1 - - template void - interpolate_zero_boundary_values (const dealii::DoFHandler &dof_handler, - std::map &boundary_values) + interpolate_zero_boundary_values (const dealii::DoFHandler<1> &dof_handler, + std::map &boundary_values) { // we only need to find the // left-most and right-most @@ -331,7 +329,7 @@ namespace internal // dof indices. that's easy :-) for (unsigned direction=0; direction<2; ++direction) { - typename dealii::DoFHandler::cell_iterator + typename dealii::DoFHandler<1>::cell_iterator cell = dof_handler.begin(0); while (!cell->at_boundary(direction)) cell = cell->neighbor(direction); @@ -342,10 +340,11 @@ namespace internal } -//codimension 1 + + // codimension 1 void - interpolate_zero_boundary_values (const dealii::DoFHandler<1,2> &dof_handler, - std::map &boundary_values) + interpolate_zero_boundary_values (const dealii::DoFHandler<1,2> &dof_handler, + std::map &boundary_values) { // we only need to find the // left-most and right-most @@ -364,7 +363,6 @@ namespace internal } -#else template void @@ -412,8 +410,6 @@ namespace internal boundary_values[face_dof_indices[i]] = 0.; } } - -#endif } } @@ -897,7 +893,6 @@ void VectorTools::create_point_source_vector (const hp::DoFHandler } -#if deal_II_dimension != 1 template void @@ -908,6 +903,12 @@ VectorTools::create_boundary_right_hand_side (const Mapping Vector &rhs_vector, const std::set &boundary_indicators) { + if (dim == 1) + { + Assert (false, ExcImpossibleInDim(dim)); + return; + } + const FiniteElement &fe = dof_handler.get_fe(); Assert (fe.n_components() == rhs_function.n_components, ExcDimensionMismatch(fe.n_components(), rhs_function.n_components)); @@ -1018,22 +1019,7 @@ VectorTools::create_boundary_right_hand_side (const Mapping } } -#else - -// Implementation for 1D -template -void -VectorTools::create_boundary_right_hand_side (const Mapping &, - const DoFHandler &, - const Quadrature &, - const Function &, - Vector &, - const std::set &) -{ - Assert (false, ExcImpossibleInDim(dim)); -} -#endif template void @@ -1053,7 +1039,33 @@ VectorTools::create_boundary_right_hand_side (const DoFHandler & -#if deal_II_dimension != 1 +template <> +void +VectorTools::create_boundary_right_hand_side (const hp::MappingCollection<1,1> &mapping, + const hp::DoFHandler<1,1> &dof_handler, + const hp::QCollection<0> &quadrature, + const Function<1> &rhs_function, + Vector &rhs_vector, + const std::set &boundary_indicators) +{ + Assert (false, ExcImpossibleInDim(1)); +} + + + +template <> +void +VectorTools::create_boundary_right_hand_side (const hp::MappingCollection<1,2> &mapping, + const hp::DoFHandler<1,2> &dof_handler, + const hp::QCollection<0> &quadrature, + const Function<2> &rhs_function, + Vector &rhs_vector, + const std::set &boundary_indicators) +{ + Assert (false, ExcImpossibleInDim(1)); +} + + template void @@ -1185,22 +1197,7 @@ VectorTools::create_boundary_right_hand_side (const hp::MappingCollection -void -VectorTools::create_boundary_right_hand_side (const hp::MappingCollection &, - const hp::DoFHandler &, - const hp::QCollection &, - const Function &, - Vector &, - const std::set &) -{ - Assert (false, ExcImpossibleInDim(1)); -} -#endif template void @@ -1221,37 +1218,42 @@ VectorTools::create_boundary_right_hand_side (const hp::DoFHandler // ----------- interpolate_boundary_values for std::map -------------------- -#if deal_II_dimension == 1 - -//TODO[?] Actually the Mapping object should be a MappingCollection object for the -// hp::DoFHandler. - -//template class DH, int spacedim> - -template -void -VectorTools::interpolate_boundary_values (const Mapping &, - const DH &dof, - const unsigned char boundary_component, - const Function &boundary_function, - std::map &boundary_values, - const std::vector &component_mask_) +// TODO: it might be possible to avoid the specialization for 1D if we could +// have hp::FEFaceValues<1>... +namespace internal { - //ConstraintMatrix boundary_constraints(); - // interpolate_boundary_values (dof, boundary_component, boundary_function, - // boundary_constraints, component_mask); + namespace VectorTools + { + template + static inline + void interpolate_boundary_values (const Mapping &mapping, + const DH &dof, + const typename FunctionMap::type &function_map, + std::map &boundary_values, + const std::vector &component_mask_, + const internal::int2type<1>) + { + const unsigned int dim = DH::dimension; + const unsigned int spacedim=DH::space_dimension; - const unsigned int dim=DH::dimension; - const unsigned int spacedim=DH::space_dimension; + Assert ((component_mask_.size() == 0) || + (component_mask_.size() == dof.get_fe().n_components()), + ExcMessage ("The number of components in the mask has to be either " + "zero or equal to the number of components in the finite " + "element.")); - Assert (boundary_component != 255, - ExcInvalidBoundaryIndicator()); - Assert ((component_mask_.size() == 0) || - (component_mask_.size() == dof.get_fe().n_components()), - ExcMessage ("The number of components in the mask has to be either " - "zero or equal to the number of components in the finite " - "element.")); + // if for whatever reason we were + // passed an empty map, return + // immediately + if (function_map.size() == 0) + return; + Assert (function_map.find(255) == function_map.end(), + dealii::VectorTools::ExcInvalidBoundaryIndicator()); + + for (typename FunctionMap::type::const_iterator i=function_map.begin(); + i!=function_map.end(); ++i) + { // check whether boundary values at // the left or right boundary of // the line are @@ -1260,34 +1262,37 @@ VectorTools::interpolate_boundary_values (const Mappingfirst; + Assert (direction < 2, + dealii::VectorTools::ExcInvalidBoundaryIndicator()); + + const Function & boundary_function = *(i->second); // first find the outermost active // cell by first traversing the coarse // grid to its end and then going // to the children - typename DH::cell_iterator outermost_cell = dof.begin(0); - while (outermost_cell->neighbor(direction).state() == IteratorState::valid) - outermost_cell = outermost_cell->neighbor(direction); + typename DH::cell_iterator outermost_cell = dof.begin(0); + while (outermost_cell->neighbor(direction).state() == IteratorState::valid) + outermost_cell = outermost_cell->neighbor(direction); - while (outermost_cell->has_children()) - outermost_cell = outermost_cell->child(direction); + while (outermost_cell->has_children()) + outermost_cell = outermost_cell->child(direction); // get the FE corresponding to this // cell - const FiniteElement &fe = outermost_cell->get_fe(); - Assert (fe.n_components() == boundary_function.n_components, - ExcDimensionMismatch(fe.n_components(), boundary_function.n_components)); + const FiniteElement &fe = outermost_cell->get_fe(); + Assert (fe.n_components() == boundary_function.n_components, + ExcDimensionMismatch(fe.n_components(), boundary_function.n_components)); // set the component mask to either // the original value or a vector // of trues - const std::vector component_mask ((component_mask_.size() == 0) ? - std::vector (fe.n_components(), true) : - component_mask_); - Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0, - ExcNoComponentSelected()); + const std::vector component_mask ((component_mask_.size() == 0) ? + std::vector (fe.n_components(), true) : + component_mask_); + Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0, + dealii::VectorTools::ExcNoComponentSelected()); // now set the value of the // outermost degree of @@ -1300,100 +1305,77 @@ VectorTools::interpolate_boundary_values (const Mapping function_values (fe.n_components()); - if (fe.n_components() == 1) - function_values(0) - = boundary_function.value (outermost_cell->vertex(direction)); - else - boundary_function.vector_value (outermost_cell->vertex(direction), - function_values); - - for (unsigned int i=0; i - vertex_dof_index(direction,i, - outermost_cell->active_fe_index())] - = function_values(fe.face_system_to_component_index(i).first); -} - - -//TODO[?] Actually the Mapping object should be a MappingCollection object for the -// hp::DoFHandler. - -// Implementation for 1D -template -void -VectorTools::interpolate_boundary_values (const Mapping &mapping, - const DH &dof, - const typename FunctionMap::type &function_map, - std::map &boundary_values, - const std::vector &component_mask) -{ - for (typename FunctionMap::type::const_iterator i=function_map.begin(); - i!=function_map.end(); ++i) - interpolate_boundary_values (mapping, dof, i->first, *i->second, - boundary_values, component_mask); -} - - -//TODO[?] Actually the Mapping object should be a MappingCollection object for the -// hp::DoFHandler. - + dealii::Vector function_values (fe.n_components()); + if (fe.n_components() == 1) + function_values(0) + = boundary_function.value (outermost_cell->vertex(direction)); + else + boundary_function.vector_value (outermost_cell->vertex(direction), + function_values); + + for (unsigned int i=0; i + vertex_dof_index(direction,i, + outermost_cell->active_fe_index())] + = function_values(fe.face_system_to_component_index(i).first); + } + } -#else -template -void -VectorTools:: -interpolate_boundary_values (const Mapping &mapping, - const DH &dof, - const typename FunctionMap::type &function_map, - std::map &boundary_values, - const std::vector &component_mask_) -{ - const unsigned int dim=DH::dimension; - const unsigned int spacedim=DH::space_dimension; + template + static inline + void + interpolate_boundary_values (const Mapping &mapping, + const DH &dof, + const typename FunctionMap::type &function_map, + std::map &boundary_values, + const std::vector &component_mask_, + const internal::int2type) + { + const unsigned int dim = DH::dimension; + const unsigned int spacedim=DH::space_dimension; - Assert ((component_mask_.size() == 0) || - (component_mask_.size() == dof.get_fe().n_components()), - ExcMessage ("The number of components in the mask has to be either " - "zero or equal to the number of components in the finite " - "element.")); + Assert ((component_mask_.size() == 0) || + (component_mask_.size() == dof.get_fe().n_components()), + ExcMessage ("The number of components in the mask has to be either " + "zero or equal to the number of components in the finite " + "element.")); // if for whatever reason we were // passed an empty map, return // immediately - if (function_map.size() == 0) - return; + if (function_map.size() == 0) + return; - Assert (function_map.find(255) == function_map.end(), - ExcInvalidBoundaryIndicator()); + Assert (function_map.find(255) == function_map.end(), + dealii::VectorTools::ExcInvalidBoundaryIndicator()); - const unsigned int n_components = DoFTools::n_components(dof); - const bool fe_is_system = (n_components != 1); + 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(); - i!=function_map.end(); ++i) - Assert (n_components == i->second->n_components, - ExcDimensionMismatch(n_components, i->second->n_components)); + for (typename FunctionMap::type::const_iterator i=function_map.begin(); + i!=function_map.end(); ++i) + Assert (n_components == i->second->n_components, + ExcDimensionMismatch(n_components, i->second->n_components)); // set the component mask to either // the original value or a vector // of trues - const std::vector component_mask ((component_mask_.size() == 0) ? - std::vector (n_components, true) : - component_mask_); - Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0, - ExcNoComponentSelected()); + const std::vector component_mask ((component_mask_.size() == 0) ? + std::vector (n_components, true) : + component_mask_); + Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0, + dealii::VectorTools::ExcNoComponentSelected()); // field to store the indices - std::vector face_dofs; - face_dofs.reserve (DoFTools::max_dofs_per_face(dof)); + std::vector face_dofs; + face_dofs.reserve (DoFTools::max_dofs_per_face(dof)); - std::vector > dof_locations; - dof_locations.reserve (DoFTools::max_dofs_per_face(dof)); + std::vector > dof_locations; + dof_locations.reserve (DoFTools::max_dofs_per_face(dof)); // array to store the values of // the boundary function at the @@ -1401,10 +1383,10 @@ interpolate_boundary_values (const Mapping // for scalar and vector functions // to use the more efficient one // respectively - std::vector dof_values_scalar; - std::vector > dof_values_system; - dof_values_scalar.reserve (DoFTools::max_dofs_per_face (dof)); - dof_values_system.reserve (DoFTools::max_dofs_per_face (dof)); + std::vector dof_values_scalar; + std::vector > dof_values_system; + dof_values_scalar.reserve (DoFTools::max_dofs_per_face (dof)); + dof_values_system.reserve (DoFTools::max_dofs_per_face (dof)); // before we start with the loop // over all cells create an @@ -1412,11 +1394,11 @@ interpolate_boundary_values (const Mapping // the interpolation points of all // finite elements that may ever be // in use - hp::FECollection finite_elements (dof.get_fe()); - hp::QCollection q_collection; - for (unsigned int f=0; f &fe = finite_elements[f]; + dealii::hp::FECollection finite_elements (dof.get_fe()); + dealii::hp::QCollection q_collection; + for (unsigned int f=0; f &fe = finite_elements[f]; // generate a quadrature rule // on the face from the unit @@ -1428,9 +1410,9 @@ interpolate_boundary_values (const Mapping // to do this, we check whether // the FE has support points on // the face at all: - if (fe.has_face_support_points()) - q_collection.push_back (Quadrature(fe.get_unit_face_support_points())); - else + if (fe.has_face_support_points()) + q_collection.push_back (Quadrature(fe.get_unit_face_support_points())); + else { // if not, then we should // try a more clever @@ -1477,23 +1459,23 @@ interpolate_boundary_values (const Mapping q_collection.push_back (Quadrature(unit_support_points)); } - } + } // now that we have a q_collection // object with all the right // quadrature points, create an // hp::FEFaceValues object that we // can use to evaluate the boundary // values at - hp::MappingCollection mapping_collection (mapping); - hp::FEFaceValues x_fe_values (mapping_collection, finite_elements, q_collection, - update_quadrature_points); + dealii::hp::MappingCollection mapping_collection (mapping); + dealii::hp::FEFaceValues x_fe_values (mapping_collection, finite_elements, q_collection, + update_quadrature_points); - typename DH::active_cell_iterator cell = dof.begin_active(), - endc = dof.end(); - for (; cell!=endc; ++cell) - if (!cell->is_artificial()) - for (unsigned int face_no = 0; face_no < GeometryInfo::faces_per_cell; - ++face_no) + typename DH::active_cell_iterator cell = dof.begin_active(), + endc = dof.end(); + for (; cell!=endc; ++cell) + if (!cell->is_artificial()) + for (unsigned int face_no = 0; face_no < GeometryInfo::faces_per_cell; + ++face_no) { const FiniteElement &fe = cell->get_fe(); @@ -1522,12 +1504,17 @@ interpolate_boundary_values (const Mapping } typename DH::face_iterator face = cell->face(face_no); + + // cast the face iterator to a DoFHandler + // iterator so that we can access the boundary + // indicators const unsigned char boundary_component = face->boundary_indicator(); if (function_map.find(boundary_component) != function_map.end()) { // face is of the right component x_fe_values.reinit(cell, face_no); - const FEFaceValues &fe_values = x_fe_values.get_present_fe_values(); + const dealii::FEFaceValues &fe_values = + x_fe_values.get_present_fe_values(); // get indices, physical location and // boundary values of dofs on this @@ -1547,7 +1534,7 @@ interpolate_boundary_values (const Mapping // possible if (dof_values_system.size() < fe.dofs_per_face) dof_values_system.resize (fe.dofs_per_face, - Vector(fe.n_components())); + dealii::Vector(fe.n_components())); else dof_values_system.resize (fe.dofs_per_face); @@ -1683,6 +1670,25 @@ interpolate_boundary_values (const Mapping } } } + } // end of interpolate_boundary_values + } // end of namespace VectorTools +} // end of namespace internal + + + +template +void +VectorTools:: +interpolate_boundary_values (const Mapping &mapping, + const DH &dof, + const typename FunctionMap::type &function_map, + std::map &boundary_values, + const std::vector &component_mask_) +{ + dealii::internal::VectorTools:: + interpolate_boundary_values (mapping, dof, function_map, boundary_values, + component_mask_, + dealii::internal::int2type()); } @@ -1702,7 +1708,6 @@ VectorTools::interpolate_boundary_values (const Mapping @@ -1824,37 +1829,25 @@ VectorTools::interpolate_boundary_values // -------- implementation for project_boundary_values with std::map -------- -#if deal_II_dimension == 1 - -// Implementation for 1D template void VectorTools::project_boundary_values (const Mapping &mapping, const DoFHandler &dof, const typename FunctionMap::type &boundary_functions, - const Quadrature &, + const Quadrature &q, std::map &boundary_values, std::vector component_mapping) { - Assert (component_mapping.size() == 0, ExcNotImplemented()); + if (dim == 1) + { + Assert (component_mapping.size() == 0, ExcNotImplemented()); // projection in 1d is equivalent // to interpolation - interpolate_boundary_values (mapping, dof, boundary_functions, - boundary_values, std::vector()); -} - -#else - + interpolate_boundary_values (mapping, dof, boundary_functions, + boundary_values, std::vector()); + return; + } -template -void -VectorTools::project_boundary_values (const Mapping &mapping, - const DoFHandler &dof, - const typename FunctionMap::type &boundary_functions, - const Quadrature &q, - std::map &boundary_values, - std::vector component_mapping) -{ //TODO:[?] In VectorTools::project_boundary_values, no condensation of sparsity // structures, matrices and right hand sides or distribution of // solution vectors is performed. This is ok for dim<3 because then @@ -2010,7 +2003,7 @@ VectorTools::project_boundary_values (const Mapping &mappin } } -#endif + template void diff --git a/deal.II/source/Makefile b/deal.II/source/Makefile index 7b93b2f61f..4d1666e8f1 100644 --- a/deal.II/source/Makefile +++ b/deal.II/source/Makefile @@ -16,8 +16,8 @@ default all: debug optimized # list the dimension dependent and dimension independent directories -dim-dep-dirs := dofs hp multigrid numerics -dim-indep-dirs := base lac fe grid distributed +dim-dep-dirs := +dim-indep-dirs := base lac dofs fe grid hp numerics multigrid distributed all-dirs := $(dim-dep-dirs) $(dim-indep-dirs) # create lists of file names. diff --git a/deal.II/source/dofs/block_info.all_dimensions.cc b/deal.II/source/dofs/block_info.cc similarity index 100% rename from deal.II/source/dofs/block_info.all_dimensions.cc rename to deal.II/source/dofs/block_info.cc diff --git a/deal.II/source/dofs/dof_accessor.all_dimensions.cc b/deal.II/source/dofs/dof_accessor.cc similarity index 100% rename from deal.II/source/dofs/dof_accessor.all_dimensions.cc rename to deal.II/source/dofs/dof_accessor.cc diff --git a/deal.II/source/dofs/dof_faces.all_dimensions.cc b/deal.II/source/dofs/dof_faces.cc similarity index 100% rename from deal.II/source/dofs/dof_faces.all_dimensions.cc rename to deal.II/source/dofs/dof_faces.cc diff --git a/deal.II/source/dofs/dof_handler.all_dimensions.cc b/deal.II/source/dofs/dof_handler.cc similarity index 100% rename from deal.II/source/dofs/dof_handler.all_dimensions.cc rename to deal.II/source/dofs/dof_handler.cc diff --git a/deal.II/source/dofs/dof_handler_policy.cc b/deal.II/source/dofs/dof_handler_policy.cc index 62d175ebae..9e151df839 100644 --- a/deal.II/source/dofs/dof_handler_policy.cc +++ b/deal.II/source/dofs/dof_handler_policy.cc @@ -1312,7 +1312,7 @@ namespace internal Assert (false, ExcNotImplemented()); #else - + //calculate new IndexSet. First try //to find out if the new indices are //contiguous blocks. This avoids @@ -1566,25 +1566,7 @@ namespace internal /*-------------- Explicit Instantiations -------------------------------*/ - -namespace internal -{ - namespace DoFHandler - { - namespace Policy - { - template class PolicyBase; - template class Sequential; - template class ParallelDistributed; - -#if deal_II_dimension==1 || deal_II_dimension==2 - template class PolicyBase; - template class Sequential; - template class ParallelDistributed; -#endif - } - } -} +#include "dof_handler_policy.inst" DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/dofs/dof_handler_policy.inst.in b/deal.II/source/dofs/dof_handler_policy.inst.in new file mode 100644 index 0000000000..0daab4203e --- /dev/null +++ b/deal.II/source/dofs/dof_handler_policy.inst.in @@ -0,0 +1,35 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ +namespace internal +\{ + namespace DoFHandler + \{ + namespace Policy + \{ + template class PolicyBase; + template class Sequential; + template class ParallelDistributed; + +#if deal_II_dimension==1 || deal_II_dimension==2 + template class PolicyBase; + template class Sequential; + template class ParallelDistributed; +#endif + \} + \} +\} + +} diff --git a/deal.II/source/dofs/dof_levels.all_dimensions.cc b/deal.II/source/dofs/dof_levels.cc similarity index 100% rename from deal.II/source/dofs/dof_levels.all_dimensions.cc rename to deal.II/source/dofs/dof_levels.cc diff --git a/deal.II/source/dofs/dof_objects.all_dimensions.cc b/deal.II/source/dofs/dof_objects.cc similarity index 100% rename from deal.II/source/dofs/dof_objects.all_dimensions.cc rename to deal.II/source/dofs/dof_objects.cc diff --git a/deal.II/source/dofs/dof_renumbering.cc b/deal.II/source/dofs/dof_renumbering.cc index 5807a0a67a..e2deeffe93 100644 --- a/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/source/dofs/dof_renumbering.cc @@ -1724,380 +1724,12 @@ namespace DoFRenumbering ExcInternalError()); } +} // namespace DoFRenumbering -// explicit instantiations - namespace boost - { -//TODO[WB]: also implement the following boost for hp DoFHandlers etc. - template - void - Cuthill_McKee (DoFHandler &, bool, bool); - - template - void - compute_Cuthill_McKee (std::vector &, - const DoFHandler &, bool, bool); - - template - void - king_ordering (DoFHandler &, bool, bool); - - template - void - compute_king_ordering (std::vector &, - const DoFHandler &, bool, bool); - - template - void - minimum_degree (DoFHandler &, bool, bool); - - template - void - compute_minimum_degree (std::vector &, - const DoFHandler &, bool, bool); - - - template - void - Cuthill_McKee (hp::DoFHandler &, bool, bool); - - template - void - compute_Cuthill_McKee (std::vector &, - const hp::DoFHandler &, bool, bool); - - template - void - king_ordering (hp::DoFHandler &, bool, bool); - - template - void - compute_king_ordering (std::vector &, - const hp::DoFHandler &, bool, bool); - - template - void - minimum_degree (hp::DoFHandler &, bool, bool); - - template - void - compute_minimum_degree (std::vector &, - const hp::DoFHandler &, bool, bool); - } - - -// non-boost functions: +/*-------------- Explicit Instantiations -------------------------------*/ +#include "dof_renumbering.inst" - template - void Cuthill_McKee > - (DoFHandler&, - const bool, - const bool, - const std::vector&); - - template - void - compute_Cuthill_McKee > - (std::vector&, - const DoFHandler&, - const bool, - const bool, - const std::vector&); - - - template - void Cuthill_McKee > - (hp::DoFHandler&, - const bool, - const bool, - const std::vector&); - - template - void - compute_Cuthill_McKee > - (std::vector&, - const hp::DoFHandler&, - const bool, - const bool, - const std::vector&); - - template - void Cuthill_McKee > - (MGDoFHandler&, - const bool, - const bool, - const std::vector&); - - template - void - compute_Cuthill_McKee > - (std::vector&, - const MGDoFHandler&, - const bool, - const bool, - const std::vector&); - - template - void component_wise - (DoFHandler&, - const std::vector&); - - template - void component_wise - (hp::DoFHandler&, - const std::vector&); - -// template -// void -// compute_component_wise -// (std::vector&, -// const DoFHandler&, -// const std::vector&); - - template - void component_wise - (MGDoFHandler&, - unsigned int, - const std::vector&); - - template - void component_wise - (MGDoFHandler&, - const std::vector&); - -// DG renumbering for DoFHandler - - template - void - cell_wise_dg > - (DoFHandler&, - const std::vector::cell_iterator>&); - - template - void - compute_cell_wise_dg > - (std::vector&, std::vector&, - const DoFHandler&, - const std::vector::cell_iterator>&); - - template - void - downstream_dg > - (DoFHandler&, - const Point&); - - template - void - compute_downstream_dg > - (std::vector&,std::vector&, - const DoFHandler&, - const Point&); - template - void - compute_downstream_dg > - (std::vector&, - const DoFHandler&, - const Point&); - - template void - cell_wise > - (DoFHandler&, - const std::vector::cell_iterator>&); - - template void - compute_cell_wise > - (std::vector&, std::vector&, - const DoFHandler&, - const std::vector::cell_iterator>&); - - template void - downstream > - (DoFHandler&, const Point&, - const bool); - - template void - compute_downstream > - (std::vector&,std::vector&, - const DoFHandler&, const Point&, - const bool); - - template - void - clockwise_dg > - (DoFHandler&, const Point&, bool); - - template - void - compute_clockwise_dg > - (std::vector&, const DoFHandler&, - const Point&, const bool); - -// Renumbering for hp::DoFHandler - - template void - cell_wise_dg > - (hp::DoFHandler&, - const std::vector::cell_iterator>&); - - template void - compute_cell_wise_dg > - (std::vector&, std::vector&, - const hp::DoFHandler&, - const std::vector::cell_iterator>&); - - template void - cell_wise > - (hp::DoFHandler&, - const std::vector::cell_iterator>&); - - template void - compute_cell_wise > - (std::vector&, std::vector&, - const hp::DoFHandler&, - const std::vector::cell_iterator>&); - - template void - downstream_dg > - (hp::DoFHandler&, - const Point&); - - template void - compute_downstream_dg > - (std::vector&,std::vector&, - const hp::DoFHandler&, - const Point&); - template - void - compute_downstream_dg > - (std::vector&, - const hp::DoFHandler&, - const Point&); - - template void - downstream > - (hp::DoFHandler&, - const Point&, - const bool); - - template void - compute_downstream > - (std::vector&,std::vector&, - const hp::DoFHandler&, - const Point&, - const bool); - - template - void - clockwise_dg > - (hp::DoFHandler&, - const Point&, bool); - - template - void - compute_clockwise_dg > - (std::vector&, - const hp::DoFHandler&, - const Point&, - const bool); - -// MG - - template - void downstream_dg - (MGDoFHandler&, const unsigned int, - const Point&); - - template - void downstream - (MGDoFHandler&, const unsigned int, - const Point&, - const bool); - - template - void clockwise_dg - (MGDoFHandler&, - const unsigned int, - const Point&, bool); - -// Generic numbering schemes - - template - void random > - (DoFHandler &); - - template - void - compute_random > - (std::vector&, - const DoFHandler &); - - template - void sort_selected_dofs_back > - (DoFHandler &, - const std::vector &); - - template - void - compute_sort_selected_dofs_back > - (std::vector&, - const DoFHandler &, - const std::vector &); - - template - void random > - (hp::DoFHandler &); - - template - void - compute_random > - (std::vector&, - const hp::DoFHandler &); - - template - void sort_selected_dofs_back > - (hp::DoFHandler &, - const std::vector &); - - template - void - compute_sort_selected_dofs_back > - (std::vector&, - const hp::DoFHandler &, - const std::vector &); - - template - void subdomain_wise > - (DoFHandler &); - - template - void subdomain_wise > - (hp::DoFHandler &); - - template - void Cuthill_McKee - (MGDoFHandler&, - const unsigned int, - const bool, - const std::vector&); - - template - void cell_wise_dg - (MGDoFHandler&, - const unsigned int, - const std::vector::cell_iterator>&); - template - void compute_cell_wise_dg - (std::vector&, std::vector&, - const MGDoFHandler&, const unsigned int, - const std::vector::cell_iterator>&); - template - void compute_downstream_dg - (std::vector&, std::vector&, - const MGDoFHandler&, const unsigned int, - const Point&); - -} // namespace DoFRenumbering DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/dofs/dof_renumbering.inst.in b/deal.II/source/dofs/dof_renumbering.inst.in new file mode 100644 index 0000000000..f83144435c --- /dev/null +++ b/deal.II/source/dofs/dof_renumbering.inst.in @@ -0,0 +1,391 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +for (deal_II_dimension : DIMENSIONS) + { + namespace DoFRenumbering + \{ + namespace boost + \{ +//TODO[WB]: also implement the following boost for hp DoFHandlers etc. + template + void + Cuthill_McKee (DoFHandler &, bool, bool); + + template + void + compute_Cuthill_McKee (std::vector &, + const DoFHandler &, bool, bool); + + template + void + king_ordering (DoFHandler &, bool, bool); + + template + void + compute_king_ordering (std::vector &, + const DoFHandler &, bool, bool); + + template + void + minimum_degree (DoFHandler &, bool, bool); + + template + void + compute_minimum_degree (std::vector &, + const DoFHandler &, bool, bool); + + + template + void + Cuthill_McKee (hp::DoFHandler &, bool, bool); + + template + void + compute_Cuthill_McKee (std::vector &, + const hp::DoFHandler &, bool, bool); + + template + void + king_ordering (hp::DoFHandler &, bool, bool); + + template + void + compute_king_ordering (std::vector &, + const hp::DoFHandler &, bool, bool); + + template + void + minimum_degree (hp::DoFHandler &, bool, bool); + + template + void + compute_minimum_degree (std::vector &, + const hp::DoFHandler &, bool, bool); + \} + + +// non-boost functions: + + template + void Cuthill_McKee > + (DoFHandler&, + const bool, + const bool, + const std::vector&); + + template + void + compute_Cuthill_McKee > + (std::vector&, + const DoFHandler&, + const bool, + const bool, + const std::vector&); + + + template + void Cuthill_McKee > + (hp::DoFHandler&, + const bool, + const bool, + const std::vector&); + + template + void + compute_Cuthill_McKee > + (std::vector&, + const hp::DoFHandler&, + const bool, + const bool, + const std::vector&); + + template + void Cuthill_McKee > + (MGDoFHandler&, + const bool, + const bool, + const std::vector&); + + template + void + compute_Cuthill_McKee > + (std::vector&, + const MGDoFHandler&, + const bool, + const bool, + const std::vector&); + + template + void component_wise + (DoFHandler&, + const std::vector&); + + template + void component_wise + (hp::DoFHandler&, + const std::vector&); + +// template +// void +// compute_component_wise +// (std::vector&, +// const DoFHandler&, +// const std::vector&); + + template + void component_wise + (MGDoFHandler&, + unsigned int, + const std::vector&); + + template + void component_wise + (MGDoFHandler&, + const std::vector&); + +// DG renumbering for DoFHandler + + template + void + cell_wise_dg > + (DoFHandler&, + const std::vector::cell_iterator>&); + + template + void + compute_cell_wise_dg > + (std::vector&, std::vector&, + const DoFHandler&, + const std::vector::cell_iterator>&); + + template + void + downstream_dg > + (DoFHandler&, + const Point&); + + template + void + compute_downstream_dg > + (std::vector&,std::vector&, + const DoFHandler&, + const Point&); + template + void + compute_downstream_dg > + (std::vector&, + const DoFHandler&, + const Point&); + + template void + cell_wise > + (DoFHandler&, + const std::vector::cell_iterator>&); + + template void + compute_cell_wise > + (std::vector&, std::vector&, + const DoFHandler&, + const std::vector::cell_iterator>&); + + template void + downstream > + (DoFHandler&, const Point&, + const bool); + + template void + compute_downstream > + (std::vector&,std::vector&, + const DoFHandler&, const Point&, + const bool); + + template + void + clockwise_dg > + (DoFHandler&, const Point&, bool); + + template + void + compute_clockwise_dg > + (std::vector&, const DoFHandler&, + const Point&, const bool); + +// Renumbering for hp::DoFHandler + + template void + cell_wise_dg > + (hp::DoFHandler&, + const std::vector::cell_iterator>&); + + template void + compute_cell_wise_dg > + (std::vector&, std::vector&, + const hp::DoFHandler&, + const std::vector::cell_iterator>&); + + template void + cell_wise > + (hp::DoFHandler&, + const std::vector::cell_iterator>&); + + template void + compute_cell_wise > + (std::vector&, std::vector&, + const hp::DoFHandler&, + const std::vector::cell_iterator>&); + + template void + downstream_dg > + (hp::DoFHandler&, + const Point&); + + template void + compute_downstream_dg > + (std::vector&,std::vector&, + const hp::DoFHandler&, + const Point&); + template + void + compute_downstream_dg > + (std::vector&, + const hp::DoFHandler&, + const Point&); + + template void + downstream > + (hp::DoFHandler&, + const Point&, + const bool); + + template void + compute_downstream > + (std::vector&,std::vector&, + const hp::DoFHandler&, + const Point&, + const bool); + + template + void + clockwise_dg > + (hp::DoFHandler&, + const Point&, bool); + + template + void + compute_clockwise_dg > + (std::vector&, + const hp::DoFHandler&, + const Point&, + const bool); + +// MG + + template + void downstream_dg + (MGDoFHandler&, const unsigned int, + const Point&); + + template + void downstream + (MGDoFHandler&, const unsigned int, + const Point&, + const bool); + + template + void clockwise_dg + (MGDoFHandler&, + const unsigned int, + const Point&, bool); + +// Generic numbering schemes + + template + void random > + (DoFHandler &); + + template + void + compute_random > + (std::vector&, + const DoFHandler &); + + template + void sort_selected_dofs_back > + (DoFHandler &, + const std::vector &); + + template + void + compute_sort_selected_dofs_back > + (std::vector&, + const DoFHandler &, + const std::vector &); + + template + void random > + (hp::DoFHandler &); + + template + void + compute_random > + (std::vector&, + const hp::DoFHandler &); + + template + void sort_selected_dofs_back > + (hp::DoFHandler &, + const std::vector &); + + template + void + compute_sort_selected_dofs_back > + (std::vector&, + const hp::DoFHandler &, + const std::vector &); + + template + void subdomain_wise > + (DoFHandler &); + + template + void subdomain_wise > + (hp::DoFHandler &); + + template + void Cuthill_McKee + (MGDoFHandler&, + const unsigned int, + const bool, + const std::vector&); + + template + void cell_wise_dg + (MGDoFHandler&, + const unsigned int, + const std::vector::cell_iterator>&); + template + void compute_cell_wise_dg + (std::vector&, std::vector&, + const MGDoFHandler&, const unsigned int, + const std::vector::cell_iterator>&); + template + void compute_downstream_dg + (std::vector&, std::vector&, + const MGDoFHandler&, const unsigned int, + const Point&); + + \} // namespace DoFRenumbering + } + diff --git a/deal.II/source/dofs/dof_tools.cc b/deal.II/source/dofs/dof_tools.cc index 1d6f9cfd43..e9eddeeac8 100644 --- a/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/source/dofs/dof_tools.cc @@ -48,7 +48,6 @@ DEAL_II_NAMESPACE_OPEN -//TODO: convert many more of the instantiations at the bottom of this file to the .inst.in mechanism //#define WOLFGANG @@ -324,83 +323,29 @@ DoFTools::make_sparsity_pattern ( -#if deal_II_dimension == 1 - template void DoFTools::make_boundary_sparsity_pattern ( - const DH &dof_handler, - const typename FunctionMap::type &function_map, - const std::vector &dof_to_boundary_mapping, - SparsityPattern &sparsity) -{ - // first check left, the right - // boundary point - for (unsigned int direction=0; direction<2; ++direction) - { - // if this boundary is not - // requested, then go on with next one - if (function_map.find(direction) == - function_map.end()) - continue; - - // find active cell at that - // boundary: first go to - // left/right, then to children - typename DH::cell_iterator cell = dof_handler.begin(0); - while (!cell->at_boundary(direction)) - cell = cell->neighbor(direction); - while (!cell->active()) - cell = cell->child(direction); - - const unsigned int dofs_per_vertex = cell->get_fe().dofs_per_vertex; - std::vector boundary_dof_boundary_indices (dofs_per_vertex); - - // next get boundary mapped dof - // indices of boundary dofs - for (unsigned int i=0; ivertex_dof_index(direction,i)]; - - for (unsigned int i=0; i -void DoFTools::make_boundary_sparsity_pattern ( - const DH &dof_handler, + const DH &dof, const std::vector &dof_to_boundary_mapping, SparsityPattern &sparsity) { + if (DH::dimension == 1) + { // there are only 2 boundary // indicators in 1d, so it is no // performance problem to call the // other function - typename DH::FunctionMap boundary_indicators; - boundary_indicators[0] = 0; - boundary_indicators[1] = 0; - make_boundary_sparsity_pattern (dof_handler, - boundary_indicators, - dof_to_boundary_mapping, - sparsity); -} - - -#else - + typename DH::FunctionMap boundary_indicators; + boundary_indicators[0] = 0; + boundary_indicators[1] = 0; + make_boundary_sparsity_pattern (dof, + boundary_indicators, + dof_to_boundary_mapping, + sparsity); + return; + } -template -void -DoFTools::make_boundary_sparsity_pattern ( - const DH &dof, - const std::vector &dof_to_boundary_mapping, - SparsityPattern &sparsity) -{ const unsigned int n_dofs = dof.n_dofs(); AssertDimension (dof_to_boundary_mapping.size(), n_dofs); @@ -460,6 +405,44 @@ void DoFTools::make_boundary_sparsity_pattern ( const std::vector &dof_to_boundary_mapping, SparsityPattern &sparsity) { + if (DH::dimension == 1) + { + // first check left, then right + // boundary point + for (unsigned int direction=0; direction<2; ++direction) + { + // if this boundary is not + // requested, then go on with next one + if (boundary_indicators.find(direction) == + boundary_indicators.end()) + continue; + + // find active cell at that + // boundary: first go to + // left/right, then to children + typename DH::cell_iterator cell = dof.begin(0); + while (!cell->at_boundary(direction)) + cell = cell->neighbor(direction); + while (!cell->active()) + cell = cell->child(direction); + + const unsigned int dofs_per_vertex = cell->get_fe().dofs_per_vertex; + std::vector boundary_dof_boundary_indices (dofs_per_vertex); + + // next get boundary mapped dof + // indices of boundary dofs + for (unsigned int i=0; ivertex_dof_index(direction,i)]; + + for (unsigned int i=0; i void DoFTools::make_flux_sparsity_pattern (const DH &dof, @@ -528,16 +509,12 @@ DoFTools::make_flux_sparsity_pattern (const DH &dof, typename DH::active_cell_iterator cell = dof.begin_active(), endc = dof.end(); - // Clear user flags because we will - // need them. But first we save them - // and make sure that we restore them - // later such that at the end of this - // function the Triangulation will be - // in the same state as it was at the - // beginning of this function. - std::vector user_flags; - dof.get_tria().save_user_flags(user_flags); - const_cast &>(dof.get_tria()).clear_user_flags (); + // TODO: in an old implementation, we used + // user flags before to tag faces that were + // already touched. this way, we could reduce + // the work a little bit. now, we instead add + // only data from one side. this should be OK, + // but we need to actually verify it. // In case we work with a distributed // sparsity pattern of Trilinos type, we @@ -553,12 +530,6 @@ DoFTools::make_flux_sparsity_pattern (const DH &dof, dofs_on_this_cell.resize (n_dofs_on_this_cell); cell->get_dof_indices (dofs_on_this_cell); - // make sparsity pattern for this cell - // for (unsigned int i=0; i::faces_per_cell; ++face) { typename DH::face_iterator cell_face = cell->face(face); - if (cell_face->user_flag_set ()) - continue; - if (! cell_face->at_boundary() ) + if (! cell->at_boundary(face) ) { typename DH::cell_iterator neighbor = cell->neighbor(face); - const unsigned int neighbor_face - = cell->neighbor_face_no(face); - if (cell_face->has_children()) { for (unsigned int sub_nr = 0; @@ -603,13 +568,17 @@ DoFTools::make_flux_sparsity_pattern (const DH &dof, constraints.add_entries_local_to_global (dofs_on_other_cell, dofs_on_this_cell, sparsity, keep_constrained_dofs); - sub_neighbor->face(neighbor_face)->set_user_flag (); } } else { // Refinement edges are taken care of // by coarser cells + + // TODO: in the distributed case, we miss out + // the constraints when the neighbor cell is + // coarser, but only the current cell is owned + // locally! if (cell->neighbor_is_coarser(face)) continue; @@ -622,140 +591,22 @@ DoFTools::make_flux_sparsity_pattern (const DH &dof, constraints.add_entries_local_to_global (dofs_on_this_cell, dofs_on_other_cell, sparsity, keep_constrained_dofs); - constraints.add_entries_local_to_global - (dofs_on_other_cell, dofs_on_this_cell, - sparsity, keep_constrained_dofs); - neighbor->face(neighbor_face)->set_user_flag (); - } - } - } - } - - // finally restore the user flags - const_cast &>(dof.get_tria()).load_user_flags(user_flags); -} - - -template -void -DoFTools::make_flux_sparsity_pattern ( - const DH &dof, - SparsityPattern &sparsity) -{ - const unsigned int n_dofs = dof.n_dofs(); - - Assert (sparsity.n_rows() == n_dofs, - ExcDimensionMismatch (sparsity.n_rows(), n_dofs)); - Assert (sparsity.n_cols() == n_dofs, - ExcDimensionMismatch (sparsity.n_cols(), n_dofs)); - - std::vector dofs_on_this_cell; - std::vector dofs_on_other_cell; - dofs_on_this_cell.reserve (max_dofs_per_cell(dof)); - dofs_on_other_cell.reserve (max_dofs_per_cell(dof)); - typename DH::active_cell_iterator cell = dof.begin_active(), - endc = dof.end(); - - // Clear user flags because we will - // need them. But first we save - // them and make sure that we - // restore them later such that at - // the end of this function the - // Triangulation will be in the - // same state as it was at the - // beginning of this function. - std::vector user_flags; - dof.get_tria().save_user_flags(user_flags); - const_cast &>(dof.get_tria()).clear_user_flags (); - - for (; cell!=endc; ++cell) - { - const unsigned int n_dofs_on_this_cell = cell->get_fe().dofs_per_cell; - dofs_on_this_cell.resize (n_dofs_on_this_cell); - cell->get_dof_indices (dofs_on_this_cell); - // make sparsity pattern for this cell - for (unsigned int i=0; i::faces_per_cell; - ++face) - { - typename DH::face_iterator cell_face = cell->face(face); - if (cell_face->user_flag_set ()) - continue; - - if (! cell_face->at_boundary() ) - { - typename DH::cell_iterator neighbor = cell->neighbor(face); - - const unsigned int neighbor_face - = cell->neighbor_face_no(face); - - if (cell_face->has_children()) - { - for (unsigned int sub_nr = 0; - sub_nr != cell_face->number_of_children(); - ++sub_nr) - { - const typename DH::cell_iterator - sub_neighbor - = cell->neighbor_child_on_subface (face, sub_nr); - - const unsigned int n_dofs_on_neighbor - = sub_neighbor->get_fe().dofs_per_cell; - dofs_on_other_cell.resize (n_dofs_on_neighbor); - sub_neighbor->get_dof_indices (dofs_on_other_cell); - - for (unsigned int i=0; iface(neighbor_face)->set_user_flag (); - } - } - else - { - // Refinement edges are - // taken care of by - // coarser cells - if (cell->neighbor_is_coarser(face)) - continue; - - const unsigned int n_dofs_on_neighbor - = neighbor->get_fe().dofs_per_cell; - dofs_on_other_cell.resize (n_dofs_on_neighbor); - - neighbor->get_dof_indices (dofs_on_other_cell); - - for (unsigned int i=0; iface(neighbor_face)->set_user_flag (); + // only need to add these in case the neighbor + // cell is not locally owned - otherwise, we + // touch each face twice and hence put the + // indices the other way around + if (cell->neighbor(face)->subdomain_id() != + cell->subdomain_id()) + constraints.add_entries_local_to_global + (dofs_on_other_cell, dofs_on_this_cell, + sparsity, keep_constrained_dofs); } } } } - - // finally restore the user flags - const_cast &>(dof.get_tria()).load_user_flags(user_flags); } -#else // deal_II_dimension == 1 - template void @@ -763,54 +614,10 @@ DoFTools::make_flux_sparsity_pattern ( const DH &dof, SparsityPattern &sparsity) { - typedef typename DH::cell_iterator cell_iterator; - typedef typename DH::active_cell_iterator active_cell_iterator; - - std::vector local_dof_indices; - std::vector neighbor_dof_indices; - local_dof_indices.reserve (max_dofs_per_cell(dof)); - neighbor_dof_indices.reserve (max_dofs_per_cell(dof)); - - active_cell_iterator cell = dof.begin_active(), - endc = dof.end(); - for (; cell!=endc; ++cell) - { - // first do couplings of dofs - // locally on this cell - const unsigned int n_dofs_on_this_cell = cell->get_fe().dofs_per_cell; - local_dof_indices.resize (n_dofs_on_this_cell); - cell->get_dof_indices (local_dof_indices); - for (unsigned int i=0; iat_boundary(nb)) - { - // find active neighbor - cell_iterator neighbor = cell->neighbor(nb); - while (neighbor->has_children()) - neighbor = neighbor->child(nb==0 ? 1 : 0); - - // get dofs on it - const unsigned int n_dofs_on_neighbor - = neighbor->get_fe().dofs_per_cell; - neighbor_dof_indices.resize (n_dofs_on_neighbor); - neighbor->get_dof_indices (neighbor_dof_indices); - - // compute couplings - for (unsigned int i=0; i @@ -1837,7 +1644,7 @@ namespace internal } -#if deal_II_dimension == 1 + static void make_hp_hanging_node_constraints (const dealii::DoFHandler<1> &, @@ -1968,11 +1775,10 @@ namespace internal // // that a bit more // //TODO[WB]: think about what to do here... // } -#endif +//#endif -#if deal_II_dimension == 2 template static void @@ -2127,10 +1933,9 @@ namespace internal } } } -#endif -#if deal_II_dimension == 3 + template static void @@ -2245,7 +2050,7 @@ namespace internal 12*fe.dofs_per_line+ 4*fe.dofs_per_quad); //TODO[TL]: think about this and the following in case of anisotropic refinement - + dofs_on_mother.resize (n_dofs_on_mother); dofs_on_children.resize (n_dofs_on_children); @@ -2368,7 +2173,6 @@ namespace internal } } } -#endif template @@ -3669,7 +3473,6 @@ DoFTools::extract_level_dofs( } -#if deal_II_dimension != 1 template void @@ -3902,249 +3705,6 @@ DoFTools::extract_dofs_with_support_on_boundary (const DH & - -#else // 1d - - -template -void -DoFTools::extract_boundary_dofs (const DH &dof_handler, - const std::vector &component_select, - std::vector &selected_dofs, - const std::set &boundary_indicators) -{ - Assert (component_select.size() == n_components(dof_handler), - ExcWrongSize (component_select.size(), - n_components(dof_handler))); - - // clear and reset array by default - // values - selected_dofs.clear (); - selected_dofs.resize (dof_handler.n_dofs(), false); - - // let's see whether we have to - // check for certain boundary - // indicators or whether we can - // accept all - const bool check_left_vertex = ((boundary_indicators.size() == 0) || - (boundary_indicators.find(0) != - boundary_indicators.end())); - const bool check_right_vertex = ((boundary_indicators.size() == 0) || - (boundary_indicators.find(1) != - boundary_indicators.end())); - - // see whether we have to check - // whether a certain vector - // component is selected, or all - const bool check_vector_component - = (component_select != std::vector(component_select.size(), - true)); - - // loop over coarse grid cells - for (typename DH::cell_iterator cell=dof_handler.begin(0); - cell!=dof_handler.end(0); ++cell) - { - const FiniteElement<1> &fe = cell->get_fe(); - - // check left-most vertex - if (check_left_vertex) - if (cell->neighbor(0) == dof_handler.end()) - { - // In 1D the number of DoFs - // on the faces should be - // equal to the number of DoFs - // on the vertices. - AssertDimension (fe.dofs_per_face, fe.dofs_per_vertex); - - for (unsigned int i=0; ivertex_dof_index(0,i)] = true; - else - // check - // component. make sure - // we don't ask the - // wrong question - // (leading to an - // exception) in case - // the shape function - // is non-primitive. note - // that the face dof - // index i is also the - // cell dof index of a - // corresponding dof in 1d - { - const unsigned int component = - (fe.is_primitive(i) ? - fe.face_system_to_component_index(i).first : - (std::find (fe.get_nonzero_components(i).begin(), - fe.get_nonzero_components(i).end(), - true) - - - fe.get_nonzero_components(i).begin())); - Assert (component < fe.n_components(), - ExcInternalError()); - - if (component_select[component] == true) - selected_dofs[cell->vertex_dof_index(0,i)] = true; - } - } - - // check right-most - // vertex. same procedure here - // as above - if (check_right_vertex) - if (cell->neighbor(1) == dof_handler.end()) - { - AssertDimension (fe.dofs_per_face, fe.dofs_per_vertex); - - for (unsigned int i=0; ivertex_dof_index(1,i)] = true; - else - { - const unsigned int component = - (fe.is_primitive(i) ? - fe.face_system_to_component_index(i).first : - (std::find (fe.get_nonzero_components(i).begin(), - fe.get_nonzero_components(i).end(), - true) - - - fe.get_nonzero_components(i).begin())); - Assert (component < fe.n_components(), - ExcInternalError()); - - if (component_select[component] == true) - selected_dofs[cell->vertex_dof_index(1,i)] = true; - } - } - } -} - - - -template -void -DoFTools::extract_dofs_with_support_on_boundary (const DH &dof_handler, - const std::vector &component_select, - std::vector &selected_dofs, - const std::set &boundary_indicators) -{ - Assert (component_select.size() == n_components(dof_handler), - ExcWrongSize (component_select.size(), - n_components(dof_handler))); - - // clear and reset array by default - // values - selected_dofs.clear (); - selected_dofs.resize (dof_handler.n_dofs(), false); - - // let's see whether we have to - // check for certain boundary - // indicators or whether we can - // accept all - const bool check_left_vertex = ((boundary_indicators.size() == 0) || - (boundary_indicators.find(0) != - boundary_indicators.end())); - const bool check_right_vertex = ((boundary_indicators.size() == 0) || - (boundary_indicators.find(1) != - boundary_indicators.end())); - - // see whether we have to check - // whether a certain vector - // component is selected, or all - const bool check_vector_component - = (component_select != std::vector(component_select.size(), - true)); - - std::vector dof_indices; - - // loop over cells - for (typename DH::active_cell_iterator cell=dof_handler.begin_active(); - cell!=dof_handler.end(); ++cell) - { - const FiniteElement<1> &fe = cell->get_fe(); - - // check left-most vertex - if (check_left_vertex) - if (cell->neighbor(0) == dof_handler.end()) - { - dof_indices.resize (fe.dofs_per_cell); - cell->get_dof_indices(dof_indices); - for (unsigned int i=0; iget_fe().has_support_on_face (i,0) == true) - { - if (!check_vector_component) - selected_dofs[dof_indices[i]] = true; - else - // check - // component. make sure - // we don't ask the - // wrong question - // (leading to an - // exception) in case - // the shape function - // is non-primitive. note - // that the face dof - // index i is also the - // cell dof index of a - // corresponding dof in 1d - { - const unsigned int component = - (fe.is_primitive(i) ? - fe.system_to_component_index(i).first : - (std::find (fe.get_nonzero_components(i).begin(), - fe.get_nonzero_components(i).end(), - true) - - - fe.get_nonzero_components(i).begin())); - Assert (component < fe.n_components(), - ExcInternalError()); - - if (component_select[component] == true) - selected_dofs[dof_indices[i]] = true; - } - } - } - - // check right-most - // vertex. same procedure here - // as above - if (check_right_vertex) - if (cell->neighbor(1) == dof_handler.end()) - { - dof_indices.resize (fe.dofs_per_cell); - cell->get_dof_indices (dof_indices); - for (unsigned int i=0; iget_fe().has_support_on_face (i,1) == true) - { - if (!check_vector_component) - selected_dofs[dof_indices[i]] = true; - else - { - const unsigned int component = - (fe.is_primitive(i) ? - fe.system_to_component_index(i).first : - (std::find (fe.get_nonzero_components(i).begin(), - fe.get_nonzero_components(i).end(), - true) - - - fe.get_nonzero_components(i).begin())); - Assert (component < fe.n_components(), - ExcInternalError()); - - if (component_select[component] == true) - selected_dofs[dof_indices[i]] = true; - } - } - } - } -} - - -#endif - - - namespace internal { namespace DoFTools @@ -4581,7 +4141,7 @@ DoFTools::dof_indices_with_subdomain_association (const DH &dof_handle "associated DoF handler objects, asking for any subdomain other " "than the locally owned one does not make sense.")); #endif - + IndexSet index_set (dof_handler.n_dofs()); std::vector local_dof_indices; @@ -4608,9 +4168,6 @@ DoFTools::dof_indices_with_subdomain_association (const DH &dof_handle - - - template void DoFTools::count_dofs_with_subdomain_association (const DH &dof_handler, @@ -5376,6 +4933,7 @@ namespace internal } + template void DoFTools::compute_intergrid_constraints ( @@ -5714,72 +5272,6 @@ compute_intergrid_transfer_representation ( -#if deal_II_dimension == 1 - - -template -void DoFTools::map_dof_to_boundary_indices ( - const DH &dof_handler, - const std::set &boundary_indicators, - std::vector &mapping) -{ - Assert (&dof_handler.get_fe() != 0, ExcNoFESelected()); - - mapping.clear (); - mapping.insert (mapping.end(), dof_handler.n_dofs(), - DH::invalid_dof_index); - - unsigned int next_free_index = 0; - - // first check left, the right - // boundary point - for (unsigned int direction=0; direction<2; ++direction) - { - // if this boundary is not - // requested, then go on with next one - if (boundary_indicators.find(direction) == - boundary_indicators.end()) - continue; - - // find active cell at that - // boundary: first go to - // left/right, then to children - typename DH::cell_iterator cell = dof_handler.begin(0); - while (!cell->at_boundary(direction)) - cell = cell->neighbor(direction); - while (!cell->active()) - cell = cell->child(direction); - - // next enumerate these degrees - // of freedom - for (unsigned int i=0; iget_fe().dofs_per_vertex; ++i) - mapping[cell->vertex_dof_index(direction,i)] = next_free_index++; - }; -} - - - -template <> -void -DoFTools::map_dof_to_boundary_indices (const DoFHandler<1> &dof_handler, - std::vector &mapping) -{ - Assert (&dof_handler.get_fe() != 0, ExcNoFESelected()); - - // in 1d, there are only 2 boundary - // indicators, so enumerate them - // and pass on to the other - // function - std::set boundary_indicators; - boundary_indicators.insert (0U); - boundary_indicators.insert (1U); - - map_dof_to_boundary_indices > (dof_handler, boundary_indicators, mapping); -} - -#else - - template void DoFTools::map_dof_to_boundary_indices (const DH &dof_handler, @@ -5868,8 +5360,6 @@ void DoFTools::map_dof_to_boundary_indices ( AssertDimension (next_boundary_index, dof_handler.n_boundary_dofs (boundary_indicators)); } -#endif - template @@ -5974,63 +5464,7 @@ DoFTools::convert_couplings_to_blocks ( } } -#if deal_II_dimension == 1 -template class DH> -void -DoFTools::make_zero_boundary_constraints (const DH &dof, - ConstraintMatrix &zero_boundary_constraints, - const std::vector &component_mask_) -{ - Assert ((component_mask_.size() == 0) || - (component_mask_.size() == dof.get_fe().n_components()), - ExcMessage ("The number of components in the mask has to be either " - "zero or equal to the number of components in the finite " - "element.")); - - // check for boundary cells in both - // directions to secure indicators - // for the entire boundary, i.e. 0 - // is left boundary and 1 is right - // boundary - for (unsigned int direction = 0; direction < 2; ++direction) - { - - // first find the outermost active - // cell by traversing the coarse - // grid to its end and then looking - // for the children - typename DH::cell_iterator outermost_cell = dof.begin(0); - while (outermost_cell->neighbor(direction).state() == IteratorState::valid) - outermost_cell = outermost_cell->neighbor(direction); - - while (outermost_cell->has_children()) - outermost_cell = outermost_cell->child(direction); - - // then get the FE corresponding to - // this cell - const FiniteElement &fe = outermost_cell->get_fe(); - - // set the component mask to either - // the original value or a vector - // of trues - const std::vector component_mask ((component_mask_.size() == 0) ? - std::vector (fe.n_components(), true) : - component_mask_); - Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0, - VectorTools::ExcNoComponentSelected()); - - // cast zero boundary constraints - // onto a matrix if component_mask - // == true - for (unsigned int i=0; ivertex_dof_index (direction, i)); - - } -} - -#else template class DH> void @@ -6104,721 +5538,11 @@ DoFTools::make_zero_boundary_constraints (const DH &dof, } } -#endif // explicit instantiations #include "dof_tools.inst" -// #if deal_II_dimension > 1 -template void -DoFTools::make_boundary_sparsity_pattern,SparsityPattern> -(const DoFHandler& dof, - const std::vector &, - SparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - CompressedSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - CompressedSetSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSimpleSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - CompressedSimpleSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - BlockSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - BlockCompressedSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - BlockCompressedSetSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSimpleSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - BlockCompressedSimpleSparsityPattern &); - -template void -DoFTools::make_boundary_sparsity_pattern,SparsityPattern> -(const hp::DoFHandler& dof, - const std::vector &, - SparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSparsityPattern> -(const hp::DoFHandler& dof, - const std::vector &, - CompressedSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> -(const hp::DoFHandler& dof, - const std::vector &, - CompressedSetSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSimpleSparsityPattern> -(const hp::DoFHandler& dof, - const std::vector &, - CompressedSimpleSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> -(const hp::DoFHandler& dof, - const std::vector &, - BlockSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> -(const hp::DoFHandler& dof, - const std::vector &, - BlockCompressedSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> -(const hp::DoFHandler& dof, - const std::vector &, - BlockCompressedSetSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSimpleSparsityPattern> -(const hp::DoFHandler& dof, - const std::vector &, - BlockCompressedSimpleSparsityPattern &); - - -template void -DoFTools::make_boundary_sparsity_pattern,SparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - SparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - CompressedSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - CompressedSetSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSimpleSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - CompressedSimpleSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - BlockSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - BlockCompressedSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - BlockCompressedSetSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSimpleSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - BlockCompressedSimpleSparsityPattern &sparsity); - -template void -DoFTools::make_boundary_sparsity_pattern,SparsityPattern> -(const hp::DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - SparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSparsityPattern> -(const hp::DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - CompressedSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> -(const hp::DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - CompressedSetSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSimpleSparsityPattern> -(const hp::DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - CompressedSimpleSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> -(const hp::DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - BlockSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> -(const hp::DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - BlockCompressedSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> -(const hp::DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - BlockCompressedSetSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSimpleSparsityPattern> -(const hp::DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - BlockCompressedSimpleSparsityPattern &sparsity); - - - -template -void -DoFTools::distribute_cell_to_dof_vector > -(const DoFHandler &dof_handler, - const Vector &cell_data, - Vector &dof_data, - const unsigned int component); -template -void -DoFTools::distribute_cell_to_dof_vector > -(const DoFHandler &dof_handler, - const Vector &cell_data, - Vector &dof_data, - const unsigned int component); - -template -void -DoFTools::distribute_cell_to_dof_vector > -(const hp::DoFHandler &dof_handler, - const Vector &cell_data, - Vector &dof_data, - const unsigned int component); -template -void -DoFTools::distribute_cell_to_dof_vector > -(const hp::DoFHandler &dof_handler, - const Vector &cell_data, - Vector &dof_data, - const unsigned int component); - - -template void DoFTools::extract_dofs -(const DoFHandler&, - const std::vector&, std::vector&, bool); - -template void DoFTools::extract_dofs -(const hp::DoFHandler&, - const std::vector&, std::vector&, bool); - -template void DoFTools::extract_level_dofs -(const unsigned int level, const MGDoFHandler&, - const std::vector&, std::vector&, bool); - -template -void -DoFTools::extract_boundary_dofs > -(const DoFHandler &, - const std::vector &, - std::vector &, - const std::set &); -template -void -DoFTools::extract_boundary_dofs > -(const hp::DoFHandler &, - const std::vector &, - std::vector &, - const std::set &); - -template -void -DoFTools::extract_dofs_with_support_on_boundary > -(const DoFHandler &, - const std::vector &, - std::vector &, - const std::set &); -template -void -DoFTools::extract_dofs_with_support_on_boundary > -(const hp::DoFHandler &, - const std::vector &, - std::vector &, - const std::set &); - -template -void -DoFTools::extract_hanging_node_dofs -(const DoFHandler &dof_handler, - std::vector &selected_dofs); - -template -void -DoFTools::extract_subdomain_dofs > -(const DoFHandler &dof_handler, - const types::subdomain_id_t subdomain_id, - std::vector &selected_dofs); -template -void -DoFTools::extract_subdomain_dofs > -(const hp::DoFHandler &dof_handler, - const types::subdomain_id_t subdomain_id, - std::vector &selected_dofs); - -template -void -DoFTools::extract_locally_owned_dofs > -(const DoFHandler & dof_handler, - IndexSet & dof_set); - -template -void -DoFTools::extract_locally_active_dofs > -(const DoFHandler & dof_handler, - IndexSet & dof_set); - - -template -void -DoFTools::extract_locally_relevant_dofs > -(const DoFHandler & dof_handler, - IndexSet & dof_set); - -template -void -DoFTools::extract_constant_modes > -(const DoFHandler &dof_handler, - const std::vector &selected_components, - std::vector > &constant_modes); - -template -void -DoFTools::get_active_fe_indices > -(const DoFHandler &dof_handler, - std::vector &active_fe_indices); - -template -void -DoFTools::get_active_fe_indices > -(const hp::DoFHandler &dof_handler, - std::vector &active_fe_indices); - -template -void -DoFTools::get_subdomain_association > -(const DoFHandler &dof_handler, - std::vector &subdomain_association); -template -void -DoFTools::get_subdomain_association > -(const hp::DoFHandler &dof_handler, - std::vector &subdomain_association); - - -template -unsigned int -DoFTools::count_dofs_with_subdomain_association > -(const DoFHandler &, - const types::subdomain_id_t); -template -IndexSet -DoFTools::dof_indices_with_subdomain_association > -(const DoFHandler &, - const types::subdomain_id_t); -template -void -DoFTools::count_dofs_with_subdomain_association > -(const DoFHandler &, - const types::subdomain_id_t, - std::vector &); - -template -unsigned int -DoFTools::count_dofs_with_subdomain_association > -(const hp::DoFHandler &, - const types::subdomain_id_t); -template -IndexSet -DoFTools::dof_indices_with_subdomain_association > -(const hp::DoFHandler &, - const types::subdomain_id_t); -template -void -DoFTools::count_dofs_with_subdomain_association > -(const hp::DoFHandler &, - const types::subdomain_id_t, - std::vector &); - -template -unsigned int -DoFTools::count_dofs_with_subdomain_association > -(const MGDoFHandler &, - const types::subdomain_id_t); -template -IndexSet -DoFTools::dof_indices_with_subdomain_association > -(const MGDoFHandler &, - const types::subdomain_id_t); -template -void -DoFTools::count_dofs_with_subdomain_association > -(const MGDoFHandler &, - const types::subdomain_id_t, - std::vector &); - - -template -void -DoFTools::count_dofs_per_component ( - const DoFHandler&, - std::vector&, bool, std::vector); - -#if deal_II_dimension < 3 -template void DoFTools::extract_level_dofs -(const unsigned int level, const MGDoFHandler&, - const std::vector&, std::vector&, bool); - -template -void -DoFTools::count_dofs_per_component ( - const DoFHandler&, - std::vector&, bool, std::vector); -#endif - -template -void -DoFTools::count_dofs_per_block ( - const DoFHandler&, - std::vector&, std::vector); - - -template -void -DoFTools::count_dofs_per_component ( - const DoFHandler&, - std::vector&, std::vector); - -template -void -DoFTools::compute_intergrid_constraints ( - const DoFHandler &, const unsigned int, - const DoFHandler &, const unsigned int, - const InterGridMap > &, - ConstraintMatrix&); - -template -void -DoFTools::compute_intergrid_transfer_representation -(const DoFHandler &, const unsigned int, - const DoFHandler &, const unsigned int, - const InterGridMap > &, - std::vector > &); - - -template -void -DoFTools::map_dof_to_boundary_indices > -(const DoFHandler &, - const std::set &, - std::vector &); - -#if deal_II_dimension != 1 - -template -void -DoFTools::map_dof_to_boundary_indices > -(const DoFHandler &, - std::vector &); - -#endif - - - -template -void -DoFTools::map_dof_to_boundary_indices > -(const hp::DoFHandler &, - const std::set &, - std::vector &); - -#if deal_II_dimension != 1 - -template -void -DoFTools::map_dof_to_boundary_indices > -(const hp::DoFHandler &, - std::vector &); - -#endif - - - - -template -void -DoFTools::map_dofs_to_support_points -(const Mapping&, - const DoFHandler&, - std::vector >&); - -#if deal_II_dimension != 3 - -template -void -DoFTools::map_dofs_to_support_points -(const Mapping&, - const DoFHandler&, - std::vector >&); - -template -void -DoFTools::count_dofs_per_block ( - const DoFHandler&, - std::vector&, std::vector); - -#endif - -template -void -DoFTools::convert_couplings_to_blocks ( - const DoFHandler&, const Table<2, Coupling>&, - std::vector >&); - -template -void -DoFTools::convert_couplings_to_blocks ( - const hp::DoFHandler&, const Table<2, Coupling>&, - std::vector >&); - -template -void -DoFTools::make_zero_boundary_constraints -(const DoFHandler &, - ConstraintMatrix &, - const std::vector &); - -template -void -DoFTools::make_zero_boundary_constraints -(const hp::DoFHandler &, - ConstraintMatrix &, - const std::vector &); - - -#if deal_II_dimension < 3 -template void -DoFTools::make_boundary_sparsity_pattern,SparsityPattern> -(const DoFHandler& dof, - const std::vector &, - SparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - CompressedSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - CompressedSetSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - BlockSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - BlockCompressedSparsityPattern &); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> -(const DoFHandler& dof, - const std::vector &, - BlockCompressedSetSparsityPattern &); - -// template void -// DoFTools::make_boundary_sparsity_pattern,SparsityPattern> -// (const hp::DoFHandler& dof, -// const std::vector &, -// SparsityPattern &); -// template void -// DoFTools::make_boundary_sparsity_pattern,CompressedSparsityPattern> -// (const hp::DoFHandler& dof, -// const std::vector &, -// CompressedSparsityPattern &); -// template void -// DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> -// (const hp::DoFHandler& dof, -// const std::vector &, -// CompressedSetSparsityPattern &); -// template void -// DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> -// (const hp::DoFHandler& dof, -// const std::vector &, -// BlockSparsityPattern &); -// template void -// DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> -// (const hp::DoFHandler& dof, -// const std::vector &, -// BlockCompressedSparsityPattern &); -// template void -// DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> -// (const hp::DoFHandler& dof, -// const std::vector &, -// BlockCompressedSetSparsityPattern &); - - -template void -DoFTools::make_boundary_sparsity_pattern,SparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - SparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - CompressedSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - CompressedSetSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - BlockSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - BlockCompressedSparsityPattern &sparsity); -template void -DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> -(const DoFHandler& dof, - const FunctionMap::type &boundary_indicators, - const std::vector &dof_to_boundary_mapping, - BlockCompressedSetSparsityPattern &sparsity); - -// template void -// DoFTools::make_boundary_sparsity_pattern,SparsityPattern> -// (const hp::DoFHandler& dof, -// const FunctionMap::type &boundary_indicators, -// const std::vector &dof_to_boundary_mapping, -// SparsityPattern &sparsity); -// template void -// DoFTools::make_boundary_sparsity_pattern,CompressedSparsityPattern> -// (const hp::DoFHandler& dof, -// const FunctionMap::type &boundary_indicators, -// const std::vector &dof_to_boundary_mapping, -// CompressedSparsityPattern &sparsity); -// template void -// DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> -// (const hp::DoFHandler& dof, -// const FunctionMap::type &boundary_indicators, -// const std::vector &dof_to_boundary_mapping, -// CompressedSetSparsityPattern &sparsity); -// template void -// DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> -// (const hp::DoFHandler& dof, -// const FunctionMap::type &boundary_indicators, -// const std::vector &dof_to_boundary_mapping, -// BlockSparsityPattern &sparsity); -// template void -// DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> -// (const hp::DoFHandler& dof, -// const FunctionMap::type &boundary_indicators, -// const std::vector &dof_to_boundary_mapping, -// BlockCompressedSparsityPattern &sparsity); -// template void -// DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> -// (const hp::DoFHandler& dof, -// const FunctionMap::type &boundary_indicators, -// const std::vector &dof_to_boundary_mapping, -// BlockCompressedSetSparsityPattern &sparsity); - - -template -void -DoFTools::map_dof_to_boundary_indices > -(const DoFHandler &, - const std::set &, - std::vector &); - -#if deal_II_dimension != 1 - -template -void -DoFTools::map_dof_to_boundary_indices > -(const DoFHandler &, - std::vector &); - -#endif - - -template -void -DoFTools::extract_hanging_node_dofs -(const DoFHandler &dof_handler, - std::vector &selected_dofs); - -// template -// void -// DoFTools::map_dof_to_boundary_indices > -// (const hp::DoFHandler &, -// const std::set &, -// std::vector &); - -// #if deal_II_dimension != 1 - -// template -// void -// DoFTools::map_dof_to_boundary_indices > -// (const hp::DoFHandler &, -// std::vector &); - -// #endif - - - -#endif - - -#if deal_II_dimension < 3 -template -void -DoFTools:: -make_hanging_node_constraints (const DoFHandler &dof_handler, - ConstraintMatrix &constraints); -#endif - DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/dofs/dof_tools.inst.in b/deal.II/source/dofs/dof_tools.inst.in index a515e04fdc..cd3273bb4a 100644 --- a/deal.II/source/dofs/dof_tools.inst.in +++ b/deal.II/source/dofs/dof_tools.inst.in @@ -12,7 +12,7 @@ //--------------------------------------------------------------------------- -for (SP : SPARSITY_PATTERNS) +for (SP : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) { template void DoFTools::make_sparsity_pattern, SP> @@ -77,6 +77,33 @@ for (SP : SPARSITY_PATTERNS) const hp::DoFHandler &dof_col, SP &sparsity); + // #if deal_II_dimension > 1 + template void + DoFTools::make_boundary_sparsity_pattern,SP> + (const DoFHandler& dof, + const std::vector &, + SP &); + + template void + DoFTools::make_boundary_sparsity_pattern,SP> + (const hp::DoFHandler& dof, + const std::vector &, + SP &); + + template void + DoFTools::make_boundary_sparsity_pattern,SP> + (const DoFHandler& dof, + const FunctionMap::type &boundary_indicators, + const std::vector &dof_to_boundary_mapping, + SP &sparsity); + + template void + DoFTools::make_boundary_sparsity_pattern,SP> + (const hp::DoFHandler& dof, + const FunctionMap::type &boundary_indicators, + const std::vector &dof_to_boundary_mapping, + SP &sparsity); + template void DoFTools::make_flux_sparsity_pattern,SP> (const DoFHandler &dof, @@ -111,10 +138,7 @@ for (SP : SPARSITY_PATTERNS) const bool, const unsigned int); #endif - } -for (SP : SPARSITY_PATTERNS) - { #if deal_II_dimension < 3 template void @@ -162,16 +186,419 @@ for (SP : SPARSITY_PATTERNS) (const hp::DoFHandler &dof_row, const hp::DoFHandler &dof_col, SP &sparsity); + + template void + DoFTools::make_boundary_sparsity_pattern,SP> + (const DoFHandler& dof, + const std::vector &, + SP &); + + //template void + //DoFTools::make_boundary_sparsity_pattern,SP> + //(const hp::DoFHandler& dof, + // const std::vector &, + // SP &); + + template void + DoFTools::make_boundary_sparsity_pattern,SP> + (const DoFHandler& dof, + const FunctionMap::type &boundary_indicators, + const std::vector &dof_to_boundary_mapping, + SP &sparsity); + + //template void + //DoFTools::make_boundary_sparsity_pattern,SP> + //(const hp::DoFHandler& dof, + // const FunctionMap::type &boundary_indicators, + // const std::vector &dof_to_boundary_mapping, + // SP &sparsity); + #endif } -for (DH : DOFHANDLERS) +for (DH : DOFHANDLERS; deal_II_dimension : DIMENSIONS) { template void DoFTools::make_hanging_node_constraints (const DH &dof_handler, ConstraintMatrix &constraints); } + + +for (deal_II_dimension : DIMENSIONS) +{ + +#if deal_II_dimension < 3 +template +void +DoFTools:: +make_hanging_node_constraints (const DoFHandler &dof_handler, + ConstraintMatrix &constraints); +#endif + + +// TODO: can cleanup a bit more to fit into the scheme used above + +template +void +DoFTools::distribute_cell_to_dof_vector > +(const DoFHandler &dof_handler, + const Vector &cell_data, + Vector &dof_data, + const unsigned int component); +template +void +DoFTools::distribute_cell_to_dof_vector > +(const DoFHandler &dof_handler, + const Vector &cell_data, + Vector &dof_data, + const unsigned int component); + +template +void +DoFTools::distribute_cell_to_dof_vector > +(const hp::DoFHandler &dof_handler, + const Vector &cell_data, + Vector &dof_data, + const unsigned int component); +template +void +DoFTools::distribute_cell_to_dof_vector > +(const hp::DoFHandler &dof_handler, + const Vector &cell_data, + Vector &dof_data, + const unsigned int component); + + +template void DoFTools::extract_dofs +(const DoFHandler&, + const std::vector&, std::vector&, bool); + +template void DoFTools::extract_dofs +(const hp::DoFHandler&, + const std::vector&, std::vector&, bool); + +template void DoFTools::extract_level_dofs +(const unsigned int level, const MGDoFHandler&, + const std::vector&, std::vector&, bool); + +template +void +DoFTools::extract_boundary_dofs > +(const DoFHandler &, + const std::vector &, + std::vector &, + const std::set &); +template +void +DoFTools::extract_boundary_dofs > +(const hp::DoFHandler &, + const std::vector &, + std::vector &, + const std::set &); + +template +void +DoFTools::extract_dofs_with_support_on_boundary > +(const DoFHandler &, + const std::vector &, + std::vector &, + const std::set &); +template +void +DoFTools::extract_dofs_with_support_on_boundary > +(const hp::DoFHandler &, + const std::vector &, + std::vector &, + const std::set &); + +template +void +DoFTools::extract_hanging_node_dofs +(const DoFHandler &dof_handler, + std::vector &selected_dofs); + +template +void +DoFTools::extract_subdomain_dofs > +(const DoFHandler &dof_handler, + const types::subdomain_id_t subdomain_id, + std::vector &selected_dofs); +template +void +DoFTools::extract_subdomain_dofs > +(const hp::DoFHandler &dof_handler, + const types::subdomain_id_t subdomain_id, + std::vector &selected_dofs); + +template +void +DoFTools::extract_locally_owned_dofs > +(const DoFHandler & dof_handler, + IndexSet & dof_set); + +template +void +DoFTools::extract_locally_active_dofs > +(const DoFHandler & dof_handler, + IndexSet & dof_set); + + +template +void +DoFTools::extract_locally_relevant_dofs > +(const DoFHandler & dof_handler, + IndexSet & dof_set); + +template +void +DoFTools::extract_constant_modes > +(const DoFHandler &dof_handler, + const std::vector &selected_components, + std::vector > &constant_modes); + +template +void +DoFTools::get_active_fe_indices > +(const DoFHandler &dof_handler, + std::vector &active_fe_indices); + +template +void +DoFTools::get_active_fe_indices > +(const hp::DoFHandler &dof_handler, + std::vector &active_fe_indices); + +template +void +DoFTools::get_subdomain_association > +(const DoFHandler &dof_handler, + std::vector &subdomain_association); +template +void +DoFTools::get_subdomain_association > +(const hp::DoFHandler &dof_handler, + std::vector &subdomain_association); + + +template +unsigned int +DoFTools::count_dofs_with_subdomain_association > +(const DoFHandler &, + const types::subdomain_id_t); +template +IndexSet +DoFTools::dof_indices_with_subdomain_association > +(const DoFHandler &, + const types::subdomain_id_t); +template +void +DoFTools::count_dofs_with_subdomain_association > +(const DoFHandler &, + const types::subdomain_id_t, + std::vector &); + +template +unsigned int +DoFTools::count_dofs_with_subdomain_association > +(const hp::DoFHandler &, + const types::subdomain_id_t); +template +IndexSet +DoFTools::dof_indices_with_subdomain_association > +(const hp::DoFHandler &, + const types::subdomain_id_t); +template +void +DoFTools::count_dofs_with_subdomain_association > +(const hp::DoFHandler &, + const types::subdomain_id_t, + std::vector &); + +template +unsigned int +DoFTools::count_dofs_with_subdomain_association > +(const MGDoFHandler &, + const types::subdomain_id_t); +template +IndexSet +DoFTools::dof_indices_with_subdomain_association > +(const MGDoFHandler &, + const types::subdomain_id_t); +template +void +DoFTools::count_dofs_with_subdomain_association > +(const MGDoFHandler &, + const types::subdomain_id_t, + std::vector &); + + +template +void +DoFTools::count_dofs_per_component ( + const DoFHandler&, + std::vector&, bool, std::vector); + +#if deal_II_dimension < 3 +template void DoFTools::extract_level_dofs +(const unsigned int level, const MGDoFHandler&, + const std::vector&, std::vector&, bool); + +template +void +DoFTools::count_dofs_per_component ( + const DoFHandler&, + std::vector&, bool, std::vector); +#endif + +template +void +DoFTools::count_dofs_per_block ( + const DoFHandler&, + std::vector&, std::vector); + + +template +void +DoFTools::count_dofs_per_component ( + const DoFHandler&, + std::vector&, std::vector); + +template +void +DoFTools::compute_intergrid_constraints ( + const DoFHandler &, const unsigned int, + const DoFHandler &, const unsigned int, + const InterGridMap > &, + ConstraintMatrix&); + +template +void +DoFTools::compute_intergrid_transfer_representation +(const DoFHandler &, const unsigned int, + const DoFHandler &, const unsigned int, + const InterGridMap > &, + std::vector > &); + + +template +void +DoFTools::map_dof_to_boundary_indices > +(const DoFHandler &, + const std::set &, + std::vector &); + +template +void +DoFTools::map_dof_to_boundary_indices > +(const DoFHandler &, + std::vector &); + + + +template +void +DoFTools::map_dof_to_boundary_indices > +(const hp::DoFHandler &, + const std::set &, + std::vector &); + +template +void +DoFTools::map_dof_to_boundary_indices > +(const hp::DoFHandler &, + std::vector &); + + + +template +void +DoFTools::map_dofs_to_support_points +(const Mapping&, + const DoFHandler&, + std::vector >&); + +#if deal_II_dimension < 3 + +template +void +DoFTools::map_dofs_to_support_points +(const Mapping&, + const DoFHandler&, + std::vector >&); + +template +void +DoFTools::count_dofs_per_block ( + const DoFHandler&, + std::vector&, std::vector); + +#endif + +template +void +DoFTools::convert_couplings_to_blocks ( + const DoFHandler&, const Table<2, Coupling>&, + std::vector >&); + +template +void +DoFTools::convert_couplings_to_blocks ( + const hp::DoFHandler&, const Table<2, Coupling>&, + std::vector >&); + +template +void +DoFTools::make_zero_boundary_constraints +(const DoFHandler &, + ConstraintMatrix &, + const std::vector &); + +template +void +DoFTools::make_zero_boundary_constraints +(const hp::DoFHandler &, + ConstraintMatrix &, + const std::vector &); + +#if deal_II_dimension < 3 + +template +void +DoFTools::map_dof_to_boundary_indices > +(const DoFHandler &, + const std::set &, + std::vector &); + +template +void +DoFTools::map_dof_to_boundary_indices > +(const DoFHandler &, + std::vector &); + + +template +void +DoFTools::extract_hanging_node_dofs +(const DoFHandler &dof_handler, + std::vector &selected_dofs); + +// template +// void +// DoFTools::map_dof_to_boundary_indices > +// (const hp::DoFHandler &, +// const std::set &, +// std::vector &); + +// template +// void +// DoFTools::map_dof_to_boundary_indices > +// (const hp::DoFHandler &, +// std::vector &); + +#endif + +} \ No newline at end of file diff --git a/deal.II/source/dofs/number_cache.all_dimensions.cc b/deal.II/source/dofs/number_cache.cc similarity index 100% rename from deal.II/source/dofs/number_cache.all_dimensions.cc rename to deal.II/source/dofs/number_cache.cc diff --git a/deal.II/source/hp/dof_faces.cc b/deal.II/source/hp/dof_faces.cc index 930a756068..2b35e74d11 100644 --- a/deal.II/source/hp/dof_faces.cc +++ b/deal.II/source/hp/dof_faces.cc @@ -22,28 +22,22 @@ namespace internal namespace hp { -#if deal_II_dimension == 1 - unsigned int DoFFaces<1>::memory_consumption () const { return 0; } -#endif -#if deal_II_dimension == 2 - + unsigned int DoFFaces<2>::memory_consumption () const { return MemoryConsumption::memory_consumption (lines); } -#endif -#if deal_II_dimension == 3 - + unsigned int DoFFaces<3>::memory_consumption () const { @@ -51,8 +45,6 @@ namespace internal MemoryConsumption::memory_consumption (quads) ); } -#endif - } } diff --git a/deal.II/source/hp/dof_handler.cc b/deal.II/source/hp/dof_handler.cc index 2995838cdf..6136a59aef 100644 --- a/deal.II/source/hp/dof_handler.cc +++ b/deal.II/source/hp/dof_handler.cc @@ -1603,7 +1603,7 @@ namespace hp == 0), ExcMessage ("The given triangulation is parallel distributed but " "this class does not currently support this.")); - + create_active_fe_table (); tria.add_refinement_listener (*this); } @@ -2664,8 +2664,6 @@ namespace hp //------------------------------------------------------------------ -#if deal_II_dimension == 1 - template <> unsigned int DoFHandler<1>::n_boundary_dofs () const { @@ -2791,9 +2789,6 @@ namespace hp -#endif - - template unsigned int DoFHandler::n_boundary_dofs () const { @@ -2902,7 +2897,6 @@ namespace hp } -#if deal_II_dimension == 2 template <> unsigned int DoFHandler<2,3>::n_boundary_dofs () const @@ -2911,6 +2905,8 @@ namespace hp return 0; } + + template <> unsigned int DoFHandler<2,3>::n_boundary_dofs (const FunctionMap &) const { @@ -2918,6 +2914,8 @@ namespace hp return 0; } + + template <> unsigned int DoFHandler<2,3>::n_boundary_dofs (const std::set &) const { @@ -2925,8 +2923,6 @@ namespace hp return 0; } -#endif - template @@ -3064,7 +3060,6 @@ namespace hp } -#if deal_II_dimension == 1 template <> void @@ -3072,13 +3067,15 @@ namespace hp compute_line_dof_identities (std::vector &) const {} + + template <> void DoFHandler<1,2>:: compute_line_dof_identities (std::vector &) const {} -#endif + template void @@ -3293,7 +3290,7 @@ namespace hp } } -#if deal_II_dimension == 1 + template <> void @@ -3307,10 +3304,7 @@ namespace hp compute_quad_dof_identities (std::vector &) const {} -#endif - -#if deal_II_dimension == 2 template <> void @@ -3319,6 +3313,7 @@ namespace hp {} + template <> void DoFHandler<2,3>:: @@ -3326,8 +3321,6 @@ namespace hp {} -#endif - template void @@ -3693,11 +3686,11 @@ namespace hp } -#if deal_II_dimension >= 2 - template + // TODO: should be simplified a bit + template<> void - DoFHandler:: + DoFHandler<2,2>:: renumber_dofs_internal (const std::vector &new_numbers, internal::int2type<2>) { @@ -3723,13 +3716,69 @@ namespace hp } } -#endif -#if deal_II_dimension >= 3 - template + template<> void - DoFHandler:: + DoFHandler<2,3>:: + renumber_dofs_internal (const std::vector &new_numbers, + internal::int2type<2>) + { + Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete()); + + renumber_dofs_internal (new_numbers, internal::int2type<1>()); + + for (quad_iterator quad=begin_quad(); quad!=end_quad(); ++quad) + { + const unsigned int n_active_fe_indices + = quad->n_active_fe_indices (); + + for (unsigned int f=0; fnth_active_fe_index (f); + + for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_quad; ++d) + quad->set_dof_index (d, + new_numbers[quad->dof_index(d,fe_index)], + fe_index); + } + } + } + + + template<> + void + DoFHandler<3,3>:: + renumber_dofs_internal (const std::vector &new_numbers, + internal::int2type<2>) + { + Assert (new_numbers.size() == n_dofs(), ExcRenumberingIncomplete()); + + renumber_dofs_internal (new_numbers, internal::int2type<1>()); + + for (quad_iterator quad=begin_quad(); quad!=end_quad(); ++quad) + { + const unsigned int n_active_fe_indices + = quad->n_active_fe_indices (); + + for (unsigned int f=0; fnth_active_fe_index (f); + + for (unsigned int d=0; d<(*finite_elements)[fe_index].dofs_per_quad; ++d) + quad->set_dof_index (d, + new_numbers[quad->dof_index(d,fe_index)], + fe_index); + } + } + } + + + template<> + void + DoFHandler<3,3>:: renumber_dofs_internal (const std::vector &new_numbers, internal::int2type<3>) { @@ -3755,7 +3804,6 @@ namespace hp } } -#endif template @@ -3872,7 +3920,6 @@ namespace hp -#if deal_II_dimension == 1 template <> void DoFHandler<1>::pre_refinement_notification (const Triangulation<1> &tria) { @@ -3931,7 +3978,7 @@ namespace hp has_children.push_back (has_children_level); } } -#endif + template @@ -4038,16 +4085,12 @@ namespace hp std::swap (vertex_dofs_offsets, tmp); } } +} -/*-------------- Explicit Instantiations -------------------------------*/ - template class DoFHandler; - -#if deal_II_dimension != 3 - template class DoFHandler; -#endif +/*-------------- Explicit Instantiations -------------------------------*/ +#include "dof_handler.inst" -} DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/hp/dof_handler.inst.in b/deal.II/source/hp/dof_handler.inst.in new file mode 100644 index 0000000000..3443bdff2c --- /dev/null +++ b/deal.II/source/hp/dof_handler.inst.in @@ -0,0 +1,24 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ + namespace hp + \{ + template class DoFHandler; + +#if deal_II_dimension != 3 + template class DoFHandler; +#endif + \} +} diff --git a/deal.II/source/hp/dof_levels.all_dimensions.cc b/deal.II/source/hp/dof_levels.all_dimensions.cc deleted file mode 100644 index 0667240893..0000000000 --- a/deal.II/source/hp/dof_levels.all_dimensions.cc +++ /dev/null @@ -1,34 +0,0 @@ -//---------------------------- hp_dof_levels.cc --------------------------- -// $Id$ -// Version: $Name$ -// -// Copyright (C) 2003, 2006 by the deal.II authors -// -// This file is subject to QPL and may not be distributed -// without copyright and license information. Please refer -// to the file deal.II/doc/license.html for the text and -// further information on this license. -// -//---------------------------- hp_dof_levels.cc ------------------------ - - -#include -#include - -DEAL_II_NAMESPACE_OPEN - -namespace internal -{ - namespace hp - { - - unsigned int - DoFLevel<0>::memory_consumption () const - { - return MemoryConsumption::memory_consumption (active_fe_indices); - } - - } -} - -DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/hp/dof_levels.cc b/deal.II/source/hp/dof_levels.cc index 01f6ffa032..2f7a74cd12 100644 --- a/deal.II/source/hp/dof_levels.cc +++ b/deal.II/source/hp/dof_levels.cc @@ -22,8 +22,6 @@ namespace internal namespace hp { -#if deal_II_dimension == 1 - unsigned int DoFLevel<1>::memory_consumption () const { @@ -31,10 +29,7 @@ namespace internal MemoryConsumption::memory_consumption (lines)); } -#endif - -#if deal_II_dimension == 2 unsigned int DoFLevel<2>::memory_consumption () const @@ -43,11 +38,8 @@ namespace internal MemoryConsumption::memory_consumption (quads)); } -#endif -#if deal_II_dimension == 3 - unsigned int DoFLevel<3>::memory_consumption () const { @@ -55,8 +47,14 @@ namespace internal MemoryConsumption::memory_consumption (hexes)); } -#endif + + unsigned int + DoFLevel<0>::memory_consumption () const + { + return MemoryConsumption::memory_consumption (active_fe_indices); + } + } } diff --git a/deal.II/source/hp/dof_objects.all_dimensions.cc b/deal.II/source/hp/dof_objects.cc similarity index 100% rename from deal.II/source/hp/dof_objects.all_dimensions.cc rename to deal.II/source/hp/dof_objects.cc diff --git a/deal.II/source/hp/fe_collection.cc b/deal.II/source/hp/fe_collection.cc index 9d39a53064..3d79d64c2d 100644 --- a/deal.II/source/hp/fe_collection.cc +++ b/deal.II/source/hp/fe_collection.cc @@ -21,17 +21,17 @@ namespace hp template FECollection::FECollection () {} - - + + template FECollection::FECollection (const FiniteElement &fe) { push_back (fe); } - - + + template FECollection:: FECollection (const FECollection &fe_collection) @@ -65,14 +65,14 @@ namespace hp Assert (new_fe.n_components() == finite_elements[0]->n_components(), ExcMessage ("All elements inside a collection need to have the " "same number of vector components!")); - + finite_elements .push_back (std_cxx1x::shared_ptr >(new_fe.clone())); } - template + template unsigned int FECollection::memory_consumption () const { @@ -84,15 +84,12 @@ namespace hp return mem; } +} + // explicit instantiations - template class FECollection; +#include "fe_collection.inst" -#if deal_II_dimension != 3 - template class FECollection; -#endif - -} DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/hp/fe_collection.inst.in b/deal.II/source/hp/fe_collection.inst.in new file mode 100644 index 0000000000..43909314e9 --- /dev/null +++ b/deal.II/source/hp/fe_collection.inst.in @@ -0,0 +1,24 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ + namespace hp + \{ + template class FECollection; + +#if deal_II_dimension != 3 + template class FECollection; +#endif + \} +} diff --git a/deal.II/source/hp/fe_values.cc b/deal.II/source/hp/fe_values.cc index 372d4b97c0..30b284914d 100644 --- a/deal.II/source/hp/fe_values.cc +++ b/deal.II/source/hp/fe_values.cc @@ -230,9 +230,9 @@ namespace hp template void FEValues::reinit (const typename MGDoFHandler::cell_iterator &cell, - const unsigned int q_index, - const unsigned int mapping_index, - const unsigned int fe_index) + const unsigned int q_index, + const unsigned int mapping_index, + const unsigned int fe_index) { // determine which indices we // should actually use @@ -270,9 +270,9 @@ namespace hp template void FEValues::reinit (const typename Triangulation::cell_iterator &cell, - const unsigned int q_index, - const unsigned int mapping_index, - const unsigned int fe_index) + const unsigned int q_index, + const unsigned int mapping_index, + const unsigned int fe_index) { // determine which indices we // should actually use @@ -336,10 +336,10 @@ namespace hp template void FEFaceValues::reinit (const typename hp::DoFHandler::cell_iterator &cell, - const unsigned int face_no, - const unsigned int q_index, - const unsigned int mapping_index, - const unsigned int fe_index) + const unsigned int face_no, + const unsigned int q_index, + const unsigned int mapping_index, + const unsigned int fe_index) { // determine which indices we // should actually use @@ -387,10 +387,10 @@ namespace hp template void FEFaceValues::reinit (const typename dealii::DoFHandler::cell_iterator &cell, - const unsigned int face_no, - const unsigned int q_index, - const unsigned int mapping_index, - const unsigned int fe_index) + const unsigned int face_no, + const unsigned int q_index, + const unsigned int mapping_index, + const unsigned int fe_index) { // determine which indices we // should actually use @@ -428,10 +428,10 @@ namespace hp template void FEFaceValues::reinit (const typename MGDoFHandler::cell_iterator &cell, - const unsigned int face_no, - const unsigned int q_index, - const unsigned int mapping_index, - const unsigned int fe_index) + const unsigned int face_no, + const unsigned int q_index, + const unsigned int mapping_index, + const unsigned int fe_index) { // determine which indices we // should actually use @@ -469,10 +469,10 @@ namespace hp template void FEFaceValues::reinit (const typename Triangulation::cell_iterator &cell, - const unsigned int face_no, - const unsigned int q_index, - const unsigned int mapping_index, - const unsigned int fe_index) + const unsigned int face_no, + const unsigned int q_index, + const unsigned int mapping_index, + const unsigned int fe_index) { // determine which indices we // should actually use @@ -536,11 +536,11 @@ namespace hp template void FESubfaceValues::reinit (const typename hp::DoFHandler::cell_iterator &cell, - const unsigned int face_no, - const unsigned int subface_no, - const unsigned int q_index, - const unsigned int mapping_index, - const unsigned int fe_index) + const unsigned int face_no, + const unsigned int subface_no, + const unsigned int q_index, + const unsigned int mapping_index, + const unsigned int fe_index) { // determine which indices we // should actually use @@ -588,11 +588,11 @@ namespace hp template void FESubfaceValues::reinit (const typename dealii::DoFHandler::cell_iterator &cell, - const unsigned int face_no, - const unsigned int subface_no, - const unsigned int q_index, - const unsigned int mapping_index, - const unsigned int fe_index) + const unsigned int face_no, + const unsigned int subface_no, + const unsigned int q_index, + const unsigned int mapping_index, + const unsigned int fe_index) { // determine which indices we // should actually use @@ -630,11 +630,11 @@ namespace hp template void FESubfaceValues::reinit (const typename MGDoFHandler::cell_iterator &cell, - const unsigned int face_no, - const unsigned int subface_no, - const unsigned int q_index, - const unsigned int mapping_index, - const unsigned int fe_index) + const unsigned int face_no, + const unsigned int subface_no, + const unsigned int q_index, + const unsigned int mapping_index, + const unsigned int fe_index) { // determine which indices we // should actually use @@ -672,11 +672,11 @@ namespace hp template void FESubfaceValues::reinit (const typename Triangulation::cell_iterator &cell, - const unsigned int face_no, - const unsigned int subface_no, - const unsigned int q_index, - const unsigned int mapping_index, - const unsigned int fe_index) + const unsigned int face_no, + const unsigned int subface_no, + const unsigned int q_index, + const unsigned int mapping_index, + const unsigned int fe_index) { // determine which indices we // should actually use @@ -712,60 +712,7 @@ namespace hp // explicit instantiations -namespace internal -{ - namespace hp - { - template class FEValuesBase >; -#if deal_II_dimension >= 2 - template class FEValuesBase >; - template class FEValuesBase >; -#endif - } -} - -namespace hp -{ - template class FEValues; -#if deal_II_dimension >= 2 - template class FEFaceValues; - template class FESubfaceValues; -#endif -} - - - -#if deal_II_dimension != 3 - -namespace internal -{ - namespace hp - { - template class FEValuesBase >; -#if deal_II_dimension == 2 - template class FEValuesBase >; - template class FEValuesBase >; -#endif - } -} - -namespace hp -{ - template class FEValues; - -#if deal_II_dimension == 2 - template class FEFaceValues; - template class FESubfaceValues; -#endif -} -#endif - +#include "fe_values.inst" DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/hp/fe_values.inst.in b/deal.II/source/hp/fe_values.inst.in new file mode 100644 index 0000000000..ef3e27d3c8 --- /dev/null +++ b/deal.II/source/hp/fe_values.inst.in @@ -0,0 +1,68 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ +namespace internal +\{ + namespace hp + \{ + template class FEValuesBase >; +#if deal_II_dimension >= 2 + template class FEValuesBase >; + template class FEValuesBase >; +#endif + \} +\} + +namespace hp +\{ + template class FEValues; +#if deal_II_dimension >= 2 + template class FEFaceValues; + template class FESubfaceValues; +#endif +\} + + + +#if deal_II_dimension != 3 + +namespace internal +\{ + namespace hp + \{ + template class FEValuesBase >; +#if deal_II_dimension >= 2 + template class FEValuesBase >; + template class FEValuesBase >; +#endif + \} +\} + +namespace hp +\{ + template class FEValues; +#if deal_II_dimension >= 2 + template class FEFaceValues; + template class FESubfaceValues; +#endif +\} +#endif +} diff --git a/deal.II/source/hp/mapping_collection.cc b/deal.II/source/hp/mapping_collection.cc index 3a9955d308..fde4d682b0 100644 --- a/deal.II/source/hp/mapping_collection.cc +++ b/deal.II/source/hp/mapping_collection.cc @@ -25,7 +25,7 @@ namespace hp {} - + template MappingCollection:: MappingCollection (const Mapping &mapping) @@ -54,8 +54,8 @@ namespace hp // mappings mappings (mapping_collection.mappings) {} - - + + template unsigned int @@ -65,7 +65,7 @@ namespace hp MemoryConsumption::memory_consumption (mappings)); } - + template void @@ -82,23 +82,19 @@ namespace hp template MappingQ1 StaticMappingQ1::mapping_q1; - + template MappingCollection StaticMappingQ1::mapping_collection = MappingCollection(mapping_q1); -// explicit instantiations - template class MappingCollection; - template struct StaticMappingQ1; +} -#if deal_II_dimension != 3 - template class MappingCollection; - template struct StaticMappingQ1; -#endif - -} + +// explicit instantiations +#include "mapping_collection.inst" + DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/hp/mapping_collection.inst.in b/deal.II/source/hp/mapping_collection.inst.in new file mode 100644 index 0000000000..6b76bab2d7 --- /dev/null +++ b/deal.II/source/hp/mapping_collection.inst.in @@ -0,0 +1,26 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ + namespace hp + \{ + template class MappingCollection; + template struct StaticMappingQ1; + +#if deal_II_dimension != 3 + template class MappingCollection; + template struct StaticMappingQ1; +#endif + \} +} diff --git a/deal.II/source/multigrid/mg_base.all_dimensions.cc b/deal.II/source/multigrid/mg_base.cc similarity index 100% rename from deal.II/source/multigrid/mg_base.all_dimensions.cc rename to deal.II/source/multigrid/mg_base.cc diff --git a/deal.II/source/multigrid/mg_dof_accessor.cc b/deal.II/source/multigrid/mg_dof_accessor.cc index d76a13a0cf..b5efa2acfc 100644 --- a/deal.II/source/multigrid/mg_dof_accessor.cc +++ b/deal.II/source/multigrid/mg_dof_accessor.cc @@ -577,129 +577,8 @@ neighbor_child_on_subface (const unsigned int face, - // explicit instantiations +#include "mg_dof_accessor.inst" -template -void -MGDoFAccessor<1,deal_II_dimension>:: -get_mg_dof_values (const int level, - const Vector &values, - Vector &dof_values) const; - -template -void -MGDoFAccessor<1,deal_II_dimension>:: -get_mg_dof_values (const int level, - const Vector &values, - Vector &dof_values) const; - - -#if deal_II_dimension >= 2 - -template -void -MGDoFAccessor<2,deal_II_dimension>:: -get_mg_dof_values (const int level, - const Vector &values, - Vector &dof_values) const; - -template -void -MGDoFAccessor<2,deal_II_dimension>:: -get_mg_dof_values (const int level, - const Vector &values, - Vector &dof_values) const; - -#endif - - -#if deal_II_dimension >= 3 - -template -void -MGDoFAccessor<3,deal_II_dimension>:: -get_mg_dof_values (const int level, - const Vector &values, - Vector &dof_values) const; - -template -void -MGDoFAccessor<3,deal_II_dimension>:: -get_mg_dof_values (const int level, - const Vector &values, - Vector &dof_values) const; - -#endif -template -void -MGDoFCellAccessor:: -get_mg_dof_values (const Vector &values, - Vector &dof_values) const; - -template -void -MGDoFCellAccessor:: -get_mg_dof_values (const Vector &values, - Vector &dof_values) const; - - - - -#if deal_II_dimension == 1 -template class MGDoFAccessor<1, 1, 1>; -template class MGDoFAccessor<1, 1, 2>; - -template class MGDoFCellAccessor<1>; -template class MGDoFCellAccessor<1,2>; - -template class TriaRawIterator >; -template class TriaIterator >; -template class TriaActiveIterator >; -#endif - -#if deal_II_dimension == 2 -template class MGDoFAccessor<1, 2, 2>; -template class MGDoFAccessor<2, 2, 2>; - -template class MGDoFAccessor<1, 2, 3>; -template class MGDoFAccessor<2, 2, 3>; - -template class MGDoFCellAccessor<2>; -template class MGDoFCellAccessor<2,3>; - -template class TriaRawIterator >; -template class TriaIterator >; -template class TriaActiveIterator >; - -template class TriaRawIterator >; -template class TriaIterator >; -template class TriaActiveIterator >; - -template class TriaRawIterator >; -template class TriaIterator >; -template class TriaActiveIterator >; -#endif - - -#if deal_II_dimension == 3 -template class MGDoFAccessor<1, 3, 3>; -template class MGDoFAccessor<2, 3, 3>; -template class MGDoFAccessor<3, 3, 3>; - -template class MGDoFCellAccessor<3>; - -template class TriaRawIterator >; -template class TriaIterator >; -template class TriaActiveIterator >; - -template class TriaRawIterator >; -template class TriaIterator >; -template class TriaActiveIterator >; - -template class TriaRawIterator >; -template class TriaIterator >; -template class TriaActiveIterator >; -#endif DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/multigrid/mg_dof_accessor.inst.in b/deal.II/source/multigrid/mg_dof_accessor.inst.in new file mode 100644 index 0000000000..4888f59abb --- /dev/null +++ b/deal.II/source/multigrid/mg_dof_accessor.inst.in @@ -0,0 +1,140 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +for (deal_II_dimension : DIMENSIONS) + { + template + void + MGDoFAccessor<1,deal_II_dimension>:: + get_mg_dof_values (const int level, + const Vector &values, + Vector &dof_values) const; + + template + void + MGDoFAccessor<1,deal_II_dimension>:: + get_mg_dof_values (const int level, + const Vector &values, + Vector &dof_values) const; + + +#if deal_II_dimension >= 2 + + template + void + MGDoFAccessor<2,deal_II_dimension>:: + get_mg_dof_values (const int level, + const Vector &values, + Vector &dof_values) const; + + template + void + MGDoFAccessor<2,deal_II_dimension>:: + get_mg_dof_values (const int level, + const Vector &values, + Vector &dof_values) const; + +#endif + + +#if deal_II_dimension >= 3 + + template + void + MGDoFAccessor<3,deal_II_dimension>:: + get_mg_dof_values (const int level, + const Vector &values, + Vector &dof_values) const; + + template + void + MGDoFAccessor<3,deal_II_dimension>:: + get_mg_dof_values (const int level, + const Vector &values, + Vector &dof_values) const; + +#endif + + template + void + MGDoFCellAccessor:: + get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + + template + void + MGDoFCellAccessor:: + get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + + + + +#if deal_II_dimension == 1 + template class MGDoFAccessor<1, 1, 1>; + template class MGDoFAccessor<1, 1, 2>; + + template class MGDoFCellAccessor<1>; + template class MGDoFCellAccessor<1,2>; + + template class TriaRawIterator >; + template class TriaIterator >; + template class TriaActiveIterator >; +#endif + +#if deal_II_dimension == 2 + template class MGDoFAccessor<1, 2, 2>; + template class MGDoFAccessor<2, 2, 2>; + + template class MGDoFAccessor<1, 2, 3>; + template class MGDoFAccessor<2, 2, 3>; + + template class MGDoFCellAccessor<2>; + template class MGDoFCellAccessor<2,3>; + + template class TriaRawIterator >; + template class TriaIterator >; + template class TriaActiveIterator >; + + template class TriaRawIterator >; + template class TriaIterator >; + template class TriaActiveIterator >; + + template class TriaRawIterator >; + template class TriaIterator >; + template class TriaActiveIterator >; +#endif + + +#if deal_II_dimension == 3 + template class MGDoFAccessor<1, 3, 3>; + template class MGDoFAccessor<2, 3, 3>; + template class MGDoFAccessor<3, 3, 3>; + + template class MGDoFCellAccessor<3>; + + template class TriaRawIterator >; + template class TriaIterator >; + template class TriaActiveIterator >; + + template class TriaRawIterator >; + template class TriaIterator >; + template class TriaActiveIterator >; + + template class TriaRawIterator >; + template class TriaIterator >; + template class TriaActiveIterator >; +#endif + } + diff --git a/deal.II/source/multigrid/mg_dof_handler.cc b/deal.II/source/multigrid/mg_dof_handler.cc index cc03d6bdf3..a1628dadf1 100644 --- a/deal.II/source/multigrid/mg_dof_handler.cc +++ b/deal.II/source/multigrid/mg_dof_handler.cc @@ -2034,8 +2034,6 @@ unsigned int MGDoFHandler::n_dofs (const unsigned int level) const -#if deal_II_dimension == 1 - template <> void MGDoFHandler<1>::renumber_dofs (const unsigned int level, const std::vector &new_numbers) { @@ -2069,11 +2067,7 @@ void MGDoFHandler<1>::renumber_dofs (const unsigned int level, } } -#endif - - -#if deal_II_dimension == 2 template <> void MGDoFHandler<2>::renumber_dofs (const unsigned int level, @@ -2134,11 +2128,7 @@ void MGDoFHandler<2>::renumber_dofs (const unsigned int level, } } -#endif - - -#if deal_II_dimension == 3 template <> void MGDoFHandler<3>::renumber_dofs (const unsigned int level, @@ -2235,8 +2225,6 @@ void MGDoFHandler<3>::renumber_dofs (const unsigned int level, } } -#endif - template @@ -2269,112 +2257,7 @@ void MGDoFHandler::clear_space () // explicit instantiations -template class MGDoFHandler; - -#if deal_II_dimension==1 || deal_II_dimension==2 -template class MGDoFHandler; -#endif +#include "mg_dof_handler.inst" -template -unsigned int -MGDoFHandler:: -get_dof_index<1> (const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index) const; - -#if deal_II_dimension < 3 -template -unsigned int -MGDoFHandler:: -get_dof_index<1> (const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index) const; -#endif - -#if deal_II_dimension >= 2 -template -unsigned int -MGDoFHandler:: -get_dof_index<2> (const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index) const; - -#if deal_II_dimension < 3 -template -unsigned int -MGDoFHandler:: -get_dof_index<2> (const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index) const; -#endif - -#if deal_II_dimension >= 3 -template -unsigned int -MGDoFHandler:: -get_dof_index<3> (const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index) const; -#endif -#endif - -template -void -MGDoFHandler:: -set_dof_index<1> (const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index) const; - -#if deal_II_dimension < 3 -template -void -MGDoFHandler:: -set_dof_index<1> (const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index) const; -#endif - -#if deal_II_dimension >= 2 -template -void -MGDoFHandler:: -set_dof_index<2> (const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index) const; - -#if deal_II_dimension < 3 -template -void -MGDoFHandler:: -set_dof_index<2> (const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index) const; -#endif - -#if deal_II_dimension >= 3 -template -void -MGDoFHandler:: -set_dof_index<3> (const unsigned int obj_level, - const unsigned int obj_index, - const unsigned int fe_index, - const unsigned int local_index, - const unsigned int global_index) const; -#endif -#endif - DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/multigrid/mg_dof_handler.inst.in b/deal.II/source/multigrid/mg_dof_handler.inst.in new file mode 100644 index 0000000000..f6aad8cb83 --- /dev/null +++ b/deal.II/source/multigrid/mg_dof_handler.inst.in @@ -0,0 +1,125 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +for (deal_II_dimension : DIMENSIONS) + { +template class MGDoFHandler; + +#if deal_II_dimension==1 || deal_II_dimension==2 +template class MGDoFHandler; +#endif + + +template +unsigned int +MGDoFHandler:: +get_dof_index<1> (const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index) const; + +#if deal_II_dimension < 3 +template +unsigned int +MGDoFHandler:: +get_dof_index<1> (const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index) const; +#endif + +#if deal_II_dimension >= 2 +template +unsigned int +MGDoFHandler:: +get_dof_index<2> (const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index) const; + +#if deal_II_dimension < 3 +template +unsigned int +MGDoFHandler:: +get_dof_index<2> (const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index) const; +#endif + +#if deal_II_dimension >= 3 +template +unsigned int +MGDoFHandler:: +get_dof_index<3> (const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index) const; +#endif +#endif + +template +void +MGDoFHandler:: +set_dof_index<1> (const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index) const; + +#if deal_II_dimension < 3 +template +void +MGDoFHandler:: +set_dof_index<1> (const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index) const; +#endif + +#if deal_II_dimension >= 2 +template +void +MGDoFHandler:: +set_dof_index<2> (const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index) const; + +#if deal_II_dimension < 3 +template +void +MGDoFHandler:: +set_dof_index<2> (const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index) const; +#endif + +#if deal_II_dimension >= 3 +template +void +MGDoFHandler:: +set_dof_index<3> (const unsigned int obj_level, + const unsigned int obj_index, + const unsigned int fe_index, + const unsigned int local_index, + const unsigned int global_index) const; +#endif +#endif + } + diff --git a/deal.II/source/multigrid/mg_tools.all_dimensions.cc b/deal.II/source/multigrid/mg_tools.all_dimensions.cc deleted file mode 100644 index 8a7fbba6f1..0000000000 --- a/deal.II/source/multigrid/mg_tools.all_dimensions.cc +++ /dev/null @@ -1,445 +0,0 @@ -//--------------------------------------------------------------------------- -// $Id$ -// Version: $Name$ -// -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2010 by the deal.II authors -// -// This file is subject to QPL and may not be distributed -// without copyright and license information. Please refer -// to the file deal.II/doc/license.html for the text and -// further information on this license. -// -//--------------------------------------------------------------------------- - - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -DEAL_II_NAMESPACE_OPEN - - -template -void -MGTools::apply_boundary_values ( - const std::set &boundary_dofs, - SparseMatrix& matrix, - const bool preserve_symmetry, - const bool ignore_zeros) -{ - // if no boundary values are to be applied - // simply return - if (boundary_dofs.size() == 0) - return; - - - const unsigned int n_dofs = matrix.m(); - - // if a diagonal entry is zero - // later, then we use another - // number instead. take it to be - // the first nonzero diagonal - // element of the matrix, or 1 if - // there is no such thing - number first_nonzero_diagonal_entry = 1; - for (unsigned int i=0; i::const_iterator dof = boundary_dofs.begin(), - endd = boundary_dofs.end(); - const SparsityPattern &sparsity = matrix.get_sparsity_pattern(); - const std::size_t *sparsity_rowstart = sparsity.get_rowstart_indices(); - const unsigned int *sparsity_colnums = sparsity.get_column_numbers(); - for (; dof != endd; ++dof) - { - Assert (*dof < n_dofs, ExcInternalError()); - - const unsigned int dof_number = *dof; - // for each boundary dof: - - // set entries of this line - // to zero except for the diagonal - // entry. Note that the diagonal - // entry is always the first one - // for square matrices, i.e. - // we shall not set - // matrix.global_entry( - // sparsity_rowstart[dof.first]) - const unsigned int last = sparsity_rowstart[dof_number+1]; - for (unsigned int j=sparsity_rowstart[dof_number]+1; j -void -MGTools::apply_boundary_values ( - const std::set& boundary_dofs, - BlockSparseMatrix& matrix, - const bool preserve_symmetry) -{ - const unsigned int blocks = matrix.n_block_rows(); - - Assert (matrix.n_block_rows() == matrix.n_block_cols(), - ExcNotQuadratic()); - Assert (matrix.get_sparsity_pattern().get_row_indices() == - matrix.get_sparsity_pattern().get_column_indices(), - ExcNotQuadratic()); - - for (unsigned int i=0; i::const_iterator dof = boundary_dofs.begin(), - endd = boundary_dofs.end(); - const BlockSparsityPattern & - sparsity_pattern = matrix.get_sparsity_pattern(); - - // pointer to the mapping between - // global and block indices. since - // the row and column mappings are - // equal, store a pointer on only - // one of them - const BlockIndices & - index_mapping = sparsity_pattern.get_column_indices(); - - // now loop over all boundary dofs - for (; dof != endd; ++dof) - { - Assert (*dof < n_dofs, ExcInternalError()); - - // get global index and index - // in the block in which this - // dof is located - const unsigned int dof_number = *dof; - const std::pair - block_index = index_mapping.global_to_local (dof_number); - - // for each boundary dof: - - // set entries of this line - // to zero except for the diagonal - // entry. Note that the diagonal - // entry is always the first one - // for square matrices, i.e. - // we shall not set - // matrix.global_entry( - // sparsity_rowstart[dof.first]) - // of the diagonal block - for (unsigned int block_col=0; block_col&, - SparseMatrix&, const bool, const bool); -template void MGTools::apply_boundary_values ( - const std::set&, - SparseMatrix&, const bool, const bool); -template void MGTools::apply_boundary_values ( - const std::set&, - BlockSparseMatrix&, const bool); -template void MGTools::apply_boundary_values ( - const std::set&, - BlockSparseMatrix&, const bool); - -DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/multigrid/mg_tools.cc b/deal.II/source/multigrid/mg_tools.cc index 825ecbfba9..fd9cd968de 100644 --- a/deal.II/source/multigrid/mg_tools.cc +++ b/deal.II/source/multigrid/mg_tools.cc @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -37,12 +40,12 @@ DEAL_II_NAMESPACE_OPEN -#if deal_II_dimension == 1 -template + // specializations for 1D +template <> void MGTools::compute_row_length_vector( - const MGDoFHandler&, + const MGDoFHandler<1,1>&, const unsigned int, std::vector&, const DoFTools::Coupling) @@ -51,10 +54,11 @@ MGTools::compute_row_length_vector( } -template + +template <> void MGTools::compute_row_length_vector( - const MGDoFHandler&, + const MGDoFHandler<1,1>&, const unsigned int, std::vector&, const Table<2,DoFTools::Coupling>&, @@ -63,7 +67,33 @@ MGTools::compute_row_length_vector( Assert(false, ExcNotImplemented()); } -#else + + +template <> +void +MGTools::compute_row_length_vector( + const MGDoFHandler<1,2>&, + const unsigned int, + std::vector&, + const DoFTools::Coupling) +{ + Assert(false, ExcNotImplemented()); +} + + +template <> +void +MGTools::compute_row_length_vector( + const MGDoFHandler<1,2>&, + const unsigned int, + std::vector&, + const Table<2,DoFTools::Coupling>&, + const Table<2,DoFTools::Coupling>&) +{ + Assert(false, ExcNotImplemented()); +} + + // Template for 2D and 3D. For 1D see specialization above template @@ -497,7 +527,7 @@ MGTools::compute_row_length_vector( } user_flags_triangulation.load_user_flags(old_flags); } -#endif + template @@ -646,9 +676,6 @@ MGTools::make_flux_sparsity_pattern_edge ( - - - template void MGTools::make_flux_sparsity_pattern ( @@ -905,6 +932,7 @@ MGTools::make_flux_sparsity_pattern_edge ( } + template void MGTools:: @@ -1017,6 +1045,7 @@ count_dofs_per_component (const MGDoFHandler &dof_handler, } + template void MGTools::count_dofs_per_block ( @@ -1097,13 +1126,25 @@ MGTools::count_dofs_per_block ( } -#if deal_II_dimension == 1 -template +template <> +void +MGTools::make_boundary_list( + const MGDoFHandler<1,1>&, + const typename FunctionMap<1>::type&, + std::vector >&, + const std::vector&) +{ + Assert(false, ExcNotImplemented()); +} + + + +template <> void MGTools::make_boundary_list( - const MGDoFHandler&, - const typename FunctionMap::type&, + const MGDoFHandler<1,2>&, + const typename FunctionMap<1>::type&, std::vector >&, const std::vector&) { @@ -1111,7 +1152,6 @@ MGTools::make_boundary_list( } -#else template void @@ -1326,7 +1366,6 @@ MGTools::make_boundary_list( } } -#endif template @@ -1353,31 +1392,56 @@ make_boundary_list(const MGDoFHandler& dof, } -#if deal_II_dimension == 1 -template +template <> void MGTools:: extract_inner_interface_dofs ( - const MGDoFHandler&, + const MGDoFHandler<1,1>&, std::vector > &, std::vector > &) { Assert(false, ExcNotImplemented()); } -template + + +template <> void MGTools:: extract_inner_interface_dofs ( - const MGDoFHandler&, + const MGDoFHandler<1,1>&, + std::vector > &) +{ + Assert(false, ExcNotImplemented()); +} + + + +template <> +void +MGTools:: +extract_inner_interface_dofs ( + const MGDoFHandler<1,2>&, + std::vector > &, + std::vector > &) +{ + Assert(false, ExcNotImplemented()); +} + + + +template <> +void +MGTools:: +extract_inner_interface_dofs ( + const MGDoFHandler<1,2>&, std::vector > &) { Assert(false, ExcNotImplemented()); } -#else template void @@ -1443,6 +1507,7 @@ extract_inner_interface_dofs (const MGDoFHandler &mg_dof_handler, } + template void MGTools:: @@ -1538,102 +1603,426 @@ extract_inner_interface_dofs (const MGDoFHandler &mg_dof_handler, } } -#endif -DEAL_II_NAMESPACE_CLOSE - +template +void +MGTools::apply_boundary_values ( + const std::set &boundary_dofs, + SparseMatrix& matrix, + const bool preserve_symmetry, + const bool ignore_zeros) +{ + // if no boundary values are to be applied + // simply return + if (boundary_dofs.size() == 0) + return; -// explicit instantiations + const unsigned int n_dofs = matrix.m(); + + // if a diagonal entry is zero + // later, then we use another + // number instead. take it to be + // the first nonzero diagonal + // element of the matrix, or 1 if + // there is no such thing + number first_nonzero_diagonal_entry = 1; + for (unsigned int i=0; i::const_iterator dof = boundary_dofs.begin(), + endd = boundary_dofs.end(); + const SparsityPattern &sparsity = matrix.get_sparsity_pattern(); + const std::size_t *sparsity_rowstart = sparsity.get_rowstart_indices(); + const unsigned int *sparsity_colnums = sparsity.get_column_numbers(); + for (; dof != endd; ++dof) + { + Assert (*dof < n_dofs, ExcInternalError()); + + const unsigned int dof_number = *dof; + // for each boundary dof: + + // set entries of this line + // to zero except for the diagonal + // entry. Note that the diagonal + // entry is always the first one + // for square matrices, i.e. + // we shall not set + // matrix.global_entry( + // sparsity_rowstart[dof.first]) + const unsigned int last = sparsity_rowstart[dof_number+1]; + for (unsigned int j=sparsity_rowstart[dof_number]+1; j +void +MGTools::apply_boundary_values ( + const std::set& boundary_dofs, + BlockSparseMatrix& matrix, + const bool preserve_symmetry) +{ + const unsigned int blocks = matrix.n_block_rows(); -#define PATTERN CompressedSimpleSparsityPattern -#include "mg_tools.pattern.in.h" -#undef PATTERN + Assert (matrix.n_block_rows() == matrix.n_block_cols(), + ExcNotQuadratic()); + Assert (matrix.get_sparsity_pattern().get_row_indices() == + matrix.get_sparsity_pattern().get_column_indices(), + ExcNotQuadratic()); -#define PATTERN BlockSparsityPattern -#include "mg_tools.pattern.in.h" -#undef PATTERN + for (unsigned int i=0; i&, unsigned int, - std::vector&, const DoFTools::Coupling); -template void -MGTools::compute_row_length_vector( - const MGDoFHandler&, unsigned int, - std::vector&, - const Table<2,DoFTools::Coupling>&, const Table<2,DoFTools::Coupling>&); - -template void MGTools::count_dofs_per_component ( - const MGDoFHandler&, std::vector >&, - bool, std::vector); -template void MGTools::count_dofs_per_component ( - const MGDoFHandler&, std::vector >&, - std::vector); -template void MGTools::count_dofs_per_block ( - const MGDoFHandler&, std::vector >&, - std::vector); - -template void MGTools::make_boundary_list( - const MGDoFHandler&, - const FunctionMap::type&, - std::vector >&, - const std::vector&); + // if a diagonal entry is zero + // later, then we use another + // number instead. take it to be + // the first nonzero diagonal + // element of the matrix, or 1 if + // there is no such thing + number first_nonzero_diagonal_entry = 0; + for (unsigned int diag_block=0; diag_block::const_iterator dof = boundary_dofs.begin(), + endd = boundary_dofs.end(); + const BlockSparsityPattern & + sparsity_pattern = matrix.get_sparsity_pattern(); + + // pointer to the mapping between + // global and block indices. since + // the row and column mappings are + // equal, store a pointer on only + // one of them + const BlockIndices & + index_mapping = sparsity_pattern.get_column_indices(); + + // now loop over all boundary dofs + for (; dof != endd; ++dof) + { + Assert (*dof < n_dofs, ExcInternalError()); + + // get global index and index + // in the block in which this + // dof is located + const unsigned int dof_number = *dof; + const std::pair + block_index = index_mapping.global_to_local (dof_number); + + // for each boundary dof: + + // set entries of this line + // to zero except for the diagonal + // entry. Note that the diagonal + // entry is always the first one + // for square matrices, i.e. + // we shall not set + // matrix.global_entry( + // sparsity_rowstart[dof.first]) + // of the diagonal block + for (unsigned int block_col=0; block_col&, - const FunctionMap::type&, - std::vector&, - const std::vector&); + matrix.block(block_index.first, block_index.first) + .diag_element(block_index.second) + = first_nonzero_diagonal_entry; + + // if the user wants to have + // the symmetry of the matrix + // preserved, and if the + // sparsity pattern is + // symmetric, then do a Gauss + // elimination step with the + // present row. this is a + // little more complicated for + // block matrices. + if (preserve_symmetry) + { + // we have to loop over all + // rows of the matrix which + // have a nonzero entry in + // the column which we work + // in presently. if the + // sparsity pattern is + // symmetric, then we can + // get the positions of + // these rows cheaply by + // looking at the nonzero + // column numbers of the + // present row. + // + // note that if we check + // whether row @p{row} in + // block (r,c) is non-zero, + // then we have to check + // for the existence of + // column @p{row} in block + // (c,r), i.e. of the + // transpose block + for (unsigned int block_row=0; block_row &mg_dof_handler, - std::vector > &interface_dofs, - std::vector > &boundary_interface_dofs); -template -void -MGTools:: -extract_inner_interface_dofs (const MGDoFHandler &mg_dof_handler, - std::vector > &interface_dofs); -#if deal_II_dimension < 3 -template void MGTools::count_dofs_per_block ( - const MGDoFHandler&, - std::vector >&, std::vector); +// explicit instantiations +#include "mg_tools.inst" + +template void MGTools::apply_boundary_values ( + const std::set&, + SparseMatrix&, const bool, const bool); +template void MGTools::apply_boundary_values ( + const std::set&, + SparseMatrix&, const bool, const bool); +template void MGTools::apply_boundary_values ( + const std::set&, + BlockSparseMatrix&, const bool); +template void MGTools::apply_boundary_values ( + const std::set&, + BlockSparseMatrix&, const bool); -#endif DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/multigrid/mg_tools.inst.in b/deal.II/source/multigrid/mg_tools.inst.in new file mode 100644 index 0000000000..26ccd68f16 --- /dev/null +++ b/deal.II/source/multigrid/mg_tools.inst.in @@ -0,0 +1,110 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +for (PATTERN : SPARSITY_PATTERNS; deal_II_dimension : DIMENSIONS) +{ +template void +MGTools::make_sparsity_pattern ( + const MGDoFHandler &, + PATTERN &, + const unsigned int); + +template void +MGTools::make_flux_sparsity_pattern ( + const MGDoFHandler &, + PATTERN &, + const unsigned int); + +template void +MGTools::make_flux_sparsity_pattern_edge ( + const MGDoFHandler &, + PATTERN &, + const unsigned int); + +#if deal_II_dimension > 1 + +template void +MGTools::make_flux_sparsity_pattern ( + const MGDoFHandler &, + PATTERN &, + const unsigned int, + const Table<2,DoFTools::Coupling>&, + const Table<2,DoFTools::Coupling>&); + +template void +MGTools::make_flux_sparsity_pattern_edge ( + const MGDoFHandler &, + PATTERN &, + const unsigned int, + const Table<2,DoFTools::Coupling>&); + +#endif +} + + +for (deal_II_dimension : DIMENSIONS) + { +template void +MGTools::compute_row_length_vector( + const MGDoFHandler&, unsigned int, + std::vector&, const DoFTools::Coupling); +template void +MGTools::compute_row_length_vector( + const MGDoFHandler&, unsigned int, + std::vector&, + const Table<2,DoFTools::Coupling>&, const Table<2,DoFTools::Coupling>&); + +template void MGTools::count_dofs_per_component ( + const MGDoFHandler&, std::vector >&, + bool, std::vector); +template void MGTools::count_dofs_per_component ( + const MGDoFHandler&, std::vector >&, + std::vector); +template void MGTools::count_dofs_per_block ( + const MGDoFHandler&, std::vector >&, + std::vector); + +template void MGTools::make_boundary_list( + const MGDoFHandler&, + const FunctionMap::type&, + std::vector >&, + const std::vector&); + +template void MGTools::make_boundary_list( + const MGDoFHandler&, + const FunctionMap::type&, + std::vector&, + const std::vector&); + +template +void +MGTools:: +extract_inner_interface_dofs (const MGDoFHandler &mg_dof_handler, + std::vector > &interface_dofs, + std::vector > &boundary_interface_dofs); +template +void +MGTools:: +extract_inner_interface_dofs (const MGDoFHandler &mg_dof_handler, + std::vector > &interface_dofs); + +#if deal_II_dimension < 3 + +template void MGTools::count_dofs_per_block ( + const MGDoFHandler&, + std::vector >&, std::vector); + +#endif + } + diff --git a/deal.II/source/multigrid/mg_tools.pattern.in.h b/deal.II/source/multigrid/mg_tools.pattern.in.h deleted file mode 100644 index 397d6c622b..0000000000 --- a/deal.II/source/multigrid/mg_tools.pattern.in.h +++ /dev/null @@ -1,61 +0,0 @@ -//--------------------------------------------------------------------------- -// $Id$ -// Version: $Name$ -// -// Copyright (C) 2002, 2003, 2005, 2006 by the deal.II authors -// -// This file is subject to QPL and may not be distributed -// without copyright and license information. Please refer -// to the file deal.II/doc/license.html for the text and -// further information on this license. -// -//--------------------------------------------------------------------------- - -// Driver file for MGTools::Make_*_sparsity_* routines. - -// Call this file after defining PATTERN to the desired sparsity -// pattern type. - -DEAL_II_NAMESPACE_OPEN - - - -template void -MGTools::make_sparsity_pattern ( - const MGDoFHandler &, - PATTERN &, - const unsigned int); - -template void -MGTools::make_flux_sparsity_pattern ( - const MGDoFHandler &, - PATTERN &, - const unsigned int); - -template void -MGTools::make_flux_sparsity_pattern_edge ( - const MGDoFHandler &, - PATTERN &, - const unsigned int); - -#if deal_II_dimension > 1 - -template void -MGTools::make_flux_sparsity_pattern ( - const MGDoFHandler &, - PATTERN &, - const unsigned int, - const Table<2,DoFTools::Coupling>&, - const Table<2,DoFTools::Coupling>&); - -template void -MGTools::make_flux_sparsity_pattern_edge ( - const MGDoFHandler &, - PATTERN &, - const unsigned int, - const Table<2,DoFTools::Coupling>&); - -#endif - - -DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/multigrid/mg_transfer_block.cc b/deal.II/source/multigrid/mg_transfer_block.cc index 216a28eb21..d6209b3360 100644 --- a/deal.II/source/multigrid/mg_transfer_block.cc +++ b/deal.II/source/multigrid/mg_transfer_block.cc @@ -565,119 +565,7 @@ void MGTransferBlock::build_matrices ( // explicit instantiations +#include "mg_transfer_block.inst" -template -void MGTransferBlock::build_matrices -(const DoFHandler&, const MGDoFHandler&, - const std::vector&); - -template -void MGTransferBlock::build_matrices -(const DoFHandler&, const MGDoFHandler&, - const std::vector&); - -template -void MGTransferBlockSelect::build_matrices -(const DoFHandler&, const MGDoFHandler&, - const unsigned int); - -template -void MGTransferBlockSelect::build_matrices -(const DoFHandler&, const MGDoFHandler&, - const unsigned int); - -template void -MGTransferBlock::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const BlockVector&) const; -template void -MGTransferBlock::copy_from_mg ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; -template void -MGTransferBlock::copy_from_mg_add ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; - -template void -MGTransferBlock::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const BlockVector&) const; -template void -MGTransferBlock::copy_from_mg ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; -template void -MGTransferBlock::copy_from_mg_add ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; - -template void -MGTransferBlockSelect::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const Vector&) const; -template void -MGTransferBlockSelect::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const BlockVector&) const; -template void -MGTransferBlockSelect::copy_from_mg ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferBlockSelect::copy_from_mg ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; -template void -MGTransferBlockSelect::copy_from_mg_add ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferBlockSelect::copy_from_mg_add ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; - -template void -MGTransferBlockSelect::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const Vector&) const; -template void -MGTransferBlockSelect::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const BlockVector&) const; -template void -MGTransferBlockSelect::copy_from_mg ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferBlockSelect::copy_from_mg ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; -template void -MGTransferBlockSelect::copy_from_mg_add ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferBlockSelect::copy_from_mg_add ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/multigrid/mg_transfer_block.inst.in b/deal.II/source/multigrid/mg_transfer_block.inst.in new file mode 100644 index 0000000000..3a6030111c --- /dev/null +++ b/deal.II/source/multigrid/mg_transfer_block.inst.in @@ -0,0 +1,131 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +for (deal_II_dimension : DIMENSIONS) + { +template +void MGTransferBlock::build_matrices +(const DoFHandler&, const MGDoFHandler&, + const std::vector&); + +template +void MGTransferBlock::build_matrices +(const DoFHandler&, const MGDoFHandler&, + const std::vector&); + +template +void MGTransferBlockSelect::build_matrices +(const DoFHandler&, const MGDoFHandler&, + const unsigned int); + +template +void MGTransferBlockSelect::build_matrices +(const DoFHandler&, const MGDoFHandler&, + const unsigned int); + +template void +MGTransferBlock::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferBlock::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferBlock::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferBlock::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferBlock::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferBlock::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferBlockSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferBlockSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferBlockSelect::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferBlockSelect::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferBlockSelect::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferBlockSelect::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferBlockSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferBlockSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferBlockSelect::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferBlockSelect::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferBlockSelect::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferBlockSelect::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + } + diff --git a/deal.II/source/multigrid/mg_transfer_component.cc b/deal.II/source/multigrid/mg_transfer_component.cc index 81b650dff2..0f165b6944 100644 --- a/deal.II/source/multigrid/mg_transfer_component.cc +++ b/deal.II/source/multigrid/mg_transfer_component.cc @@ -32,6 +32,7 @@ #include #include #include + DEAL_II_NAMESPACE_OPEN @@ -674,85 +675,7 @@ void MGTransferSelect::build_matrices ( // explicit instantiations +#include "mg_transfer_component.inst" -template -void MGTransferSelect::build_matrices -(const DoFHandler &d, - const MGDoFHandler &, - unsigned int, unsigned int, - const std::vector&, - const std::vector&, - const std::vector >&); - -template -void MGTransferSelect::build_matrices -(const DoFHandler &d, - const MGDoFHandler &, - unsigned int, unsigned int, - const std::vector&, - const std::vector&, - const std::vector >&); - -template void -MGTransferSelect::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const Vector&) const; -template void -MGTransferSelect::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const BlockVector&) const; -template void -MGTransferSelect::copy_from_mg ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferSelect::copy_from_mg ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; -template void -MGTransferSelect::copy_from_mg_add ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferSelect::copy_from_mg_add ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; - -template void -MGTransferSelect::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const Vector&) const; -template void -MGTransferSelect::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const BlockVector&) const; -template void -MGTransferSelect::copy_from_mg ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferSelect::copy_from_mg ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; -template void -MGTransferSelect::copy_from_mg_add ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferSelect::copy_from_mg_add ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/multigrid/mg_transfer_component.inst.in b/deal.II/source/multigrid/mg_transfer_component.inst.in new file mode 100644 index 0000000000..9b32e36b71 --- /dev/null +++ b/deal.II/source/multigrid/mg_transfer_component.inst.in @@ -0,0 +1,97 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +for (deal_II_dimension : DIMENSIONS) + { +template +void MGTransferSelect::build_matrices +(const DoFHandler &d, + const MGDoFHandler &, + unsigned int, unsigned int, + const std::vector&, + const std::vector&, + const std::vector >&); + +template +void MGTransferSelect::build_matrices +(const DoFHandler &d, + const MGDoFHandler &, + unsigned int, unsigned int, + const std::vector&, + const std::vector&, + const std::vector >&); + +template void +MGTransferSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferSelect::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferSelect::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + } + diff --git a/deal.II/source/multigrid/mg_transfer_prebuilt.cc b/deal.II/source/multigrid/mg_transfer_prebuilt.cc index 0a60fe656f..1e269c2271 100644 --- a/deal.II/source/multigrid/mg_transfer_prebuilt.cc +++ b/deal.II/source/multigrid/mg_transfer_prebuilt.cc @@ -292,7 +292,7 @@ void MGTransferPrebuilt::build_matrices ( // need to filter away. constrain_indices.resize (0); constrain_indices.resize (prolongation_matrices[level]->n(), 0); - std::set::const_iterator dof + std::set::const_iterator dof = mg_constrained_dofs->get_boundary_indices()[level].begin(), endd = mg_constrained_dofs->get_boundary_indices()[level].end(); for (; dof != endd; ++dof) @@ -384,146 +384,9 @@ void MGTransferPrebuilt::build_matrices ( } -//TODO: Use template expander script - -template -void MGTransferPrebuilt >::build_matrices -(const MGDoFHandler &mg_dof); - -template -void MGTransferPrebuilt >::build_matrices -(const MGDoFHandler &mg_dof); - -template -void MGTransferPrebuilt >::build_matrices -(const MGDoFHandler &mg_dof); - -template -void MGTransferPrebuilt >::build_matrices -(const MGDoFHandler &mg_dof); - -template void -MGTransferPrebuilt >::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const Vector&) const; -template void -MGTransferPrebuilt >::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const BlockVector&) const; -template void -MGTransferPrebuilt >::copy_from_mg ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg_add ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg_add ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; - -template void -MGTransferPrebuilt >::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const Vector&) const; -template void -MGTransferPrebuilt >::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const BlockVector&) const; -template void -MGTransferPrebuilt >::copy_from_mg ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg_add ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg_add ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; - -template void -MGTransferPrebuilt >::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const Vector&) const; -template void -MGTransferPrebuilt >::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const BlockVector&) const; -template void -MGTransferPrebuilt >::copy_from_mg ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg_add ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg_add ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; - -template void -MGTransferPrebuilt >::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const Vector&) const; -template void -MGTransferPrebuilt >::copy_to_mg ( - const MGDoFHandler&, - MGLevelObject >&, - const BlockVector&) const; -template void -MGTransferPrebuilt >::copy_from_mg ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg_add ( - const MGDoFHandler&, - Vector&, - const MGLevelObject >&) const; -template void -MGTransferPrebuilt >::copy_from_mg_add ( - const MGDoFHandler&, - BlockVector&, - const MGLevelObject >&) const; + +// explicit instantiation +#include "mg_transfer_prebuilt.inst" + DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/multigrid/mg_transfer_prebuilt.inst.in b/deal.II/source/multigrid/mg_transfer_prebuilt.inst.in new file mode 100644 index 0000000000..49660ae0bf --- /dev/null +++ b/deal.II/source/multigrid/mg_transfer_prebuilt.inst.in @@ -0,0 +1,159 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +for (deal_II_dimension : DIMENSIONS) + { +//TODO: Use template expander script + +template +void MGTransferPrebuilt >::build_matrices +(const MGDoFHandler &mg_dof); + +template +void MGTransferPrebuilt >::build_matrices +(const MGDoFHandler &mg_dof); + +template +void MGTransferPrebuilt >::build_matrices +(const MGDoFHandler &mg_dof); + +template +void MGTransferPrebuilt >::build_matrices +(const MGDoFHandler &mg_dof); + +template void +MGTransferPrebuilt >::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferPrebuilt >::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferPrebuilt >::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferPrebuilt >::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferPrebuilt >::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferPrebuilt >::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferPrebuilt >::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferPrebuilt >::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt >::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + } + diff --git a/deal.II/source/multigrid/multigrid.all_dimensions.cc b/deal.II/source/multigrid/multigrid.cc similarity index 99% rename from deal.II/source/multigrid/multigrid.all_dimensions.cc rename to deal.II/source/multigrid/multigrid.cc index 73c90dba11..ce06736b3c 100644 --- a/deal.II/source/multigrid/multigrid.all_dimensions.cc +++ b/deal.II/source/multigrid/multigrid.cc @@ -36,6 +36,8 @@ DEAL_II_NAMESPACE_OPEN // If this function is to be used, its declaration must be added to // the class Multigrid again. + +// TODO: deal_II_dimension not set any more, so this will not compile! #ifdef MG_DEBUG template <> void diff --git a/deal.II/source/numerics/data_out.inst.in b/deal.II/source/numerics/data_out.inst.in index 2d29adf0b7..6a2c8dbcec 100644 --- a/deal.II/source/numerics/data_out.inst.in +++ b/deal.II/source/numerics/data_out.inst.in @@ -11,7 +11,7 @@ // //--------------------------------------------------------------------------- -for (VEC : SERIAL_VECTORS; DH : DOFHANDLER_TEMPLATES) +for (VEC : SERIAL_VECTORS; DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS) { // codim=0 @@ -102,7 +102,7 @@ for (VEC : SERIAL_VECTORS; DH : DOFHANDLER_TEMPLATES) } -for (DH : DOFHANDLER_TEMPLATES) +for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS) { template class DataOut_DoFData,deal_II_dimension>; template class DataOut_DoFData,deal_II_dimension+1>; diff --git a/deal.II/source/numerics/data_out_faces.cc b/deal.II/source/numerics/data_out_faces.cc index cad21ea6b0..87c03b39b3 100644 --- a/deal.II/source/numerics/data_out_faces.cc +++ b/deal.II/source/numerics/data_out_faces.cc @@ -449,11 +449,8 @@ DataOutFaces::next_face (const FaceDescriptor &old_face) } + // explicit instantiations -// don't instantiate anything for the 1d -#if deal_II_dimension >=2 -template class DataOutFaces >; -template class DataOutFaces >; -#endif +#include "data_out_faces.inst" DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/data_out_faces.inst.in b/deal.II/source/numerics/data_out_faces.inst.in new file mode 100644 index 0000000000..87a8b2ee40 --- /dev/null +++ b/deal.II/source/numerics/data_out_faces.inst.in @@ -0,0 +1,21 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ + // don't instantiate anything for the 1d +#if deal_II_dimension >=2 + template class DataOutFaces >; + template class DataOutFaces >; +#endif +} diff --git a/deal.II/source/numerics/data_out_rotation.cc b/deal.II/source/numerics/data_out_rotation.cc index 4d14e22165..386e662d50 100644 --- a/deal.II/source/numerics/data_out_rotation.cc +++ b/deal.II/source/numerics/data_out_rotation.cc @@ -89,13 +89,12 @@ namespace internal patches.push_back (new_patches[i]); patches.back().patch_index = patches.size()-1; } - } + } } } - -#if deal_II_dimension < 3 + template void DataOutRotation:: @@ -103,6 +102,16 @@ build_one_patch (const cell_iterator *cell, internal::DataOutRotation::ParallelData &data, std::vector > &patches) { + if (dim == 3) + { + // would this function make any + // sense after all? who would want + // to output/compute in four space + // dimensions? + Assert (false, ExcNotImplemented()); + return; + } + Assert (!(*cell)->is_ghost() && !(*cell)->is_artificial(), ExcNotImplemented()); @@ -113,7 +122,7 @@ build_one_patch (const cell_iterator *cell, // the number of q_points in each // direction const unsigned int n_points = data.n_subdivisions+1; - + // set up an array that holds the // directions in the plane of // rotation in which we will put @@ -131,7 +140,7 @@ build_one_patch (const cell_iterator *cell, angle_directions[i][DH::dimension] = std::sin(2*numbers::PI * i/n_patches_per_circle); } - + for (unsigned int angle=0; anglevertex(0)(0), r2 = (*cell)->vertex(1)(0); - Assert (r1 >= 0, ExcRadialVariableHasNegativeValues(r1)); + Assert (r1 >= 0, ExcRadialVariableHasNegativeValues(r1)); Assert (r2 >= 0, ExcRadialVariableHasNegativeValues(r2)); - + patches[angle].vertices[0] = r1*angle_directions[angle]; patches[angle].vertices[1] = r2*angle_directions[angle]; patches[angle].vertices[2] = r1*angle_directions[angle+1]; @@ -157,7 +166,7 @@ build_one_patch (const cell_iterator *cell, break; }; - + case 2: { for (unsigned int vertex=0; @@ -165,33 +174,33 @@ build_one_patch (const cell_iterator *cell, ++vertex) { const Point v = (*cell)->vertex(vertex); - + // make sure that the // radial variable does // attain negative // values Assert (v(0) >= 0, ExcRadialVariableHasNegativeValues(v(0))); - + // now set the vertices // of the patch patches[angle].vertices[vertex] = v(0) * angle_directions[angle]; patches[angle].vertices[vertex][0] = v(1); - + patches[angle].vertices[vertex+GeometryInfo::vertices_per_cell] = v(0) * angle_directions[angle+1]; patches[angle].vertices[vertex+GeometryInfo::vertices_per_cell][0] = v(1); }; - + break; }; default: Assert (false, ExcNotImplemented()); }; - + unsigned int offset=0; - + // then fill in data if (data.n_datasets > 0) { @@ -224,9 +233,9 @@ build_one_patch (const cell_iterator *cell, if (update_flags & update_hessians) this->dof_data[dataset]->get_function_hessians (fe_patch_values, data.patch_hessians); - + if (update_flags & update_quadrature_points) - data.patch_evaluation_points = fe_patch_values.get_quadrature_points(); + data.patch_evaluation_points = fe_patch_values.get_quadrature_points(); std::vector > dummy_normals; postprocessor-> @@ -252,10 +261,10 @@ build_one_patch (const cell_iterator *cell, if (update_flags & update_hessians) this->dof_data[dataset]->get_function_hessians (fe_patch_values, data.patch_hessians_system); - + if (update_flags & update_quadrature_points) - data.patch_evaluation_points = fe_patch_values.get_quadrature_points(); - + data.patch_evaluation_points = fe_patch_values.get_quadrature_points(); + std::vector > dummy_normals; postprocessor-> compute_derived_quantities_vector(data.patch_values_system, @@ -265,7 +274,7 @@ build_one_patch (const cell_iterator *cell, data.patch_evaluation_points, data.postprocessed_values[dataset]); } - + for (unsigned int component=0; componentdof_data[dataset]->n_output_variables; ++component) @@ -279,7 +288,7 @@ build_one_patch (const cell_iterator *cell, x*n_points + y) = data.postprocessed_values[dataset][x](component); break; - + case 2: for (unsigned int x=0; xdof_data[dataset]->get_function_values (fe_patch_values, data.patch_values); - + switch (DH::dimension) { case 1: @@ -311,7 +320,7 @@ build_one_patch (const cell_iterator *cell, x*n_points + y) = data.patch_values[x]; break; - + case 2: for (unsigned int x=0; xdof_data[dataset]->get_function_values (fe_patch_values, data.patch_values_system); - + for (unsigned int component=0; componentdof_data[dataset]->n_output_variables; } - + // then do the cell data for (unsigned int dataset=0; datasetcell_data.size(); ++dataset) { @@ -395,7 +404,7 @@ build_one_patch (const cell_iterator *cell, y) = value; break; - + case 2: for (unsigned int x=0; x -void -DataOutRotation:: -build_one_patch (const cell_iterator *, - internal::DataOutRotation::ParallelData &, - std::vector > &) -{ - // would this function make any - // sense after all? who would want - // to output/compute in four space - // dimensions? - Assert (false, ExcNotImplemented()); -} - -#endif - - - template void DataOutRotation::build_patches (const unsigned int n_patches_per_circle, - const unsigned int nnnn_subdivisions) + const unsigned int nnnn_subdivisions) { // Check consistency of redundant // template parameter @@ -449,13 +438,13 @@ void DataOutRotation::build_patches (const unsigned int n_patches_per_ci const unsigned int n_subdivisions = (nnnn_subdivisions != 0) ? nnnn_subdivisions - : this->default_subdivisions; + : this->default_subdivisions; Assert (n_subdivisions >= 1, ExcInvalidNumberOfSubdivisions(n_subdivisions)); const QTrapez<1> q_trapez; const QIterated patch_points (q_trapez, n_subdivisions); - + const unsigned int n_components = this->dofs->get_fe().n_components(); unsigned int n_datasets=this->cell_data.size(); for (unsigned int i=0; idof_data.size(); ++i) @@ -471,7 +460,7 @@ void DataOutRotation::build_patches (const unsigned int n_patches_per_ci Assert (!(update_flags & update_normal_vectors), ExcMessage("The update of normal vectors may not be requested for " "evaluation of data on cells via DataPostprocessor.")); - + // first count the cells we want to // create patches of and make sure // there is enough memory for that @@ -479,7 +468,7 @@ void DataOutRotation::build_patches (const unsigned int n_patches_per_ci for (cell_iterator cell=first_cell(); cell != this->dofs->end(); cell = next_cell(cell)) all_cells.push_back (cell); - + // then also take into account that // we want more than one patch to // come out of every cell, as they @@ -487,8 +476,8 @@ void DataOutRotation::build_patches (const unsigned int n_patches_per_ci // rotation this->patches.clear(); this->patches.reserve (all_cells.size() * n_patches_per_circle); - - + + std::vector n_postprocessor_outputs (this->dof_data.size()); for (unsigned int dataset=0; datasetdof_data.size(); ++dataset) if (this->dof_data[dataset]->postprocessor) @@ -527,7 +516,7 @@ void DataOutRotation::build_patches (const unsigned int n_patches_per_ci template typename DataOutRotation::cell_iterator -DataOutRotation::first_cell () +DataOutRotation::first_cell () { return this->dofs->begin_active (); } @@ -535,7 +524,7 @@ DataOutRotation::first_cell () template typename DataOutRotation::cell_iterator -DataOutRotation::next_cell (const cell_iterator &cell) +DataOutRotation::next_cell (const cell_iterator &cell) { // convert the iterator to an // active_iterator and advance @@ -546,7 +535,9 @@ DataOutRotation::next_cell (const cell_iterator &cell) } + // explicit instantiations -template class DataOutRotation >; +#include "data_out_rotation.inst" + DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/data_out_rotation.inst.in b/deal.II/source/numerics/data_out_rotation.inst.in new file mode 100644 index 0000000000..ed90dd3f87 --- /dev/null +++ b/deal.II/source/numerics/data_out_rotation.inst.in @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ + template class DataOutRotation >; +} diff --git a/deal.II/source/numerics/data_out_stack.cc b/deal.II/source/numerics/data_out_stack.cc index 59ed4fcc33..235c4841ab 100644 --- a/deal.II/source/numerics/data_out_stack.cc +++ b/deal.II/source/numerics/data_out_stack.cc @@ -468,23 +468,9 @@ std::vector DataOutStack::get_dataset_names () con } + // explicit instantiations -template class DataOutStack >; - -template void DataOutStack >:: -add_data_vector (const Vector &vec, - const std::string &name); - -template void DataOutStack >:: -add_data_vector (const Vector &vec, - const std::string &name); - -template class DataOutStack >; -template void DataOutStack >:: -add_data_vector (const Vector &vec, - const std::string &name); -template void DataOutStack >:: -add_data_vector (const Vector &vec, - const std::string &name); +#include "data_out_stack.inst" + DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/data_out_stack.inst.in b/deal.II/source/numerics/data_out_stack.inst.in new file mode 100644 index 0000000000..401fa981a7 --- /dev/null +++ b/deal.II/source/numerics/data_out_stack.inst.in @@ -0,0 +1,33 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ +template class DataOutStack >; + +template void DataOutStack >:: +add_data_vector (const Vector &vec, + const std::string &name); + +template void DataOutStack >:: +add_data_vector (const Vector &vec, + const std::string &name); + +template class DataOutStack >; +template void DataOutStack >:: +add_data_vector (const Vector &vec, + const std::string &name); +template void DataOutStack >:: +add_data_vector (const Vector &vec, + const std::string &name); +} diff --git a/deal.II/source/numerics/data_postprocessor.cc b/deal.II/source/numerics/data_postprocessor.cc index 502b24452c..1a314caa01 100644 --- a/deal.II/source/numerics/data_postprocessor.cc +++ b/deal.II/source/numerics/data_postprocessor.cc @@ -95,6 +95,7 @@ DataPostprocessor::get_data_component_interpretation () const // explicit instantiation -template class DataPostprocessor; +#include "data_postprocessor.inst" + DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/data_postprocessor.inst.in b/deal.II/source/numerics/data_postprocessor.inst.in new file mode 100644 index 0000000000..3cf15e8778 --- /dev/null +++ b/deal.II/source/numerics/data_postprocessor.inst.in @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ + template class DataPostprocessor; +} diff --git a/deal.II/source/numerics/derivative_approximation.cc b/deal.II/source/numerics/derivative_approximation.cc index 8aeaaa50b0..edaedeb534 100644 --- a/deal.II/source/numerics/derivative_approximation.cc +++ b/deal.II/source/numerics/derivative_approximation.cc @@ -132,7 +132,6 @@ get_projected_derivative (const FEValues &fe_values, } -#if deal_II_dimension == 1 template <> inline @@ -143,9 +142,7 @@ derivative_norm (const Derivative &d) return std::fabs (d[0][0]); } -#endif -#if deal_II_dimension == 2 template <> inline @@ -166,15 +163,12 @@ derivative_norm (const Derivative &d) const double eigenvalues[2] = { 0.5*(d[0][0] + d[1][1] + std::sqrt(radicand)), 0.5*(d[0][0] + d[1][1] - std::sqrt(radicand)) }; - + return std::max (std::fabs (eigenvalues[0]), std::fabs (eigenvalues[1])); } -#endif - -#if deal_II_dimension == 3 template <> inline @@ -186,7 +180,7 @@ derivative_norm (const Derivative &d) compute the three eigenvalues of the tensor @p{d} and take the largest. one could use the following maple script to generate C code: - + with(linalg); readlib(C); A:=matrix(3,3,[[a00,a01,a02],[a01,a11,a12],[a02,a12,a22]]); @@ -205,7 +199,7 @@ derivative_norm (const Derivative &d) augmented by a test for R>0, since R==0 indicates that all three eigenvalues are equal.) - + PROGRAM MAIN C FIND EIGENVALUES OF REAL SYMMETRIC MATRIX @@ -232,7 +226,7 @@ C DEFINE A TEST MATRIX A22 = -2.D0 A23 = 0.5D0 A33 = 4.D0 - + I1 = A11 + A22 + A33 AM = I1/3.D0 @@ -279,7 +273,7 @@ C DEFINE A TEST MATRIX ENDIF THETA = (ACOS(XX))/3.D0 - + A1 = AM + R*COS(THETA) A2 = AM + R*COS(THETA + 2.D0*PI/3.D0) A3 = AM + R*COS(THETA + 4.D0*PI/3.D0) @@ -288,7 +282,7 @@ C DEFINE A TEST MATRIX STOP END - + */ const double am = trace(d) / 3.; @@ -297,7 +291,7 @@ C DEFINE A TEST MATRIX Tensor<2,3> s = d; for (unsigned int i=0; i<3; ++i) s[i][i] -= am; - + const double ss01 = s[0][1] * s[0][1], ss12 = s[1][2] * s[1][2], ss02 = s[0][2] * s[0][2]; @@ -309,7 +303,7 @@ C DEFINE A TEST MATRIX + 3. * s[1][1] * (ss01 + ss12) + 3. * s[2][2] * (ss02 + ss12) + 6. * s[0][1] * s[0][2] * s[1][2]) / 3.; - + const double R = std::sqrt (4. * J2 / 3.); double EE[3] = { 0, 0, 0 }; @@ -330,7 +324,7 @@ C DEFINE A TEST MATRIX const double YY = 1. - std::fabs(XX); Assert (YY > -1e-14, ExcInternalError()); - + if (YY < 0) { // two roots are equal @@ -352,7 +346,6 @@ C DEFINE A TEST MATRIX std::fabs (EE[2]))); } -#endif template @@ -420,7 +413,6 @@ get_projected_derivative (const FEValues &fe_values, } -#if deal_II_dimension == 1 template <> inline @@ -431,7 +423,6 @@ derivative_norm (const Derivative &d) return std::fabs (d[0][0][0]); } -#endif template @@ -499,13 +490,13 @@ DerivativeApproximation::ThirdDerivative::symmetrize (Derivative &d) = d[j][j][i] = t; }; - + } template class DH, class InputVector, int spacedim> -void +void DerivativeApproximation:: approximate_gradient (const Mapping &mapping, const DH &dof_handler, @@ -522,7 +513,7 @@ approximate_gradient (const Mapping &mapping, template class DH, class InputVector, int spacedim> -void +void DerivativeApproximation:: approximate_gradient (const DH &dof_handler, const InputVector &solution, @@ -539,7 +530,7 @@ approximate_gradient (const DH &dof_handler, template class DH, class InputVector, int spacedim> -void +void DerivativeApproximation:: approximate_second_derivative (const Mapping &mapping, const DH &dof_handler, @@ -556,7 +547,7 @@ approximate_second_derivative (const Mapping &mapping, template class DH, class InputVector, int spacedim> -void +void DerivativeApproximation:: approximate_second_derivative (const DH &dof_handler, const InputVector &solution, @@ -617,7 +608,7 @@ approximate_derivative_tensor (const DH template class DH, class InputVector, int spacedim> -void +void DerivativeApproximation:: approximate_derivative (const Mapping &mapping, const DH &dof_handler, @@ -646,8 +637,8 @@ approximate_derivative (const Mapping &mapping, template approximate; -//TODO: Use WorkStream here - Threads::TaskGroup<> tasks; +//TODO: Use WorkStream here + Threads::TaskGroup<> tasks; for (unsigned int i=0; i &mapping, template class DH, class InputVector, int spacedim> -void +void DerivativeApproximation::approximate (const Mapping &mapping, const DH &dof_handler, const InputVector &solution, @@ -675,7 +666,7 @@ DerivativeApproximation::approximate (const Mapping &mapping, Vector::iterator derivative_norm_on_this_cell = derivative_norm.begin() + index_interval.first; - + typename DH::active_cell_iterator cell, endc; cell = endc = dof_handler.begin_active(); // (static_cast to avoid warnings @@ -705,15 +696,15 @@ DerivativeApproximation::approximate (const Mapping &mapping, template class DH, class InputVector, int spacedim> -void +void DerivativeApproximation:: -approximate_cell (const Mapping &mapping, - const DH &dof_handler, +approximate_cell (const Mapping &mapping, + const DH &dof_handler, const InputVector &solution, const unsigned int component, const typename DH::active_cell_iterator &cell, - typename DerivativeDescription::Derivative &derivative) -{ + typename DerivativeDescription::Derivative &derivative) +{ QMidpoint midpoint_rule; // create collection objects from @@ -726,15 +717,15 @@ approximate_cell (const Mapping &mappin const hp::QCollection q_collection (midpoint_rule); const hp::FECollection fe_collection(dof_handler.get_fe()); const hp::MappingCollection mapping_collection (mapping); - + hp::FEValues x_fe_midpoint_value (mapping_collection, fe_collection, q_collection, DerivativeDescription::update_flags | update_quadrature_points); - + // matrix Y=sum_i y_i y_i^T Tensor<2,dim> Y; - + // vector to hold iterators to all // active neighbors of a cell @@ -748,24 +739,24 @@ approximate_cell (const Mapping &mappin // g=sum_i y_i (f(x+y_i)-f(x))/|y_i| // or related type for higher // derivatives - typename DerivativeDescription::Derivative projected_derivative; + typename DerivativeDescription::Derivative projected_derivative; // reinit fe values object... - x_fe_midpoint_value.reinit (cell); - const FEValues &fe_midpoint_value - = x_fe_midpoint_value.get_present_fe_values(); + x_fe_midpoint_value.reinit (cell); + const FEValues &fe_midpoint_value + = x_fe_midpoint_value.get_present_fe_values(); // ...and get the value of the // projected derivative... - const typename DerivativeDescription::ProjectedDerivative - this_midpoint_value - = DerivativeDescription::get_projected_derivative (fe_midpoint_value, - solution, - component); + const typename DerivativeDescription::ProjectedDerivative + this_midpoint_value + = DerivativeDescription::get_projected_derivative (fe_midpoint_value, + solution, + component); // ...and the place where it lives - const Point this_center = fe_midpoint_value.quadrature_point(0); + const Point this_center = fe_midpoint_value.quadrature_point(0); + - // loop over all neighbors and // accumulate the difference // quotients from them. note @@ -778,44 +769,44 @@ approximate_cell (const Mapping &mappin // first collect all neighbor // cells in a vector, and then // collect the data from them - GridTools::template get_active_neighbors >(cell, active_neighbors); - + GridTools::template get_active_neighbors >(cell, active_neighbors); + // now loop over all active // neighbors and collect the // data we need - typename std::vector::active_cell_iterator>::const_iterator - neighbor_ptr = active_neighbors.begin(); - for (; neighbor_ptr!=active_neighbors.end(); ++neighbor_ptr) - { - const typename DH::active_cell_iterator - neighbor = *neighbor_ptr; - + typename std::vector::active_cell_iterator>::const_iterator + neighbor_ptr = active_neighbors.begin(); + for (; neighbor_ptr!=active_neighbors.end(); ++neighbor_ptr) + { + const typename DH::active_cell_iterator + neighbor = *neighbor_ptr; + // reinit fe values object... - x_fe_midpoint_value.reinit (neighbor); - const FEValues &fe_midpoint_value - = x_fe_midpoint_value.get_present_fe_values(); - + x_fe_midpoint_value.reinit (neighbor); + const FEValues &fe_midpoint_value + = x_fe_midpoint_value.get_present_fe_values(); + // ...and get the value of the // solution... - const typename DerivativeDescription::ProjectedDerivative - neighbor_midpoint_value - = DerivativeDescription::get_projected_derivative (fe_midpoint_value, + const typename DerivativeDescription::ProjectedDerivative + neighbor_midpoint_value + = DerivativeDescription::get_projected_derivative (fe_midpoint_value, solution, component); - + // ...and the place where it lives - const Point - neighbor_center = fe_midpoint_value.quadrature_point(0); - - + const Point + neighbor_center = fe_midpoint_value.quadrature_point(0); + + // vector for the // normalized // direction between // the centers of two // cells - Point y = neighbor_center - this_center; - const double distance = std::sqrt(y.square()); + Point y = neighbor_center - this_center; + const double distance = std::sqrt(y.square()); // normalize y - y /= distance; + y /= distance; // *** note that unlike in // the docs, y denotes the // normalized vector @@ -823,29 +814,29 @@ approximate_cell (const Mapping &mappin // of the two cells, rather // than the normal // difference! *** - + // add up the // contribution of // this cell to Y - for (unsigned int i=0; i &mappin // otherwise we would not have // all components of the // gradient - AssertThrow (determinant(Y) != 0, - ExcInsufficientDirections()); - + AssertThrow (determinant(Y) != 0, + ExcInsufficientDirections()); + // compute Y^-1 g - const Tensor<2,dim> Y_inverse = invert(Y); - - contract (derivative, Y_inverse, projected_derivative); - + const Tensor<2,dim> Y_inverse = invert(Y); + + contract (derivative, Y_inverse, projected_derivative); + // finally symmetrize the derivative - DerivativeDescription::symmetrize (derivative); + DerivativeDescription::symmetrize (derivative); } @@ -878,129 +869,9 @@ derivative_norm(const Tensor &derivative) } -// -------------------------------------------------------------------- - -// explicit instantiations -#define INSTANTIATE(InputVector,DH) \ -template \ -void \ -DerivativeApproximation:: \ -approximate_gradient \ -(const Mapping &mapping, \ - const DH &dof_handler, \ - const InputVector &solution, \ - Vector &derivative_norm, \ - const unsigned int component); \ - \ -template \ -void \ -DerivativeApproximation:: \ -approximate_gradient \ -(const DH &dof_handler, \ - const InputVector &solution, \ - Vector &derivative_norm, \ - const unsigned int component); \ - \ -template \ -void \ -DerivativeApproximation:: \ -approximate_second_derivative \ -(const Mapping &mapping, \ - const DH &dof_handler, \ - const InputVector &solution, \ - Vector &derivative_norm, \ - const unsigned int component); \ - \ -template \ -void \ -DerivativeApproximation:: \ -approximate_second_derivative \ -(const DH &dof_handler, \ - const InputVector &solution, \ - Vector &derivative_norm, \ - const unsigned int component); \ - \ -template \ -void \ -DerivativeApproximation:: \ -approximate_derivative_tensor \ -(const DH &dof_handler, \ - const InputVector &solution, \ - const DH::active_cell_iterator &cell,\ - Tensor<1,deal_II_dimension> &derivative, \ - const unsigned int component); \ - \ -template \ -void \ -DerivativeApproximation:: \ -approximate_derivative_tensor \ -(const DH &dof_handler, \ - const InputVector &solution, \ - const DH::active_cell_iterator &cell,\ - Tensor<2,deal_II_dimension> &derivative, \ - const unsigned int component); \ - \ -template \ -void \ -DerivativeApproximation:: \ -approximate_derivative_tensor \ -(const DH &dof_handler, \ - const InputVector &solution, \ - const DH::active_cell_iterator &cell,\ - Tensor<3,deal_II_dimension> &derivative, \ - const unsigned int component) - - -INSTANTIATE(Vector, DoFHandler); -INSTANTIATE(Vector, DoFHandler); -INSTANTIATE(BlockVector, DoFHandler); -INSTANTIATE(BlockVector, DoFHandler); - -INSTANTIATE(Vector, hp::DoFHandler); -INSTANTIATE(Vector, hp::DoFHandler); -INSTANTIATE(BlockVector, hp::DoFHandler); -INSTANTIATE(BlockVector, hp::DoFHandler); - -#ifdef DEAL_II_USE_PETSC -INSTANTIATE(PETScWrappers::Vector, DoFHandler); -INSTANTIATE(PETScWrappers::BlockVector, DoFHandler); - -INSTANTIATE(PETScWrappers::Vector, hp::DoFHandler); -INSTANTIATE(PETScWrappers::BlockVector, hp::DoFHandler); -#endif - -#undef INSTANTIATE - -template -double -DerivativeApproximation:: -derivative_norm(const Tensor<1,deal_II_dimension> &derivative); - -template -double -DerivativeApproximation:: -derivative_norm(const Tensor<2,deal_II_dimension> &derivative); - -template -double -DerivativeApproximation:: -derivative_norm(const Tensor<3,deal_II_dimension> &derivative); +// --------------------------- explicit instantiations --------------------- +#include "derivative_approximation.inst" -// static variables -// -// on AIX, the linker is unhappy about some missing symbols. they -// should really be there, but explicitly instantiating them will also -// not hurt -template -const UpdateFlags -DerivativeApproximation::Gradient::update_flags; - -template -const UpdateFlags -DerivativeApproximation::SecondDerivative::update_flags; -template -const UpdateFlags -DerivativeApproximation::ThirdDerivative::update_flags; DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/derivative_approximation.inst.in b/deal.II/source/numerics/derivative_approximation.inst.in new file mode 100644 index 0000000000..3723b4e8e5 --- /dev/null +++ b/deal.II/source/numerics/derivative_approximation.inst.in @@ -0,0 +1,137 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ +#define INSTANTIATE(InputVector,DH) \ +template \ +void \ +DerivativeApproximation:: \ +approximate_gradient \ +(const Mapping &mapping, \ + const DH &dof_handler, \ + const InputVector &solution, \ + Vector &derivative_norm, \ + const unsigned int component); \ + \ +template \ +void \ +DerivativeApproximation:: \ +approximate_gradient \ +(const DH &dof_handler, \ + const InputVector &solution, \ + Vector &derivative_norm, \ + const unsigned int component); \ + \ +template \ +void \ +DerivativeApproximation:: \ +approximate_second_derivative \ +(const Mapping &mapping, \ + const DH &dof_handler, \ + const InputVector &solution, \ + Vector &derivative_norm, \ + const unsigned int component); \ + \ +template \ +void \ +DerivativeApproximation:: \ +approximate_second_derivative \ +(const DH &dof_handler, \ + const InputVector &solution, \ + Vector &derivative_norm, \ + const unsigned int component); \ + \ +template \ +void \ +DerivativeApproximation:: \ +approximate_derivative_tensor \ +(const DH &dof_handler, \ + const InputVector &solution, \ + const DH::active_cell_iterator &cell,\ + Tensor<1,deal_II_dimension> &derivative, \ + const unsigned int component); \ + \ +template \ +void \ +DerivativeApproximation:: \ +approximate_derivative_tensor \ +(const DH &dof_handler, \ + const InputVector &solution, \ + const DH::active_cell_iterator &cell,\ + Tensor<2,deal_II_dimension> &derivative, \ + const unsigned int component); \ + \ +template \ +void \ +DerivativeApproximation:: \ +approximate_derivative_tensor \ +(const DH &dof_handler, \ + const InputVector &solution, \ + const DH::active_cell_iterator &cell,\ + Tensor<3,deal_II_dimension> &derivative, \ + const unsigned int component) + + +INSTANTIATE(Vector, DoFHandler); +INSTANTIATE(Vector, DoFHandler); +INSTANTIATE(BlockVector, DoFHandler); +INSTANTIATE(BlockVector, DoFHandler); + +INSTANTIATE(Vector, hp::DoFHandler); +INSTANTIATE(Vector, hp::DoFHandler); +INSTANTIATE(BlockVector, hp::DoFHandler); +INSTANTIATE(BlockVector, hp::DoFHandler); + +#ifdef DEAL_II_USE_PETSC +INSTANTIATE(PETScWrappers::Vector, DoFHandler); +INSTANTIATE(PETScWrappers::BlockVector, DoFHandler); + +INSTANTIATE(PETScWrappers::Vector, hp::DoFHandler); +INSTANTIATE(PETScWrappers::BlockVector, hp::DoFHandler); +#endif + +#undef INSTANTIATE + +template +double +DerivativeApproximation:: +derivative_norm(const Tensor<1,deal_II_dimension> &derivative); + +template +double +DerivativeApproximation:: +derivative_norm(const Tensor<2,deal_II_dimension> &derivative); + +template +double +DerivativeApproximation:: +derivative_norm(const Tensor<3,deal_II_dimension> &derivative); + + +// static variables +// +// on AIX, the linker is unhappy about some missing symbols. they +// should really be there, but explicitly instantiating them will also +// not hurt +template +const UpdateFlags +DerivativeApproximation::Gradient::update_flags; + +template +const UpdateFlags +DerivativeApproximation::SecondDerivative::update_flags; +template +const UpdateFlags +DerivativeApproximation::ThirdDerivative::update_flags; +} diff --git a/deal.II/source/numerics/error_estimator.cc b/deal.II/source/numerics/error_estimator.cc index 55106b8c3a..16bce12dd5 100644 --- a/deal.II/source/numerics/error_estimator.cc +++ b/deal.II/source/numerics/error_estimator.cc @@ -1001,7 +1001,6 @@ namespace internal -#if deal_II_dimension == 1 template @@ -1425,7 +1424,6 @@ estimate (const Mapping<1,spacedim> &mapping, } -#else // #if deal_II_dimension !=1 @@ -1770,120 +1768,11 @@ void KellyErrorEstimator::estimate (const DH -#endif // explicit instantiations -#if deal_II_dimension != 1 -template class KellyErrorEstimator; -#endif - -// instantiate the externally visible functions. define a list of functions -// for vectors, where the vector/matrix can be replaced using a preprocessor -// variable VectorType/MatrixType -#define INSTANTIATE_1(InputVector,DH,Q) \ -template \ -void \ -KellyErrorEstimator:: \ -estimate (const Mapping &, \ - const DH &, \ - const Q &, \ - const FunctionMap::type &, \ - const InputVector &, \ - Vector &, \ - const std::vector &, \ - const Function *, \ - const unsigned int , \ - const unsigned int , \ - const unsigned int); \ - \ -template \ -void \ -KellyErrorEstimator:: \ -estimate (const DH &, \ - const Q &, \ - const FunctionMap::type &, \ - const InputVector &, \ - Vector &, \ - const std::vector &, \ - const Function *, \ - const unsigned int , \ - const unsigned int , \ - const unsigned int); \ - \ -template \ -void \ -KellyErrorEstimator:: \ -estimate (const Mapping &, \ - const DH &, \ - const Q &, \ - const FunctionMap::type &, \ - const std::vector &, \ - std::vector*> &, \ - const std::vector &, \ - const Function *, \ - const unsigned int , \ - const unsigned int , \ - const unsigned int); \ - \ -template \ -void \ -KellyErrorEstimator:: \ -estimate (const DH &, \ - const Q &, \ - const FunctionMap::type &, \ - const std::vector &, \ - std::vector*> &, \ - const std::vector &, \ - const Function *, \ - const unsigned int , \ - const unsigned int , \ - const unsigned int) - -#define INSTANTIATE(InputVector,DH) \ - INSTANTIATE_1(InputVector,DH,Quadrature); \ - INSTANTIATE_1(InputVector,DH,hp::QCollection) - - -INSTANTIATE(Vector,DoFHandler); -INSTANTIATE(Vector,DoFHandler); -INSTANTIATE(BlockVector,DoFHandler); -INSTANTIATE(BlockVector,DoFHandler); - -INSTANTIATE(Vector,hp::DoFHandler); -INSTANTIATE(Vector,hp::DoFHandler); -INSTANTIATE(BlockVector,hp::DoFHandler); -INSTANTIATE(BlockVector,hp::DoFHandler); - -#ifdef DEAL_II_USE_PETSC -INSTANTIATE(PETScWrappers::Vector,DoFHandler); -INSTANTIATE(PETScWrappers::BlockVector,DoFHandler); - -INSTANTIATE(PETScWrappers::Vector,hp::DoFHandler); -INSTANTIATE(PETScWrappers::BlockVector,hp::DoFHandler); - -INSTANTIATE(PETScWrappers::MPI::Vector,DoFHandler); -INSTANTIATE(PETScWrappers::MPI::BlockVector,DoFHandler); - -#endif - -#ifdef DEAL_II_USE_TRILINOS -INSTANTIATE(TrilinosWrappers::Vector,DoFHandler); -INSTANTIATE(TrilinosWrappers::BlockVector,DoFHandler); - -INSTANTIATE(TrilinosWrappers::Vector,hp::DoFHandler); -INSTANTIATE(TrilinosWrappers::BlockVector,hp::DoFHandler); - -INSTANTIATE(TrilinosWrappers::MPI::Vector,DoFHandler); -INSTANTIATE(TrilinosWrappers::MPI::BlockVector,DoFHandler); - -INSTANTIATE(TrilinosWrappers::MPI::Vector,hp::DoFHandler); -INSTANTIATE(TrilinosWrappers::MPI::BlockVector,hp::DoFHandler); -#endif - -#undef INSTANTIATE -#undef INSTANTIATE_1 +#include "error_estimator.inst" DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/error_estimator.inst.in b/deal.II/source/numerics/error_estimator.inst.in new file mode 100644 index 0000000000..2400e5eb5b --- /dev/null +++ b/deal.II/source/numerics/error_estimator.inst.in @@ -0,0 +1,125 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ +#if deal_II_dimension != 1 +template class KellyErrorEstimator; +#endif + +// instantiate the externally visible functions. define a list of functions +// for vectors, where the vector/matrix can be replaced using a preprocessor +// variable VectorType/MatrixType +#define INSTANTIATE_1(InputVector,DH,Q) \ +template \ +void \ +KellyErrorEstimator:: \ +estimate (const Mapping &, \ + const DH &, \ + const Q &, \ + const FunctionMap::type &, \ + const InputVector &, \ + Vector &, \ + const std::vector &, \ + const Function *, \ + const unsigned int , \ + const unsigned int , \ + const unsigned int); \ + \ +template \ +void \ +KellyErrorEstimator:: \ +estimate (const DH &, \ + const Q &, \ + const FunctionMap::type &, \ + const InputVector &, \ + Vector &, \ + const std::vector &, \ + const Function *, \ + const unsigned int , \ + const unsigned int , \ + const unsigned int); \ + \ +template \ +void \ +KellyErrorEstimator:: \ +estimate (const Mapping &, \ + const DH &, \ + const Q &, \ + const FunctionMap::type &, \ + const std::vector &, \ + std::vector*> &, \ + const std::vector &, \ + const Function *, \ + const unsigned int , \ + const unsigned int , \ + const unsigned int); \ + \ +template \ +void \ +KellyErrorEstimator:: \ +estimate (const DH &, \ + const Q &, \ + const FunctionMap::type &, \ + const std::vector &, \ + std::vector*> &, \ + const std::vector &, \ + const Function *, \ + const unsigned int , \ + const unsigned int , \ + const unsigned int) + +#define INSTANTIATE(InputVector,DH) \ + INSTANTIATE_1(InputVector,DH,Quadrature); \ + INSTANTIATE_1(InputVector,DH,hp::QCollection) + + +INSTANTIATE(Vector,DoFHandler); +INSTANTIATE(Vector,DoFHandler); +INSTANTIATE(BlockVector,DoFHandler); +INSTANTIATE(BlockVector,DoFHandler); + +INSTANTIATE(Vector,hp::DoFHandler); +INSTANTIATE(Vector,hp::DoFHandler); +INSTANTIATE(BlockVector,hp::DoFHandler); +INSTANTIATE(BlockVector,hp::DoFHandler); + +#ifdef DEAL_II_USE_PETSC +INSTANTIATE(PETScWrappers::Vector,DoFHandler); +INSTANTIATE(PETScWrappers::BlockVector,DoFHandler); + +INSTANTIATE(PETScWrappers::Vector,hp::DoFHandler); +INSTANTIATE(PETScWrappers::BlockVector,hp::DoFHandler); + +INSTANTIATE(PETScWrappers::MPI::Vector,DoFHandler); +INSTANTIATE(PETScWrappers::MPI::BlockVector,DoFHandler); + +#endif + +#ifdef DEAL_II_USE_TRILINOS +INSTANTIATE(TrilinosWrappers::Vector,DoFHandler); +INSTANTIATE(TrilinosWrappers::BlockVector,DoFHandler); + +INSTANTIATE(TrilinosWrappers::Vector,hp::DoFHandler); +INSTANTIATE(TrilinosWrappers::BlockVector,hp::DoFHandler); + +INSTANTIATE(TrilinosWrappers::MPI::Vector,DoFHandler); +INSTANTIATE(TrilinosWrappers::MPI::BlockVector,DoFHandler); + +INSTANTIATE(TrilinosWrappers::MPI::Vector,hp::DoFHandler); +INSTANTIATE(TrilinosWrappers::MPI::BlockVector,hp::DoFHandler); +#endif + +#undef INSTANTIATE +#undef INSTANTIATE_1 +} diff --git a/deal.II/source/numerics/fe_field_function.inst.in b/deal.II/source/numerics/fe_field_function.inst.in index 54a65c46a7..7e51bae6b8 100644 --- a/deal.II/source/numerics/fe_field_function.inst.in +++ b/deal.II/source/numerics/fe_field_function.inst.in @@ -11,7 +11,7 @@ //--------------------------------------------------------------------------- -for (VECTOR : SERIAL_VECTORS) +for (VECTOR : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS) { template class FEFieldFunction, diff --git a/deal.II/source/numerics/histogram.all_dimensions.cc b/deal.II/source/numerics/histogram.cc similarity index 100% rename from deal.II/source/numerics/histogram.all_dimensions.cc rename to deal.II/source/numerics/histogram.cc diff --git a/deal.II/source/numerics/matrices.all_dimensions.cc b/deal.II/source/numerics/matrices.all_dimensions.cc deleted file mode 100644 index 910c8147f3..0000000000 --- a/deal.II/source/numerics/matrices.all_dimensions.cc +++ /dev/null @@ -1,1179 +0,0 @@ -//--------------------------------------------------------------------------- -// $Id$ -// Version: $Name$ -// -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 by the deal.II authors -// -// This file is subject to QPL and may not be distributed -// without copyright and license information. Please refer -// to the file deal.II/doc/license.html for the text and -// further information on this license. -// -//--------------------------------------------------------------------------- - - -#include -#include -#include -#include -#include -#include - -#ifdef DEAL_II_USE_PETSC -# include -# include -# include -# include -# include -#endif - -#ifdef DEAL_II_USE_TRILINOS -# include -# include -# include -# include -#endif - -#include - -DEAL_II_NAMESPACE_OPEN - - -//TODO:[WB] I don't think that the optimized storage of diagonals is needed (GK) -template -void -MatrixTools::apply_boundary_values (const std::map &boundary_values, - SparseMatrix &matrix, - Vector &solution, - Vector &right_hand_side, - const bool eliminate_columns) -{ - // Require that diagonals are first - // in each row - Assert (matrix.get_sparsity_pattern().optimize_diagonal(), - typename SparsityPattern::ExcDiagonalNotOptimized()); - Assert (matrix.n() == right_hand_side.size(), - ExcDimensionMismatch(matrix.n(), right_hand_side.size())); - Assert (matrix.n() == solution.size(), - ExcDimensionMismatch(matrix.n(), solution.size())); - // if no boundary values are to be applied - // simply return - if (boundary_values.size() == 0) - return; - - - const unsigned int n_dofs = matrix.m(); - - // if a diagonal entry is zero - // later, then we use another - // number instead. take it to be - // the first nonzero diagonal - // element of the matrix, or 1 if - // there is no such thing - number first_nonzero_diagonal_entry = 1; - for (unsigned int i=0; i::const_iterator dof = boundary_values.begin(), - endd = boundary_values.end(); - const SparsityPattern &sparsity = matrix.get_sparsity_pattern(); - const std::size_t *sparsity_rowstart = sparsity.get_rowstart_indices(); - const unsigned int *sparsity_colnums = sparsity.get_column_numbers(); - for (; dof != endd; ++dof) - { - Assert (dof->first < n_dofs, ExcInternalError()); - - const unsigned int dof_number = dof->first; - // for each boundary dof: - - // set entries of this line - // to zero except for the diagonal - // entry. Note that the diagonal - // entry is always the first one - // for square matrices, i.e. - // we shall not set - // matrix.global_entry( - // sparsity_rowstart[dof.first]) - const unsigned int last = sparsity_rowstart[dof_number+1]; - for (unsigned int j=sparsity_rowstart[dof_number]+1; jsecond * matrix.diag_element(dof_number); - right_hand_side(dof_number) = new_rhs; - } - else - { - matrix.set (dof_number, dof_number, - first_nonzero_diagonal_entry); - new_rhs = dof->second * first_nonzero_diagonal_entry; - right_hand_side(dof_number) = new_rhs; - } - - - // if the user wants to have - // the symmetry of the matrix - // preserved, and if the - // sparsity pattern is - // symmetric, then do a Gauss - // elimination step with the - // present row - if (eliminate_columns) - { - // store the only nonzero entry - // of this line for the Gauss - // elimination step - const number diagonal_entry = matrix.diag_element(dof_number); - - // we have to loop over all - // rows of the matrix which - // have a nonzero entry in - // the column which we work - // in presently. if the - // sparsity pattern is - // symmetric, then we can - // get the positions of - // these rows cheaply by - // looking at the nonzero - // column numbers of the - // present row. we need not - // look at the first entry, - // since that is the - // diagonal element and - // thus the present row - for (unsigned int j=sparsity_rowstart[dof_number]+1; jsecond; - } -} - - - -template -void -MatrixTools::apply_boundary_values (const std::map &boundary_values, - BlockSparseMatrix &matrix, - BlockVector &solution, - BlockVector &right_hand_side, - const bool eliminate_columns) -{ - const unsigned int blocks = matrix.n_block_rows(); - - Assert (matrix.n() == right_hand_side.size(), - ExcDimensionMismatch(matrix.n(), right_hand_side.size())); - Assert (matrix.n() == solution.size(), - ExcDimensionMismatch(matrix.n(), solution.size())); - Assert (matrix.n_block_rows() == matrix.n_block_cols(), - ExcNotQuadratic()); - Assert (matrix.get_sparsity_pattern().get_row_indices() == - matrix.get_sparsity_pattern().get_column_indices(), - ExcNotQuadratic()); - Assert (matrix.get_sparsity_pattern().get_column_indices() == - solution.get_block_indices (), - ExcBlocksDontMatch ()); - Assert (matrix.get_sparsity_pattern().get_row_indices() == - right_hand_side.get_block_indices (), - ExcBlocksDontMatch ()); - - for (unsigned int i=0; i::const_iterator dof = boundary_values.begin(), - endd = boundary_values.end(); - const BlockSparsityPattern & - sparsity_pattern = matrix.get_sparsity_pattern(); - - // pointer to the mapping between - // global and block indices. since - // the row and column mappings are - // equal, store a pointer on only - // one of them - const BlockIndices & - index_mapping = sparsity_pattern.get_column_indices(); - - // now loop over all boundary dofs - for (; dof != endd; ++dof) - { - Assert (dof->first < n_dofs, ExcInternalError()); - - // get global index and index - // in the block in which this - // dof is located - const unsigned int dof_number = dof->first; - const std::pair - block_index = index_mapping.global_to_local (dof_number); - - // for each boundary dof: - - // set entries of this line - // to zero except for the diagonal - // entry. Note that the diagonal - // entry is always the first one - // for square matrices, i.e. - // we shall not set - // matrix.global_entry( - // sparsity_rowstart[dof.first]) - // of the diagonal block - for (unsigned int block_col=0; block_colsecond * - matrix.block(block_index.first, block_index.first) - .diag_element(block_index.second); - else - { - matrix.block(block_index.first, block_index.first) - .diag_element(block_index.second) - = first_nonzero_diagonal_entry; - new_rhs = dof->second * first_nonzero_diagonal_entry; - } - right_hand_side.block(block_index.first)(block_index.second) - = new_rhs; - - - // if the user wants to have - // the symmetry of the matrix - // preserved, and if the - // sparsity pattern is - // symmetric, then do a Gauss - // elimination step with the - // present row. this is a - // little more complicated for - // block matrices. - if (eliminate_columns) - { - // store the only nonzero entry - // of this line for the Gauss - // elimination step - const number diagonal_entry - = matrix.block(block_index.first,block_index.first) - .diag_element(block_index.second); - - // we have to loop over all - // rows of the matrix which - // have a nonzero entry in - // the column which we work - // in presently. if the - // sparsity pattern is - // symmetric, then we can - // get the positions of - // these rows cheaply by - // looking at the nonzero - // column numbers of the - // present row. - // - // note that if we check - // whether row @p{row} in - // block (r,c) is non-zero, - // then we have to check - // for the existence of - // column @p{row} in block - // (c,r), i.e. of the - // transpose block - for (unsigned int block_row=0; block_rowsecond; - } -} - - - -#ifdef DEAL_II_USE_PETSC - -namespace PETScWrappers -{ - template - void - apply_boundary_values (const std::map &boundary_values, - PETScMatrix &matrix, - PETScVector &solution, - PETScVector &right_hand_side, - const bool eliminate_columns) - { - Assert (eliminate_columns == false, ExcNotImplemented()); - - Assert (matrix.n() == right_hand_side.size(), - ExcDimensionMismatch(matrix.n(), right_hand_side.size())); - Assert (matrix.n() == solution.size(), - ExcDimensionMismatch(matrix.n(), solution.size())); - - // if no boundary values are to be applied - // simply return - if (boundary_values.size() == 0) - return; - - const std::pair local_range - = matrix.local_range(); - Assert (local_range == right_hand_side.local_range(), - ExcInternalError()); - Assert (local_range == solution.local_range(), - ExcInternalError()); - - - // we have to read and write from this - // matrix (in this order). this will only - // work if we compress the matrix first, - // done here - matrix.compress (); - - // determine the first nonzero diagonal - // entry from within the part of the - // matrix that we can see. if we can't - // find such an entry, take one - PetscScalar average_nonzero_diagonal_entry = 1; - for (unsigned int i=local_range.first; i constrained_rows; - for (std::map::const_iterator - dof = boundary_values.begin(); - dof != boundary_values.end(); - ++dof) - if ((dof->first >= local_range.first) && - (dof->first < local_range.second)) - constrained_rows.push_back (dof->first); - - // then eliminate these rows and set - // their diagonal entry to what we have - // determined above. note that for petsc - // matrices interleaving read with write - // operations is very expensive. thus, we - // here always replace the diagonal - // element, rather than first checking - // whether it is nonzero and in that case - // preserving it. this is different from - // the case of deal.II sparse matrices - // treated in the other functions. - matrix.clear_rows (constrained_rows, average_nonzero_diagonal_entry); - - // the next thing is to set right hand - // side to the wanted value. there's one - // drawback: if we write to individual - // vector elements, then we have to do - // that on all processors. however, some - // processors may not need to set - // anything because their chunk of - // matrix/rhs do not contain any boundary - // nodes. therefore, rather than using - // individual calls, we use one call for - // all elements, thereby making sure that - // all processors call this function, - // even if some only have an empty set of - // elements to set - right_hand_side.compress (); - solution.compress (); - - std::vector indices; - std::vector solution_values; - for (std::map::const_iterator - dof = boundary_values.begin(); - dof != boundary_values.end(); - ++dof) - if ((dof->first >= local_range.first) && - (dof->first < local_range.second)) - { - indices.push_back (dof->first); - solution_values.push_back (dof->second); - } - solution.set (indices, solution_values); - - // now also set appropriate values for - // the rhs - for (unsigned int i=0; i &boundary_values, - PETScWrappers::SparseMatrix &matrix, - PETScWrappers::Vector &solution, - PETScWrappers::Vector &right_hand_side, - const bool eliminate_columns) -{ - // simply redirect to the generic function - // used for both petsc matrix types - PETScWrappers::apply_boundary_values (boundary_values, matrix, solution, - right_hand_side, eliminate_columns); -} - - - -void -MatrixTools:: -apply_boundary_values (const std::map &boundary_values, - PETScWrappers::MPI::SparseMatrix &matrix, - PETScWrappers::MPI::Vector &solution, - PETScWrappers::MPI::Vector &right_hand_side, - const bool eliminate_columns) -{ - // simply redirect to the generic function - // used for both petsc matrix types - PETScWrappers::apply_boundary_values (boundary_values, matrix, solution, - right_hand_side, eliminate_columns); - - // compress the matrix once we're done - matrix.compress (); -} - - -void -MatrixTools:: -apply_boundary_values (const std::map &boundary_values, - PETScWrappers::MPI::BlockSparseMatrix &matrix, - PETScWrappers::MPI::BlockVector &solution, - PETScWrappers::MPI::BlockVector &right_hand_side, - const bool eliminate_columns) -{ - Assert (matrix.n() == right_hand_side.size(), - ExcDimensionMismatch(matrix.n(), right_hand_side.size())); - Assert (matrix.n() == solution.size(), - ExcDimensionMismatch(matrix.n(), solution.size())); - Assert (matrix.n_block_rows() == matrix.n_block_cols(), - ExcNotQuadratic()); - - const unsigned int n_blocks = matrix.n_block_rows(); - - matrix.compress(); - - // We need to find the subdivision - // into blocks for the boundary values. - // To this end, generate a vector of - // maps with the respective indices. - std::vector > block_boundary_values(n_blocks); - { - int offset = 0, block=0; - for (std::map::const_iterator - dof = boundary_values.begin(); - dof != boundary_values.end(); - ++dof) - { - if (dof->first >= matrix.block(block,0).m() + offset) - { - offset += matrix.block(block,0).m(); - block++; - } - const unsigned int index = dof->first - offset; - block_boundary_values[block].insert(std::pair (index,dof->second)); - } - } - - // Now call the non-block variants on - // the diagonal subblocks and the - // solution/rhs. - for (unsigned int block=0; block local_range - = matrix.block(block_m,0).local_range(); - - std::vector constrained_rows; - for (std::map::const_iterator - dof = block_boundary_values[block_m].begin(); - dof != block_boundary_values[block_m].end(); - ++dof) - if ((dof->first >= local_range.first) && - (dof->first < local_range.second)) - constrained_rows.push_back (dof->first); - - for (unsigned int block_n=0; block_n - void - apply_boundary_values (const std::map &boundary_values, - TrilinosMatrix &matrix, - TrilinosVector &solution, - TrilinosVector &right_hand_side, - const bool eliminate_columns) - { - Assert (eliminate_columns == false, ExcNotImplemented()); - - Assert (matrix.n() == right_hand_side.size(), - ExcDimensionMismatch(matrix.n(), right_hand_side.size())); - Assert (matrix.n() == solution.size(), - ExcDimensionMismatch(matrix.m(), solution.size())); - - // if no boundary values are to be applied - // simply return - if (boundary_values.size() == 0) - return; - - const std::pair local_range - = matrix.local_range(); - Assert (local_range == right_hand_side.local_range(), - ExcInternalError()); - Assert (local_range == solution.local_range(), - ExcInternalError()); - - // we have to read and write from this - // matrix (in this order). this will only - // work if we compress the matrix first, - // done here - matrix.compress (); - - // determine the first nonzero diagonal - // entry from within the part of the - // matrix that we can see. if we can't - // find such an entry, take one - TrilinosScalar average_nonzero_diagonal_entry = 1; - for (unsigned int i=local_range.first; i constrained_rows; - for (std::map::const_iterator - dof = boundary_values.begin(); - dof != boundary_values.end(); - ++dof) - if ((dof->first >= local_range.first) && - (dof->first < local_range.second)) - constrained_rows.push_back (dof->first); - - // then eliminate these rows and - // set their diagonal entry to - // what we have determined - // above. if the value already is - // nonzero, it will be preserved, - // in accordance with the basic - // matrix classes in deal.II. - matrix.clear_rows (constrained_rows, average_nonzero_diagonal_entry); - - // the next thing is to set right - // hand side to the wanted - // value. there's one drawback: - // if we write to individual - // vector elements, then we have - // to do that on all - // processors. however, some - // processors may not need to set - // anything because their chunk - // of matrix/rhs do not contain - // any boundary nodes. therefore, - // rather than using individual - // calls, we use one call for all - // elements, thereby making sure - // that all processors call this - // function, even if some only - // have an empty set of elements - // to set - right_hand_side.compress (); - solution.compress (); - - std::vector indices; - std::vector solution_values; - for (std::map::const_iterator - dof = boundary_values.begin(); - dof != boundary_values.end(); - ++dof) - if ((dof->first >= local_range.first) && - (dof->first < local_range.second)) - { - indices.push_back (dof->first); - solution_values.push_back (dof->second); - } - solution.set (indices, solution_values); - - // now also set appropriate - // values for the rhs - for (unsigned int i=0; i - void - apply_block_boundary_values (const std::map &boundary_values, - TrilinosMatrix &matrix, - TrilinosBlockVector &solution, - TrilinosBlockVector &right_hand_side, - const bool eliminate_columns) - { - Assert (eliminate_columns == false, ExcNotImplemented()); - - Assert (matrix.n() == right_hand_side.size(), - ExcDimensionMismatch(matrix.n(), right_hand_side.size())); - Assert (matrix.n() == solution.size(), - ExcDimensionMismatch(matrix.n(), solution.size())); - Assert (matrix.n_block_rows() == matrix.n_block_cols(), - ExcNotQuadratic()); - - const unsigned int n_blocks = matrix.n_block_rows(); - - matrix.compress(); - - // We need to find the subdivision - // into blocks for the boundary values. - // To this end, generate a vector of - // maps with the respective indices. - std::vector > block_boundary_values(n_blocks); - { - int offset = 0, block=0; - for (std::map::const_iterator - dof = boundary_values.begin(); - dof != boundary_values.end(); - ++dof) - { - if (dof->first >= matrix.block(block,0).m() + offset) - { - offset += matrix.block(block,0).m(); - block++; - } - const unsigned int index = dof->first - offset; - block_boundary_values[block].insert( - std::pair (index,dof->second)); - } - } - - // Now call the non-block variants on - // the diagonal subblocks and the - // solution/rhs. - for (unsigned int block=0; block local_range - = matrix.block(block_m,0).local_range(); - - std::vector constrained_rows; - for (std::map::const_iterator - dof = block_boundary_values[block_m].begin(); - dof != block_boundary_values[block_m].end(); - ++dof) - if ((dof->first >= local_range.first) && - (dof->first < local_range.second)) - constrained_rows.push_back (dof->first); - - for (unsigned int block_n=0; block_n &boundary_values, - TrilinosWrappers::SparseMatrix &matrix, - TrilinosWrappers::Vector &solution, - TrilinosWrappers::Vector &right_hand_side, - const bool eliminate_columns) -{ - // simply redirect to the generic function - // used for both trilinos matrix types - TrilinosWrappers::apply_boundary_values (boundary_values, matrix, solution, - right_hand_side, eliminate_columns); -} - - - -void -MatrixTools:: -apply_boundary_values (const std::map &boundary_values, - TrilinosWrappers::SparseMatrix &matrix, - TrilinosWrappers::MPI::Vector &solution, - TrilinosWrappers::MPI::Vector &right_hand_side, - const bool eliminate_columns) -{ - // simply redirect to the generic function - // used for both trilinos matrix types - TrilinosWrappers::apply_boundary_values (boundary_values, matrix, solution, - right_hand_side, eliminate_columns); -} - - - -void -MatrixTools:: -apply_boundary_values (const std::map &boundary_values, - TrilinosWrappers::BlockSparseMatrix &matrix, - TrilinosWrappers::BlockVector &solution, - TrilinosWrappers::BlockVector &right_hand_side, - const bool eliminate_columns) -{ - TrilinosWrappers::apply_block_boundary_values (boundary_values, matrix, - solution, right_hand_side, - eliminate_columns); -} - - - -void -MatrixTools:: -apply_boundary_values (const std::map &boundary_values, - TrilinosWrappers::BlockSparseMatrix &matrix, - TrilinosWrappers::MPI::BlockVector &solution, - TrilinosWrappers::MPI::BlockVector &right_hand_side, - const bool eliminate_columns) -{ - TrilinosWrappers::apply_block_boundary_values (boundary_values, matrix, - solution, right_hand_side, - eliminate_columns); -} - -#endif - - - -void -MatrixTools:: -local_apply_boundary_values (const std::map &boundary_values, - const std::vector &local_dof_indices, - FullMatrix &local_matrix, - Vector &local_rhs, - const bool eliminate_columns) -{ - Assert (local_dof_indices.size() == local_matrix.m(), - ExcDimensionMismatch(local_dof_indices.size(), - local_matrix.m())); - Assert (local_dof_indices.size() == local_matrix.n(), - ExcDimensionMismatch(local_dof_indices.size(), - local_matrix.n())); - Assert (local_dof_indices.size() == local_rhs.size(), - ExcDimensionMismatch(local_dof_indices.size(), - local_rhs.size())); - - // if there is nothing to do, then exit - // right away - if (boundary_values.size() == 0) - return; - - // otherwise traverse all the dofs used in - // the local matrices and vectors and see - // what's there to do - - // if we need to treat an entry, then we - // set the diagonal entry to its absolute - // value. if it is zero, we used to set it - // to one, which is a really terrible - // choice that can lead to hours of - // searching for bugs in programs (I - // experienced this :-( ) if the matrix - // entries are otherwise very large. this - // is so since iterative solvers would - // simply not correct boundary nodes for - // their correct values since the residual - // contributions of their rows of the - // linear system is almost zero if the - // diagonal entry is one. thus, set it to - // the average absolute value of the - // nonzero diagonal elements. - // - // we only compute this value lazily the - // first time we need it. - double average_diagonal = 0; - const unsigned int n_local_dofs = local_dof_indices.size(); - for (unsigned int i=0; i::const_iterator - boundary_value = boundary_values.find (local_dof_indices[i]); - if (boundary_value != boundary_values.end()) - { - // remove this row, except for the - // diagonal element - for (unsigned j=0; jsecond; - - // finally do the elimination step - // if requested - if (eliminate_columns == true) - { - for (unsigned int row=0; rowsecond; - local_matrix(row,i) = 0; - } - } - } - } -} - - - - - -// explicit instantiations - -template -void -MatrixTools::apply_boundary_values (const std::map &boundary_values, - SparseMatrix &matrix, - Vector &solution, - Vector &right_hand_side, - const bool eliminate_columns); -template -void -MatrixTools::apply_boundary_values (const std::map &boundary_values, - SparseMatrix &matrix, - Vector &solution, - Vector &right_hand_side, - const bool eliminate_columns); - -template -void -MatrixTools::apply_boundary_values (const std::map &boundary_values, - BlockSparseMatrix &matrix, - BlockVector &solution, - BlockVector &right_hand_side, - const bool eliminate_columns); -template -void -MatrixTools::apply_boundary_values (const std::map &boundary_values, - BlockSparseMatrix &matrix, - BlockVector &solution, - BlockVector &right_hand_side, - const bool eliminate_columns); - -DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/matrices.cc b/deal.II/source/numerics/matrices.cc index 0c3b0e709c..2a87aaaf9f 100644 --- a/deal.II/source/numerics/matrices.cc +++ b/deal.II/source/numerics/matrices.cc @@ -32,9 +32,28 @@ #include #include #include +#include #include #include +#ifdef DEAL_II_USE_PETSC +# include +# include +# include +# include +# include +#endif + +#ifdef DEAL_II_USE_TRILINOS +# include +# include +# include +# include +#endif + +#include + + #include #include #include @@ -766,48 +785,6 @@ void MatrixCreator::create_mass_matrix (const hp::DoFHandler &d - -#if deal_II_dimension == 1 - -template <> -void MatrixCreator::create_boundary_mass_matrix (const Mapping<1,1>&, - const DoFHandler<1,1>&, - const Quadrature<0>&, - SparseMatrix&, - const FunctionMap<1>::type&, - Vector&, - std::vector&, - const Function<1>* const, - std::vector) -{ - // what would that be in 1d? the - // identity matrix on the boundary - // dofs? - Assert (false, ExcNotImplemented()); -} - -template <> -void MatrixCreator::create_boundary_mass_matrix (const Mapping<1,2>&, - const DoFHandler<1,2>&, - const Quadrature<0>&, - SparseMatrix&, - const FunctionMap<2>::type&, - Vector&, - std::vector&, - const Function<2>* const, - std::vector) -{ - // what would that be in 1d? the - // identity matrix on the boundary - // dofs? - Assert (false, ExcNotImplemented()); -} - - -#else - - - template void MatrixCreator::create_boundary_mass_matrix (const Mapping &mapping, @@ -820,6 +797,15 @@ MatrixCreator::create_boundary_mass_matrix (const Mapping &mappi const Function * const coefficient, std::vector component_mapping) { + // what would that be in 1d? the + // identity matrix on the boundary + // dofs? + if (dim == 1) + { + Assert (false, ExcNotImplemented()); + return; + } + const FiniteElement &fe = dof.get_fe(); const unsigned int n_components = fe.n_components(); @@ -886,7 +872,6 @@ MatrixCreator::create_boundary_mass_matrix (const Mapping &mappi } -#if deal_II_dimension == 2 template <> void @@ -906,7 +891,6 @@ create_boundary_mass_matrix_1<2,3> (std_cxx1x::tuple &, Assert(false,ExcNotImplemented()); } -#endif template @@ -1177,7 +1161,7 @@ create_boundary_mass_matrix_1 (std_cxx1x::tuple &, } } -#endif + template void MatrixCreator::create_boundary_mass_matrix (const DoFHandler &dof, @@ -1196,30 +1180,6 @@ void MatrixCreator::create_boundary_mass_matrix (const DoFHandler -#if deal_II_dimension == 1 - -template -void -MatrixCreator::create_boundary_mass_matrix (const hp::MappingCollection&, - const hp::DoFHandler&, - const hp::QCollection&, - SparseMatrix&, - const typename FunctionMap::type&, - Vector&, - std::vector&, - const Function* const, - std::vector) -{ - // what would that be in 1d? the - // identity matrix on the boundary - // dofs? - Assert (false, ExcNotImplemented()); -} - - -#else - - template void MatrixCreator::create_boundary_mass_matrix (const hp::MappingCollection &mapping, @@ -1232,6 +1192,15 @@ MatrixCreator::create_boundary_mass_matrix (const hp::MappingCollection * const coefficient, std::vector component_mapping) { + // what would that be in 1d? the + // identity matrix on the boundary + // dofs? + if (dim == 1) + { + Assert (false, ExcNotImplemented()); + return; + } + const hp::FECollection &fe_collection = dof.get_fe(); const unsigned int n_components = fe_collection.n_components(); @@ -1664,7 +1633,7 @@ create_boundary_mass_matrix_1 (std_cxx1x::tuple void MatrixCreator::create_boundary_mass_matrix (const hp::DoFHandler &dof, @@ -1906,442 +1875,1141 @@ void MatrixCreator::create_laplace_matrix (const hp::DoFHandler +//TODO:[WB] I don't think that the optimized storage of diagonals is needed (GK) +template +void +MatrixTools::apply_boundary_values (const std::map &boundary_values, + SparseMatrix &matrix, + Vector &solution, + Vector &right_hand_side, + const bool eliminate_columns) +{ + // Require that diagonals are first + // in each row + Assert (matrix.get_sparsity_pattern().optimize_diagonal(), + typename SparsityPattern::ExcDiagonalNotOptimized()); + Assert (matrix.n() == right_hand_side.size(), + ExcDimensionMismatch(matrix.n(), right_hand_side.size())); + Assert (matrix.n() == solution.size(), + ExcDimensionMismatch(matrix.n(), solution.size())); + // if no boundary values are to be applied + // simply return + if (boundary_values.size() == 0) + return; + + + const unsigned int n_dofs = matrix.m(); + + // if a diagonal entry is zero + // later, then we use another + // number instead. take it to be + // the first nonzero diagonal + // element of the matrix, or 1 if + // there is no such thing + number first_nonzero_diagonal_entry = 1; + for (unsigned int i=0; i::const_iterator dof = boundary_values.begin(), + endd = boundary_values.end(); + const SparsityPattern &sparsity = matrix.get_sparsity_pattern(); + const std::size_t *sparsity_rowstart = sparsity.get_rowstart_indices(); + const unsigned int *sparsity_colnums = sparsity.get_column_numbers(); + for (; dof != endd; ++dof) + { + Assert (dof->first < n_dofs, ExcInternalError()); + + const unsigned int dof_number = dof->first; + // for each boundary dof: + + // set entries of this line + // to zero except for the diagonal + // entry. Note that the diagonal + // entry is always the first one + // for square matrices, i.e. + // we shall not set + // matrix.global_entry( + // sparsity_rowstart[dof.first]) + const unsigned int last = sparsity_rowstart[dof_number+1]; + for (unsigned int j=sparsity_rowstart[dof_number]+1; jsecond * matrix.diag_element(dof_number); + right_hand_side(dof_number) = new_rhs; + } + else + { + matrix.set (dof_number, dof_number, + first_nonzero_diagonal_entry); + new_rhs = dof->second * first_nonzero_diagonal_entry; + right_hand_side(dof_number) = new_rhs; + } -// explicit instantiations + // if the user wants to have + // the symmetry of the matrix + // preserved, and if the + // sparsity pattern is + // symmetric, then do a Gauss + // elimination step with the + // present row + if (eliminate_columns) + { + // store the only nonzero entry + // of this line for the Gauss + // elimination step + const number diagonal_entry = matrix.diag_element(dof_number); + + // we have to loop over all + // rows of the matrix which + // have a nonzero entry in + // the column which we work + // in presently. if the + // sparsity pattern is + // symmetric, then we can + // get the positions of + // these rows cheaply by + // looking at the nonzero + // column numbers of the + // present row. we need not + // look at the first entry, + // since that is the + // diagonal element and + // thus the present row + for (unsigned int j=sparsity_rowstart[dof_number]+1; j -(const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); + // preset solution vector + solution(dof_number) = dof->second; + } +} -template -void MatrixCreator::create_mass_matrix -(const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); - -// hp versions of functions -template -void MatrixCreator::create_mass_matrix -(const hp::MappingCollection &mapping, - const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const hp::MappingCollection &mapping, - const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); +template +void +MatrixTools::apply_boundary_values (const std::map &boundary_values, + BlockSparseMatrix &matrix, + BlockVector &solution, + BlockVector &right_hand_side, + const bool eliminate_columns) +{ + const unsigned int blocks = matrix.n_block_rows(); + + Assert (matrix.n() == right_hand_side.size(), + ExcDimensionMismatch(matrix.n(), right_hand_side.size())); + Assert (matrix.n() == solution.size(), + ExcDimensionMismatch(matrix.n(), solution.size())); + Assert (matrix.n_block_rows() == matrix.n_block_cols(), + ExcNotQuadratic()); + Assert (matrix.get_sparsity_pattern().get_row_indices() == + matrix.get_sparsity_pattern().get_column_indices(), + ExcNotQuadratic()); + Assert (matrix.get_sparsity_pattern().get_column_indices() == + solution.get_block_indices (), + ExcBlocksDontMatch ()); + Assert (matrix.get_sparsity_pattern().get_row_indices() == + right_hand_side.get_block_indices (), + ExcBlocksDontMatch ()); + + for (unsigned int i=0; i::const_iterator dof = boundary_values.begin(), + endd = boundary_values.end(); + const BlockSparsityPattern & + sparsity_pattern = matrix.get_sparsity_pattern(); + + // pointer to the mapping between + // global and block indices. since + // the row and column mappings are + // equal, store a pointer on only + // one of them + const BlockIndices & + index_mapping = sparsity_pattern.get_column_indices(); + + // now loop over all boundary dofs + for (; dof != endd; ++dof) + { + Assert (dof->first < n_dofs, ExcInternalError()); + + // get global index and index + // in the block in which this + // dof is located + const unsigned int dof_number = dof->first; + const std::pair + block_index = index_mapping.global_to_local (dof_number); + + // for each boundary dof: + + // set entries of this line + // to zero except for the diagonal + // entry. Note that the diagonal + // entry is always the first one + // for square matrices, i.e. + // we shall not set + // matrix.global_entry( + // sparsity_rowstart[dof.first]) + // of the diagonal block + for (unsigned int block_col=0; block_colsecond * + matrix.block(block_index.first, block_index.first) + .diag_element(block_index.second); + else + { + matrix.block(block_index.first, block_index.first) + .diag_element(block_index.second) + = first_nonzero_diagonal_entry; + new_rhs = dof->second * first_nonzero_diagonal_entry; + } + right_hand_side.block(block_index.first)(block_index.second) + = new_rhs; + + + // if the user wants to have + // the symmetry of the matrix + // preserved, and if the + // sparsity pattern is + // symmetric, then do a Gauss + // elimination step with the + // present row. this is a + // little more complicated for + // block matrices. + if (eliminate_columns) + { + // store the only nonzero entry + // of this line for the Gauss + // elimination step + const number diagonal_entry + = matrix.block(block_index.first,block_index.first) + .diag_element(block_index.second); + + // we have to loop over all + // rows of the matrix which + // have a nonzero entry in + // the column which we work + // in presently. if the + // sparsity pattern is + // symmetric, then we can + // get the positions of + // these rows cheaply by + // looking at the nonzero + // column numbers of the + // present row. + // + // note that if we check + // whether row @p{row} in + // block (r,c) is non-zero, + // then we have to check + // for the existence of + // column @p{row} in block + // (c,r), i.e. of the + // transpose block + for (unsigned int block_row=0; block_row -(const hp::MappingCollection &mapping, - const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const hp::MappingCollection &mapping, - const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); + // preset solution vector + solution.block(block_index.first)(block_index.second) = dof->second; + } +} -#if deal_II_dimension != 1 -template -void MatrixCreator::create_boundary_mass_matrix -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const FunctionMap::type &rhs, - Vector &rhs_vector, - std::vector &dof_to_boundary_mapping, - const Function * const a, - std::vector); +#ifdef DEAL_II_USE_PETSC + +namespace PETScWrappers +{ + template + void + apply_boundary_values (const std::map &boundary_values, + PETScMatrix &matrix, + PETScVector &solution, + PETScVector &right_hand_side, + const bool eliminate_columns) + { + Assert (eliminate_columns == false, ExcNotImplemented()); + + Assert (matrix.n() == right_hand_side.size(), + ExcDimensionMismatch(matrix.n(), right_hand_side.size())); + Assert (matrix.n() == solution.size(), + ExcDimensionMismatch(matrix.n(), solution.size())); + + // if no boundary values are to be applied + // simply return + if (boundary_values.size() == 0) + return; + + const std::pair local_range + = matrix.local_range(); + Assert (local_range == right_hand_side.local_range(), + ExcInternalError()); + Assert (local_range == solution.local_range(), + ExcInternalError()); + + + // we have to read and write from this + // matrix (in this order). this will only + // work if we compress the matrix first, + // done here + matrix.compress (); + + // determine the first nonzero diagonal + // entry from within the part of the + // matrix that we can see. if we can't + // find such an entry, take one + PetscScalar average_nonzero_diagonal_entry = 1; + for (unsigned int i=local_range.first; i constrained_rows; + for (std::map::const_iterator + dof = boundary_values.begin(); + dof != boundary_values.end(); + ++dof) + if ((dof->first >= local_range.first) && + (dof->first < local_range.second)) + constrained_rows.push_back (dof->first); + + // then eliminate these rows and set + // their diagonal entry to what we have + // determined above. note that for petsc + // matrices interleaving read with write + // operations is very expensive. thus, we + // here always replace the diagonal + // element, rather than first checking + // whether it is nonzero and in that case + // preserving it. this is different from + // the case of deal.II sparse matrices + // treated in the other functions. + matrix.clear_rows (constrained_rows, average_nonzero_diagonal_entry); + + // the next thing is to set right hand + // side to the wanted value. there's one + // drawback: if we write to individual + // vector elements, then we have to do + // that on all processors. however, some + // processors may not need to set + // anything because their chunk of + // matrix/rhs do not contain any boundary + // nodes. therefore, rather than using + // individual calls, we use one call for + // all elements, thereby making sure that + // all processors call this function, + // even if some only have an empty set of + // elements to set + right_hand_side.compress (); + solution.compress (); + + std::vector indices; + std::vector solution_values; + for (std::map::const_iterator + dof = boundary_values.begin(); + dof != boundary_values.end(); + ++dof) + if ((dof->first >= local_range.first) && + (dof->first < local_range.second)) + { + indices.push_back (dof->first); + solution_values.push_back (dof->second); + } + solution.set (indices, solution_values); + + // now also set appropriate values for + // the rhs + for (unsigned int i=0; i -(const Mapping &, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const FunctionMap::type &rhs, - Vector &rhs_vector, - std::vector &dof_to_boundary_mapping, - const Function * const a, - std::vector); -template void -MatrixCreator::create_boundary_mass_matrix -(const hp::MappingCollection&, - const hp::DoFHandler&, - const hp::QCollection&, - SparseMatrix&, - const FunctionMap::type&, - Vector&, - std::vector&, - const Function * const, - std::vector); +MatrixTools:: +apply_boundary_values (const std::map &boundary_values, + PETScWrappers::SparseMatrix &matrix, + PETScWrappers::Vector &solution, + PETScWrappers::Vector &right_hand_side, + const bool eliminate_columns) +{ + // simply redirect to the generic function + // used for both petsc matrix types + PETScWrappers::apply_boundary_values (boundary_values, matrix, solution, + right_hand_side, eliminate_columns); +} -template -void MatrixCreator::create_boundary_mass_matrix -(const hp::DoFHandler&, - const hp::QCollection&, - SparseMatrix&, - const FunctionMap::type&, - Vector&, - std::vector&, - const Function * const, - std::vector); + + +void +MatrixTools:: +apply_boundary_values (const std::map &boundary_values, + PETScWrappers::MPI::SparseMatrix &matrix, + PETScWrappers::MPI::Vector &solution, + PETScWrappers::MPI::Vector &right_hand_side, + const bool eliminate_columns) +{ + // simply redirect to the generic function + // used for both petsc matrix types + PETScWrappers::apply_boundary_values (boundary_values, matrix, solution, + right_hand_side, eliminate_columns); + + // compress the matrix once we're done + matrix.compress (); +} + + +void +MatrixTools:: +apply_boundary_values (const std::map &boundary_values, + PETScWrappers::MPI::BlockSparseMatrix &matrix, + PETScWrappers::MPI::BlockVector &solution, + PETScWrappers::MPI::BlockVector &right_hand_side, + const bool eliminate_columns) +{ + Assert (matrix.n() == right_hand_side.size(), + ExcDimensionMismatch(matrix.n(), right_hand_side.size())); + Assert (matrix.n() == solution.size(), + ExcDimensionMismatch(matrix.n(), solution.size())); + Assert (matrix.n_block_rows() == matrix.n_block_cols(), + ExcNotQuadratic()); + + const unsigned int n_blocks = matrix.n_block_rows(); + + matrix.compress(); + + // We need to find the subdivision + // into blocks for the boundary values. + // To this end, generate a vector of + // maps with the respective indices. + std::vector > block_boundary_values(n_blocks); + { + int offset = 0, block=0; + for (std::map::const_iterator + dof = boundary_values.begin(); + dof != boundary_values.end(); + ++dof) + { + if (dof->first >= matrix.block(block,0).m() + offset) + { + offset += matrix.block(block,0).m(); + block++; + } + const unsigned int index = dof->first - offset; + block_boundary_values[block].insert(std::pair (index,dof->second)); + } + } + + // Now call the non-block variants on + // the diagonal subblocks and the + // solution/rhs. + for (unsigned int block=0; block local_range + = matrix.block(block_m,0).local_range(); + + std::vector constrained_rows; + for (std::map::const_iterator + dof = block_boundary_values[block_m].begin(); + dof != block_boundary_values[block_m].end(); + ++dof) + if ((dof->first >= local_range.first) && + (dof->first < local_range.second)) + constrained_rows.push_back (dof->first); + + for (unsigned int block_n=0; block_n -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_laplace_matrix -(const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_laplace_matrix -(const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); -template -void MatrixCreator::create_laplace_matrix -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); - -// hp versions of create_laplace_matrix -template -void MatrixCreator::create_laplace_matrix -(const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_laplace_matrix -(const hp::MappingCollection &mapping, - const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_laplace_matrix -(const hp::MappingCollection &mapping, - const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); -template -void MatrixCreator::create_laplace_matrix -(const hp::DoFHandler &dof, - const hp::QCollection &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); +#ifdef DEAL_II_USE_TRILINOS +namespace TrilinosWrappers +{ + template + void + apply_boundary_values (const std::map &boundary_values, + TrilinosMatrix &matrix, + TrilinosVector &solution, + TrilinosVector &right_hand_side, + const bool eliminate_columns) + { + Assert (eliminate_columns == false, ExcNotImplemented()); + + Assert (matrix.n() == right_hand_side.size(), + ExcDimensionMismatch(matrix.n(), right_hand_side.size())); + Assert (matrix.n() == solution.size(), + ExcDimensionMismatch(matrix.m(), solution.size())); + + // if no boundary values are to be applied + // simply return + if (boundary_values.size() == 0) + return; + + const std::pair local_range + = matrix.local_range(); + Assert (local_range == right_hand_side.local_range(), + ExcInternalError()); + Assert (local_range == solution.local_range(), + ExcInternalError()); + + // we have to read and write from this + // matrix (in this order). this will only + // work if we compress the matrix first, + // done here + matrix.compress (); + + // determine the first nonzero diagonal + // entry from within the part of the + // matrix that we can see. if we can't + // find such an entry, take one + TrilinosScalar average_nonzero_diagonal_entry = 1; + for (unsigned int i=local_range.first; i constrained_rows; + for (std::map::const_iterator + dof = boundary_values.begin(); + dof != boundary_values.end(); + ++dof) + if ((dof->first >= local_range.first) && + (dof->first < local_range.second)) + constrained_rows.push_back (dof->first); + + // then eliminate these rows and + // set their diagonal entry to + // what we have determined + // above. if the value already is + // nonzero, it will be preserved, + // in accordance with the basic + // matrix classes in deal.II. + matrix.clear_rows (constrained_rows, average_nonzero_diagonal_entry); + + // the next thing is to set right + // hand side to the wanted + // value. there's one drawback: + // if we write to individual + // vector elements, then we have + // to do that on all + // processors. however, some + // processors may not need to set + // anything because their chunk + // of matrix/rhs do not contain + // any boundary nodes. therefore, + // rather than using individual + // calls, we use one call for all + // elements, thereby making sure + // that all processors call this + // function, even if some only + // have an empty set of elements + // to set + right_hand_side.compress (); + solution.compress (); + + std::vector indices; + std::vector solution_values; + for (std::map::const_iterator + dof = boundary_values.begin(); + dof != boundary_values.end(); + ++dof) + if ((dof->first >= local_range.first) && + (dof->first < local_range.second)) + { + indices.push_back (dof->first); + solution_values.push_back (dof->second); + } + solution.set (indices, solution_values); + + // now also set appropriate + // values for the rhs + for (unsigned int i=0; i -(const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); + template + void + apply_block_boundary_values (const std::map &boundary_values, + TrilinosMatrix &matrix, + TrilinosBlockVector &solution, + TrilinosBlockVector &right_hand_side, + const bool eliminate_columns) + { + Assert (eliminate_columns == false, ExcNotImplemented()); + + Assert (matrix.n() == right_hand_side.size(), + ExcDimensionMismatch(matrix.n(), right_hand_side.size())); + Assert (matrix.n() == solution.size(), + ExcDimensionMismatch(matrix.n(), solution.size())); + Assert (matrix.n_block_rows() == matrix.n_block_cols(), + ExcNotQuadratic()); + + const unsigned int n_blocks = matrix.n_block_rows(); + + matrix.compress(); + + // We need to find the subdivision + // into blocks for the boundary values. + // To this end, generate a vector of + // maps with the respective indices. + std::vector > block_boundary_values(n_blocks); + { + int offset = 0, block=0; + for (std::map::const_iterator + dof = boundary_values.begin(); + dof != boundary_values.end(); + ++dof) + { + if (dof->first >= matrix.block(block,0).m() + offset) + { + offset += matrix.block(block,0).m(); + block++; + } + const unsigned int index = dof->first - offset; + block_boundary_values[block].insert( + std::pair (index,dof->second)); + } + } + + // Now call the non-block variants on + // the diagonal subblocks and the + // solution/rhs. + for (unsigned int block=0; block local_range + = matrix.block(block_m,0).local_range(); + + std::vector constrained_rows; + for (std::map::const_iterator + dof = block_boundary_values[block_m].begin(); + dof != block_boundary_values[block_m].end(); + ++dof) + if ((dof->first >= local_range.first) && + (dof->first < local_range.second)) + constrained_rows.push_back (dof->first); + + for (unsigned int block_n=0; block_n -(const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); -template -void MatrixCreator::create_mass_matrix -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const Function &rhs, - Vector &rhs_vector, - const Function * const coefficient); -#if deal_II_dimension == 2 -template -void MatrixCreator::create_boundary_mass_matrix -(const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const FunctionMap::type &rhs, - Vector &rhs_vector, - std::vector &dof_to_boundary_mapping, - const Function * const a, - std::vector); +void +MatrixTools:: +apply_boundary_values (const std::map &boundary_values, + TrilinosWrappers::SparseMatrix &matrix, + TrilinosWrappers::Vector &solution, + TrilinosWrappers::Vector &right_hand_side, + const bool eliminate_columns) +{ + // simply redirect to the generic function + // used for both trilinos matrix types + TrilinosWrappers::apply_boundary_values (boundary_values, matrix, solution, + right_hand_side, eliminate_columns); +} -template -void MatrixCreator::create_boundary_mass_matrix -(const Mapping &, - const DoFHandler &dof, - const Quadrature &q, - SparseMatrix &matrix, - const FunctionMap::type &rhs, - Vector &rhs_vector, - std::vector &dof_to_boundary_mapping, - const Function * const a, - std::vector); -#endif -// #if deal_II_dimension != 1 -// template -// void -// MatrixCreator::create_boundary_mass_matrix -// (const Mapping &mapping, -// const DoFHandler &dof, -// const Quadrature &q, -// SparseMatrix &matrix, -// const FunctionMap::type &boundary_functions, -// Vector &rhs_vector, -// std::vector &dof_to_boundary_mapping, -// const Function * const a, -// std::vector &component_mapping); -// #endif - -// template -// void MatrixCreator::create_boundary_mass_matrix -// (const DoFHandler &dof, -// const Quadrature &q, -// SparseMatrix &matrix, -// const FunctionMap::type &rhs, -// Vector &rhs_vector, -// std::vector &dof_to_boundary_mapping, -// const Function * const a, -// std::vector &component_mapping); - - -// // non-hp version of create_mass_matrix -// template -// void MatrixCreator::create_mass_matrix -// (const Mapping &mapping, -// const DoFHandler &dof, -// const Quadrature &q, -// SparseMatrix &matrix, -// const Function * const coefficient); -// template -// void MatrixCreator::create_mass_matrix -// (const DoFHandler &dof, -// const Quadrature &q, -// SparseMatrix &matrix, -// const Function * const coefficient); -// template -// void MatrixCreator::create_mass_matrix -// (const Mapping &mapping, -// const DoFHandler &dof, -// const Quadrature &q, -// SparseMatrix &matrix, -// const Function &rhs, -// Vector &rhs_vector, -// const Function * const coefficient); -// template -// void MatrixCreator::create_mass_matrix -// (const DoFHandler &dof, -// const Quadrature &q, -// SparseMatrix &matrix, -// const Function &rhs, -// Vector &rhs_vector, -// const Function * const coefficient); - - -// template -// void MatrixCreator::create_mass_matrix -// (const Mapping &mapping, -// const DoFHandler &dof, -// const Quadrature &q, -// SparseMatrix &matrix, -// const Function * const coefficient); -// template -// void MatrixCreator::create_mass_matrix -// (const DoFHandler &dof, -// const Quadrature &q, -// SparseMatrix &matrix, -// const Function * const coefficient); -// template -// void MatrixCreator::create_mass_matrix -// (const Mapping &mapping, -// const DoFHandler &dof, -// const Quadrature &q, -// SparseMatrix &matrix, -// const Function &rhs, -// Vector &rhs_vector, -// const Function * const coefficient); -// template -// void MatrixCreator::create_mass_matrix -// (const DoFHandler &dof, -// const Quadrature &q, -// SparseMatrix &matrix, -// const Function &rhs, -// Vector &rhs_vector, -// const Function * const coefficient); +void +MatrixTools:: +apply_boundary_values (const std::map &boundary_values, + TrilinosWrappers::SparseMatrix &matrix, + TrilinosWrappers::MPI::Vector &solution, + TrilinosWrappers::MPI::Vector &right_hand_side, + const bool eliminate_columns) +{ + // simply redirect to the generic function + // used for both trilinos matrix types + TrilinosWrappers::apply_boundary_values (boundary_values, matrix, solution, + right_hand_side, eliminate_columns); +} + +void +MatrixTools:: +apply_boundary_values (const std::map &boundary_values, + TrilinosWrappers::BlockSparseMatrix &matrix, + TrilinosWrappers::BlockVector &solution, + TrilinosWrappers::BlockVector &right_hand_side, + const bool eliminate_columns) +{ + TrilinosWrappers::apply_block_boundary_values (boundary_values, matrix, + solution, right_hand_side, + eliminate_columns); +} + + + +void +MatrixTools:: +apply_boundary_values (const std::map &boundary_values, + TrilinosWrappers::BlockSparseMatrix &matrix, + TrilinosWrappers::MPI::BlockVector &solution, + TrilinosWrappers::MPI::BlockVector &right_hand_side, + const bool eliminate_columns) +{ + TrilinosWrappers::apply_block_boundary_values (boundary_values, matrix, + solution, right_hand_side, + eliminate_columns); +} + #endif + + +void +MatrixTools:: +local_apply_boundary_values (const std::map &boundary_values, + const std::vector &local_dof_indices, + FullMatrix &local_matrix, + Vector &local_rhs, + const bool eliminate_columns) +{ + Assert (local_dof_indices.size() == local_matrix.m(), + ExcDimensionMismatch(local_dof_indices.size(), + local_matrix.m())); + Assert (local_dof_indices.size() == local_matrix.n(), + ExcDimensionMismatch(local_dof_indices.size(), + local_matrix.n())); + Assert (local_dof_indices.size() == local_rhs.size(), + ExcDimensionMismatch(local_dof_indices.size(), + local_rhs.size())); + + // if there is nothing to do, then exit + // right away + if (boundary_values.size() == 0) + return; + + // otherwise traverse all the dofs used in + // the local matrices and vectors and see + // what's there to do + + // if we need to treat an entry, then we + // set the diagonal entry to its absolute + // value. if it is zero, we used to set it + // to one, which is a really terrible + // choice that can lead to hours of + // searching for bugs in programs (I + // experienced this :-( ) if the matrix + // entries are otherwise very large. this + // is so since iterative solvers would + // simply not correct boundary nodes for + // their correct values since the residual + // contributions of their rows of the + // linear system is almost zero if the + // diagonal entry is one. thus, set it to + // the average absolute value of the + // nonzero diagonal elements. + // + // we only compute this value lazily the + // first time we need it. + double average_diagonal = 0; + const unsigned int n_local_dofs = local_dof_indices.size(); + for (unsigned int i=0; i::const_iterator + boundary_value = boundary_values.find (local_dof_indices[i]); + if (boundary_value != boundary_values.end()) + { + // remove this row, except for the + // diagonal element + for (unsigned j=0; jsecond; + + // finally do the elimination step + // if requested + if (eliminate_columns == true) + { + for (unsigned int row=0; rowsecond; + local_matrix(row,i) = 0; + } + } + } + } +} + + + +// explicit instantiations +#include "matrices.inst" + +template +void +MatrixTools::apply_boundary_values (const std::map &boundary_values, + SparseMatrix &matrix, + Vector &solution, + Vector &right_hand_side, + const bool eliminate_columns); +template +void +MatrixTools::apply_boundary_values (const std::map &boundary_values, + SparseMatrix &matrix, + Vector &solution, + Vector &right_hand_side, + const bool eliminate_columns); + +template +void +MatrixTools::apply_boundary_values (const std::map &boundary_values, + BlockSparseMatrix &matrix, + BlockVector &solution, + BlockVector &right_hand_side, + const bool eliminate_columns); +template +void +MatrixTools::apply_boundary_values (const std::map &boundary_values, + BlockSparseMatrix &matrix, + BlockVector &solution, + BlockVector &right_hand_side, + const bool eliminate_columns); + + DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/matrices.inst.in b/deal.II/source/numerics/matrices.inst.in new file mode 100644 index 0000000000..c6f007188b --- /dev/null +++ b/deal.II/source/numerics/matrices.inst.in @@ -0,0 +1,450 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ +// non-hp version of create_mass_matrix +template +void MatrixCreator::create_mass_matrix +(const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); + + +template +void MatrixCreator::create_mass_matrix +(const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); + +// hp versions of functions +template +void MatrixCreator::create_mass_matrix +(const hp::MappingCollection &mapping, + const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const hp::MappingCollection &mapping, + const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); + + +template +void MatrixCreator::create_mass_matrix +(const hp::MappingCollection &mapping, + const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const hp::MappingCollection &mapping, + const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); + + +#if deal_II_dimension != 1 + +template +void MatrixCreator::create_boundary_mass_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const FunctionMap::type &rhs, + Vector &rhs_vector, + std::vector &dof_to_boundary_mapping, + const Function * const a, + std::vector); + +template +void MatrixCreator::create_boundary_mass_matrix +(const Mapping &, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const FunctionMap::type &rhs, + Vector &rhs_vector, + std::vector &dof_to_boundary_mapping, + const Function * const a, + std::vector); + +template +void +MatrixCreator::create_boundary_mass_matrix +(const hp::MappingCollection&, + const hp::DoFHandler&, + const hp::QCollection&, + SparseMatrix&, + const FunctionMap::type&, + Vector&, + std::vector&, + const Function * const, + std::vector); + +template +void MatrixCreator::create_boundary_mass_matrix +(const hp::DoFHandler&, + const hp::QCollection&, + SparseMatrix&, + const FunctionMap::type&, + Vector&, + std::vector&, + const Function * const, + std::vector); + +#endif + + +// non-hp versions of create_laplace_matrix +template +void MatrixCreator::create_laplace_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_laplace_matrix +(const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_laplace_matrix +(const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); +template +void MatrixCreator::create_laplace_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); + +// hp versions of create_laplace_matrix +template +void MatrixCreator::create_laplace_matrix +(const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_laplace_matrix +(const hp::MappingCollection &mapping, + const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_laplace_matrix +(const hp::MappingCollection &mapping, + const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); +template +void MatrixCreator::create_laplace_matrix +(const hp::DoFHandler &dof, + const hp::QCollection &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); + + + +#if deal_II_dimension != 3 + +// non-hp version of create_mass_matrix +template +void MatrixCreator::create_mass_matrix +(const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); + + +template +void MatrixCreator::create_mass_matrix +(const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); +template +void MatrixCreator::create_mass_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function &rhs, + Vector &rhs_vector, + const Function * const coefficient); + +#if deal_II_dimension == 2 + +template +void MatrixCreator::create_boundary_mass_matrix +(const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const FunctionMap::type &rhs, + Vector &rhs_vector, + std::vector &dof_to_boundary_mapping, + const Function * const a, + std::vector); + +template +void MatrixCreator::create_boundary_mass_matrix +(const Mapping &, + const DoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const FunctionMap::type &rhs, + Vector &rhs_vector, + std::vector &dof_to_boundary_mapping, + const Function * const a, + std::vector); + +#endif + +// #if deal_II_dimension != 1 +// template +// void +// MatrixCreator::create_boundary_mass_matrix +// (const Mapping &mapping, +// const DoFHandler &dof, +// const Quadrature &q, +// SparseMatrix &matrix, +// const FunctionMap::type &boundary_functions, +// Vector &rhs_vector, +// std::vector &dof_to_boundary_mapping, +// const Function * const a, +// std::vector &component_mapping); +// #endif + +// template +// void MatrixCreator::create_boundary_mass_matrix +// (const DoFHandler &dof, +// const Quadrature &q, +// SparseMatrix &matrix, +// const FunctionMap::type &rhs, +// Vector &rhs_vector, +// std::vector &dof_to_boundary_mapping, +// const Function * const a, +// std::vector &component_mapping); + + +// // non-hp version of create_mass_matrix +// template +// void MatrixCreator::create_mass_matrix +// (const Mapping &mapping, +// const DoFHandler &dof, +// const Quadrature &q, +// SparseMatrix &matrix, +// const Function * const coefficient); +// template +// void MatrixCreator::create_mass_matrix +// (const DoFHandler &dof, +// const Quadrature &q, +// SparseMatrix &matrix, +// const Function * const coefficient); +// template +// void MatrixCreator::create_mass_matrix +// (const Mapping &mapping, +// const DoFHandler &dof, +// const Quadrature &q, +// SparseMatrix &matrix, +// const Function &rhs, +// Vector &rhs_vector, +// const Function * const coefficient); +// template +// void MatrixCreator::create_mass_matrix +// (const DoFHandler &dof, +// const Quadrature &q, +// SparseMatrix &matrix, +// const Function &rhs, +// Vector &rhs_vector, +// const Function * const coefficient); + + +// template +// void MatrixCreator::create_mass_matrix +// (const Mapping &mapping, +// const DoFHandler &dof, +// const Quadrature &q, +// SparseMatrix &matrix, +// const Function * const coefficient); +// template +// void MatrixCreator::create_mass_matrix +// (const DoFHandler &dof, +// const Quadrature &q, +// SparseMatrix &matrix, +// const Function * const coefficient); +// template +// void MatrixCreator::create_mass_matrix +// (const Mapping &mapping, +// const DoFHandler &dof, +// const Quadrature &q, +// SparseMatrix &matrix, +// const Function &rhs, +// Vector &rhs_vector, +// const Function * const coefficient); +// template +// void MatrixCreator::create_mass_matrix +// (const DoFHandler &dof, +// const Quadrature &q, +// SparseMatrix &matrix, +// const Function &rhs, +// Vector &rhs_vector, +// const Function * const coefficient); + + +#endif +} + diff --git a/deal.II/source/numerics/mesh_worker.all_dimensions.cc b/deal.II/source/numerics/mesh_worker.cc similarity index 100% rename from deal.II/source/numerics/mesh_worker.all_dimensions.cc rename to deal.II/source/numerics/mesh_worker.cc diff --git a/deal.II/source/numerics/mesh_worker_info.cc b/deal.II/source/numerics/mesh_worker_info.cc index 44fe4ad0c8..229e3a088e 100644 --- a/deal.II/source/numerics/mesh_worker_info.cc +++ b/deal.II/source/numerics/mesh_worker_info.cc @@ -22,39 +22,8 @@ DEAL_II_NAMESPACE_OPEN - -namespace MeshWorker -{ - template class IntegrationInfo; - template class IntegrationInfoBox; - - template class DoFInfo; - template class DoFInfoBox >; - - template void IntegrationInfo::fill_local_data( - const DoFInfo&, bool); - - template class DoFInfo; - template class DoFInfoBox >; - - template void IntegrationInfo::fill_local_data( - const DoFInfo&, bool); - -// template void IntegrationInfo -// ::initialize >( -// const FiniteElement&, const Mapping&, -// const Quadrature::integral_dimension>&, const UpdateFlags, const BlockInfo*); -// template void IntegrationInfo -// ::initialize >( -// const FiniteElement&, const Mapping&, -// const Quadrature::integral_dimension>&, const UpdateFlags, const BlockInfo*); -// template void IntegrationInfo -// ::initialize >( -// const FiniteElement&, const Mapping&, -// const Quadrature::integral_dimension>&, const UpdateFlags, const BlockInfo*); -} +// explicit instantiations +#include "mesh_worker_info.inst" DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/mesh_worker_info.inst.in b/deal.II/source/numerics/mesh_worker_info.inst.in new file mode 100644 index 0000000000..92f6d95f8f --- /dev/null +++ b/deal.II/source/numerics/mesh_worker_info.inst.in @@ -0,0 +1,48 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ +namespace MeshWorker +\{ + template class IntegrationInfo; + template class IntegrationInfoBox; + + template class DoFInfo; + template class DoFInfoBox >; + + template void IntegrationInfo::fill_local_data( + const DoFInfo&, bool); + + template class DoFInfo; + template class DoFInfoBox >; + + template void IntegrationInfo::fill_local_data( + const DoFInfo&, bool); + +// template void IntegrationInfo +// ::initialize >( +// const FiniteElement&, const Mapping&, +// const Quadrature::integral_dimension>&, const UpdateFlags, const BlockInfo*); +// template void IntegrationInfo +// ::initialize >( +// const FiniteElement&, const Mapping&, +// const Quadrature::integral_dimension>&, const UpdateFlags, const BlockInfo*); +// template void IntegrationInfo +// ::initialize >( +// const FiniteElement&, const Mapping&, +// const Quadrature::integral_dimension>&, const UpdateFlags, const BlockInfo*); +\} +} diff --git a/deal.II/source/numerics/mesh_worker_vector_selector.cc b/deal.II/source/numerics/mesh_worker_vector_selector.cc index 90c2b12642..2c7424c7a2 100644 --- a/deal.II/source/numerics/mesh_worker_vector_selector.cc +++ b/deal.II/source/numerics/mesh_worker_vector_selector.cc @@ -22,13 +22,7 @@ DEAL_II_NAMESPACE_OPEN -namespace MeshWorker -{ - template class VectorDataBase; - #include "mesh_worker_vector_selector.inst" -} - DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/mesh_worker_vector_selector.inst.in b/deal.II/source/numerics/mesh_worker_vector_selector.inst.in index 743ef908ce..02c033d720 100644 --- a/deal.II/source/numerics/mesh_worker_vector_selector.inst.in +++ b/deal.II/source/numerics/mesh_worker_vector_selector.inst.in @@ -11,8 +11,19 @@ //--------------------------------------------------------------------------- -for (VECTOR : SERIAL_VECTORS) +for (deal_II_dimension : DIMENSIONS) { - template class VectorData; - template class MGVectorData; + namespace MeshWorker + \{ + template class VectorDataBase; + \} +} + +for (VECTOR : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS) +{ + namespace MeshWorker + \{ + template class VectorData; + template class MGVectorData; + \} } diff --git a/deal.II/source/numerics/operator.inst.in b/deal.II/source/numerics/operator.inst.in index 631ec8e983..536d4db147 100644 --- a/deal.II/source/numerics/operator.inst.in +++ b/deal.II/source/numerics/operator.inst.in @@ -11,7 +11,7 @@ // //--------------------------------------------------------------------------- -for (VEC : SERIAL_VECTORS) +for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS) { template class DoFOutputOperator; } diff --git a/deal.II/source/numerics/point_value_history.cc b/deal.II/source/numerics/point_value_history.cc index 621f4f3179..3a7fd9a253 100644 --- a/deal.II/source/numerics/point_value_history.cc +++ b/deal.II/source/numerics/point_value_history.cc @@ -23,7 +23,6 @@ DEAL_II_NAMESPACE_OPEN -#include "point_value_history.inst" namespace internal { @@ -788,8 +787,9 @@ bool PointValueHistory } + // explicit instantiations -template class PointValueHistory; +#include "point_value_history.inst" DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/point_value_history.inst.in b/deal.II/source/numerics/point_value_history.inst.in index 7d1fcd96d9..92625c0d72 100644 --- a/deal.II/source/numerics/point_value_history.inst.in +++ b/deal.II/source/numerics/point_value_history.inst.in @@ -11,7 +11,14 @@ // //--------------------------------------------------------------------------- -for (VEC : SERIAL_VECTORS) + +for (deal_II_dimension : DIMENSIONS) +{ + template class PointValueHistory; +} + + +for (VEC : SERIAL_VECTORS ; deal_II_dimension : DIMENSIONS) { template void PointValueHistory::evaluate_field diff --git a/deal.II/source/numerics/solution_transfer.cc b/deal.II/source/numerics/solution_transfer.cc index ceddc927c3..0186b349e0 100644 --- a/deal.II/source/numerics/solution_transfer.cc +++ b/deal.II/source/numerics/solution_transfer.cc @@ -441,44 +441,7 @@ SolutionTransfer::Pointerstruct::memory_consumption () const -template class SolutionTransfer, DoFHandler >; -template class SolutionTransfer, DoFHandler >; -template class SolutionTransfer, hp::DoFHandler >; -template class SolutionTransfer, hp::DoFHandler >; - -template class SolutionTransfer, DoFHandler >; -template class SolutionTransfer, DoFHandler >; -template class SolutionTransfer, hp::DoFHandler >; -template class SolutionTransfer, hp::DoFHandler >; - - -#ifdef DEAL_II_USE_PETSC -template class SolutionTransfer >; -template class SolutionTransfer >; - -template class SolutionTransfer >; -template class SolutionTransfer >; -#endif - -#ifdef DEAL_II_USE_TRILINOS -template class SolutionTransfer >; -template class SolutionTransfer >; - -template class SolutionTransfer >; -template class SolutionTransfer >; - -template class SolutionTransfer >; -template class SolutionTransfer >; - -template class SolutionTransfer >; -template class SolutionTransfer >; -#endif - -#if deal_II_dimension < 3 -template class SolutionTransfer, DoFHandler >; -template class SolutionTransfer, hp::DoFHandler >; - -#endif -/*---------------------------- solution_transfer.cc ----------------------*/ +/*-------------- Explicit Instantiations -------------------------------*/ +#include "solution_transfer.inst" DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/solution_transfer.inst.in b/deal.II/source/numerics/solution_transfer.inst.in new file mode 100644 index 0000000000..625603e114 --- /dev/null +++ b/deal.II/source/numerics/solution_transfer.inst.in @@ -0,0 +1,54 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ +template class SolutionTransfer, DoFHandler >; +template class SolutionTransfer, DoFHandler >; +template class SolutionTransfer, hp::DoFHandler >; +template class SolutionTransfer, hp::DoFHandler >; + +template class SolutionTransfer, DoFHandler >; +template class SolutionTransfer, DoFHandler >; +template class SolutionTransfer, hp::DoFHandler >; +template class SolutionTransfer, hp::DoFHandler >; + + +#ifdef DEAL_II_USE_PETSC +template class SolutionTransfer >; +template class SolutionTransfer >; + +template class SolutionTransfer >; +template class SolutionTransfer >; +#endif + +#ifdef DEAL_II_USE_TRILINOS +template class SolutionTransfer >; +template class SolutionTransfer >; + +template class SolutionTransfer >; +template class SolutionTransfer >; + +template class SolutionTransfer >; +template class SolutionTransfer >; + +template class SolutionTransfer >; +template class SolutionTransfer >; +#endif + +#if deal_II_dimension < 3 +template class SolutionTransfer, DoFHandler >; +template class SolutionTransfer, hp::DoFHandler >; + +#endif +} diff --git a/deal.II/source/numerics/time_dependent.all_dimensions.cc b/deal.II/source/numerics/time_dependent.all_dimensions.cc deleted file mode 100644 index 77be7a637d..0000000000 --- a/deal.II/source/numerics/time_dependent.all_dimensions.cc +++ /dev/null @@ -1,403 +0,0 @@ -//--------------------------------------------------------------------------- -// $Id: time_dependent.all_dimensions.cc 21627 2010-08-09 05:10:10Z bangerth $ -// Version: $Name$ -// -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2008, 2009, 2010 by the deal.II authors -// -// This file is subject to QPL and may not be distributed -// without copyright and license information. Please refer -// to the file deal.II/doc/license.html for the text and -// further information on this license. -// -//--------------------------------------------------------------------------- - - -#include -#include -#include - -#include -#include -#include - -DEAL_II_NAMESPACE_OPEN - -TimeDependent::TimeSteppingData::TimeSteppingData (const unsigned int look_ahead, - const unsigned int look_back) - : - look_ahead (look_ahead), - look_back (look_back) -{} - - -TimeDependent::TimeDependent (const TimeSteppingData &data_primal, - const TimeSteppingData &data_dual, - const TimeSteppingData &data_postprocess): - sweep_no (numbers::invalid_unsigned_int), - timestepping_data_primal (data_primal), - timestepping_data_dual (data_dual), - timestepping_data_postprocess (data_postprocess) -{} - - -TimeDependent::~TimeDependent () -{ - while (timesteps.size() != 0) - delete_timestep (0); -} - - -void -TimeDependent::insert_timestep (const TimeStepBase *position, - TimeStepBase *new_timestep) -{ - Assert ((std::find(timesteps.begin(), timesteps.end(), position) != timesteps.end()) || - (position == 0), - ExcInvalidPosition()); - // first insert the new time step - // into the doubly linked list - // of timesteps - if (position == 0) - { - // at the end - new_timestep->set_next_timestep (0); - if (timesteps.size() > 0) - { - timesteps.back()->set_next_timestep (new_timestep); - new_timestep->set_previous_timestep (timesteps.back()); - } - else - new_timestep->set_previous_timestep (0); - } - else - if (position == timesteps[0]) - { - // at the beginning - new_timestep->set_previous_timestep (0); - if (timesteps.size() > 0) - { - timesteps[0]->set_previous_timestep (new_timestep); - new_timestep->set_next_timestep (timesteps[0]); - } - else - new_timestep->set_next_timestep (0); - } - else - { - // inner time step - std::vector >::iterator insert_position - = std::find(timesteps.begin(), timesteps.end(), position); - - (*(insert_position-1))->set_next_timestep (new_timestep); - new_timestep->set_previous_timestep (*(insert_position-1)); - new_timestep->set_next_timestep (*insert_position); - (*insert_position)->set_previous_timestep (new_timestep); - }; - - // finally enter it into the - // array - timesteps.insert ((position == 0 ? - timesteps.end() : - std::find(timesteps.begin(), timesteps.end(), position)), - new_timestep); -} - - -void -TimeDependent::add_timestep (TimeStepBase *new_timestep) -{ - insert_timestep (0, new_timestep); -} - - -void TimeDependent::delete_timestep (const unsigned int position) -{ - Assert (positionset_next_timestep ((position()); - - // same for "previous" pointer of next - // time step - if (positionset_previous_timestep ((position!=0) ? - timesteps[position-1] : - /*null*/SmartPointer()); -} - - -void -TimeDependent::solve_primal_problem () -{ - do_loop (std::mem_fun(&TimeStepBase::init_for_primal_problem), - std::mem_fun(&TimeStepBase::solve_primal_problem), - timestepping_data_primal, - forward); -} - - -void -TimeDependent::solve_dual_problem () -{ - do_loop (std::mem_fun(&TimeStepBase::init_for_dual_problem), - std::mem_fun(&TimeStepBase::solve_dual_problem), - timestepping_data_dual, - backward); -} - - -void -TimeDependent::postprocess () -{ - do_loop (std::mem_fun(&TimeStepBase::init_for_postprocessing), - std::mem_fun(&TimeStepBase::postprocess_timestep), - timestepping_data_postprocess, - forward); -} - - - -void TimeDependent::start_sweep (const unsigned int s) -{ - sweep_no = s; - - // reset the number each - // time step has, since some time - // steps might have been added since - // the last time we visited them - // - // also set the sweep we will - // process in the sequel - for (unsigned int step=0; stepset_timestep_no (step); - timesteps[step]->set_sweep_no (sweep_no); - }; - - for (unsigned int step=0; stepstart_sweep (); -} - - - -void TimeDependent::end_sweep (const unsigned int n_threads) -{ - if (DEAL_II_USE_MT && (n_threads > 1)) - { - const unsigned int stride = timesteps.size() / n_threads; - Threads::ThreadGroup<> threads; - void (TimeDependent::*p) (const unsigned int, const unsigned int) - = &TimeDependent::end_sweep; - for (unsigned int i=0; iend_sweep (); -} - - - -unsigned int TimeDependent::memory_consumption () const -{ - unsigned int mem = (MemoryConsumption::memory_consumption (timesteps) + - MemoryConsumption::memory_consumption (sweep_no) + - sizeof(timestepping_data_primal) + - sizeof(timestepping_data_dual) + - sizeof(timestepping_data_postprocess)); - for (unsigned int i=0; itime; -} - - - -double -TimeStepBase::get_forward_timestep () const -{ - Assert (next_timestep != 0, ExcCantComputeTimestep()); - return next_timestep->time - time; -} - - - -void -TimeStepBase::set_previous_timestep (const TimeStepBase *previous) -{ - previous_timestep = previous; -} - - - -void -TimeStepBase::set_next_timestep (const TimeStepBase *next) -{ - next_timestep = next; -} - - - -void -TimeStepBase::set_timestep_no (const unsigned int step_no) -{ - timestep_no = step_no; -} - - - -void -TimeStepBase::set_sweep_no (const unsigned int sweep) -{ - sweep_no = sweep; -} - - - -unsigned int -TimeStepBase::memory_consumption () const -{ - // only simple data types - return sizeof(*this); -} - - -DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/time_dependent.cc b/deal.II/source/numerics/time_dependent.cc index 5408052388..baa908189e 100644 --- a/deal.II/source/numerics/time_dependent.cc +++ b/deal.II/source/numerics/time_dependent.cc @@ -27,6 +27,384 @@ DEAL_II_NAMESPACE_OPEN +TimeDependent::TimeSteppingData::TimeSteppingData (const unsigned int look_ahead, + const unsigned int look_back) + : + look_ahead (look_ahead), + look_back (look_back) +{} + + +TimeDependent::TimeDependent (const TimeSteppingData &data_primal, + const TimeSteppingData &data_dual, + const TimeSteppingData &data_postprocess): + sweep_no (numbers::invalid_unsigned_int), + timestepping_data_primal (data_primal), + timestepping_data_dual (data_dual), + timestepping_data_postprocess (data_postprocess) +{} + + +TimeDependent::~TimeDependent () +{ + while (timesteps.size() != 0) + delete_timestep (0); +} + + +void +TimeDependent::insert_timestep (const TimeStepBase *position, + TimeStepBase *new_timestep) +{ + Assert ((std::find(timesteps.begin(), timesteps.end(), position) != timesteps.end()) || + (position == 0), + ExcInvalidPosition()); + // first insert the new time step + // into the doubly linked list + // of timesteps + if (position == 0) + { + // at the end + new_timestep->set_next_timestep (0); + if (timesteps.size() > 0) + { + timesteps.back()->set_next_timestep (new_timestep); + new_timestep->set_previous_timestep (timesteps.back()); + } + else + new_timestep->set_previous_timestep (0); + } + else + if (position == timesteps[0]) + { + // at the beginning + new_timestep->set_previous_timestep (0); + if (timesteps.size() > 0) + { + timesteps[0]->set_previous_timestep (new_timestep); + new_timestep->set_next_timestep (timesteps[0]); + } + else + new_timestep->set_next_timestep (0); + } + else + { + // inner time step + std::vector >::iterator insert_position + = std::find(timesteps.begin(), timesteps.end(), position); + + (*(insert_position-1))->set_next_timestep (new_timestep); + new_timestep->set_previous_timestep (*(insert_position-1)); + new_timestep->set_next_timestep (*insert_position); + (*insert_position)->set_previous_timestep (new_timestep); + }; + + // finally enter it into the + // array + timesteps.insert ((position == 0 ? + timesteps.end() : + std::find(timesteps.begin(), timesteps.end(), position)), + new_timestep); +} + + +void +TimeDependent::add_timestep (TimeStepBase *new_timestep) +{ + insert_timestep (0, new_timestep); +} + + +void TimeDependent::delete_timestep (const unsigned int position) +{ + Assert (positionset_next_timestep ((position()); + + // same for "previous" pointer of next + // time step + if (positionset_previous_timestep ((position!=0) ? + timesteps[position-1] : + /*null*/SmartPointer()); +} + + +void +TimeDependent::solve_primal_problem () +{ + do_loop (std::mem_fun(&TimeStepBase::init_for_primal_problem), + std::mem_fun(&TimeStepBase::solve_primal_problem), + timestepping_data_primal, + forward); +} + + +void +TimeDependent::solve_dual_problem () +{ + do_loop (std::mem_fun(&TimeStepBase::init_for_dual_problem), + std::mem_fun(&TimeStepBase::solve_dual_problem), + timestepping_data_dual, + backward); +} + + +void +TimeDependent::postprocess () +{ + do_loop (std::mem_fun(&TimeStepBase::init_for_postprocessing), + std::mem_fun(&TimeStepBase::postprocess_timestep), + timestepping_data_postprocess, + forward); +} + + + +void TimeDependent::start_sweep (const unsigned int s) +{ + sweep_no = s; + + // reset the number each + // time step has, since some time + // steps might have been added since + // the last time we visited them + // + // also set the sweep we will + // process in the sequel + for (unsigned int step=0; stepset_timestep_no (step); + timesteps[step]->set_sweep_no (sweep_no); + }; + + for (unsigned int step=0; stepstart_sweep (); +} + + + +void TimeDependent::end_sweep (const unsigned int n_threads) +{ + if (DEAL_II_USE_MT && (n_threads > 1)) + { + const unsigned int stride = timesteps.size() / n_threads; + Threads::ThreadGroup<> threads; + void (TimeDependent::*p) (const unsigned int, const unsigned int) + = &TimeDependent::end_sweep; + for (unsigned int i=0; iend_sweep (); +} + + + +unsigned int TimeDependent::memory_consumption () const +{ + unsigned int mem = (MemoryConsumption::memory_consumption (timesteps) + + MemoryConsumption::memory_consumption (sweep_no) + + sizeof(timestepping_data_primal) + + sizeof(timestepping_data_dual) + + sizeof(timestepping_data_postprocess)); + for (unsigned int i=0; itime; +} + + + +double +TimeStepBase::get_forward_timestep () const +{ + Assert (next_timestep != 0, ExcCantComputeTimestep()); + return next_timestep->time - time; +} + + + +void +TimeStepBase::set_previous_timestep (const TimeStepBase *previous) +{ + previous_timestep = previous; +} + + + +void +TimeStepBase::set_next_timestep (const TimeStepBase *next) +{ + next_timestep = next; +} + + + +void +TimeStepBase::set_timestep_no (const unsigned int step_no) +{ + timestep_no = step_no; +} + + + +void +TimeStepBase::set_sweep_no (const unsigned int sweep) +{ + sweep_no = sweep; +} + + + +unsigned int +TimeStepBase::memory_consumption () const +{ + // only simple data types + return sizeof(*this); +} + + template TimeStepBase_Tria::TimeStepBase_Tria() : @@ -864,14 +1242,9 @@ RefinementData (const double _refinement_threshold, } -// explicit instantiations -template class TimeStepBase_Tria; -namespace TimeStepBase_Tria_Flags -{ - template class Flags; - template class RefinementFlags; - template class RefinementData; -} +/*-------------- Explicit Instantiations -------------------------------*/ +#include "time_dependent.inst" + DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/source/numerics/time_dependent.inst.in b/deal.II/source/numerics/time_dependent.inst.in new file mode 100644 index 0000000000..bb159429db --- /dev/null +++ b/deal.II/source/numerics/time_dependent.inst.in @@ -0,0 +1,23 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + +for (deal_II_dimension : DIMENSIONS) +{ + template class TimeStepBase_Tria; + namespace TimeStepBase_Tria_Flags + \{ + template class Flags; + template class RefinementFlags; + template class RefinementData; + \} +} diff --git a/deal.II/source/numerics/vectors.all_dimensions.cc b/deal.II/source/numerics/vectors.all_dimensions.cc deleted file mode 100644 index 7e8e7d5c66..0000000000 --- a/deal.II/source/numerics/vectors.all_dimensions.cc +++ /dev/null @@ -1,47 +0,0 @@ -//--------------------------------------------------------------------------- -// $Id$ -// Version: $Name$ -// -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006 by the deal.II authors -// -// This file is subject to QPL and may not be distributed -// without copyright and license information. Please refer -// to the file deal.II/doc/license.html for the text and -// further information on this license. -// -//--------------------------------------------------------------------------- - - -#include -#include - -DEAL_II_NAMESPACE_OPEN - - -void -VectorTools::subtract_mean_value(Vector &v, - const std::vector &p_select) -{ - const unsigned int n = v.size(); - Assert(n == p_select.size(), - ExcDimensionMismatch(n, p_select.size())); - - double s = 0; - unsigned int counter = 0; - - for (unsigned int i=0; i 0, ExcNoComponentSelected()); - - s /= counter; - - for (unsigned int i=0; i -// explicit instantiations - - DEAL_II_NAMESPACE_OPEN -#include "vectors.inst" - -template -void VectorTools::create_right_hand_side -(const Mapping &, - const DoFHandler &, - const Quadrature &, - const Function &, - Vector &); -template -void VectorTools::create_right_hand_side -(const DoFHandler &, - const Quadrature &, - const Function &, - Vector &); - -template -void VectorTools::create_right_hand_side -(const hp::MappingCollection &, - const hp::DoFHandler &, - const hp::QCollection &, - const Function &, - Vector &); -template -void VectorTools::create_right_hand_side -(const hp::DoFHandler &, - const hp::QCollection &, - const Function &, - Vector &); - -template -void VectorTools::create_point_source_vector -(const Mapping &, - const DoFHandler &, - const Point &, - Vector &); -template -void VectorTools::create_point_source_vector -(const DoFHandler &, - const Point &, - Vector &); - -template -void VectorTools::create_point_source_vector -(const hp::MappingCollection &, - const hp::DoFHandler &, - const Point &, - Vector &); -template -void VectorTools::create_point_source_vector -(const hp::DoFHandler &, - const Point &, - Vector &); - -template -void -VectorTools::create_boundary_right_hand_side -(const Mapping &, - const DoFHandler &, - const Quadrature &, - const Function &, - Vector &, - const std::set &); - -template -void -VectorTools::create_boundary_right_hand_side -(const DoFHandler &, - const Quadrature &, - const Function &, - Vector &, - const std::set &); - -template -void -VectorTools::create_boundary_right_hand_side -(const hp::MappingCollection &, - const hp::DoFHandler &, - const hp::QCollection &, - const Function &, - Vector &, - const std::set &); - -template -void -VectorTools::create_boundary_right_hand_side -(const hp::DoFHandler &, - const hp::QCollection &, - const Function &, - Vector &, - const std::set &); - -template -void VectorTools::interpolate_boundary_values ( - const DoFHandler &, - const unsigned char, - const Function &, - std::map &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const hp::DoFHandler &, - const unsigned char, - const Function &, - std::map &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const MGDoFHandler &, - const unsigned char, - const Function &, - std::map &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const DoFHandler &, - const unsigned char, - const Function &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const hp::DoFHandler &, - const unsigned char, - const Function &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const MGDoFHandler &, - const unsigned char, - const Function &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const Mapping &, - const DoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const Mapping &, - const hp::DoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const Mapping &, - const MGDoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const DoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const hp::DoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const MGDoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); - -#if deal_II_dimension < 3 -template -void VectorTools::interpolate_boundary_values ( - const DoFHandler &, - const unsigned char, - const Function &, - std::map &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const hp::DoFHandler &, - const unsigned char, - const Function &, - std::map &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const MGDoFHandler &, - const unsigned char, - const Function &, - std::map &, - const std::vector &); -template -void VectorTools::interpolate_boundary_values ( - const DoFHandler &, - const unsigned char, - const Function &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const hp::DoFHandler &, - const unsigned char, - const Function &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const MGDoFHandler &, - const unsigned char, - const Function &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const Mapping &, - const DoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const Mapping &, - const hp::DoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const Mapping &, - const MGDoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const DoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const hp::DoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values ( - const MGDoFHandler &, - const FunctionMap::type &, - ConstraintMatrix &, - const std::vector &); -#endif - -template -void VectorTools::project_boundary_values -(const Mapping &, - const DoFHandler &, - const FunctionMap::type &, - const Quadrature&, - std::map&, std::vector); - -template -void VectorTools::project_boundary_values -(const DoFHandler &, - const FunctionMap::type &, - const Quadrature&, - std::map&, std::vector); - - -template -void VectorTools::project_boundary_values -(const Mapping &, - const DoFHandler &, - const FunctionMap::type &, - const Quadrature&, - ConstraintMatrix&, std::vector); - -template -void VectorTools::project_boundary_values -(const DoFHandler &, - const FunctionMap::type &, - const Quadrature&, - ConstraintMatrix&, std::vector); - - -#if deal_II_dimension != 1 -template -void VectorTools::project_boundary_values_curl_conforming -(const DoFHandler&, - const unsigned int, - const Function&, - const unsigned char, - ConstraintMatrix&, - const Mapping&); -template -void VectorTools::project_boundary_values_curl_conforming -(const hp::DoFHandler&, - const unsigned int, - const Function&, - const unsigned char, - ConstraintMatrix&, - const hp::MappingCollection&); -template void -VectorTools::compute_no_normal_flux_constraints (const DoFHandler &dof_handler, - const unsigned int first_vector_component, - const std::set &boundary_ids, - ConstraintMatrix &constraints, - const Mapping &mapping); -#endif - - - -template -void VectorTools::interpolate_boundary_values -(const Mapping &, - const DoFHandler &, - const FunctionMap::type &, - std::map &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values -(const Mapping &, - const DoFHandler &, - const unsigned char, - const Function &, - std::map &, - const std::vector &); - -#if deal_II_dimension < 3 -template -void VectorTools::interpolate_boundary_values -(const Mapping &, - const DoFHandler &, - const FunctionMap::type &, - std::map &, - const std::vector &); - -template -void VectorTools::interpolate_boundary_values -(const Mapping &, - const DoFHandler &, - const unsigned char, - const Function &, - std::map &, - const std::vector &); -#endif - - -template -void -VectorTools::interpolate_boundary_values -(const DoFHandler &, - const FunctionMap::type &, - std::map &, - const std::vector &); - - -#if deal_II_dimension != 3 - -template -void VectorTools::create_right_hand_side -(const Mapping &, - const DoFHandler &, - const Quadrature &, - const Function &, - Vector &); -template -void VectorTools::create_right_hand_side -(const DoFHandler &, - const Quadrature &, - const Function &, - Vector &); - -// template -// void VectorTools::create_right_hand_side -// (const hp::MappingCollection &, -// const hp::DoFHandler &, -// const hp::QCollection &, -// const Function &, -// Vector &); -// template -// void VectorTools::create_right_hand_side -// (const hp::DoFHandler &, -// const hp::QCollection &, -// const Function &, -// Vector &); - -#endif +VectorTools::subtract_mean_value(Vector &v, + const std::vector &p_select) +{ + const unsigned int n = v.size(); + Assert(n == p_select.size(), + ExcDimensionMismatch(n, p_select.size())); + + double s = 0; + unsigned int counter = 0; + + for (unsigned int i=0; i 0, ExcNoComponentSelected()); + + s /= counter; + + for (unsigned int i=0; i +(const Mapping &, + const DoFHandler &, + const Quadrature &, + const Function &, + Vector &); +template +void VectorTools::create_right_hand_side +(const DoFHandler &, + const Quadrature &, + const Function &, + Vector &); + +template +void VectorTools::create_right_hand_side +(const hp::MappingCollection &, + const hp::DoFHandler &, + const hp::QCollection &, + const Function &, + Vector &); +template +void VectorTools::create_right_hand_side +(const hp::DoFHandler &, + const hp::QCollection &, + const Function &, + Vector &); + +template +void VectorTools::create_point_source_vector +(const Mapping &, + const DoFHandler &, + const Point &, + Vector &); +template +void VectorTools::create_point_source_vector +(const DoFHandler &, + const Point &, + Vector &); + +template +void VectorTools::create_point_source_vector +(const hp::MappingCollection &, + const hp::DoFHandler &, + const Point &, + Vector &); +template +void VectorTools::create_point_source_vector +(const hp::DoFHandler &, + const Point &, + Vector &); + +template +void +VectorTools::create_boundary_right_hand_side +(const Mapping &, + const DoFHandler &, + const Quadrature &, + const Function &, + Vector &, + const std::set &); + +template +void +VectorTools::create_boundary_right_hand_side +(const DoFHandler &, + const Quadrature &, + const Function &, + Vector &, + const std::set &); + +template +void +VectorTools::create_boundary_right_hand_side +(const hp::MappingCollection &, + const hp::DoFHandler &, + const hp::QCollection &, + const Function &, + Vector &, + const std::set &); + +template +void +VectorTools::create_boundary_right_hand_side +(const hp::DoFHandler &, + const hp::QCollection &, + const Function &, + Vector &, + const std::set &); + +template +void VectorTools::interpolate_boundary_values ( + const DoFHandler &, + const unsigned char, + const Function &, + std::map &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const hp::DoFHandler &, + const unsigned char, + const Function &, + std::map &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const MGDoFHandler &, + const unsigned char, + const Function &, + std::map &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const DoFHandler &, + const unsigned char, + const Function &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const hp::DoFHandler &, + const unsigned char, + const Function &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const MGDoFHandler &, + const unsigned char, + const Function &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const Mapping &, + const DoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const Mapping &, + const hp::DoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const Mapping &, + const MGDoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const DoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const hp::DoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const MGDoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); + +#if deal_II_dimension < 3 +template +void VectorTools::interpolate_boundary_values ( + const DoFHandler &, + const unsigned char, + const Function &, + std::map &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const hp::DoFHandler &, + const unsigned char, + const Function &, + std::map &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const MGDoFHandler &, + const unsigned char, + const Function &, + std::map &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const DoFHandler &, + const unsigned char, + const Function &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const hp::DoFHandler &, + const unsigned char, + const Function &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const MGDoFHandler &, + const unsigned char, + const Function &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const Mapping &, + const DoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const Mapping &, + const hp::DoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const Mapping &, + const MGDoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const DoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const hp::DoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values ( + const MGDoFHandler &, + const FunctionMap::type &, + ConstraintMatrix &, + const std::vector &); +#endif + +template +void VectorTools::project_boundary_values +(const Mapping &, + const DoFHandler &, + const FunctionMap::type &, + const Quadrature&, + std::map&, std::vector); + +template +void VectorTools::project_boundary_values +(const DoFHandler &, + const FunctionMap::type &, + const Quadrature&, + std::map&, std::vector); + + +template +void VectorTools::project_boundary_values +(const Mapping &, + const DoFHandler &, + const FunctionMap::type &, + const Quadrature&, + ConstraintMatrix&, std::vector); + +template +void VectorTools::project_boundary_values +(const DoFHandler &, + const FunctionMap::type &, + const Quadrature&, + ConstraintMatrix&, std::vector); + + +#if deal_II_dimension != 1 +template +void VectorTools::project_boundary_values_curl_conforming +(const DoFHandler&, + const unsigned int, + const Function&, + const unsigned char, + ConstraintMatrix&, + const Mapping&); +template +void VectorTools::project_boundary_values_curl_conforming +(const hp::DoFHandler&, + const unsigned int, + const Function&, + const unsigned char, + ConstraintMatrix&, + const hp::MappingCollection&); +template +void +VectorTools::compute_no_normal_flux_constraints (const DoFHandler &dof_handler, + const unsigned int first_vector_component, + const std::set &boundary_ids, + ConstraintMatrix &constraints, + const Mapping &mapping); +#endif + + + +template +void VectorTools::interpolate_boundary_values +(const Mapping &, + const DoFHandler &, + const FunctionMap::type &, + std::map &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values +(const Mapping &, + const DoFHandler &, + const unsigned char, + const Function &, + std::map &, + const std::vector &); + +#if deal_II_dimension < 3 +template +void VectorTools::interpolate_boundary_values +(const Mapping &, + const DoFHandler &, + const FunctionMap::type &, + std::map &, + const std::vector &); + +template +void VectorTools::interpolate_boundary_values +(const Mapping &, + const DoFHandler &, + const unsigned char, + const Function &, + std::map &, + const std::vector &); +#endif + + +template +void +VectorTools::interpolate_boundary_values +(const DoFHandler &, + const FunctionMap::type &, + std::map &, + const std::vector &); + + +#if deal_II_dimension != 3 + +template +void VectorTools::create_right_hand_side +(const Mapping &, + const DoFHandler &, + const Quadrature &, + const Function &, + Vector &); +template +void VectorTools::create_right_hand_side +(const DoFHandler &, + const Quadrature &, + const Function &, + Vector &); + +// template +// void VectorTools::create_right_hand_side +// (const hp::MappingCollection &, +// const hp::DoFHandler &, +// const hp::QCollection &, +// const Function &, +// Vector &); +// template +// void VectorTools::create_right_hand_side +// (const hp::DoFHandler &, +// const hp::QCollection &, +// const Function &, +// Vector &); + +#endif +} -- 2.39.5