NORMALIZED_POLYNOMIAL< T > Class Template Reference

This class is used to define polynomial axisymmetric coarse-graining functions. More...

#include <NormalisedPolynomial.h>

Public Member Functions

 NORMALIZED_POLYNOMIAL ()
 Basic constructor; note that this does not determine the particular polynomial; one needs to call set_polynomial to define the coefficients. More...
 
void set_polynomial (std::vector< Mdouble > new_coefficients, unsigned int new_dim)
 Use this function to set the polynomial coefficients \(c_i\). This function calls finish_set_polynomial to normalize the coefficients. More...
 
void set_polynomial (Mdouble *new_coefficients, unsigned int num_coeff, unsigned int new_dim)
 Some as set_polynomial, but avoids the use of a vector. More...
 
void setName (const char *new_name)
 Use this function to change the name of the polynomial. More...
 
std::string getName ()
 Returns name of the polynomial. More...
 
Mdouble evaluate (Mdouble r)
 Returns the value of the polynomial, \(p(r)=\sum_{i=0}^N c_i r^{N-i}\). More...
 
Mdouble evaluateGradient (Mdouble r)
 Returns the gradient of the polynomial, \(\partial_\alpha p(x,y,z)=\sum_{i=0}^N c_{i,\alpha} r^{N-i},\ \alpha=x,y,z\). More...
 
Mdouble evaluateIntegral (Mdouble a, Mdouble b, Mdouble t)
 Returns the value of the line integral along the normal P1P2 "from a to b" over the axisymmetric function. More...
 
int getOrder (void)
 Returns the order of the polynomial. More...
 

Private Member Functions

void finish_set_polynomial ()
 Normalizes the polynomial coefficients \(c_i\) such that the integral over the unit sphere of the axisymmetric function \(p(r)\) is unity. More...
 
Mdouble get_volume ()
 Returns the integral over the unit sphere of the axisymmetric function \(p(r)\). More...
 
Mdouble evaluate_1D (Mdouble r)
 Returns the value of the polynomial averaged over 2 dimensions. For StatType=X, \(r=|x|\). See also set_average_1D. More...
 
Mdouble evaluate_2D (Mdouble r)
 Returns the value of the polynomial averaged over 1 dimension. For StatType=XY, \(r=\sqrt{x^2+y^2}\). More...
 
void set_average ()
 Sets averaged_coefficients. More...
 
void set_average_1D ()
 Sets averaged_coefficients \(\bar{c}_i\) for StatType=X,Y,Z such that \(\sum_{i=0}^N \bar{c}_i x^{N-i} = \int\int_{|\vec{x}|\leq 1} p(|\vec{x}|) dy dz\). See evaluate_1D. More...
 
void set_average_2D ()
 For StatType=XY,XZ,XZ, averaged_coefficients is not used since \(\bar{p}(r)\) can be evaluated as a function of \(c_i\). See evaluate_2D. More...
 
Mdouble evaluateGradient_1D (Mdouble r)
 Returns the value of the gradient averaged over 2 dimensions. More...
 
Mdouble evaluateGradient_2D (Mdouble r)
 Returns the value of the gradient averaged over 1 dimensions. More...
 
Mdouble evaluateIntegral_1D (Mdouble a, Mdouble b, Mdouble t)
 Returns the value of the line integral along the normal P1P2 "from a to b" over the axisymmetric function averaged over 2 dimensions. More...
 
Mdouble evaluateIntegral_2D (Mdouble a, Mdouble b, Mdouble t)
 Returns the value of the line integral along the normal P1P2 "from a to b" over the axisymmetric function averaged over 1 dimensions. More...
 
Mdouble operator[] (int i) const
 Access to the coefficients. More...
 

Private Attributes

std::string name
 Contains the name of the polynomial which will be displayed as CGtype by the statistical code. More...
 
unsigned int dim
 The system dimension. More...
 
