Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Polynomials::HermiteLikeInterpolation Class Reference

#include <deal.II/base/polynomial.h>

Inheritance diagram for Polynomials::HermiteLikeInterpolation:
[legend]

Public Member Functions

 HermiteLikeInterpolation (const unsigned int degree, const unsigned int index)
 
double value (const double x) const
 
void value (const double x, std::vector< double > &values) const
 
void value (const Number2 x, const unsigned int n_derivatives, Number2 *values) const
 
void values_of_array (const std::array< Number2, n_entries > &points, const unsigned int n_derivatives, std::array< Number2, n_entries > *values) const
 
unsigned int degree () const
 
void scale (const double factor)
 
void shift (const number2 offset)
 
Polynomial< double > derivative () const
 
Polynomial< double > primitive () const
 
Polynomial< double > & operator*= (const double s)
 
Polynomial< double > & operator*= (const Polynomial< double > &p)
 
Polynomial< double > & operator+= (const Polynomial< double > &p)
 
Polynomial< double > & operator-= (const Polynomial< double > &p)
 
bool operator== (const Polynomial< double > &p) const
 
void print (std::ostream &out) const
 
void serialize (Archive &ar, const unsigned int version)
 
virtual std::size_t memory_consumption () const
 
Subscriptor functionality

Classes derived from Subscriptor provide a facility to subscribe to this object. This is mostly used by the SmartPointer class.

void subscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
void unsubscribe (std::atomic< bool > *const validity, const std::string &identifier="") const
 
unsigned int n_subscriptions () const
 
template<typename StreamType >
void list_subscribers (StreamType &stream) const
 
void list_subscribers () const
 

Static Public Member Functions

static std::vector< Polynomial< double > > generate_complete_basis (const unsigned int degree)
 
static ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)
 
static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)
 

Protected Member Functions

void transform_into_standard_form ()
 

Static Protected Member Functions

static void scale (std::vector< double > &coefficients, const double factor)
 
static void shift (std::vector< double > &coefficients, const number2 shift)
 
static void multiply (std::vector< double > &coefficients, const double factor)
 

Protected Attributes

std::vector< double > coefficients
 
bool in_lagrange_product_form
 
std::vector< double > lagrange_support_points
 
double lagrange_weight
 

Private Types

using map_value_type = decltype(counter_map)::value_type
 
using map_iterator = decltype(counter_map)::iterator
 

Private Member Functions

void check_no_subscribers () const noexcept
 

Private Attributes

std::atomic< unsigned intcounter
 
std::map< std::string, unsigned intcounter_map
 
std::vector< std::atomic< bool > * > validity_pointers
 
const std::type_info * object_info
 

Static Private Attributes

static std::mutex mutex
 

Detailed Description

Polynomials for a variant of Hermite polynomials with better condition number in the interpolation than the basis from HermiteInterpolation.

In analogy to the proper Hermite polynomials, this basis evaluates the first polynomial \(p_0\) to 1 at \(x=0\) and has both a zero value and zero derivative at \(x=1\). Likewise, the last polynomial \(p_n\) evaluates to 1 at \(x=1\) with a zero value and zero derivative at \(x=0\). The second polynomial \(p_1\) and the second to last polynomial \(p_{n-1}\) represent the derivative degree of freedom at \(x=0\) and \(x=1\), respectively. They are zero at both the end points \(x=0, x=1\) and have zero derivative at the opposite end, \(p_1'(1)=0\) and \(p_{n-1}'(0)=0\). As opposed to the original Hermite polynomials, \(p_0\) does not have zero derivative at \(x=0\). The additional degree of freedom is used to make \(p_0\) and \(p_1\) orthogonal, which for \(n=3\) results in a root at \(x=\frac{2}{7}\) for \(p_0\) and at \(x=\frac{5}{7}\) for \(p_n\), respectively. Furthermore, the extension of these polynomials to higher degrees \(n>3\) is constructed by adding additional nodes inside the unit interval, again ensuring better conditioning. The nodes are computed as the roots of the Jacobi polynomials for \(\alpha=\beta=4\), which are orthogonal against the square of the generating function \(x^2(1-x)^2\) with the Hermite property. Then, these polynomials are constructed in the usual way as Lagrange polynomials with double roots at \(x=0\) and \(x=1\). For example with \(n=4\), all of \(p_0, p_1, p_3, p_4\) get an additional root at \(x=0.5\) through the factor \((x-0.5)\). In summary, this basis is dominated by nodal contributions, but it is not a nodal one because the second and second to last polynomials that are non-nodal, and due to the presence of double nodes in \(x=0\) and \(x=1\). The weights of the basis functions are set such that the sum of all polynomials with unit weight represents the constant function 1, similarly to Lagrange polynomials.

