NeoPZ
pzgeopyramid.h
Go to the documentation of this file.
1 
6 #ifndef TPZGEOTETRAPIRAMIDH
7 #define TPZGEOTETRAPIRAMIDH
8 
9 #include "pznoderep.h"
10 #include "pzvec.h"
11 #include "pzeltype.h"
12 #include "tpzpyramid.h"
13 #include "pzfmatrix.h"
14 
15 class TPZGeoEl;
16 class TPZGeoMesh;
17 
18 namespace pzgeom {
19 
24  class TPZGeoPyramid : public TPZNodeRep<5, pztopology::TPZPyramid>
25  {
26  public:
29  enum {NNodes = 5};
30 
31  int ClassId() const override;
32  void Read(TPZStream &buf, void *context) override;
33  void Write(TPZStream &buf, int withclassid) const override;
34 
35 
38  TPZNodeRep<NNodes, pztopology::TPZPyramid>(nodeindexes)
39  {
40  }
41 
45  {
46  }
47 
50  std::map<int64_t,int64_t> & gl2lcNdMap) : TPZRegisterClassId(&TPZGeoPyramid::ClassId),
51  TPZNodeRep<NNodes, pztopology::TPZPyramid>(cp,gl2lcNdMap)
52  {
53  }
54 
58  {
59  }
60 
64  {
65  }
66 
67  static bool IsLinearMapping(int side)
68  {
69  return true;
70  }
71 
73  static std::string TypeName() { return "Pyramid";}
74 
75 
76 
78  static void Jacobian(const TPZFMatrix<REAL> & coord, TPZVec<REAL>& par, TPZFMatrix<REAL> &jacobian, TPZFMatrix<REAL> &axes, REAL &detjac, TPZFMatrix<REAL> &jacinv);
79 
81  template<class T>
82  static void X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &x);
83 
85  template<class T>
86  static void GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx);
87 
88 
89 
90 
91  public:
92 
94  /* @param gmesh mesh in which the element should be inserted
95  @param matid material id of the element
96  @param lowercorner (in/out) on input lower corner o the cube where the element should be created, on exit position of the next cube
97  @param size (in) size of space where the element should be created
98  */
99  static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size);
100 
102  // static TPZGeoEl *CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
103  // TPZVec<int64_t>& nodeindexes,
104  // int matid,
105  // int64_t& index);
106  };
107 
108 
109  template<class T>
110  inline void TPZGeoPyramid::X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &x){
111 
112  TPZFNMatrix<5,T> phi(5,1);
113  TPZFNMatrix<15,T> dphi(3,5);
114  TShape(loc,phi,dphi);
115  int space = nodes.Rows();
116 
117  for(int i = 0; i < space; i++) {
118  x[i] = 0.0;
119  for(int j = 0; j < 5; j++) {
120  x[i] += phi(j,0)*nodes.GetVal(i,j);
121  }
122  }
123  }
124 
125 
126  template<class T>
127  inline void TPZGeoPyramid::GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx){
128 
129  gradx.Resize(3,3);
130  gradx.Zero();
131  int nrow = nodes.Rows();
132  int ncol = nodes.Cols();
133 #ifdef PZDEBUG
134  if(nrow != 3 || ncol != 5){
135  std::cout << "Objects of incompatible lengths, gradient cannot be computed." << std::endl;
136  std::cout << "nodes matrix must be 3x5." << std::endl;
137  DebugStop();
138  }
139 
140 #endif
141  TPZFNMatrix<5,T> phi(5,1);
142  TPZFNMatrix<15,T> dphi(3,5);
143  TShape(loc,phi,dphi);
144  for(int i = 0; i < 5; i++)
145  {
146  for(int j = 0; j < 3; j++)
147  {
148  gradx(j,0) += nodes.GetVal(j,i)*dphi(0,i);
149  gradx(j,1) += nodes.GetVal(j,i)*dphi(1,i);
150  gradx(j,2) += nodes.GetVal(j,i)*dphi(2,i);
151  }
152  }
153 
154  }
155 
156 };
157 
158 #endif
Defines the topology of a Pyramid element. Topology Sides 0 to 4 are vertices, sides 5 to 12 are line...
Definition: tpzpyramid.h:35
TPZPyramid()
Default constructor.
Definition: tpzpyramid.h:46
int ClassId() const override
Define the class id associated with the class.
Templated vector implementation.
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Defines enum MElementType and contains the implementation of MElementType_NNodes(...) functions.
TPZGeoPyramid(const TPZGeoPyramid &cp)
Copy constructor.
Definition: pzgeopyramid.h:56
pztopology::TPZPyramid Top
Definition: pzgeopyramid.h:27
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
static void X(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZVec< T > &x)
Computes the geometric location.
Definition: pzgeopyramid.h:110
static void GradX(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZFMatrix< T > &gradx)
Compute gradient of x mapping from element nodes and local parametric coordinates.
Definition: pzgeopyramid.h:127
Groups all classes defining the structure of the master element.
Definition: PrismExtend.cpp:15
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
TPZGeoPyramid(const TPZGeoPyramid &cp, TPZGeoMesh &)
Copy constructor.
Definition: pzgeopyramid.h:62
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
Contains the TPZNodeRep class which implements ... Clase intermediaria que guarda.
Implements ... Geometry Topology.
Definition: pznoderep.h:40
Implements the geometry of pyramid element. Geometry.
Definition: pzgeopyramid.h:24
Contains the TPZPyramid class which defines the topology of a pyramid element.
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)
create an example element based on the topology
static std::string TypeName()
Returns the type name of the element.
Definition: pzgeopyramid.h:73
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
static bool IsLinearMapping(int side)
Definition: pzgeopyramid.h:67
static void TShape(const TPZVec< T > &loc, TPZFMatrix< T > &phi, TPZFMatrix< T > &dphi)
Compute the shape being used to construct the x mapping from local parametric coordinates.
Definition: tpzpyramid.cpp:302
TPZGeoPyramid(const TPZGeoPyramid &cp, std::map< int64_t, int64_t > &gl2lcNdMap)
Constructor with node map.
Definition: pzgeopyramid.h:49
static void Jacobian(const TPZFMatrix< REAL > &coord, TPZVec< REAL > &par, TPZFMatrix< REAL > &jacobian, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv)
Computes the jacobian.
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
Definition: pzfmatrix.cpp:1016
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
void Read(TPZStream &buf, void *context) override
read objects from the stream
const TVar & GetVal(const int64_t row, const int64_t col) const override
Get values without bounds checking This method is faster than "Get" if DEBUG is defined.
Definition: pzfmatrix.h:566
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716
TPZGeoPyramid(TPZVec< int64_t > &nodeindexes)
Constructor with list of nodes.
Definition: pzgeopyramid.h:37
TPZGeoPyramid()
Empty constructor.
Definition: pzgeopyramid.h:43