std::vector< Mdoublecoefficients
 Stores the coefficients \(c_i\). More...
 
std::vector< Mdoubleaveraged_coefficients
 Stores some coefficients used in evaluate and evaluateIntegral for StatTypes different from XYZ. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const NORMALIZED_POLYNOMIAL &P)
 Returns a text description of the polynomial. More...
 

Detailed Description

template<StatType T>
class NORMALIZED_POLYNOMIAL< T >

This class is used to define polynomial axisymmetric coarse-graining functions.

This class stores a polynomial, \(p(r)=\sum_{i=0}^N c_i r^{N-i}\), which is normalized such that the integral over the unit sphere of the axisymmetric function \(p(|\vec{x}|)\) is unity.
Use set_polynomial to define the polynomial. Use evaluate to evaluate the polynomial. Use evaluateGradient to evaluate the polynomial's gradient.
Calculations can be found in Src/docs/Polynomials.nb
This is used to define polynomial axisymmetric coarse-graining functions (see StatisticsVector).
Note: not everything is implemented yet: only dim=3 is working, no gradients are computed.

Constructor & Destructor Documentation

◆ NORMALIZED_POLYNOMIAL()

template<StatType T>
NORMALIZED_POLYNOMIAL< T >::NORMALIZED_POLYNOMIAL ( )
inline

Basic constructor; note that this does not determine the particular polynomial; one needs to call set_polynomial to define the coefficients.

86  {
87  setName("Polynomial");
88  coefficients.resize(0);
89  dim = 0;
90  }
unsigned int dim
The system dimension.
Definition: NormalisedPolynomial.h:66
std::vector< Mdouble > coefficients
Stores the coefficients .
Definition: NormalisedPolynomial.h:71
void setName(const char *new_name)
Use this function to change the name of the polynomial.
Definition: NormalisedPolynomial.h:105

References NORMALIZED_POLYNOMIAL< T >::coefficients, NORMALIZED_POLYNOMIAL< T >::dim, and NORMALIZED_POLYNOMIAL< T >::setName().

Member Function Documentation

◆ evaluate()

template<StatType T>
Mdouble NORMALIZED_POLYNOMIAL< T >::evaluate ( Mdouble  r)

Returns the value of the polynomial, \(p(r)=\sum_{i=0}^N c_i r^{N-i}\).

For averaged StatType this function is templated. If averaging statistics are used, then an averaged function is stored as well; for averaging a over certain dimensions is stored as well.

For averaging over two dimensions, \((y_{max}-y_{min})\cdot (z_{max}-z_{min})\cdot \bar{p}(x)=\int_{\vec{x}\leq1} p(|\vec{x}|) dy\,dz = \sum_{i=0}^N \bar{c}_i r^{N-i}\).

For averaging over one dimensions, \((z_{max}-z_{min})\cdot \bar{p}(x,y)=\int_{\vec{x}\leq1} p(|\vec{x}|) dz = \sum_{i=0}^N \bar{c}_i r^{N-i}\).

◆ evaluate_1D()

template<StatType T>
Mdouble NORMALIZED_POLYNOMIAL< T >::evaluate_1D ( Mdouble  r)
private

Returns the value of the polynomial averaged over 2 dimensions. For StatType=X, \(r=|x|\). See also set_average_1D.

◆ evaluate_2D()

template<StatType T>
Mdouble NORMALIZED_POLYNOMIAL< T >::evaluate_2D ( Mdouble  r)
private

Returns the value of the polynomial averaged over 1 dimension. For StatType=XY, \(r=\sqrt{x^2+y^2}\).

◆ evaluateGradient()

template<StatType T>
Mdouble NORMALIZED_POLYNOMIAL< T >::evaluateGradient ( Mdouble  r)

Returns the gradient of the polynomial, \(\partial_\alpha p(x,y,z)=\sum_{i=0}^N c_{i,\alpha} r^{N-i},\ \alpha=x,y,z\).

