NeoPZ
TPZGeoCube.h
Go to the documentation of this file.
1 
5 // $Id: TPZGeoCube.h,v 1.12 2011-05-11 01:38:40 phil Exp $
6 
7 #ifndef TPZGEOCUBEH
8 #define TPZGEOCUBEH
9 
10 
11 #include "pzvec.h"
12 #include "pzeltype.h"
13 #include "pznoderep.h"
14 #include "tpzcube.h"
15 #include "pzfmatrix.h"
16 
17 #include <string>
18 
19 class TPZGeoEl;
20 class TPZGeoMesh;
21 
22 namespace pzgeom {
23 
28  class TPZGeoCube : public TPZNodeRep<8, pztopology::TPZCube> {
29 
30  public:
33  enum {NNodes = 8};
34 
37  {
38  }
39 
42  {
43  }
44 
47  std::map<int64_t,int64_t> & gl2lcNdMap) : TPZRegisterClassId(&TPZGeoCube::ClassId),
48  TPZNodeRep<NNodes, pztopology::TPZCube>(cp,gl2lcNdMap)
49  {
50  }
51 
55  {
56  }
57 
61  {
62  }
63 
64  static bool IsLinearMapping(int side)
65  {
66  return true;
67  }
68 
70  static std::string TypeName() { return "Hexahedron";}
71 
73  template<class T>
74  static void X(const TPZFMatrix<REAL> &nodecoordinates,TPZVec<T> &loc,TPZVec<T> &x);
75 
77  template<class T>
78  static void GradX(const TPZFMatrix<REAL> &nodecoordinates,TPZVec<T> &loc, TPZFMatrix<T> &gradx);
79 
80 
81 
82 
84  /* @param gmesh mesh in which the element should be inserted
85  @param matid material id of the element
86  @param lowercorner (in/out) on input lower corner o the cube where the element should be created, on exit position of the next cube
87  @param size (in) size of space where the element should be created
88  */
89  static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size);
90 
91  public:
92 int ClassId() const override;
93  void Read(TPZStream &buf, void *context) override;
94  void Write(TPZStream &buf, int withclassid) const override;
95 
96  public:
98  // static TPZGeoEl *CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
99  // TPZVec<int64_t>& nodeindexes,
100  // int matid,
101  // int64_t& index);
102 
103  };
104 
105 
106  template<class T>
107  inline void TPZGeoCube::X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &x){
108 
109  TPZFNMatrix<8,T> phi(NNodes,1);
110  TPZFNMatrix<24,T> dphi(3,NNodes);
111  TShape(loc,phi,dphi);
112  int space = nodes.Rows();
113 
114  for(int i = 0; i < space; i++) {
115  x[i] = 0.0;
116  for(int j = 0; j < NNodes; j++) {
117  x[i] += phi(j,0)*nodes.GetVal(i,j);
118  }
119  }
120  }
121 
122 
123  template<class T>
124  inline void TPZGeoCube::GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx){
125 
126  gradx.Resize(3,3);
127  gradx.Zero();
128  int nrow = nodes.Rows();
129  int ncol = nodes.Cols();
130 #ifdef PZDEBUG
131  if(nrow != 3 || ncol != 8){
132  std::cout << "Objects of incompatible lengths, gradient cannot be computed." << std::endl;
133  std::cout << "nodes matrix must be 3x8." << std::endl;
134  DebugStop();
135  }
136 
137 #endif
138  TPZFNMatrix<4,T> phi(NNodes,1);
139  TPZFNMatrix<12,T> dphi(3,NNodes);
140  TShape(loc,phi,dphi);
141  for(int i = 0; i < NNodes; i++)
142  {
143  for(int j = 0; j < 3; j++)
144  {
145  gradx(j,0) += nodes.GetVal(j,i)*dphi(0,i);
146  gradx(j,1) += nodes.GetVal(j,i)*dphi(1,i);
147  gradx(j,2) += nodes.GetVal(j,i)*dphi(2,i);
148  }
149  }
150 
151  }
152 
153 };
154 
155 #endif
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: TPZGeoCube.cpp:63
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)
create an example element based on the topology
Definition: TPZGeoCube.cpp:32
static std::string TypeName()
Returns the type name of the element.
Definition: TPZGeoCube.h:70
TPZGeoCube(TPZVec< int64_t > &nodeindexes)
Constructor with list of nodes.
Definition: TPZGeoCube.h:36
Templated vector implementation.
TPZGeoCube()
Empty constructor.
Definition: TPZGeoCube.h:41
TPZGeoCube(const TPZGeoCube &cp, std::map< int64_t, int64_t > &gl2lcNdMap)
Constructor with node map.
Definition: TPZGeoCube.h:46
TPZGeoCube(const TPZGeoCube &cp, TPZGeoMesh &)
Copy constructor.
Definition: TPZGeoCube.h:59
Defines enum MElementType and contains the implementation of MElementType_NNodes(...) functions.
static bool IsLinearMapping(int side)
Definition: TPZGeoCube.h:64
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
Defines the topology of the hexahedron element. Topology Sides 0 to 7 are vertices, sides 8 to 19 are lines, 20 to 25 are quadrilaterals and side 26 is the hexahedra (cube).
Definition: tpzcube.h:38
Groups all classes defining the structure of the master element.
Definition: PrismExtend.cpp:15
TPZCube()
Default constructor.
Definition: tpzcube.h:49
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
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
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: tpzcube.cpp:429
int ClassId() const override
Define the class id associated with the class.
Definition: TPZGeoCube.cpp:55
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: TPZGeoCube.cpp:59
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
static void X(const TPZFMatrix< REAL > &nodecoordinates, TPZVec< T > &loc, TPZVec< T > &x)
Compute x mapping from element nodes and local parametric coordinates.
Definition: TPZGeoCube.h:107
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
Contains the TPZCube class which defines the topology of the hexahedron element.
pztopology::TPZCube Top
Definition: TPZGeoCube.h:31
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
Implements the geometry of hexahedra element. Geometry.
Definition: TPZGeoCube.h:28
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
TPZGeoCube(const TPZGeoCube &cp)
Copy constructor.
Definition: TPZGeoCube.h:53
static void GradX(const TPZFMatrix< REAL > &nodecoordinates, TPZVec< T > &loc, TPZFMatrix< T > &gradx)
Compute gradient of x mapping from element nodes and local parametric coordinates.
Definition: TPZGeoCube.h:124
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716