The basis only contains Hermite information for degree>=3, but it is also implemented for degrees between 0 and two. For the linear case, the usual hat functions are implemented, whereas the polynomials for degree=2 are \(p_0(x)=(1-x)^2\), \(p_1(x)=2x(x-1)\), and \(p_2(x)=x^2\), in accordance with the construction principle for degree 3.

These two relaxations improve the condition number of the mass matrix (i.e., interpolation) significantly, as can be seen from the following table:

  Condition number mass matrix
degree HermiteInterpolation HermiteLikeInterpolation
n=3 1057 17.18
n=4 6580 16.83
n=5 1.875e+04 15.99
n=6 6.033e+04 16.34
n=10 9.756e+05 20.70
n=15 9.431e+06 27.91
n=25 2.220e+08 43.54
n=35 2.109e+09 59.51

This polynomial inherits the advantageous property of Hermite polynomials where only two functions have value and/or derivative nonzero on a face advantageous for discontinuous Galerkin methods but gives better condition numbers of interpolation, which improves the performance of some iterative schemes like conjugate gradients with point-Jacobi. This polynomial is used in FE_DGQHermite.

Definition at line 727 of file polynomial.h.

Member Typedef Documentation

◆ map_value_type

using Subscriptor::map_value_type = decltype(counter_map)::value_type
privateinherited

The data type used in counter_map.

Definition at line 230 of file subscriptor.h.

◆ map_iterator

using Subscriptor::map_iterator = decltype(counter_map)::iterator
privateinherited

The iterator type used in counter_map.

Definition at line 235 of file subscriptor.h.

Constructor & Destructor Documentation

◆ HermiteLikeInterpolation()

Polynomials::HermiteLikeInterpolation::HermiteLikeInterpolation ( const unsigned int  degree,
const unsigned int  index 
)

Constructor for the polynomial with index index within the set up polynomials of degree degree.

Definition at line 1175 of file polynomial.cc.

Member Function Documentation

◆ generate_complete_basis()

std::vector< Polynomial< double > > Polynomials::HermiteLikeInterpolation::generate_complete_basis ( const unsigned int  degree)
static

Return the polynomials with index 0 up to degree+1 in a space of degree up to degree.

Definition at line 1405 of file polynomial.cc.

◆ value() [1/3]

double Polynomials::Polynomial< double >::value ( const double  x) const
inlineinherited

Return the value of this polynomial at the given point.

This function uses the most numerically stable evaluation algorithm for the provided form of the polynomial. If the polynomial is in the product form of roots, the evaluation is based on products of the form (x - x_i), whereas the Horner scheme is used for polynomials in the coefficient form.

Definition at line 108 of file polynomial.h.

◆ value() [2/3]

void Polynomials::Polynomial< double >::value ( const double  x,
std::vector< double > &  values 
) const
inherited

Return the values and the derivatives of the Polynomial at point x. values[i], i=0,...,values.size()-1 includes the ith derivative. The number of derivatives to be computed is thus determined by the size of the array passed.

This function uses the Horner scheme for numerical stability of the evaluation for polynomials in the coefficient form or the product of terms involving the roots if that representation is used.

Definition at line 121 of file polynomial.cc.

◆ value() [3/3]

void Polynomials::Polynomial< double >::value ( const Number2  x,
const unsigned int  n_derivatives,
Number2 *  values 
) const
inlineinherited

Return the values and the derivatives of the Polynomial at point x. values[i], i=0,...,n_derivatives includes the ith derivative. The number of derivatives to be computed is determined by n_derivatives and values has to provide sufficient space for n_derivatives + 1 values.

This function uses the most numerically stable evaluation algorithm for the provided form of the polynomial. If the polynomial is in the product form of roots, the evaluation is based on products of the form (x - x_i), whereas the Horner scheme is used for polynomials in the coefficient form.

The template type Number2 must implement arithmetic operations such as additions or multiplication with the type number of the polynomial, and must be convertible from number by operator=.

Definition at line 143 of file polynomial.h.

◆ values_of_array()

void Polynomials::Polynomial< double >::values_of_array ( const std::array< Number2, n_entries > &  points,
const unsigned int  n_derivatives,
std::array< Number2, n_entries > *  values 
) const
inlineinherited

Similar to the function above, but evaluate the polynomials on several positions at once, as described by the array argument points. This function is can be faster than the other function when the same polynomial should be evaluated on several positions at once, e.g., the x,y,z coordinates of a point for tensor-product polynomials.

The template type Number2 must implement arithmetic operations such as additions or multiplication with the type number of the polynomial, and must be convertible from number by operator=.

