// ---------------------------------------------------------------------
//
// Copyright (C) 2009 - 2022 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE.md at
// the top level directory of deal.II.
//
// ---------------------------------------------------------------------

for (scalar : REAL_AND_COMPLEX_SCALARS; deal_II_dimension : DIMENSIONS)
  {
    template void DoFTools::make_boundary_sparsity_pattern<deal_II_dimension,
                                                           deal_II_dimension,
                                                           scalar>(
      const DoFHandler<deal_II_dimension> &                        dof,
      const std::map<types::boundary_id,
                     const Function<deal_II_dimension, scalar> *> &boundary_ids,
      const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
      SparsityPatternBase &                       sparsity);

#if deal_II_dimension < 3

    template void
    DoFTools::make_boundary_sparsity_pattern<deal_II_dimension,
                                             deal_II_dimension + 1,
                                             scalar>(
      const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
      const std::map<types::boundary_id,
                     const Function<deal_II_dimension + 1, scalar> *>
        &                                         boundary_ids,
      const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
      SparsityPatternBase &                       sparsity);

#endif

#if deal_II_dimension == 1
    template void
    DoFTools::make_boundary_sparsity_pattern<deal_II_dimension,
                                             deal_II_dimension + 2,
                                             scalar>(
      const DoFHandler<deal_II_dimension, deal_II_dimension + 2> &dof,
      const std::map<types::boundary_id,
                     const Function<deal_II_dimension + 2, scalar> *>
        &                                         boundary_ids,
      const std::vector<types::global_dof_index> &dof_to_boundary_mapping,
      SparsityPatternBase &                       sparsity);
#endif
  }

for (deal_II_dimension : DIMENSIONS; S : REAL_AND_COMPLEX_SCALARS)
  {
    template void
    DoFTools::make_sparsity_pattern<deal_II_dimension, deal_II_dimension>(
      const DoFHandler<deal_II_dimension, deal_II_dimension> &dof,
      SparsityPatternBase &                                   sparsity,
      const AffineConstraints<S> &,
      const bool,
      const types::subdomain_id);

    template void
    DoFTools::make_sparsity_pattern<deal_II_dimension, deal_II_dimension>(
      const DoFHandler<deal_II_dimension, deal_II_dimension> &,
      const Table<2, Coupling> &,
      SparsityPatternBase &,
      const AffineConstraints<S> &,
      const bool,
      const types::subdomain_id);

    template void
    DoFTools::make_flux_sparsity_pattern<deal_II_dimension, deal_II_dimension>(
      const DoFHandler<deal_II_dimension> &dof,
      SparsityPatternBase &                sparsity,
      const AffineConstraints<S> &,
      const bool,
      const Table<2, Coupling> &,
      const Table<2, Coupling> &,
      const types::subdomain_id,
      const std::function<bool(
        const typename DoFHandler<deal_II_dimension>::active_cell_iterator &,
        const unsigned int)> &);

    template void
    DoFTools::make_flux_sparsity_pattern<deal_II_dimension, deal_II_dimension>(
      const DoFHandler<deal_II_dimension> &dof,
      SparsityPatternBase &                sparsity,
      const AffineConstraints<S> &,
      const bool,
      const types::subdomain_id);

#if deal_II_dimension < 3

    template void
    DoFTools::make_sparsity_pattern<deal_II_dimension, deal_II_dimension + 1>(
      const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
      SparsityPatternBase &                                       sparsity,
      const AffineConstraints<S> &,
      const bool,
      const types::subdomain_id);

    template void
    DoFTools::make_sparsity_pattern<deal_II_dimension, deal_II_dimension + 1>(
      const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &,
      const Table<2, Coupling> &,
      SparsityPatternBase &,
      const AffineConstraints<S> &,
      const bool,
      const types::subdomain_id);

    template void DoFTools::make_flux_sparsity_pattern<deal_II_dimension,
                                                       deal_II_dimension + 1>(
      const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
      SparsityPatternBase &                                       sparsity,
      const AffineConstraints<S> &,
      const bool,
      const Table<2, Coupling> &,
      const Table<2, Coupling> &,
      const types::subdomain_id,
      const std::function<bool(
        const typename DoFHandler<deal_II_dimension, deal_II_dimension + 1>::
          active_cell_iterator &,
        const unsigned int)> &);

    template void DoFTools::make_flux_sparsity_pattern<deal_II_dimension,
                                                       deal_II_dimension + 1>(
      const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
      SparsityPatternBase &                                       sparsity,
      const AffineConstraints<S> &,
      const bool,
      const types::subdomain_id);

#endif

#if deal_II_dimension == 3

    template void DoFTools::make_sparsity_pattern<1, 3>(
      const DoFHandler<1, 3> &dof,
      SparsityPatternBase &   sparsity,
      const AffineConstraints<S> &,
      const bool,
      const types::subdomain_id);

    template void DoFTools::make_sparsity_pattern<1, 3>(
      const DoFHandler<1, 3> &,
      const Table<2, Coupling> &,
      SparsityPatternBase &,
      const AffineConstraints<S> &,
      const bool,
      const types::subdomain_id);

    template void DoFTools::make_flux_sparsity_pattern<1, 3>(
      const DoFHandler<1, 3> &dof,
      SparsityPatternBase &   sparsity,
      const AffineConstraints<S> &,
      const bool,
      const Table<2, Coupling> &,
      const Table<2, Coupling> &,
      const types::subdomain_id,
      const std::function<
        bool(const typename DoFHandler<1, 3>::active_cell_iterator &,
             const unsigned int)> &);

    template void DoFTools::make_flux_sparsity_pattern<1, 3>(
      const DoFHandler<1, 3> &dof,
      SparsityPatternBase &   sparsity,
      const AffineConstraints<S> &,
      const bool,
      const types::subdomain_id);

#endif
  }

