NeoPZ
pzgeotriangle.h
Go to the documentation of this file.
1 
6 #ifndef TPZGEOTRIANGLEH
7 #define TPZGEOTRIANGLEH
8 
9 #include "pzvec.h"
10 #include "pzeltype.h"
11 #include "pznoderep.h"
12 #include "tpztriangle.h"
13 #include "pzfmatrix.h"
14 
15 #include <string>
16 #include <map>
17 
18 class TPZGeoEl;
19 class TPZGeoMesh;
20 
21 
22 namespace pzgeom {
23 
28  class TPZGeoTriangle : public TPZNodeRep<3, pztopology::TPZTriangle>
29  {
30  public:
33  enum {NNodes = 3};
34 
38  {
39  }
40 
44  {
45  }
46 
49  std::map<int64_t,int64_t> & gl2lcNdMap) : TPZRegisterClassId(&TPZGeoTriangle::ClassId),
50  TPZNodeRep<NNodes,pztopology::TPZTriangle>(cp,gl2lcNdMap)
51  {
52  }
53 
57  {
58  }
59 
63  {
64  }
65 
66 
67  void Jacobian(const TPZFMatrix<REAL> & coord, TPZVec<REAL> &param,TPZFMatrix<REAL> &jacobian,TPZFMatrix<REAL> &axes,REAL &detjac,TPZFMatrix<REAL> &jacinv);
68 
69  static bool IsLinearMapping(int side)
70  {
71  return true;
72  }
73 
75  static std::string TypeName() { return "Triangle";}
76 
77 
78  template<class T>
79  static void X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &x) {
80 
81  TPZFNMatrix<3,T> phi(3,1);
82  TPZFNMatrix<6,T> dphi(2,3);
83  TShape(loc,phi,dphi);
84  int space = nodes.Rows();
85 
86  for(int i = 0; i < space; i++) {
87  x[i] = 0.0;
88  for(int j = 0; j < 3; j++) {
89  x[i] += phi(j,0)*nodes.GetVal(i,j);
90  }
91  }
92  }
93 
94 
96  template<class T>
97  static void GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx);
98 
99 
100 // /** @brief Compute the jacoabina associated to the x mapping from local parametric coordinates */
101 // static void Jacobian(const TPZFMatrix<REAL> &nodes,TPZVec<REAL> &param,TPZFMatrix<REAL> &jacobian,
102 // TPZFMatrix<REAL> &axes,REAL &detjac,TPZFMatrix<REAL> &jacinv);
103 
104  // /**
105  // * @brief Method which creates a geometric boundary condition
106  // * element based on the current geometric element, \n
107  // * a side and a boundary condition number
108  // */
109  // static TPZGeoEl * CreateBCGeoEl(TPZGeoEl *orig,int side,int bc);
110 
112  static void ComputeNormal(TPZVec<REAL> &p1, TPZVec<REAL> &p2,TPZVec<REAL> &p3,TPZVec<REAL> &result);
113 
114  static void VectorialProduct(TPZVec<REAL> &v1, TPZVec<REAL> &v2,TPZVec<REAL> &result);
115 
116 // static void VecHdiv(TPZFMatrix<REAL> & coord, TPZFMatrix<REAL> & fNormalVec,TPZVec<int> &sidevector);
117 
118  /* brief compute the vectors for defining an HDiv approximation space */
119 // void VecHdiv(const TPZGeoEl &gel,TPZFMatrix<REAL> &NormalVec,TPZVec<int> & VectorSide) const
120 // {
121 // TPZFNMatrix<3*NNodes> coord(3,NNodes);
122 // CornerCoordinates(gel, coord);
123 // VecHdiv(coord,NormalVec,VectorSide);
124 // }
125 
126  public:
127  int ClassId() const override;
128  void Read(TPZStream &buf, void *context) override;
129  void Write(TPZStream &buf, int withclassid) const override;
130 
131 
132  public:
133 
135  /* @param gmesh mesh in which the element should be inserted
136  @param matid material id of the element
137  @param lowercorner (in/out) on input lower corner o the cube where the element should be created, on exit position of the next cube
138  @param size (in) size of space where the element should be created
139  */
140  static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size);
141 
143  // static TPZGeoEl *CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
144  // TPZVec<int64_t>& nodeindexes, int matid, int64_t& index);
145 
146  };
147 
148 
149  template<class T>
150  inline void TPZGeoTriangle::GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx){
151 
152  int space = nodes.Rows();
153  int ncol = nodes.Cols();
154 
155  gradx.Resize(space,2);
156  gradx.Zero();
157 
158 #ifdef PZDEBUG
159  if(/* nrow != 3 || */ ncol != 3){
160  std::cout << "Objects of incompatible lengths, gradient cannot be computed." << std::endl;
161  std::cout << "nodes matrix must be 3x3." << std::endl;
162  DebugStop();
163  }
164 
165 #endif
166  TPZFNMatrix<3,T> phi(NNodes,1);
167  TPZFNMatrix<6,T> dphi(2,NNodes);
168  TShape(loc,phi,dphi);
169  for(int i = 0; i < 3; i++)
170  {
171  for(int j = 0; j < space; j++)
172  {
173  gradx(j,0) += nodes.GetVal(j,i)*dphi(0,i);
174  gradx(j,1) += nodes.GetVal(j,i)*dphi(1,i);
175 
176  }
177  }
178 
179  }
180 
181 };
182 
183 #endif
void Read(TPZStream &buf, void *context) override
read objects from the stream
static void VectorialProduct(TPZVec< REAL > &v1, TPZVec< REAL > &v2, TPZVec< REAL > &result)
TPZGeoTriangle()
Empty constructor.
Definition: pzgeotriangle.h:42
static void X(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZVec< T > &x)
Definition: pzgeotriangle.h:79
static bool IsLinearMapping(int side)
Definition: pzgeotriangle.h:69
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: tpztriangle.cpp:27
Templated vector implementation.
Defines the topology of a triangle element. Topology Sides 0 to 2 are vertices, sides 3 to 5 are line...
Definition: tpztriangle.h:35
int ClassId() const override
Define the class id associated with the class.
pztopology::TPZTriangle Top
Definition: pzgeotriangle.h:31
void Jacobian(const TPZFMatrix< REAL > &coord, TPZVec< REAL > &param, TPZFMatrix< REAL > &jacobian, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv)
TPZTriangle()
Default constructor.
Definition: tpztriangle.h:46
TPZGeoTriangle(const TPZGeoTriangle &cp, std::map< int64_t, int64_t > &gl2lcNdMap)
Constructor with node map.
Definition: pzgeotriangle.h:48
Defines enum MElementType and contains the implementation of MElementType_NNodes(...) functions.
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: pzgeotriangle.h:75
Contains the TPZTriangle class which defines the topology of a triangle.
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 void ComputeNormal(TPZVec< REAL > &p1, TPZVec< REAL > &p2, TPZVec< REAL > &p3, TPZVec< REAL > &result)
Compute the jacoabina associated to the x mapping from local parametric coordinates.
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.
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.
TPZGeoTriangle(const TPZGeoTriangle &cp)
Copy constructor.
Definition: pzgeotriangle.h:55
Implements ... Geometry Topology.
Definition: pznoderep.h:40
Implements the geometry of a triangle element. Geometry.
Definition: pzgeotriangle.h:28
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
TPZGeoTriangle(TPZVec< int64_t > &nodeindexes)
Constructor with list of nodes.
Definition: pzgeotriangle.h:36
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
TPZGeoTriangle(const TPZGeoTriangle &cp, TPZGeoMesh &)
Copy constructor.
Definition: pzgeotriangle.h:61
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