<commit_before>// ---------------------------------------------------------------------
//
// Copyright (C) 2002 - 2015 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 at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------


#include <deal.II/fe/fe_q_hierarchical.h>
#include <deal.II/fe/fe_nothing.h>

#include <cmath>
#include <sstream>

//TODO: implement the adjust_quad_dof_index_for_face_orientation_table and
//adjust_line_dof_index_for_line_orientation_table fields, and write tests
//similar to bits/face_orientation_and_fe_q_*


DEAL_II_NAMESPACE_OPEN

namespace
{
  /**
   * A function which maps  in[i] to i,i.e. output[in[i]] = i;
   */
  inline
  std::vector<unsigned int>
  invert_numbering (const std::vector<unsigned int> &in)
  {
    std::vector<unsigned int> out (in.size());
    for (unsigned int i=0; i<in.size(); ++i)
      {
        Assert (in[i] < out.size(),
                dealii::ExcIndexRange(in[i],0,out.size()));
        out[in[i]]=i;
      }
    return out;
  }
}



template <int dim>
FE_Q_Hierarchical<dim>::FE_Q_Hierarchical (const unsigned int degree)
  :
  FE_Poly<TensorProductPolynomials<dim>, dim> (
    Polynomials::Hierarchical::generate_complete_basis(degree),
    FiniteElementData<dim>(get_dpo_vector(degree),1, degree,
                           FiniteElementData<dim>::H1),
    std::vector<bool> (FiniteElementData<dim>(
                         get_dpo_vector(degree),1, degree).dofs_per_cell, false),
    std::vector<ComponentMask>(FiniteElementData<dim>(
                                 get_dpo_vector(degree),1, degree).dofs_per_cell, std::vector<bool>(1,true))),
  face_renumber(face_fe_q_hierarchical_to_hierarchic_numbering (degree))
{
  this->poly_space.set_numbering(
    hierarchic_to_fe_q_hierarchical_numbering(*this));

  // The matrix @p{dofs_cell} contains the
  // values of the linear functionals of
  // the master 1d cell applied to the
  // shape functions of the two 1d subcells.
  // The matrix @p{dofs_subcell} contains
  // the values of the linear functionals
  // on each 1d subcell applied to the
  // shape functions on the master 1d
  // subcell.
  // We use @p{dofs_cell} and
  // @p{dofs_subcell} to compute the
  // @p{prolongation}, @p{restriction} and
  // @p{interface_constraints} matrices
  // for all dimensions.
  std::vector<FullMatrix<double> >
  dofs_cell (GeometryInfo<1>::max_children_per_cell,
             FullMatrix<double> (2*this->dofs_per_vertex + this->dofs_per_line,
                                 2*this->dofs_per_vertex + this->dofs_per_line));
  std::vector<FullMatrix<double> >
  dofs_subcell (GeometryInfo<1>::max_children_per_cell,
                FullMatrix<double> (2*this->dofs_per_vertex + this->dofs_per_line,
                                    2*this->dofs_per_vertex + this->dofs_per_line));
  // build these fields, as they are
  // needed as auxiliary fields later
  // on
  build_dofs_cell (dofs_cell, dofs_subcell);

  // then use them to initialize
  // other fields
  initialize_constraints (dofs_subcell);
  initialize_embedding_and_restriction (dofs_cell, dofs_subcell);

  // finally fill in support points
  // on cell and face
  initialize_unit_support_points ();
  initialize_unit_face_support_points ();
}



template <int dim>
std::string
FE_Q_Hierarchical<dim>::get_name () const
{
  // note that the
  // FETools::get_fe_from_name
  // function depends on the
  // particular format of the string
  // this function returns, so they
  // have to be kept in synch

  std::ostringstream namebuf;
  namebuf << "FE_Q_Hierarchical<" << dim << ">(" << this->degree << ")";

  return namebuf.str();
}


template <int dim>
void
FE_Q_Hierarchical<dim>::interpolate(
  std::vector<double> &,
  const std::vector<double> &) const
{
  // The default implementation assumes that the FE has a delta property,
  // i.e., values at the support points equal the corresponding DoFs. This
  // is obviously not the case here.
  Assert (false, ExcNotImplemented());
}


template <int dim>
void
FE_Q_Hierarchical<dim>::interpolate(
  std::vector<double> &,
  const std::vector<Vector<double> > &,
  unsigned int) const
{
  Assert (false, ExcNotImplemented());
}


template <int dim>
void
FE_Q_Hierarchical<dim>::interpolate(
  std::vector<double> &local_dofs,
  const VectorSlice<const std::vector<std::vector<double> > > &values) const
{
  Assert (false, ExcNotImplemented());
}


template <int dim>
FiniteElement<dim> *
FE_Q_Hierarchical<dim>::clone() const
{
  return new FE_Q_Hierarchical<dim>(*this);
}