for (deal_II_dimension : DIMENSIONS)
  {
    template void
    DoFTools::make_sparsity_pattern<deal_II_dimension, deal_II_dimension>(
      const DoFHandler<deal_II_dimension, deal_II_dimension> &dof_row,
      const DoFHandler<deal_II_dimension, deal_II_dimension> &dof_col,
      SparsityPatternBase &                                   sparsity);

    template void DoFTools::make_boundary_sparsity_pattern<deal_II_dimension,
                                                           deal_II_dimension>(
      const DoFHandler<deal_II_dimension> &dof,
      const std::vector<types::global_dof_index> &,
      SparsityPatternBase &);

    template void
    DoFTools::make_flux_sparsity_pattern<deal_II_dimension, deal_II_dimension>(
      const DoFHandler<deal_II_dimension> &dof, SparsityPatternBase &sparsity);

    template void
    DoFTools::make_flux_sparsity_pattern<deal_II_dimension, deal_II_dimension>(
      const DoFHandler<deal_II_dimension> &dof,
      SparsityPatternBase &                sparsity,
      const Table<2, Coupling> &,
      const Table<2, Coupling> &,
      const types::subdomain_id);

#if deal_II_dimension < 3

    template void DoFTools::make_flux_sparsity_pattern<deal_II_dimension,
                                                       deal_II_dimension + 1>(
      const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
      SparsityPatternBase &                                       sparsity);

    template void DoFTools::make_flux_sparsity_pattern<deal_II_dimension,
                                                       deal_II_dimension + 1>(
      const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
      SparsityPatternBase &                                       sparsity,
      const Table<2, Coupling> &,
      const Table<2, Coupling> &,
      const types::subdomain_id);

    template void
    DoFTools::make_sparsity_pattern<deal_II_dimension, deal_II_dimension + 1>(
      const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof_row,
      const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof_col,
      SparsityPatternBase &                                       sparsity);

    template void
    DoFTools::make_boundary_sparsity_pattern<deal_II_dimension,
                                             deal_II_dimension + 1>(
      const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
      const std::vector<types::global_dof_index> &,
      SparsityPatternBase &);

#endif


#if deal_II_dimension == 3

    template void DoFTools::make_sparsity_pattern<1, 3>(
      const DoFHandler<1, 3> &dof_row,
      const DoFHandler<1, 3> &dof_col,
      SparsityPatternBase &   sparsity);

    template void DoFTools::make_boundary_sparsity_pattern<1, 3>(
      const DoFHandler<1, 3> &dof,
      const std::vector<types::global_dof_index> &,
      SparsityPatternBase &);

    template void DoFTools::make_flux_sparsity_pattern<1, 3>(
      const DoFHandler<1, 3> &dof, SparsityPatternBase &sparsity);

    template void DoFTools::make_flux_sparsity_pattern<1, 3>(
      const DoFHandler<1, 3> &dof,
      SparsityPatternBase &   sparsity,
      const Table<2, Coupling> &,
      const Table<2, Coupling> &,
      const types::subdomain_id);
#endif
  }


for (deal_II_dimension : DIMENSIONS)
  {
    template Table<2, DoFTools::Coupling>
    DoFTools::dof_couplings_from_component_couplings(
      const FiniteElement<deal_II_dimension> &fe,
      const Table<2, DoFTools::Coupling> &    component_couplings);

    template std::vector<Table<2, DoFTools::Coupling>>
    DoFTools::dof_couplings_from_component_couplings(
      const hp::FECollection<deal_II_dimension> &fe,
      const Table<2, DoFTools::Coupling> &       component_couplings);
  }