◆ evaluateGradient_1D()

template<StatType T>
Mdouble NORMALIZED_POLYNOMIAL< T >::evaluateGradient_1D ( Mdouble  r)
private

Returns the value of the gradient averaged over 2 dimensions.

◆ evaluateGradient_2D()

template<StatType T>
Mdouble NORMALIZED_POLYNOMIAL< T >::evaluateGradient_2D ( Mdouble  r)
private

Returns the value of the gradient averaged over 1 dimensions.

◆ evaluateIntegral()

template<StatType T>
Mdouble NORMALIZED_POLYNOMIAL< T >::evaluateIntegral ( Mdouble  a,
Mdouble  b,
Mdouble  t 
)

Returns the value of the line integral along the normal P1P2 "from a to b" over the axisymmetric function.

circle denotes the cutoff radius of the cg function around P

For averaged StatType this function is templated.

◆ evaluateIntegral_1D()

template<StatType T>
Mdouble NORMALIZED_POLYNOMIAL< T >::evaluateIntegral_1D ( Mdouble  a,
Mdouble  b,
Mdouble  t 
)
private

Returns the value of the line integral along the normal P1P2 "from a to b" over the axisymmetric function averaged over 2 dimensions.

◆ evaluateIntegral_2D()

template<StatType T>
Mdouble NORMALIZED_POLYNOMIAL< T >::evaluateIntegral_2D ( Mdouble  a,
Mdouble  b,
Mdouble  t 
)
private

Returns the value of the line integral along the normal P1P2 "from a to b" over the axisymmetric function averaged over 1 dimensions.

◆ finish_set_polynomial()

template<StatType T>
void NORMALIZED_POLYNOMIAL< T >::finish_set_polynomial ( )
private

Normalizes the polynomial coefficients \(c_i\) such that the integral over the unit sphere of the axisymmetric function \(p(r)\) is unity.

\(\int_0^1 f(r) p(r) dr = 1\), with \(f(r)=4\pi r^2\) for 3D, \(f(r)=2\pi r\) for 2D, \(f(r)=2\) for 1D systems.

Also sets averaged_coefficients

Assumes that dim and coefficients are already set.

◆ get_volume()

template<StatType T>
Mdouble NORMALIZED_POLYNOMIAL< T >::get_volume ( )
private

Returns the integral over the unit sphere of the axisymmetric function \(p(r)\).

\(\int_{|\vec{x}|\leq1} p(|\vec{x}|) d\vec{x} = \int_0^1 f(r) p(r) dr = 1\), with \(f(r)=4\pi r^2\) for 3D, \(f(r)=2\pi r\) for 2D, \(f(r)=2\) for 1D systems.

For \(p(r)=\sum_{i=0}^{N-1} c_i r^{N-1-i}\), we obtain \(V = \sum_{i=0}^{N-1} 4\pi c_i/(2+N-i)\) for 3D, \(V = \sum_{i=0}^{N-1} 2\pi c_i/(1+N-i)\) for 2D, \(V = \sum_{i=0}^{N-1} 2 c_i/(N-i)\) for 1D systems.

◆ getName()

template<StatType T>
std::string NORMALIZED_POLYNOMIAL< T >::getName ( )
inline

Returns name of the polynomial.

114  {
115  return name;
116  }
std::string name
Contains the name of the polynomial which will be displayed as CGtype by the statistical code.
Definition: NormalisedPolynomial.h:61

References NORMALIZED_POLYNOMIAL< T >::name.

◆ getOrder()

template<StatType T>
int NORMALIZED_POLYNOMIAL< T >::getOrder ( void  )
inline

Returns the order of the polynomial.

149  {
150  return coefficients.size() - 1;
151  }

References NORMALIZED_POLYNOMIAL< T >::coefficients.

◆ operator[]()

template<StatType T>
Mdouble NORMALIZED_POLYNOMIAL< T >::operator[] ( int  i) const
inlineprivate

