NeoPZ
pzshapeextend.h
Go to the documentation of this file.
1 
5 // $Id: pzshapeextend.h,v 1.1 2008-10-08 02:44:18 phil Exp $
6 #ifndef SHAPEEXTENDHPP
7 #define SHAPEEXTENDHPP
8 
9 #include "pzfmatrix.h"
10 #include "pzstack.h"
11 #include "pztrnsform.h"
12 //#include "pzgeoelside.h"
13 
14 
16 namespace pzshape {
17 
25  template<class TFather>
26  class SPr : public TFather {
27 
28  public:
29 
30  typedef typename TFather::TMem FatMem;
31  typedef typename TFather::Top FatTop;
32 
34 
36  class TMem
37  {
39  FatMem fUpper;
41  FatMem fLower;
43  FatMem fExtension;
45  int fExtSideOrders[TFather::Top::NSides];
53  TPZManVector<REAL> fExtShapes[TFather::Top::NSides];
57  int fMaxOrder;
60 
61  };
62 
76  static void Shape(TPZVec<REAL> &pt, TPZVec<int> &id, TPZVec<int> &order, TPZFMatrix<REAL> &phi,TPZFMatrix<REAL> &dphi, TMem &memory);
77  static void SideShape(int side, TPZVec<REAL> &pt, TPZVec<int> &id, TPZVec<int> &order, TPZFMatrix<REAL> &phi,TPZFMatrix<REAL> &dphi);
78 
79 
86  static void ShapeCorner(TPZVec<REAL> &pt, TPZFMatrix<REAL> &phi, TPZFMatrix<REAL> &dphi);
87 
95  static int NSideShapeF(int side, int order);
96 
103  //static int NShapeF(TPZVec<int> &order);
104 
112  static int NSideShapeF(int side, const TMem &mem);
113 
120  static int NShapeF(TPZVec<int> &order);
134  static void ShapeInternal(TPZVec<REAL> &x, int order,TPZFMatrix<REAL> &phi,
135  TPZFMatrix<REAL> &dphi);//,int quad_transformation_index
136 
137 
138  };
139 
140  template<class TFather>
142  {
143  if(!mem.IsInitialized())
144  {
145  mem.Initialize(id,order);
146  }
147  else if(pt == mem.fpt)
148  {
149  shape = mem.fphi;
150  dshape = mem.fdphi;
151  return;
152  }
153  TPZFNMatrix<100> shapeupper,dshapeupper;
154  TPZFNMatrix<100> shapelower,dshapelower;
155  TPZFNMatrix<100> shapeextend,dshapeextend;
156  // compute (or copy) the shape functions of the upper and lower sides
157  TFather::Shape(pt,shapeupper,dshapeupper,TMem::fUpper);
158  TFather::Shape(pt,shapelower,dshapelower,TMem::fLower);
159  // compute (or copy) the shape function values of the shapefunctions which will be extended
160  TFather::Shape(pt,shapeextend,dshapeextend,TMem::fExtension);
161 
162  REAL ExtendPoint = pt[Top::Dimension-1];
163  TPZFNMatrix<100> shape1d(mem.fMaxOrder,1),dshape1d(1,mem.fMaxOrder);
164  if(ExtendPoint == mem.fExtendPoint)
165  {
166  shape1d = mem.fshape1d;
167  dshape1d = mem.fdshape1d;
168  }
169  else
170  {
171  // compute the onedimensional shapefunctions
172  }
173  // compute the shapefunctions of the lower and upper sides
174  int i,j;
175  int imax0 = shapelower.Rows();
176  REAL fac = (1-ExtendPoint)/2.;
177  for(i=0; i<imax0; i++)
178  {
179  shape(i,0) = shapelower(i,0)*fac;
180  for(j=0; j< Top::Dimension-1; j++)
181  {
182  dshape(j,i) = dshapelower(j,i)*fac;
183  }
184  dshape(j,i) = -shapelower(i,0)/2;
185  }
186  int imax1 = imax0+shapeupper.Rows();
187  fac = (1+ExtendPoint)/2.;
188  for(i=imax0; i<imax1; i++)
189  {
190  shape(i,0) = shapeupper(i-imax0,0)*fac;
191  for(j=0; j< Top::Dimension-1; j++)
192  {
193  dshape(j,i) = dshapelower(j,i-imax0)*fac;
194  }
195  dshape(j,i) = shapelower(i-imax0,0)/2;
196  }
197  // compute the contributions of the extended side shape functions
198 
199 // REAL bubble = (1.+ExtendPoint)*(1.-ExtendPoint);
200  // for each side
201  int is;
202  for(is = 0; is < TFather::Top::NSides; is++)
203  {
204  int ishape, ishapebef, ishapeaft, ishapeext;
205  int next = mem.fExtShapes[is].NElements();
206  for(ishape=0; ishape<mem.fNShape[is]; ishape++)
207  {
208  ishapebef = ishape%mem.fNShapeBefore[is];
209  ishapeext = ishape/mem.fNShapeBefore[is];
210  ishapeaft = ishape/(mem.fNShapeBefore[is]*next);
211  int orgind = ishapebef+ishapeaft*mem.fNShapeBefore[is];
212  // this could be lower too
213  shape(ishape,0) = mem.fExtShapes[is][orgind]*shapelower[ishapeext];
214  }
215  }
216  // project the point to the side
217  // compute the internal shape functions
218  // compute the extended derivatives of the internal shape functions
219  // compute the extension function for the side
220  // multiply both
221  }
222 
229  template<class TFather>
231  {
233  TPZFNMatrix<TFather::TOP::Dimension*TFather::TOP::NCornerNodes> dphifather(FatTop::Dimension,FatTop::NCornerNodes);
234  TFather::ShapeCorner(pt,phifather,dphifather);
235  phi.Resize(Top::NCornerNodes,1);
237  REAL faclower = -(pt[Top::Dimension-1]-1.)/2.;
238  REAL facupper = (pt[Top::Dimension-1]+1.)/2.;
239  int i;
240  for(i=0; i< FatTop::NCornerNodes; i++)
241  {
242  phi(i,0) = faclower*phifather(i,0);
243  phi(i+FatTop::NCornerNodes,0) = facupper*phifather(i,0);
244  dphi(Top::Dimension-1,i) = -0.5*phifather(i,0);
245  dphi(Top::Dimension-1,i+FatTop::NCornerNodes) = 0.5*phifather(i,0);
246  int j;
247  for(j=0; j<FatTop::Dimension; j++)
248  {
249  dphi(j,i) = faclower*dphifather(j,i);
250  dphi(j,i+FatTop::NCornerNodes) = facupper*dphifather(j,i);
251  }
252  }
253  }
254 
255 };
256 
257 #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
Implements the shape functions of a hexahedral (3D) element. Shape.
Definition: pzshapeextend.h:26
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:31
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:33
TFather::TMem FatMem
Definition: pzshapeextend.h:30
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