NeoPZ
pzgeoquad.h
Go to the documentation of this file.
1 
6 #ifndef TPZGEOQUADH
7 #define TPZGEOQUADH
8 
9 #include "pznoderep.h"
10 #include "pzvec.h"
11 #include "pzeltype.h"
12 #include "tpzquadrilateral.h"
13 #include "pzfmatrix.h"
14 
15 #include <string>
16 
17 class TPZGeoEl;
18 class TPZGeoMesh;
19 
20 namespace pzgeom {
21 
26  class TPZGeoQuad : public TPZNodeRep<4, pztopology::TPZQuadrilateral>
27  {
28  public:
31  enum {NNodes = 4};
32 
36  {
37  }
38 
42  {
43  }
44 
47  std::map<int64_t,int64_t> & gl2lcNdMap) : TPZRegisterClassId(&TPZGeoQuad::ClassId),
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 "Quad";}
71 
73  template<class T>
74  static void X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &x);
75 
77  template<class T>
78  static void GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx);
79 
80 
81  // /**
82  // * @brief Method which creates a geometric boundary condition
83  // * element based on the current geometric element, \n
84  // * a side and a boundary condition number
85  // */
86  // static TPZGeoEl * CreateBCGeoEl(TPZGeoEl *orig,int side,int bc);
87 
88 
93 // static void VecHdiv(TPZFMatrix<REAL> & coord,TPZFMatrix<REAL> &NormalVec,TPZVec<int> & VectorSide);
95  static void VectorialProduct(TPZVec<REAL> &v1, TPZVec<REAL> &v2,TPZVec<REAL> &result);
97  static void ComputeNormal(TPZVec<REAL> &p1, TPZVec<REAL> &p2,TPZVec<REAL> &p3,TPZVec<REAL> &result);
98 
99  /* brief compute the coordinate of a point given in parameter space */
100 // void VecHdiv(const TPZGeoEl &gel,TPZFMatrix<REAL> &NormalVec,TPZVec<int> & VectorSide) const
101 // {
102 // TPZFNMatrix<3*NNodes> coord(3,NNodes);
103 // CornerCoordinates(gel, coord);
104 // VecHdiv(coord,NormalVec,VectorSide);
105 // }
106 
108  /* @param gmesh mesh in which the element should be inserted
109  @param matid material id of the element
110  @param lowercorner (in/out) on input lower corner o the cube where the element should be created, on exit position of the next cube
111  @param size (in) size of space where the element should be created
112  */
113  static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size);
114  public:
116  // static TPZGeoEl *CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
117  // TPZVec<int64_t>& nodeindexes,
118  // int matid,
119  // int64_t& index);
120  int ClassId() const override;
121  void Read(TPZStream &buf, void *context) override;
122  void Write(TPZStream &buf, int withclassid) const override;
123  };
124 
125 
126  template<class T>
127  inline void TPZGeoQuad::X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &x){
128 
129  TPZFNMatrix<4,T> phi(NNodes,1);
130  TPZFNMatrix<8,T> dphi(2,NNodes);
131  TShape(loc,phi,dphi);
132  int space = nodes.Rows();
133 
134  for(int i = 0; i < space; i++) {
135  x[i] = 0.0;
136  for(int j = 0; j < 4; j++) {
137  x[i] += phi(j,0)*nodes.GetVal(i,j);
138  }
139  }
140 
141  }
142 
143  template<class T>
144  inline void TPZGeoQuad::GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx){
145 
146  int space = nodes.Rows();
147  int ncol = nodes.Cols();
148 
149  gradx.Resize(space,2);
150  gradx.Zero();
151 
152 #ifdef PZDEBUG
153  if(/* nrow != 3 || */ ncol != 4){
154  std::cout << "Objects of incompatible lengths, gradient cannot be computed." << std::endl;
155  std::cout << "nodes matrix must be spacex4." << std::endl;
156  DebugStop();
157  }
158 
159 #endif
160  TPZFNMatrix<3,T> phi(4,1);
161  TPZFNMatrix<6,T> dphi(2,4);
162  TShape(loc,phi,dphi);
163  for(int i = 0; i < 4; i++)
164  {
165  for(int j = 0; j < space; j++)
166  {
167  gradx(j,0) += nodes.GetVal(j,i)*dphi(0,i);
168  gradx(j,1) += nodes.GetVal(j,i)*dphi(1,i);
169  }
170  }
171 
172  }
173 
174 
175 };
176 
177 #endif
TPZGeoQuad(const TPZGeoQuad &cp)
Copy constructor.
Definition: pzgeoquad.h:53
static void ComputeNormal(TPZVec< REAL > &p1, TPZVec< REAL > &p2, TPZVec< REAL > &p3, TPZVec< REAL > &result)
Computes normal vector to plane determinated by three points.
Definition: pzgeoquad.cpp:36
Templated vector implementation.
TPZGeoQuad(const TPZGeoQuad &cp, std::map< int64_t, int64_t > &gl2lcNdMap)
Constructor with node map.
Definition: pzgeoquad.h:46
Defines enum MElementType and contains the implementation of MElementType_NNodes(...) functions.
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: pzgeoquad.h:144
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: pzgeoquad.cpp:126
static void X(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZVec< T > &x)
Compute x mapping from element nodes and local parametric coordinates.
Definition: pzgeoquad.h:127
static void VectorialProduct(TPZVec< REAL > &v1, TPZVec< REAL > &v2, TPZVec< REAL > &result)
Method which creates a geometric boundary condition element based on the current geometric element...
Definition: pzgeoquad.cpp:23
static std::string TypeName()
Returns the type name of the element.
Definition: pzgeoquad.h:70
pztopology::TPZQuadrilateral Top
Definition: pzgeoquad.h:29
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
int ClassId() const override
Creates a geometric element according to the type of the father element.
Definition: pzgeoquad.cpp:118
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
Contains the TPZQuadrilateral class which defines the topology of a quadrilateral element...
TPZGeoQuad()
Empty constructor.
Definition: pzgeoquad.h:40
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
Contains the TPZNodeRep class which implements ... Clase intermediaria que guarda.
Implements the geometry of a quadrilateral element. Geometry.
Definition: pzgeoquad.h:26
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)
create an example element based on the topology
Definition: pzgeoquad.cpp:90
TPZGeoQuad(const TPZGeoQuad &cp, TPZGeoMesh &)
Copy constructor.
Definition: pzgeoquad.h:59
Implements ... Geometry Topology.
Definition: pznoderep.h:40
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pzgeoquad.cpp:122
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
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.
Defines the topology of a quadrilateral element. Topology Sides 0 to 3 are vertices, sides 4 to 7 are lines, side 8 is the quadrilateral.
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
TPZGeoQuad(TPZVec< int64_t > &nodeindexes)
Constructor with list of nodes.
Definition: pzgeoquad.h:34
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
TPZQuadrilateral()
Default constructor.
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
static bool IsLinearMapping(int side)
Definition: pzgeoquad.h:64
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716