NeoPZ
pzgeotetrahedra.h
Go to the documentation of this file.
1 
6 #ifndef TPZGEOTETRAHEDRAH
7 #define TPZGEOTETRAHEDRAH
8 
9 #include "pznoderep.h"
10 #include "pzvec.h"
11 #include "pzeltype.h"
12 #include "tpztetrahedron.h"
13 #include "pzfmatrix.h"
14 
15 #include <string>
16 
17 class TPZGeoEl;
18 class TPZGeoMesh;
19 
20 namespace pzgeom {
21 
26  class TPZGeoTetrahedra : public TPZNodeRep<4,pztopology::TPZTetrahedron>
27  {
28  public:
31  enum {NNodes = 4};
32 
33  int ClassId() const override;
34 
35  void Read(TPZStream &buf, void *context) override;
36 
37  void Write(TPZStream &buf, int withclassid) const override;
38 
39 
43  {
44  }
45 
49  {
50  }
51 
54  std::map<int64_t,int64_t> & gl2lcNdMap) : TPZRegisterClassId(&TPZGeoTetrahedra::ClassId),
56  {
57  }
58 
62  {
63  }
64 
68  {
69  }
70 
71  static bool IsLinearMapping(int side)
72  {
73  return true;
74  }
75 
77  static std::string TypeName() { return "Tetrahedron";}
78 
80  template<class T>
81  static void X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &x);
82 
84  template<class T>
85  static void GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx);
86 
87  public:
88 
90  /* @param gmesh mesh in which the element should be inserted
91  @param matid material id of the element
92  @param lowercorner (in/out) on input lower corner o the cube where the element should be created, on exit position of the next cube
93  @param size (in) size of space where the element should be created
94  */
95  static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size);
96 
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 TPZGeoTetrahedra::X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &x){
108 
109  TPZFNMatrix<4,T> phi(NNodes,1);
110  TPZFNMatrix<12,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 TPZGeoTetrahedra::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 != 4){
132  std::cout << "Objects of incompatible lengths, gradient cannot be computed." << std::endl;
133  std::cout << "nodes matrix must be 3x4." << 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 < 4; 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
TPZGeoTetrahedra(const TPZGeoTetrahedra &cp, TPZGeoMesh &)
Copy constructor.
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Templated vector implementation.
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.
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)
create an example element based on the topology
Defines enum MElementType and contains the implementation of MElementType_NNodes(...) functions.
int ClassId() const override
Define the class id associated with the class.
void Read(TPZStream &buf, void *context) override
read objects from the stream
TPZGeoTetrahedra(const TPZGeoTetrahedra &cp, std::map< int64_t, int64_t > &gl2lcNdMap)
Constructor with node map.
Contains the TPZTetrahedron class which defines the topology of the tetrahedron element.
static std::string TypeName()
Returns the type name of the element.
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.
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
Groups all classes defining the structure of the master element.
Definition: PrismExtend.cpp:15
static bool IsLinearMapping(int side)
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
TPZGeoTetrahedra(TPZVec< int64_t > &nodeindexes)
Constructor with list of nodes.
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.
pztopology::TPZTetrahedron Top
Implements ... Geometry Topology.
Definition: pznoderep.h:40
static void X(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZVec< T > &x)
Compute x mapping from element nodes and local parametric coordinates.
Implements the geometry of a tetrahedral element. Geometry.
Defines the topology of the tetrahedron element. Topology Sides 0 to 3 are vertices, sides 4 to 9 are lines, sides 10 to 13 are triangles and side 14 is the tetrahedra.
TPZGeoTetrahedra(const TPZGeoTetrahedra &cp)
Copy constructor.
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
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
TPZGeoTetrahedra()
Empty constructor.
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
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
TPZTetrahedron()
Default constructor.
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716