NeoPZ
TPZGeoLinear.h
Go to the documentation of this file.
1 
2 #ifndef TPZGEOLINEARH
3 #define TPZGEOLINEARH
4 
10 #include "pznoderep.h"
11 
12 #include "pzvec.h"
13 #include "pzeltype.h"
14 #include "pzfmatrix.h"
15 #include "tpzline.h"
16 
17 #include <string>
18 
19 class TPZGeoEl;
20 class TPZGeoMesh;
21 
22 namespace pzgeom
23 {
24 
25 
30  class TPZGeoLinear : public TPZNodeRep<2, pztopology::TPZLine> {
31 
32  public:
35  enum {NNodes = 2};
36 
39  {
40  }
41 
44  {
45  }
46 
48  TPZGeoLinear(const TPZGeoLinear &cp, std::map<int64_t,int64_t> & gl2lcNdMap) :
50  {
51  }
52 
56  {
57  }
58 
62  {
63  }
64 
66  static bool IsLinearMapping(int side)
67  {
68  return true;
69  }
70 
72  static std::string TypeName() { return "Linear";}
73 
75  template<class T>
76  static void X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &x);
77 
79  template<class T>
80  static void GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx);
81 
82 
84  static void Jacobian(const TPZFMatrix<REAL> &nodes,TPZVec<REAL> &param,TPZFMatrix<REAL> &jacobian,
85  TPZFMatrix<REAL> &axes,REAL &detjac,TPZFMatrix<REAL> &jacinv);
86 
87  // /**
88  // * @brief Method which creates a geometric boundary condition
89  // * element based on the current geometric element, \n
90  // * a side and a boundary condition number
91  // */
92  // static TPZGeoEl *CreateBCGeoEl(TPZGeoEl *gel, int side,int bc);
93 
94  public:
95  int ClassId() const override;
96  void Read(TPZStream &buf, void *context) override;
97  void Write(TPZStream &buf, int withclassid) const override;
98 
99 
101  /* @param gmesh mesh in which the element should be inserted
102  @param matid material id of the element
103  @param lowercorner (in/out) on input lower corner o the cube where the element should be created, on exit position of the next cube
104  @param size (in) size of space where the element should be created
105  */
106  static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size);
107 
109  // static TPZGeoEl *CreateGeoElement(TPZGeoMesh &mesh,
110  // MElementType type,
111  // TPZVec<int64_t>& nodeindexes,
112  // int matid,
113  // int64_t& index);
114 
115  };
116 
117 
118  template<class T>
119  inline void TPZGeoLinear::X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &x){
120 
121  T xi = loc[0];
122  int nrow = nodes.Rows();
123  for(int i = 0; i < nrow; i++)
124  {
125  x[i] = nodes.GetVal(i,0)*(1.-xi)*0.5+nodes.GetVal(i,1)*(1.+xi)*0.5;
126  }
127 
128  }
129 
130 
131  template<class T>
132  inline void TPZGeoLinear::GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx){
133 
134  int nrow = nodes.Rows();
135  int ncol = nodes.Cols();
136 
137  gradx.Resize(nrow,1);
138  gradx.Zero();
139 
140  TPZFNMatrix<3,T> phi(2,1);
141  TPZFNMatrix<6,T> dphi(2,2);
142  TShape(loc,phi,dphi);
143  for(int i = 0; i < ncol; i++)
144  {
145  for(int j = 0; j < nrow; j++)
146  {
147  gradx(j,0) += nodes.GetVal(j,i)*dphi(0,i);
148 
149  }
150  }
151 
152  }
153 
154 };
155 
156 #endif
void Read(TPZStream &buf, void *context) override
read objects from the stream
TPZGeoLinear()
Empty constructor.
Definition: TPZGeoLinear.h:43
static void Jacobian(const TPZFMatrix< REAL > &nodes, TPZVec< REAL > &param, TPZFMatrix< REAL > &jacobian, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv)
Compute the jacoabina associated to the x mapping from local parametric coordinates.
Implements a line. Utility.
Definition: pzline.h:18
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: TPZGeoLinear.h:132
Templated vector implementation.
Defines enum MElementType and contains the implementation of MElementType_NNodes(...) functions.
Implements the geometry of a one dimensional linear element. Geometry.
Definition: TPZGeoLinear.h:30
TPZGeoLinear(const TPZGeoLinear &cp, std::map< int64_t, int64_t > &gl2lcNdMap)
Constructor with node map.
Definition: TPZGeoLinear.h:48
static bool IsLinearMapping(int side)
answer if the element side is a linear map
Definition: TPZGeoLinear.h:66
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)
create an example element based on the topology
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
TPZGeoLinear(TPZVec< int64_t > &nodeindexes)
Constructor with list of nodes.
Definition: TPZGeoLinear.h:38
int ClassId() const override
Method which creates a geometric boundary condition element based on the current geometric element...
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
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).
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
Contains the TPZNodeRep class which implements ... Clase intermediaria que guarda.
pztopology::TPZLine Top
Definition: TPZGeoLinear.h:33
Defines the topology of a line element. Topology Sides 0 and 1 are vertices, side 2 is the line...
Definition: tpzline.h:38
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: tpzline.cpp:69
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
static void X(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZVec< T > &x)
Compute X mapping from element nodes and local parametric coordinates.
Definition: TPZGeoLinear.h:119
static std::string TypeName()
Returns the type name of the element.
Definition: TPZGeoLinear.h:72
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
TPZGeoLinear(const TPZGeoLinear &cp)
Copy constructor.
Definition: TPZGeoLinear.h:54
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
Contains the TPZLine class which defines the topology of a line element.
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
TPZGeoLinear(const TPZGeoLinear &cp, TPZGeoMesh &)
Copy constructor.
Definition: TPZGeoLinear.h:60
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