From 8770681364578e5794b6b7b87a393232414f3acb Mon Sep 17 00:00:00 2001 From: grahambenharper Date: Mon, 26 Aug 2019 20:40:12 -0600 Subject: [PATCH] Implement the ScalarPolynomialsBase class --- .../deal.II/base/scalar_polynomials_base.h | 175 ++++++++++++++++++ .../deal.II/base/tensor_polynomials_base.h | 2 +- source/base/CMakeLists.txt | 1 + source/base/scalar_polynomials_base.cc | 42 +++++ 4 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 include/deal.II/base/scalar_polynomials_base.h create mode 100644 source/base/scalar_polynomials_base.cc diff --git a/include/deal.II/base/scalar_polynomials_base.h b/include/deal.II/base/scalar_polynomials_base.h new file mode 100644 index 0000000000..78e263c830 --- /dev/null +++ b/include/deal.II/base/scalar_polynomials_base.h @@ -0,0 +1,175 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2005 - 2019 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. +// +// --------------------------------------------------------------------- + +#ifndef dealii_scalar_polynomials_base_h +#define dealii_scalar_polynomials_base_h + + +#include + +#include +#include +#include + +#include + +DEAL_II_NAMESPACE_OPEN + +/** + * This class provides a framework for the finite element polynomial + * classes for use with finite element classes that are derived from + * FE_Poly. An object of this type (or rather of a type derived from + * this class) is stored as a member variable in each object of type + * FE_Poly. + * + *

Deriving classes

+ * + * Any derived class must provide the most basic properties for shape + * functions evaluated on the reference cell. This includes, but is not + * limited to, implementing the evaluate(), name(), and + * clone() member functions. These functions are necessary to store the + * most basic information of how the polynomials in the derived class evaluate + * at a given point on the reference cell. More information on each function can + * be found in the corresponding function's documentation. + * + * Some classes that derive from this class include + *
    + *
  • PolynomialsRannacherTurek + *
  • PolynomialsP + *
  • PolynomialSpace + *
  • TensorProductPolynomials + *
  • TensorProductPolynomialsConst + *
  • TensorProductPolynomialsBubbles + *
+ * + * @ingroup Polynomials + * @author Graham Harper + * @date 2019 + */ +template +class ScalarPolynomialsBase +{ +public: + /** + * Constructor. This takes the degree of the space, @p deg from the finite element + * class, and @p n, the number of polynomials for the space. + */ + ScalarPolynomialsBase(const unsigned int deg, + const unsigned int n_polynomials); + + /** + * Move constructor. + */ + ScalarPolynomialsBase(ScalarPolynomialsBase &&) = default; // NOLINT + + /** + * Copy constructor. + */ + ScalarPolynomialsBase(const ScalarPolynomialsBase &) = default; + + /** + * Virtual destructor. Makes sure that pointers to this class are deleted + * properly. + */ + virtual ~ScalarPolynomialsBase() = default; + + /** + * Compute the value and the derivatives of the polynomials at + * @p unit_point. + * + * The size of the vectors must either be zero or equal n(). In + * the first case, the function will not compute these values. + * + * If you need values or derivatives of all polynomials then use this + * function, rather than using any of the compute_value, + * compute_grad or compute_grad_grad functions, see below, + * in a loop over all tensor product polynomials. + */ + virtual void + evaluate(const Point & unit_point, + std::vector & values, + std::vector> &grads, + std::vector> &grad_grads, + std::vector> &third_derivatives, + std::vector> &fourth_derivatives) const = 0; + + /** + * Return the number of polynomials. + */ + unsigned int + n() const; + + /** + * Return the highest polynomial degree of polynomials represented by this + * class. A derived class may override this if its value is different from + * @p my_degree. + */ + unsigned int + degree() const; + + /** + * A sort of virtual copy constructor, this function returns a copy of + * the polynomial space object. Derived classes need to override the function + * here in this base class and return an object of the same type as the + * derived class. + * + * Some places in the library, for example the constructors of FE_Poly, + * need to make copies of polynomial spaces without knowing their exact type. + * They do so through this function. + */ + virtual std::unique_ptr> + clone() const = 0; + + /** + * Return the name of the space. + */ + virtual std::string + name() const = 0; + +private: + /** + * The highest polynomial degree of this functions represented by this object. + */ + const unsigned int polynomial_degree; + + /** + * The number of polynomials represented by this object. + */ + const unsigned int n_pols; +}; + + + +template +inline unsigned int +ScalarPolynomialsBase::n() const +{ + return n_pols; +} + + + +template +inline unsigned int +ScalarPolynomialsBase::degree() const +{ + return polynomial_degree; +} + + + +DEAL_II_NAMESPACE_CLOSE + +#endif diff --git a/include/deal.II/base/tensor_polynomials_base.h b/include/deal.II/base/tensor_polynomials_base.h index 49cfe2c4de..d7810d0879 100644 --- a/include/deal.II/base/tensor_polynomials_base.h +++ b/include/deal.II/base/tensor_polynomials_base.h @@ -31,7 +31,7 @@ DEAL_II_NAMESPACE_OPEN * This class provides a framework for the finite element polynomial * classes for use with finite element classes that are derived from * FE_PolyTensor. An object of this type (or rather of a type derived - * from this class) is stored as a member variable each object of + * from this class) is stored as a member variable in each object of * type FE_PolyTensor. * *

Deriving classes

diff --git a/source/base/CMakeLists.txt b/source/base/CMakeLists.txt index fa6554fb48..6920744d5f 100644 --- a/source/base/CMakeLists.txt +++ b/source/base/CMakeLists.txt @@ -75,6 +75,7 @@ SET(_unity_include_src quadrature.cc quadrature_lib.cc quadrature_selector.cc + scalar_polynomials_base.cc subscriptor.cc table_handler.cc tensor_function.cc diff --git a/source/base/scalar_polynomials_base.cc b/source/base/scalar_polynomials_base.cc new file mode 100644 index 0000000000..c067980ed4 --- /dev/null +++ b/source/base/scalar_polynomials_base.cc @@ -0,0 +1,42 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2005 - 2019 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. +// +// --------------------------------------------------------------------- + + +#include +#include +#include + +#include +#include + +DEAL_II_NAMESPACE_OPEN + +template +ScalarPolynomialsBase::ScalarPolynomialsBase( + const unsigned int deg, + const unsigned int n_polynomials) + : polynomial_degree(deg) + , n_pols(n_polynomials) +{ + // nothing to do here for now +} + + + +template class ScalarPolynomialsBase<1>; +template class ScalarPolynomialsBase<2>; +template class ScalarPolynomialsBase<3>; + +DEAL_II_NAMESPACE_CLOSE -- 2.39.5