deal.II version GIT relicensing-2206-gaa53ff9447 2024-12-02 09:10:00+00:00
\(\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 Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Polynomials::PiecewisePolynomial< number > Class Template Reference

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

Inheritance diagram for Polynomials::PiecewisePolynomial< number >:
Inheritance graph
[legend]

Public Member Functions

 PiecewisePolynomial (const Polynomial< number > &coefficients_on_interval, const unsigned int n_intervals, const unsigned int interval, const bool spans_next_interval)
 
 PiecewisePolynomial (const std::vector< Point< 1, number > > &points, const unsigned int index)
 
number value (const number x) const
 
void value (const number x, std::vector< number > &values) const
 
void value (const number x, const unsigned int n_derivatives, number *values) const
 
unsigned int degree () const
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 
virtual std::size_t memory_consumption () const
 
EnableObserverPointer functionality

Classes derived from EnableObserverPointer provide a facility to subscribe to this object. This is mostly used by the ObserverPointer 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 ::ExceptionBaseExcInUse (int arg1, std::string arg2, std::string arg3)
 
static ::ExceptionBaseExcNoSubscriber (std::string arg1, std::string arg2)
 

Protected Attributes

Polynomial< number > polynomial
 
unsigned int n_intervals
 
unsigned int interval
 
bool spans_two_intervals
 
std::vector< number > points
 
std::vector< number > one_over_lengths
 
unsigned int index
 

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

template<typename number>
class Polynomials::PiecewisePolynomial< number >

Definition of piecewise 1d polynomials for the unit interval. This space allows the description of interpolating polynomials on parts of the unit interval, similarly to the definition of finite element basis functions on subdivided elements. The primary purpose of this class is to allow constructing the shape functions of the FE_Q_iso_Q1 class that has a number of interpolation points in each coordinate direction, but instead of using them for higher-order polynomials just chooses piecewise linear shape functions – in effect, it is a \(Q_1\) element defined on a subdivision of the reference cell, and replicated on each of these sub-cells.

This class is not derived from the ScalarPolynomialsBase base class because it is not actually a polynomial – it is a piecewise polynomial. However, it is interface-compatible with the Polynomials::Polynomial class, and consequently can be used as template argument for TensorProductPolynomials.

Definition at line 63 of file polynomials_piecewise.h.

Member Typedef Documentation

◆ map_value_type

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

The data type used in counter_map.

Definition at line 238 of file enable_observer_pointer.h.

◆ map_iterator

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

The iterator type used in counter_map.

Definition at line 243 of file enable_observer_pointer.h.

Constructor & Destructor Documentation

◆ PiecewisePolynomial() [1/2]

template<typename number >
Polynomials::PiecewisePolynomial< number >::PiecewisePolynomial ( const Polynomial< number > &  coefficients_on_interval,
const unsigned int  n_intervals,
const unsigned int  interval,
const bool  spans_next_interval 
)

Constructor for Lagrange polynomial on an interval that is a subset of the unit interval. It uses a polynomial description that is scaled to the size of the subinterval compared to the unit interval, the total number of intervals (subdivisions), the current index of the interval as well as if the polynomial spans onto the next interval (e.g., if it lives on two neighboring intervals).

If the number of intervals is one, the piecewise polynomial behaves exactly like a usual polynomial.

Definition at line 26 of file polynomials_piecewise.cc.

◆ PiecewisePolynomial() [2/2]

template<typename number >
Polynomials::PiecewisePolynomial< number >::PiecewisePolynomial ( const std::vector< Point< 1, number > > &  points,
const unsigned int  index 
)

Constructor for linear Lagrange polynomial on an interval that is a subset of the unit interval. It uses a polynomial description that is scaled to the size of the subinterval compared to the unit interval. The subintervals are bounded by the adjacent points in points.

Definition at line 44 of file polynomials_piecewise.cc.

Member Function Documentation

◆ value() [1/3]

template<typename number >
number Polynomials::PiecewisePolynomial< number >::value ( const number  x) const
inline

Return the value of this polynomial at the given point, evaluating the underlying polynomial. The polynomial evaluates to zero when outside of the given interval (and possible the next one to the right when it spans over that range).

Definition at line 245 of file polynomials_piecewise.h.

◆ value() [2/3]

template<typename number >
void Polynomials::PiecewisePolynomial< number >::value ( const number  x,
std::vector< number > &  values 
) const

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 vector passed.

Note that all the derivatives evaluate to zero at the border between intervals (assuming exact arithmetic) in the interior of the unit interval, as there is no unique gradient value in that case for a piecewise polynomial. This is not always desired (e.g., when evaluating jumps of gradients on the element boundary), but it is the user's responsibility to avoid evaluation at these points when it does not make sense.

Definition at line 69 of file polynomials_piecewise.cc.

◆ value() [3/3]

template<typename number >
void Polynomials::PiecewisePolynomial< number >::value ( const number  x,
const unsigned int  n_derivatives,
number *  values 
) const

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.

Note that all the derivatives evaluate to zero at the border between intervals (assuming exact arithmetic) in the interior of the unit interval, as there is no unique gradient value in that case for a piecewise polynomial. This is not always desired (e.g., when evaluating jumps of gradients on the element boundary), but it is the user's responsibility to avoid evaluation at these points when it does not make sense.

Definition at line 81 of file polynomials_piecewise.cc.

◆ degree()

template<typename number >
unsigned int Polynomials::PiecewisePolynomial< number >::degree ( ) const
inline

Degree of the polynomial. This is the degree of the underlying base polynomial.

Definition at line 234 of file polynomials_piecewise.h.

◆ serialize()

template<typename number >
template<class Archive >
void Polynomials::PiecewisePolynomial< number >::serialize ( Archive &  ar,
const unsigned int  version 
)
inline

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 301 of file polynomials_piecewise.h.

◆ memory_consumption()

template<typename number >
std::size_t Polynomials::PiecewisePolynomial< number >::memory_consumption ( ) const
virtual

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

Definition at line 177 of file polynomials_piecewise.cc.

◆ subscribe()

void EnableObserverPointer::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 131 of file enable_observer_pointer.cc.

◆ unsubscribe()

void EnableObserverPointer::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 151 of file enable_observer_pointer.cc.

◆ n_subscriptions()

unsigned int EnableObserverPointer::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 322 of file enable_observer_pointer.h.

◆ list_subscribers() [1/2]

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

List the subscribers to the input stream.

Definition at line 339 of file enable_observer_pointer.h.

◆ list_subscribers() [2/2]

void EnableObserverPointer::list_subscribers ( ) const
inherited

List the subscribers to deallog.

Definition at line 199 of file enable_observer_pointer.cc.

◆ check_no_subscribers()

void EnableObserverPointer::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 enable_observer_pointer.cc.

Member Data Documentation

◆ polynomial

template<typename number >
Polynomial<number> Polynomials::PiecewisePolynomial< number >::polynomial
protected

Underlying polynomial object that is scaled to a subinterval and concatenated accordingly.

Definition at line 164 of file polynomials_piecewise.h.

◆ n_intervals

template<typename number >
unsigned int Polynomials::PiecewisePolynomial< number >::n_intervals
protected

A variable storing the number of intervals that the unit interval is divided into.

Definition at line 170 of file polynomials_piecewise.h.

◆ interval

template<typename number >
unsigned int Polynomials::PiecewisePolynomial< number >::interval
protected

A variable storing the index of the current polynomial in the range of intervals.

Definition at line 176 of file polynomials_piecewise.h.

◆ spans_two_intervals

template<typename number >
bool Polynomials::PiecewisePolynomial< number >::spans_two_intervals
protected

Store if the polynomial spans over two adjacent intervals, i.e., the one given in subinterval and the next one.

Definition at line 182 of file polynomials_piecewise.h.

◆ points

template<typename number >
std::vector<number> Polynomials::PiecewisePolynomial< number >::points
protected

Points bounding the subintervals in the case that piecewise linear polynomial on varying subintervals is requested.

Definition at line 188 of file polynomials_piecewise.h.

◆ one_over_lengths

template<typename number >
std::vector<number> Polynomials::PiecewisePolynomial< number >::one_over_lengths
protected

Precomputed inverses of the lengths of the subintervals, i.e., one_over_lengths[i] = 1.0 / (points[i + 1] - points[i].

Definition at line 194 of file polynomials_piecewise.h.

◆ index

template<typename number >
unsigned int Polynomials::PiecewisePolynomial< number >::index
protected

A variable storing the index of the current polynomial in the case that piecewise linear polynomial on varying subintervals is requested.

Definition at line 200 of file polynomials_piecewise.h.

◆ counter

std::atomic<unsigned int> EnableObserverPointer::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 227 of file enable_observer_pointer.h.

◆ counter_map

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

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

Definition at line 233 of file enable_observer_pointer.h.

◆ validity_pointers

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

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

Definition at line 249 of file enable_observer_pointer.h.

◆ object_info

const std::type_info* EnableObserverPointer::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 257 of file enable_observer_pointer.h.

◆ mutex

std::mutex EnableObserverPointer::mutex
staticprivateinherited

A mutex used to ensure data consistency when accessing the mutable members of this class. This lock is used in the subscribe() and unsubscribe() functions, as well as in list_subscribers().

Definition at line 280 of file enable_observer_pointer.h.


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