Definition at line 161 of file polynomial.h.

◆ degree()

unsigned int Polynomials::Polynomial< double >::degree
inlineinherited

Degree of the polynomial. This is the degree reflected by the number of coefficients provided by the constructor. Leading non-zero coefficients are not treated separately.

Definition at line 171 of file polynomial.h.

◆ scale() [1/2]

void Polynomials::Polynomial< double >::scale ( const double  factor)
inherited

Scale the abscissa of the polynomial. Given the polynomial p(t) and the scaling t = ax, then the result of this operation is the polynomial q, such that q(x) = p(t).

The operation is performed in place.

Definition at line 181 of file polynomial.cc.

◆ scale() [2/2]

void Polynomials::Polynomial< double >::scale ( std::vector< double > &  coefficients,
const double  factor 
)
staticprotectedinherited

This function performs the actual scaling.

Definition at line 271 of file polynomial.cc.

◆ shift() [1/2]

void Polynomials::Polynomial< double >::shift ( const number2  offset)
inherited

Shift the abscissa oft the polynomial. Given the polynomial p(t) and the shift t = x + a, then the result of this operation is the polynomial q, such that q(x) = p(t).

The template parameter allows to compute the new coefficients with higher accuracy, since all computations are performed with type number2. This may be necessary, since this operation involves a big number of additions. On a Sun Sparc Ultra with Solaris 2.8, the difference between double and long double was not significant, though.

The operation is performed in place, i.e. the coefficients of the present object are changed.

Definition at line 200 of file polynomial.cc.

◆ shift() [2/2]

void Polynomials::Polynomial< double >::shift ( std::vector< double > &  coefficients,
const number2  shift 
)
staticprotectedinherited

This function performs the actual shift

Definition at line 278 of file polynomial.cc.

◆ derivative()

Polynomial< double > Polynomials::Polynomial< double >::derivative
inherited

Compute the derivative of a polynomial.

Definition at line 206 of file polynomial.cc.

◆ primitive()

Polynomial< double > Polynomials::Polynomial< double >::primitive
inherited

Compute the primitive of a polynomial. the coefficient of the zero order term of the polynomial is zero.

Definition at line 213 of file polynomial.cc.

◆ operator*=() [1/2]

Polynomial< double > & Polynomials::Polynomial< double >::operator*= ( const double  s)
inherited

Multiply with a scalar.

Definition at line 219 of file polynomial.cc.

◆ operator*=() [2/2]

Polynomial< double > & Polynomials::Polynomial< double >::operator*= ( const Polynomial< double > &  p)
inherited

Multiply with another polynomial.

Definition at line 225 of file polynomial.cc.

◆ operator+=()

Polynomial< double > & Polynomials::Polynomial< double >::operator+= ( const Polynomial< double > &  p)
inherited

Add a second polynomial.

Definition at line 231 of file polynomial.cc.

◆ operator-=()

Polynomial< double > & Polynomials::Polynomial< double >::operator-= ( const Polynomial< double > &  p)
inherited

Subtract a second polynomial.

Definition at line 237 of file polynomial.cc.

◆ operator==()

bool Polynomials::Polynomial< double >::operator== ( const Polynomial< double > &  p) const
inherited

Test for equality of two polynomials.

Definition at line 243 of file polynomial.cc.

◆ print()

void Polynomials::Polynomial< double >::print ( std::ostream &  out) const
inherited

Print coefficients.

Definition at line 249 of file polynomial.cc.

◆ serialize()

void Polynomials::Polynomial< double >::serialize ( Archive &  ar,
const unsigned int  version 
)
inlineinherited

Write or read the data of this object to or from a stream for the purpose of serialization using the BOOST serialization library.

Definition at line 258 of file polynomial.h.

◆ memory_consumption()

std::size_t Polynomials::Polynomial< double >::memory_consumption
virtualinherited

Return an estimate (in bytes) for the memory consumption of this object.

Definition at line 264 of file polynomial.cc.

◆ multiply()

void Polynomials::Polynomial< double >::multiply ( std::vector< double > &  coefficients,
const double  factor 
)
staticprotectedinherited

Multiply polynomial by a factor.

Definition at line 284 of file polynomial.cc.

◆ transform_into_standard_form()

void Polynomials::Polynomial< double >::transform_into_standard_form
protectedinherited

Transform polynomial form of product of linear factors into standard form, \(\sum_i a_i x^i\). Deletes all data structures related to the product form.

Definition at line 292 of file polynomial.cc.

◆ subscribe()

void Subscriptor::subscribe ( std::atomic< bool > *const  validity,
const std::string &  identifier = "" 
) const
inherited

