NeoPZ
tpzintrulep3d.cpp
Go to the documentation of this file.
1 
6 #include <cmath>
7 
8 #include "tpzintrulep3d.h"
9 #include "pzerror.h"
10 #include "pzvec.h"
11 #include "tpzgaussrule.h"
12 
13 #include <fstream>
14 
15 using namespace std;
16 
18  if(order < 0)
19  {
20  order = 1;
21  }
22 // if (order > NRULESPYRAMID_ORDER){
23 // PZError << "TPZGaussRule creation precision = " << order << " not available\n";
24 // order = NRULESPYRAMID_ORDER;
25 // }
26  // Computing integration points and weights to cubature rule for pyramid
27  fOrder = ComputingCubatureRuleForPyramid(order);
28 }
29 
31  fLocationKsi.Resize(0);
32  fLocationEta.Resize(0);
33  fLocationZeta.Resize(0);
34  fWeight.Resize(0);
35  fNumInt = 0;
36 }
37 
38 void TPZIntRuleP3D::Loc(int i, TPZVec<REAL> &Points) const {
39  if (i>=0 && i<fNumInt){
40  Points[0] = fLocationKsi[i];
41  Points[1] = fLocationEta[i];
42  Points[2] = fLocationZeta[i];
43  return;
44  }
45  else {
46  PZError << "ERROR(TPZIntRuleP3D::loc) Out of bounds!!\n";
47  }
48 }
49 
50 REAL TPZIntRuleP3D::W(int i) const {
51  if(i>=0 && i<fNumInt)
52  return fWeight[i];
53  else {
54  PZError << "ERROR(TPZIntRuleP3D::w) Out of bounds!!\n";
55  return 0.0;
56  }
57 }
58 
59 
61 long double TransformM1AndP1ToZeroP1(long double ksi) {
62  return 0.5L * (ksi + 1.0L);
63 }
65 long double TransformM1AndP1ToM1PZAndP1MZ(long double zeta,long double ksi) {
66  return ((1.0L - zeta)*ksi);
67 }
73  int i, j, k, l;
74 
75  // Cleaning the vectors
76  fWeight.Resize(0);
77  fLocationKsi.Resize(0);
78  fLocationEta.Resize(0);
79  fLocationZeta.Resize(0);
80 
81  long double wi, wj, wk, xi, xj, xk;
82  long double volume;
83 
84  TPZVec<long double> leg_w;
85  TPZVec<long double> leg_x;
86  TPZVec<long double> jacobi_w;
87  TPZVec<long double> jacobi_x;
88 
89  // Determining the number of points needed for order
90  int plane_order = (int)(0.51*(order+2));
91  int zeta_order = plane_order + 1;
92  fNumInt = plane_order * plane_order * zeta_order;
93 
94  fWeight.Resize(fNumInt,0.0L);
95  fLocationKsi.Resize(fNumInt,0.0L);
96  fLocationEta.Resize(fNumInt,0.0L);
97  fLocationZeta.Resize(fNumInt,0.0L);
98 
101  leg_w.Resize(plane_order,0.0L);
102  leg_x.Resize(plane_order,0.0L);
103  TPZGaussRule intrule(2);
104  intrule.ComputingGaussLegendreQuadrature(&plane_order,leg_x,leg_w);
105 
107  jacobi_w.Resize(zeta_order,0.0L);
108  jacobi_x.Resize(zeta_order,0.0L);
109  intrule.ComputingGaussJacobiQuadrature(&zeta_order,2.0L,0.0L,jacobi_x,jacobi_w);
110 
111  //volume = pztopology::TPZPyramid::RefElVolume();
112  volume = 4.0L/3.0L;
113 
114  l = 0;
115  for(k=0;k<zeta_order;k++) {
116  xk = (jacobi_x[k] + 1.0L) / 2.0L;
117  wk = jacobi_w[k] / 2.0L;
118  for(j=0;j<plane_order;j++) {
119  xj = leg_x[j];
120  wj = leg_w[j];
121  for ( i = 0; i < plane_order; i++ )
122  {
123  xi = leg_x[i];
124  wi = leg_w[i];
125  fWeight[l] = wi * wj * wk / 4.0L / volume;
126  fLocationKsi[l] = xi * ( 1.0L - xk );
127  fLocationEta[l] = xj * ( 1.0L - xk );
128  fLocationZeta[l] = xk;
129  l = l + 1;
130  }
131  }
132  }
134  for(k=0;k<fNumInt;k++)
135  {
136  fWeight[k] *= volume;
137  }
138  return order;
139 }
140 
141 void TPZIntRuleP3D::Print(std::ostream &out) {
142  int i;
143  out << "\nQuadrature For Pyramid - " << " \tNumber of points : " << fNumInt << std::endl;
144  for(i=0;i<fNumInt;i++) {
145  out << i << " : \t" << fLocationKsi[i] << " \t" << fLocationEta[i] << " \t" << fLocationZeta[i] << " \t" << fWeight[i] << std::endl;
146  }
147  out << std::endl;
148 }
TPZIntRuleP3D(int &order)
Constructor of cubature rule for pyramid.
Templated vector implementation.
Defines PZError.
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...
long double TransformM1AndP1ToM1PZAndP1MZ(long double zeta, long double ksi)
Auxiliar function to compute the linear transformation from [-1,1] to [-(1-z),(1-z)] ; Tz(ksi) = (1-z...
long double TransformM1AndP1ToZeroP1(long double ksi)
Auxiliar function to compute the linear transformation [-1,1] into [0,1] : T(ksi) = 1/2 * ksi + 1/2...
void Print(std::ostream &out=std::cout)
Prints the number of integration points, all points and weights (as one dimension) ...
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
Definition: pzvec.h:373
Contains the TPZIntRuleP3D class which defines the integration rule for pyramid.
REAL W(int i) const
Returns weight for the ith point.
int ComputingCubatureRuleForPyramid(int order)
Computes the points and weights for pyramid cubature rule as first version of PZ. ...
~TPZIntRuleP3D()
Default destructor.
Contains the TPZGaussRule class which implements the Gaussian quadrature.
void Loc(int i, TPZVec< REAL > &pos) 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...
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15