Access to the coefficients.

248  {
249  return coefficients[i];
250  }
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References NORMALIZED_POLYNOMIAL< T >::coefficients, and constants::i.

◆ set_average()

template<StatType T>
void NORMALIZED_POLYNOMIAL< T >::set_average ( )
private

Sets averaged_coefficients.

This function is templated, with the default used only for StatType=XYZ, so it does nothing.

◆ set_average_1D()

template<StatType T>
void NORMALIZED_POLYNOMIAL< T >::set_average_1D ( )
private

Sets averaged_coefficients \(\bar{c}_i\) for StatType=X,Y,Z such that \(\sum_{i=0}^N \bar{c}_i x^{N-i} = \int\int_{|\vec{x}|\leq 1} p(|\vec{x}|) dy dz\). See evaluate_1D.

◆ set_average_2D()

template<StatType T>
void NORMALIZED_POLYNOMIAL< T >::set_average_2D ( )
private

For StatType=XY,XZ,XZ, averaged_coefficients is not used since \(\bar{p}(r)\) can be evaluated as a function of \(c_i\). See evaluate_2D.

◆ set_polynomial() [1/2]

template<StatType T>
void NORMALIZED_POLYNOMIAL< T >::set_polynomial ( Mdouble new_coefficients,
unsigned int  num_coeff,
unsigned int  new_dim 
)

Some as set_polynomial, but avoids the use of a vector.

◆ set_polynomial() [2/2]

template<StatType T>
void NORMALIZED_POLYNOMIAL< T >::set_polynomial ( std::vector< Mdouble new_coefficients,
unsigned int  new_dim 
)

Use this function to set the polynomial coefficients \(c_i\). This function calls finish_set_polynomial to normalize the coefficients.

◆ setName()

template<StatType T>
void NORMALIZED_POLYNOMIAL< T >::setName ( const char new_name)
inline

Use this function to change the name of the polynomial.

106  {
107  name = new_name;
108  }

References NORMALIZED_POLYNOMIAL< T >::name.

Referenced by NORMALIZED_POLYNOMIAL< T >::NORMALIZED_POLYNOMIAL().

Friends And Related Function Documentation

◆ operator<<

template<StatType T>
std::ostream& operator<< ( std::ostream &  os,
const NORMALIZED_POLYNOMIAL< T > &  P 
)
friend

Returns a text description of the polynomial.

157  {
158  unsigned int N = P.coefficients.size();
159  for (unsigned int i = 0; i < N; i++)
160  {
161  if (P[i] == 0.0)
162  continue;
163  if (P[i] >= 0)
164  os << "+";
165  os << std::setprecision(2) << P[i];
166  if (N - 1 - i > 1)
167  os << "r^" << N - 1 - i;
168  else if (N - 1 - i == 1)
169  os << "r";
170  }
171  return os;
172  }
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:73

Member Data Documentation

◆ averaged_coefficients

template<StatType T>
std::vector<Mdouble> NORMALIZED_POLYNOMIAL< T >::averaged_coefficients
private

Stores some coefficients used in evaluate and evaluateIntegral for StatTypes different from XYZ.

◆ coefficients

template<StatType T>
std::vector<Mdouble> NORMALIZED_POLYNOMIAL< T >::coefficients
private

◆ dim

template<StatType T>
unsigned int NORMALIZED_POLYNOMIAL< T >::dim
private

The system dimension.

Referenced by NORMALIZED_POLYNOMIAL< T >::NORMALIZED_POLYNOMIAL().

◆ name

template<StatType T>
std::string NORMALIZED_POLYNOMIAL< T >::name
private

Contains the name of the polynomial which will be displayed as CGtype by the statistical code.

Referenced by NORMALIZED_POLYNOMIAL< T >::getName(), and NORMALIZED_POLYNOMIAL< T >::setName().


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