NeoPZ
tpzgaussrule.h
Go to the documentation of this file.
1 
6 #ifndef TPZGAUSSRULE_H
7 #define TPZGAUSSRULE_H
8 
9 #include "pzvec.h"
10 
11 #define PZINTEGRAL_MAXITERATIONS_ALLOWED 100000
12 
19 class TPZGaussRule {
26  int fType;
27 
29  friend class TPZIntRuleP3D;
30 
32  friend class TPZIntRuleList;
33 
35  int fNumInt;
40 
42  long double fAlpha;
44  long double fBeta;
45 
47  int fOrder;
48 
57  TPZGaussRule(int order,int type = 0,long double alpha = 0.0L,long double beta = 0.0L);
58 
59  TPZGaussRule(const TPZGaussRule &copy);
60 
61  TPZGaussRule &operator=(const TPZGaussRule &copy);
62 
64  ~TPZGaussRule();
65 
66 public:
68 
70  int NInt() const{ return fNumInt;}
71 
73  int Type() { return fType; }
74 
76  long double Loc(int i) const;
78  long double W(int i) const;
79 
81  long double Alpha() { return fAlpha; }
83  long double Beta() { return fBeta; }
84 
86  int Order()
87  {
88  return fOrder;
89  }
95  void SetParametersJacobi(long double alpha, long double beta) {
96  fAlpha = alpha; fBeta = beta;
97  }
98 
105  void SetType(int &type,int order);
106 
108  void Print(std::ostream & out = std::cout);
109 
110 protected:
115  int ComputingGaussLegendreQuadrature(int order);
123  void ComputingGaussLegendreQuadrature(int *npoints,TPZVec<long double> &Location,TPZVec<long double> &Weight);
131  int ComputingGaussLobattoQuadrature(int order);
132 // /**
133 // * @brief Computes the points and weights for Gauss Lobatto Quadrature over the parametric 1D element \f$ [-1.0, 1.0] \f$
134 // * It is to integrate functions \f$ f(x) \f$, but one of integration point is \f$-1.0\f$ or \f$1.0\f$
135 // * @param order Order of the polinomial will be integrated exactly with this cubature rule
136 // */
137 // int ComputingGaussRadauQuadrature(int order) {
138 // DebugStop();
139 // }
140 
148  int ComputingGaussJacobiQuadrature(int order,long double alpha,long double beta);
159  void ComputingGaussJacobiQuadrature(int *npoints,long double alpha, long double beta,TPZVec<long double> &Location,TPZVec<long double> &Weight);
160 
172  long double JacobiPolinomial(long double x,int order,long double alpha,long double beta,
173  TPZVec<long double> &b,TPZVec<long double> &c,long double *dp2,long double *p1);
174 
183  long double JacobiPolinomial(long double x,int alpha,int beta,unsigned int n);
184 
190  int ComputingGaussChebyshevQuadrature(int order);
191 
192 };
193 
201 long double machinePrecision();
202 
208 long double gamma(unsigned int n);
209 
216 long double gamma(long double x);
217 
222 #endif
223 
229 // bool CheckCubatureRule();
230 
231 /*bool TPZGaussRule::CheckCubatureRule() {
232  int i;
233  TPZVec<REAL> point(3,0.0L);
234  long double sum = 0.0L;
235 
236  // The cubature rule has not zero integration points
237  if(!fNumInt)
238  return false;
239 
240  // Checking all the integration points belong at the master element
241  for(i=0;i<fNumInt;i++) {
242  point[0] = fLocation[i];
243  if(!pztopology::TPZLine::IsInParametricDomain(point))
244  break;
245  sum += fWeight[i];
246  }
247  // Checking sum of the weights is equal to measure of the master element
248  if(i==fNumInt) {
249  if(IsZero((REAL)(sum) - pztopology::TPZLine::RefElVolume()))
250  return true;
251  }
252  return false; // because any integration point is outside of the master element
253  }*/
long double JacobiPolinomial(long double x, int order, long double alpha, long double beta, TPZVec< long double > &b, TPZVec< long double > &c, long double *dp2, long double *p1)
Evaluates the Jacobi polinomial for real x.
long double Beta()
Returns BETA: it is the exponent of (1-X) in the quadrature rule: .
Definition: tpzgaussrule.h:83
void SetType(int &type, int order)
Sets a gaussian quadrature: 0 - Gauss Legendre, 1 - Gauss Lobatto, 2 - Gauss Jacobi with alpha = beta...
long double W(int i) const
Returns weight for the ith point.
TPZVec< long double > fWeight
Weight of the integration point.
Definition: tpzgaussrule.h:39
Templated vector implementation.
int ComputingGaussLobattoQuadrature(int order)
Computes the points and weights for Gauss Lobatto Quadrature over the parametric 1D element It is to...
Integration rule for pyramid. Numerical Integration.
Definition: tpzintrulep3d.h:17
int fOrder
order of the integration rule
Definition: tpzgaussrule.h:47
int ComputingGaussJacobiQuadrature(int order, long double alpha, long double beta)
Computes the points and weights for Gauss Lobatto Quadrature over the parametric 1D element It is to...
int ComputingGaussChebyshevQuadrature(int order)
Computes the points and weights for Gauss Chebyshev Quadrature over the parametric 1D element [-1...
TPZGaussRule & operator=(const TPZGaussRule &copy)
Creates instances of all integration rules for rapid selection. Numerical Integration.
int fNumInt
Number of integration points for this object.
Definition: tpzgaussrule.h:35
void SetParametersJacobi(long double alpha, long double beta)
Sets alpha and beta, the parameters of the Jacobi polynomials.
Definition: tpzgaussrule.h:95
int NInt() const
Returns number of integration points.
Definition: tpzgaussrule.h:70
long double fBeta
BETA is the exponent of (1+X) in the quadrature rule: weight = (1-X)^ALPHA * (1+X)^BETA.
Definition: tpzgaussrule.h:44
int Type()
Returns the gaussian quadrature type (Legendre, Lobatto, Jacobi)
Definition: tpzgaussrule.h:73
TPZGaussRule(int order, int type=0, long double alpha=0.0L, long double beta=0.0L)
Constructor of quadrature rule.
long double gamma(unsigned int n)
Evaluate the factorial of a integer.
void Print(std::ostream &out=std::cout)
Prints the number of integration points, all points and weights (as one dimension) ...
~TPZGaussRule()
Default destructor.
long double fAlpha
ALPHA is the exponent of (1-X) in the quadrature rule: weight = (1-X)^ALPHA * (1+X)^BETA.
Definition: tpzgaussrule.h:42
TPZVec< long double > fLocation
Location of the integration point.
Definition: tpzgaussrule.h:37
long double machinePrecision()
long double Alpha()
Returns ALPHA: it is the exponent of (1-X) in the quadrature rule: .
Definition: tpzgaussrule.h:81
int fType
fType = 1 (Gauss Lobatto quadrature), fType = 2 (Gauss Jacobi quadrature) for any alpha and beta the ...
Definition: tpzgaussrule.h:26
int Order()
return the order of the integration rule
Definition: tpzgaussrule.h:86
long double Loc(int i) const
Returns location of the ith point.
Implements the Gaussian quadrature. Numerical Integration Abstract class.
Definition: tpzgaussrule.h:19
int ComputingGaussLegendreQuadrature(int order)
Computes the points and weights for Gauss Legendre Quadrature over the parametric 1D element [-1...