NeoPZ
pzshapeextend.h
Go to the documentation of this file.
1 
6 #ifndef SHAPEEXTENDHPP
7 #define SHAPEEXTENDHPP
8 
9 #include "pzfmatrix.h"
10 #include "pzstack.h"
11 #include "pztrnsform.h"
12 
14 namespace pzshape {
15 
21  template<class TFather>
22  class SPr : public TFather {
23 
24  public:
25 
26 
27  typedef typename TFather::TMem FatMem;
28  typedef typename TFather::Top FatTop;
29 
31 
33  class TMem
34  {
36  FatMem fUpper;
38  FatMem fLower;
40  FatMem fExtension;
42  int fExtSideOrders[TFather::Top::NSides];
50  TPZManVector<REAL> fExtShapes[TFather::Top::NSides];
54  int fMaxOrder;
57 
58  };
59 
73  static void Shape(TPZVec<REAL> &pt, TPZVec<int64_t> &id, TPZVec<int> &order, TPZFMatrix<REAL> &phi,TPZFMatrix<REAL> &dphi, TMem &memory);
74  static void SideShape(int side, TPZVec<REAL> &pt, TPZVec<int64_t> &id, TPZVec<int> &order, TPZFMatrix<REAL> &phi,TPZFMatrix<REAL> &dphi);
75 
76 
83  static void ShapeCorner(TPZVec<REAL> &pt, TPZFMatrix<REAL> &phi, TPZFMatrix<REAL> &dphi);
84 
92  static int NSideShapeF(int side, int order);
93 
101  static int NSideShapeF(int side, const TMem &mem);
102 
109  static int NShapeF(TPZVec<int> &order);
123  static void ShapeInternal(TPZVec<REAL> &x, int order,TPZFMatrix<REAL> &phi,
124  TPZFMatrix<REAL> &dphi);//,int quad_transformation_index
125 
126  };
127 
128  template<class TFather>
130  {
131  if(!mem.IsInitialized())
132  {
133  mem.Initialize(id,order);
134  }
135  else if(pt == mem.fpt)
136  {
137  shape = mem.fphi;
138  dshape = mem.fdphi;
139  return;
140  }
141  TPZFNMatrix<100> shapeupper,dshapeupper;
142  TPZFNMatrix<100> shapelower,dshapelower;
143  TPZFNMatrix<100> shapeextend,dshapeextend;
144  // compute (or copy) the shape functions of the upper and lower sides
145  TFather::Shape(pt,shapeupper,dshapeupper,TMem::fUpper);
146  TFather::Shape(pt,shapelower,dshapelower,TMem::fLower);
147  // compute (or copy) the shape function values of the shapefunctions which will be extended
148  TFather::Shape(pt,shapeextend,dshapeextend,TMem::fExtension);
149 
150  REAL ExtendPoint = pt[Top::Dimension-1];
151  TPZFNMatrix<100> shape1d(mem.fMaxOrder,1),dshape1d(1,mem.fMaxOrder);
152  if(ExtendPoint == mem.fExtendPoint)
153  {
154  shape1d = mem.fshape1d;
155  dshape1d = mem.fdshape1d;
156  }
157  else
158  {
159  // compute the onedimensional shapefunctions
160  }
161  // compute the shapefunctions of the lower and upper sides
162  int i,j;
163  int imax0 = shapelower.Rows();
164  REAL fac = (1-ExtendPoint)/2.;
165  for(i=0; i<imax0; i++)
166  {
167  shape(i,0) = shapelower(i,0)*fac;
168  for(j=0; j< Top::Dimension-1; j++)
169  {
170  dshape(j,i) = dshapelower(j,i)*fac;
171  }
172  dshape(j,i) = -shapelower(i,0)/2;
173  }
174  int imax1 = imax0+shapeupper.Rows();
175  fac = (1+ExtendPoint)/2.;
176  for(i=imax0; i<imax1; i++)
177  {
178  shape(i,0) = shapeupper(i-imax0,0)*fac;
179  for(j=0; j< Top::Dimension-1; j++)
180  {
181  dshape(j,i) = dshapelower(j,i-imax0)*fac;
182  }
183  dshape(j,i) = shapelower(i-imax0,0)/2;
184  }
185  // compute the contributions of the extended side shape functions
186 
187  REAL bubble = (1.+ExtendPoint)*(1.-ExtendPoint);
188  // for each side
189  int is;
190  for(is = 0; is < TFather::Top::NSides; is++)
191  {
192  int ishape, ishapebef, ishapeaft, ishapeext;
193  int next = mem.fExtShapes[is].NElements();
194  for(ishape=0; ishape<mem.fNShape[is]; ishape++)
195  {
196  ishapebef = ishape%mem.fNShapeBefore[is];
197  ishapeext = ishape/mem.fNShapeBefore[is];
198  ishapeaft = ishape/(mem.fNShapeBefore[is]*next);
199  int orgind = ishapebef+ishapeaft*mem.fNShapeBefore[is];
200  // this could be lower too
201  shape(index,0) = mem.fExtShapes[is][orgind]*shapelower[ishapeext];
202  }
203  }
204  // project the point to the side
205  // compute the internal shape functions
206  // compute the extended derivatives of the internal shape functions
207  // compute the extension function for the side
208  // multiply both
209  }
210 
211  // Computes the corner shape functions for a hexahedral element
212  template<class TFather>
214  {
216  TPZFNMatrix<TFather::TOP::Dimension*TFather::TOP::NCornerNodes> dphifather(FatTop::Dimension,FatTop::NCornerNodes);
217  TFather::ShapeCorner(pt,phifather,dphifather);
218  phi.Resize(Top::NCornerNodes,1);
220  REAL faclower = -(pt[Top::Dimension-1]-1.)/2.;
221  REAL facupper = (pt[Top::Dimension-1]+1.)/2.;
222  int i;
223  for(i=0; i< FatTop::NCornerNodes; i++)
224  {
225  phi(i,0) = faclower*phifather(i,0);
226  phi(i+FatTop::NCornerNodes,0) = facupper*phifather(i,0);
227  dphi(Top::Dimension-1,i) = -0.5*phifather(i,0);
228  dphi(Top::Dimension-1,i+FatTop::NCornerNodes) = 0.5*phifather(i,0);
229  int j;
230  for(j=0; j<FatTop::Dimension; j++)
231  {
232  dphi(j,i) = faclower*dphifather(j,i);
233  dphi(j,i+FatTop::NCornerNodes) = facupper*dphifather(j,i);
234  }
235  }
236  }
237 
238 };
239 
240 #endif
static int NShapeF(TPZVec< int > &order)
Total number of shapefunctions, considering the order of interpolation of the element.
int fExtSideOrders[TFather::Top::NSides]
Interpolation order of the extension sides.
Definition: pzshapeextend.h:45
int fMaxOrder
Value of maximum order of the extension sides.
Definition: pzshapeextend.h:57
groups all classes dedicated to the computation of shape functions
Definition: pzshapeextend.h:16
FatMem fUpper
Retained values of the upper shape functions.
Definition: pzshapeextend.h:39
TPZManVector< int, TFather::Top::NSides > fNShapeBefore
Number of shape functions before "my" shapefunctions (only for the extension sides) ...
Definition: pzshapeextend.h:49
TPZManVector< int, TFather::Top::NSides > fNShape
Number of shape functions for each extension side.
Definition: pzshapeextend.h:55
Contains TPZMatrixclass which implements full matrix (using column major representation).
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
void Shape(TPZVec< REAL > &pt, TPZVec< int > orders, TPZVec< TPZTransform< REAL > > &transvec, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi)
FatMem fLower
Retained values of the lower shape functions.
Definition: pzshapeextend.h:41
static void SideShape(int side, TPZVec< REAL > &pt, TPZVec< int > &id, TPZVec< int > &order, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi)
A simple stack.
static int NSideShapeF(int side, int order)
Number of shapefunctions of the connect associated with the side, considering the order of interpolat...
TPZManVector< int, TFather::Top::NSides > fNShapeAfter
number of shape functions after "my" shapefunctions (only for the extension sides) ...
Definition: pzshapeextend.h:51
TPZManVector< int, TFather::Top::NSides > fSign
sign of the shape functions (positive or negative)
Definition: pzshapeextend.h:47
static void Shape(TPZVec< REAL > &pt, TPZVec< int > &id, TPZVec< int > &order, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi, TMem &memory)
Computes the values of the shape functions and their derivatives for a hexahedral element...
TPZManVector< REAL > fShape
Values of the last computed shape functions.
Definition: pzshapeextend.h:59
TFather::Top FatTop
Definition: pzshapeextend.h:28
FatMem fExtension
Retained values of the extension shape functions.
Definition: pzshapeextend.h:43
static void ShapeInternal(TPZVec< REAL > &x, int order, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi)
Compute the internal functions of the hexahedral shape function at a point The internal shape functi...
Temporary storage to accelerate the computation of shape functions.
Definition: pzshapeextend.h:36
Defines the Prismatic extension of a topology. Topology.
Definition: PrismExtend.h:25
pztopology::Pr< FatTop > Top
Definition: pzshapeextend.h:30
TFather::TMem FatMem
Definition: pzshapeextend.h:27
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
Definition: pzfmatrix.cpp:1016
Contains the TPZTransform<> class which implements an affine transformation between points in paramet...
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
static void ShapeCorner(TPZVec< REAL > &pt, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi)
Computes the corner shape functions for a hexahedral element.
TPZManVector< REAL > fExtShapes[TFather::Top::NSides]
Values of the shape functions associated with the extension sides.
Definition: pzshapeextend.h:53
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716