// ---------------------------------------------------------------------
//
// Copyright (C) 2009 - 2021 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; SP : SPARSITY_PATTERNS;
     deal_II_dimension : DIMENSIONS)
  {
    template void DoFTools::make_boundary_sparsity_pattern<deal_II_dimension,
                                                           deal_II_dimension,
                                                           SP,
                                                           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,
      SP &                                        sparsity);

#if deal_II_dimension < 3

    template void
    DoFTools::make_boundary_sparsity_pattern<deal_II_dimension,
                                             deal_II_dimension + 1,
                                             SP,
                                             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,
      SP &                                        sparsity);

#endif

#if deal_II_dimension == 1
    template void
    DoFTools::make_boundary_sparsity_pattern<deal_II_dimension,
                                             deal_II_dimension + 2,
                                             SP,
                                             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,
      SP &                                        sparsity);
#endif
  }

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

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

    template void DoFTools::
      make_flux_sparsity_pattern<deal_II_dimension, deal_II_dimension, SP>(
        const DoFHandler<deal_II_dimension> &dof,
        SP &                                 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, SP>(
        const DoFHandler<deal_II_dimension> &dof,
        SP &                                 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, SP>(
        const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
        SP &                                                        sparsity,
        const AffineConstraints<S> &,
        const bool,
        const types::subdomain_id);

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

    template void DoFTools::
      make_flux_sparsity_pattern<deal_II_dimension, deal_II_dimension + 1, SP>(
        const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
        SP &                                                        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, SP>(
        const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
        SP &                                                        sparsity,
        const AffineConstraints<S> &,
        const bool,
        const types::subdomain_id);

#endif

#if deal_II_dimension == 3

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

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

    template void DoFTools::make_flux_sparsity_pattern<1, 3, SP>(
      const DoFHandler<1, 3> &dof,
      SP &                    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, SP>(
      const DoFHandler<1, 3> &dof,
      SP &                    sparsity,
      const AffineConstraints<S> &,
      const bool,
      const types::subdomain_id);

#endif
  }

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

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

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

    template void DoFTools::
      make_flux_sparsity_pattern<deal_II_dimension, deal_II_dimension, SP>(
        const DoFHandler<deal_II_dimension> &dof,
        SP &                                 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, SP>(
        const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
        SP &                                                        sparsity);

    template void DoFTools::
      make_flux_sparsity_pattern<deal_II_dimension, deal_II_dimension + 1, SP>(
        const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof,
        SP &                                                        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, SP>(
        const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof_row,
        const DoFHandler<deal_II_dimension, deal_II_dimension + 1> &dof_col,
        SP &                                                        sparsity);

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

#endif


#if deal_II_dimension == 3

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

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

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

    template void DoFTools::make_flux_sparsity_pattern<1, 3, SP>(
      const DoFHandler<1, 3> &dof,
      SP &                    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);
  }