template <int dim>
void
FE_Q_Hierarchical<dim>::get_interpolation_matrix(const FiniteElement< dim> &source,
                                                 FullMatrix< double > &matrix) const
{
  // support interpolation between FE_Q_Hierarchical only.
  if (const FE_Q_Hierarchical<dim> *source_fe
      = dynamic_cast<const FE_Q_Hierarchical<dim>*>(&source))
    {
      // ok, source is a Q_Hierarchical element, so we will be able to do the work<commit_msg>Fix warning introduced with the latest commit<commit_after>// ---------------------------------------------------------------------
//
// Copyright (C) 2002 - 2015 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 at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------


#include <deal.II/fe/fe_q_hierarchical.h>
#include <deal.II/fe/fe_nothing.h>

#include <cmath>
#include <sstream>

//TODO: implement the adjust_quad_dof_index_for_face_orientation_table and
//adjust_line_dof_index_for_line_orientation_table fields, and write tests
//similar to bits/face_orientation_and_fe_q_*


DEAL_II_NAMESPACE_OPEN

namespace
{
  /**
   * A function which maps  in[i] to i,i.e. output[in[i]] = i;
   */
  inline
  std::vector<unsigned int>
  invert_numbering (const std::vector<unsigned int> &in)
  {
    std::vector<unsigned int> out (in.size());
    for (unsigned int i=0; i<in.size(); ++i)
      {
        Assert (in[i] < out.size(),
                dealii::ExcIndexRange(in[i],0,out.size()));
        out[in[i]]=i;
      }
    return out;
  }
}



template <int dim>
FE_Q_Hierarchical<dim>::FE_Q_Hierarchical (const unsigned int degree)
  :
  FE_Poly<TensorProductPolynomials<dim>, dim> (
    Polynomials::Hierarchical::generate_complete_basis(degree),
    FiniteElementData<dim>(get_dpo_vector(degree),1, degree,
                           FiniteElementData<dim>::H1),
    std::vector<bool> (FiniteElementData<dim>(
                         get_dpo_vector(degree),1, degree).dofs_per_cell, false),
    std::vector<ComponentMask>(FiniteElementData<dim>(
                                 get_dpo_vector(degree),1, degree).dofs_per_cell, std::vector<bool>(1,true))),
  face_renumber(face_fe_q_hierarchical_to_hierarchic_numbering (degree))
{
  this->poly_space.set_numbering(
    hierarchic_to_fe_q_hierarchical_numbering(*this));

  // The matrix @p{dofs_cell} contains the
  // values of the linear functionals of
  // the master 1d cell applied to the
  // shape functions of the two 1d subcells.
  // The matrix @p{dofs_subcell} contains
  // the values of the linear functionals
  // on each 1d subcell applied to the
  // shape functions on the master 1d
  // subcell.
  // We use @p{dofs_cell} and
  // @p{dofs_subcell} to compute the
  // @p{prolongation}, @p{restriction} and
  // @p{interface_constraints} matrices
  // for all dimensions.
  std::vector<FullMatrix<double> >
  dofs_cell (GeometryInfo<1>::max_children_per_cell,
             FullMatrix<double> (2*this->dofs_per_vertex + this->dofs_per_line,
                                 2*this->dofs_per_vertex + this->dofs_per_line));
  std::vector<FullMatrix<double> >
  dofs_subcell (GeometryInfo<1>::max_children_per_cell,
                FullMatrix<double> (2*this->dofs_per_vertex + this->dofs_per_line,
                                    2*this->dofs_per_vertex + this->dofs_per_line));
  // build these fields, as they are
  // needed as auxiliary fields later
  // on
  build_dofs_cell (dofs_cell, dofs_subcell);

  // then use them to initialize
  // other fields
  initialize_constraints (dofs_subcell);
  initialize_embedding_and_restriction (dofs_cell, dofs_subcell);

  // finally fill in support points
  // on cell and face
  initialize_unit_support_points ();
  initialize_unit_face_support_points ();
}



template <int dim>
std::string
FE_Q_Hierarchical<dim>::get_name () const
{
  // note that the
  // FETools::get_fe_from_name
  // function depends on the
  // particular format of the string
  // this function returns, so they
  // have to be kept in synch

  std::ostringstream namebuf;
  namebuf << "FE_Q_Hierarchical<" << dim << ">(" << this->degree << ")";

  return namebuf.str();
}


template <int dim>
void
FE_Q_Hierarchical<dim>::interpolate(
  std::vector<double> &,
  const std::vector<double> &) const
{
  // The default implementation assumes that the FE has a delta property,
  // i.e., values at the support points equal the corresponding DoFs. This
  // is obviously not the case here.
  Assert (false, ExcNotImplemented());
}


template <int dim>
void
FE_Q_Hierarchical<dim>::interpolate(
  std::vector<double> &,
  const std::vector<Vector<double> > &,
  unsigned int) const
{
  Assert (false, ExcNotImplemented());
}


template <int dim>
void
FE_Q_Hierarchical<dim>::interpolate(
  std::vector<double> &,
  const VectorSlice<const std::vector<std::vector<double> > > &) const
{
  Assert (false, ExcNotImplemented());
}


template <int dim>
FiniteElement<dim> *
FE_Q_Hierarchical<dim>::clone() const
{
  return new FE_Q_Hierarchical<dim>(*this);
}

template <int dim>
void
FE_Q_Hierarchical<dim>::get_interpolation_matrix(const FiniteElement< dim> &source,
                                                 FullMatrix< double > &matrix) const
{
  // support interpolation between FE_Q_Hierarchical only.
  if (const FE_Q_Hierarchical<dim> *source_fe
      = dynamic_cast<const FE_Q_Hierarchical<dim>*>(&source))
    {
      // ok, source is a Q_Hierarchical element, so we will be able to do the work
{'fraction_non_alphanumeric': 0.13948774645292059, 'fraction_numerical': 0.004975124378109453, 'mean_word_length': 3.1226737561716673, 'pattern_counts': {'":': 0, '<': 137, '<?xml version=': 0, '>': 133, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6320218', 'n_tokens_mistral': 3584, 'n_tokens_neox': 3495, 'n_words': 883}