Subscribes a user of the object by storing the pointer validity. The subscriber may be identified by text supplied as identifier.

Definition at line 136 of file subscriptor.cc.

◆ unsubscribe()

void Subscriptor::unsubscribe ( std::atomic< bool > *const  validity,
const std::string &  identifier = "" 
) const
inherited

Unsubscribes a user from the object.

Note
The identifier and the validity pointer must be the same as the one supplied to subscribe().

Definition at line 156 of file subscriptor.cc.

◆ n_subscriptions()

unsigned int Subscriptor::n_subscriptions ( ) const
inlineinherited

Return the present number of subscriptions to this object. This allows to use this class for reference counted lifetime determination where the last one to unsubscribe also deletes the object.

Definition at line 300 of file subscriptor.h.

◆ list_subscribers() [1/2]

template<typename StreamType >
void Subscriptor::list_subscribers ( StreamType &  stream) const
inlineinherited

List the subscribers to the input stream.

Definition at line 317 of file subscriptor.h.

◆ list_subscribers() [2/2]

void Subscriptor::list_subscribers ( ) const
inherited

List the subscribers to deallog.

Definition at line 204 of file subscriptor.cc.

◆ check_no_subscribers()

void Subscriptor::check_no_subscribers ( ) const
privatenoexceptinherited

Check that there are no objects subscribing to this object. If this check passes then it is safe to destroy the current object. It this check fails then this function will either abort or print an error message to deallog (by using the AssertNothrow mechanism), but will not throw an exception.

Note
Since this function is just a consistency check it does nothing in release mode.
If this function is called when there is an uncaught exception then, rather than aborting, this function prints an error message to the standard error stream and returns.

Definition at line 53 of file subscriptor.cc.

Member Data Documentation

◆ coefficients

std::vector<double > Polynomials::Polynomial< double >::coefficients
protectedinherited

Coefficients of the polynomial \(\sum_i a_i x^i\). This vector is filled by the constructor of this class and may be passed down by derived classes.

This vector cannot be constant since we want to allow copying of polynomials.

Definition at line 302 of file polynomial.h.

◆ in_lagrange_product_form

bool Polynomials::Polynomial< double >::in_lagrange_product_form
protectedinherited

Stores whether the polynomial is in Lagrange product form, i.e., constructed as a product \((x-x_0) (x-x_1) \ldots (x-x_n)/c\), or not.

Definition at line 308 of file polynomial.h.

◆ lagrange_support_points

std::vector<double > Polynomials::Polynomial< double >::lagrange_support_points
protectedinherited

If the polynomial is in Lagrange product form, i.e., constructed as a product \((x-x_0) (x-x_1) \ldots (x-x_n)/c\), store the shifts \(x_i\).

Definition at line 314 of file polynomial.h.

◆ lagrange_weight

double Polynomials::Polynomial< double >::lagrange_weight
protectedinherited

If the polynomial is in Lagrange product form, i.e., constructed as a product \((x-x_0) (x-x_1) \ldots (x-x_n)/c\), store the weight c.

Definition at line 320 of file polynomial.h.

◆ counter

std::atomic<unsigned int> Subscriptor::counter
mutableprivateinherited

Store the number of objects which subscribed to this object. Initially, this number is zero, and upon destruction it shall be zero again (i.e. all objects which subscribed should have unsubscribed again).

The creator (and owner) of an object is counted in the map below if HE manages to supply identification.

We use the mutable keyword in order to allow subscription to constant objects also.

This counter may be read from and written to concurrently in multithreaded code: hence we use the std::atomic class template.

Definition at line 219 of file subscriptor.h.

◆ counter_map

std::map<std::string, unsigned int> Subscriptor::counter_map
mutableprivateinherited

In this map, we count subscriptions for each different identification string supplied to subscribe().

Definition at line 225 of file subscriptor.h.

◆ validity_pointers

std::vector<std::atomic<bool> *> Subscriptor::validity_pointers
mutableprivateinherited

In this vector, we store pointers to the validity bool in the SmartPointer objects that subscribe to this class.

Definition at line 241 of file subscriptor.h.

◆ object_info

const std::type_info* Subscriptor::object_info
mutableprivateinherited

Pointer to the typeinfo object of this object, from which we can later deduce the class name. Since this information on the derived class is neither available in the destructor, nor in the constructor, we obtain it in between and store it here.

Definition at line 249 of file subscriptor.h.

◆ mutex

std::mutex Subscriptor::mutex
staticprivateinherited

A mutex used to ensure data consistency when printing out the list of subscribers.

Definition at line 271 of file subscriptor.h.


The documentation for this class was generated from the following files: