NeoPZ
TPZGeoExtend.h
Go to the documentation of this file.
1 
6 #ifndef TPZGEOPRISMEXTENDH
7 #define TPZGEOPRISMEXTENDH
8 
9 #include "pznoderep.h"
10 
11 #include "pzvec.h"
12 #include "pzeltype.h"
13 #include "pzfmatrix.h"
14 
15 #include <string>
16 #include "PrismExtend.h"
17 
18 #include "pzlog.h"
19 
20 #ifdef LOG4CXX
21 static LoggerPtr loggernoderep2(Logger::getLogger("pz.geom.extend"));
22 #endif
23 
24 class TPZGeoEl;
25 class TPZGeoMesh;
26 
27 namespace pzgeom {
28 
33  template<class TFather, class Topology>
34  class GPr : public TFather {
35 
36  public:
37 
38  typedef typename TFather::TMem FatMem;
39  typedef typename TFather::Top FatTop;
40 
41  typedef Topology Top;
42 
43  enum {NNodes = 2*TFather::NNodes};
44 
45  int64_t fNodeIndexes[TFather::NNodes];
47  GPr(TPZVec<int64_t> &nodeindexes, TPZGeoMesh &mesh) : TFather(nodeindexes, mesh)
48  {
49  int i;
50  for(i=0; i<TFather::NNodes; i++) fNodeIndexes[i] = nodeindexes[TFather::NNodes+i];
51  }
52 
54  GPr() : TFather()
55  {
56  int i;
57  for(i=0; i<TFather::NNodes; i++) fNodeIndexes[i] = -1;
58  }
59 
62  std::map<int64_t,int64_t> & gl2lcNdMap) : TFather(cp,gl2lcNdMap)
63  {
64  int i;
65  for(i = 0; i < TFather::NNodes; i++)
66  {
67 #ifdef PZDEBUG
68  if (gl2lcNdMap.find(cp.fNodeIndexes[i+TFather::NNodes]) == gl2lcNdMap.end())
69  {
70  std::stringstream sout;
71  sout << "ERROR in - " << __PRETTY_FUNCTION__
72  << " trying to clone a node " << i << " index " << cp.fNodeIndexes[i]
73  << " wich is not mapped";
74  LOGPZ_ERROR(loggernoderep2,sout.str().c_str());
75  fNodeIndexes[i] = -1;
76  continue;
77  }
78 #endif
79  fNodeIndexes[i] = gl2lcNdMap [ cp.fNodeIndexes[i+TFather::NNodes] ];
80  }
81  }
82 
84  GPr(const GPr<TFather, Topology> &cp) : TFather(cp)
85  {
86  int i;
87  for(i=0; i<TFather::NNodes; i++) fNodeIndexes[i] = cp.fNodeIndexes[i];
88  }
89 
91  GPr(const GPr<TFather,Topology> &cp, TPZGeoMesh &) : TFather(cp)
92  {
93  int i;
94  for(i=0; i<TFather::NNodes; i++) fNodeIndexes[i] = cp.fNodeIndexes[i];
95  }
96 
98  static std::string TypeName() { return "Pr:"+TFather::TypeName();}
99 
100  static void X(const TPZFMatrix<REAL> &nodes,TPZVec<REAL> &loc,TPZVec<REAL> &result);
101 
102  static void Shape(TPZVec<REAL> &pt,TPZFMatrix<REAL> &phi,TPZFMatrix<REAL> &dphi);
103 
104  static void Jacobian(const TPZFMatrix<REAL> &nodes,TPZVec<REAL> &param,TPZFMatrix<REAL> &jacobian,
105  TPZFMatrix<REAL> &axes,REAL &detjac,TPZFMatrix<REAL> &jacinv);
106 
107  static void Jacobian(const TPZFMatrix<REAL> &nodes,TPZVec<REAL> &param,TPZFMatrix<REAL> &jacobian);
108 
109 
110  // static TPZGeoEl *CreateBCGeoEl(TPZGeoEl *gel, int side,int bc);
111 
112  static void Diagnostic(TPZFMatrix<REAL> &coord);
113 
114 
115  };
116 
117  template<class TFather, class Topology>
119  {
120 
121  int spacedim = coord.Rows();
122  TPZFNMatrix<3*TFather::NNodes> coordlower(spacedim,TFather::NNodes),coordupper(spacedim,TFather::NNodes);
123  TPZFNMatrix<100> jacobianlower,jacobianupper;
124  TFather::Jacobian(coordupper,param,jacobianlower);
125  TFather::Jacobian(coordupper,param,jacobianupper);
126  REAL ksi = param[Top::Dimension-1];
127  jacobian.Resize(spacedim,Top::Dimension);
128  TPZManVector<REAL> xlower(spacedim),xupper(spacedim);
129  TPZManVector<REAL> resultlower,resultupper;
130  int i,j;
131  for(i=0; i<spacedim; i++) for(j=0; j<TFather::NNodes; j++)
132  {
133  coordlower(i,j) = coord.GetVal(i,j);
134  coordupper(i,j) = coord.GetVal(i,j+TFather::NNodes);
135  }
136  TFather::X(coordlower,param,xlower);
137  TFather::X(coordupper,param,xupper);
138  for(i=0; i<spacedim; i++)
139  {
140  for(j=0; j<Top::Dimension-1; j++)
141  {
142  jacobian(i,j) = jacobianlower(i,j)*(1.-ksi)/2.+jacobianupper(i,j)*(1.+ksi)/2.;
143  }
144  jacobian(i,j) = (xupper[i]-xlower[i])/2.;
145  }
146  }
147 
148  template<class TFather, class Topology>
150  {
151  TPZFNMatrix<16> axest,VecMatrix;
152  Jacobian(coord,param,VecMatrix);
153  VecMatrix.GramSchmidt(axest,jacobian);
154  axest.Transpose(&axes);
155  jacobian.DeterminantInverse(detjac,jacinv);
156 
157  }
158 
159  template<class TFather, class Topology>
160  inline void GPr<TFather, Topology>::X(const TPZFMatrix<REAL> &coord,TPZVec<REAL> &loc,TPZVec<REAL> &result){
161 
162 
163  int spacedim = coord.Rows();
164  TPZFNMatrix<3*TFather::NNodes> lower(spacedim,TFather::NNodes),upper(spacedim,TFather::NNodes);
165  TPZManVector<REAL> resultlower(spacedim),resultupper(spacedim);
166  int i,j;
167  for(i=0; i<spacedim; i++) for(j=0; j<TFather::NNodes; j++)
168  {
169  lower(i,j) = coord.GetVal(i,j);
170  upper(i,j) = coord.GetVal(i,j+TFather::NNodes);
171  }
172  TFather::X(lower,loc,resultlower);
173  TFather::X(upper,loc,resultupper);
174  REAL ksi = loc[Top::Dimension-1];
175  for(i=0; i<spacedim; i++)
176  {
177  result[i] = resultlower[i]*(1.-ksi)/2.+resultupper[i]*(1.+ksi)/2.;
178  }
179  }
180 
181  template<class TFather, class Topology>
183  {
184 #ifdef LOG4CXX
185  LoggerPtr logger(Logger::getLogger("pz.geom.pzgeoextend"));
186 
187  TPZIntPoints *integ = Top::CreateSideIntegrationRule(Top::NSides-1,3);
188  int np = integ->NPoints();
189  REAL w;
190  TPZVec<REAL> pos(integ->Dimension());
191  int ip;
192  for(ip=0; ip<np; ip++)
193  {
194  integ->Point(ip,pos,w);
195  TPZFMatrix<REAL> jacobian(coord.Rows(),Top::Dimension);
196  Jacobian(coord,pos,jacobian);
197  {
198  std::stringstream sout;
199  sout << "Testing Jacobian\n";
200  sout << "position " << pos << " jacobian " << jacobian;
201  LOGPZ_DEBUG(logger,sout.str());
202  }
203  TPZFMatrix<REAL> axes(Top::Dimension,coord.Rows());
204  TPZFMatrix<REAL> jacinv(Top::Dimension,Top::Dimension);
205  REAL detjac;
206  Jacobian(coord,pos,jacobian,axes,detjac,jacinv);
207  {
208  std::stringstream sout;
209  sout << "Testing Jacobian\n";
210  sout << "position " << pos << " jacobian " << jacobian <<
211  " axes " << axes << " detjac " << detjac << " jacinv " << jacinv;
212  LOGPZ_DEBUG(logger,sout.str());
213  }
214  TPZVec<REAL> x(coord.Rows());
215  X(coord,pos,x);
216  {
217  std::stringstream sout;
218  sout << "Testing X\n";
219  sout << "position " << pos << " x " << x;
220  LOGPZ_DEBUG(logger,sout.str());
221  }
222  }
223 
224  delete integ;
225 
226 #endif
227 
228  }
229 
230 };
231 
232 #endif
GPr(const GPr< TFather, Topology > &cp)
Copy constructor.
Definition: TPZGeoExtend.h:84
GPr(const GPr< TFather, Topology > &cp, TPZGeoMesh &)
Copy constructor.
Definition: TPZGeoExtend.h:91
GPr(TPZVec< int64_t > &nodeindexes, TPZGeoMesh &mesh)
Constructor with list of nodes.
Definition: TPZGeoExtend.h:47
virtual int NPoints() const =0
Returns number of points for the cubature rule related.
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
Geometric derivated class (template). Geometry.
Definition: TPZGeoExtend.h:34
void GramSchmidt(TPZFMatrix< TVar > &Orthog, TPZFMatrix< TVar > &TransfToOrthog)
This method implements a Gram Schimidt method. this = Orthog.TransfToOrthog.
Definition: pzfmatrix.cpp:341
int64_t fNodeIndexes[TFather::NNodes]
Definition: TPZGeoExtend.h:45
Templated vector implementation.
TFather::Top FatTop
Definition: TPZGeoExtend.h:39
Topology Top
Definition: TPZGeoExtend.h:41
GPr()
Empty constructor.
Definition: TPZGeoExtend.h:54
Defines enum MElementType and contains the implementation of MElementType_NNodes(...) functions.
Contains the Pr class(template) which defines the Prismatic extension of a topology.
Abstract class defining integration rules. Numerical Integration.
Definition: tpzintpoints.h:19
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 LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
Contains the TPZNodeRep class which implements ... Clase intermediaria que guarda.
#define LOGPZ_ERROR(A, B)
Define log for errors (cout)
Definition: pzlog.h:93
static void Diagnostic(TPZFMatrix< REAL > &coord)
Definition: TPZGeoExtend.h:182
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
TFather::TMem FatMem
Definition: TPZGeoExtend.h:38
static void X(const TPZFMatrix< REAL > &nodes, TPZVec< REAL > &loc, TPZVec< REAL > &result)
Definition: TPZGeoExtend.h:160
virtual int Dimension() const =0
Returns the dimension of the master element related for the cubature rule.
static std::string TypeName()
Returns the type name of the element.
Definition: TPZGeoExtend.h:98
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
Definition: pzfmatrix.cpp:1016
GPr(const GPr< TFather, Topology > &cp, std::map< int64_t, int64_t > &gl2lcNdMap)
Constructor with node map.
Definition: TPZGeoExtend.h:61
void DeterminantInverse(TVar &determinant, TPZFMatrix< TVar > &inverse)
Definition: pzfmatrix.cpp:507
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
static void Jacobian(const TPZFMatrix< REAL > &nodes, TPZVec< REAL > &param, TPZFMatrix< REAL > &jacobian, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv)
Definition: TPZGeoExtend.h:149
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
void Transpose(TPZMatrix< TVar > *const T) const override
It makes *T the transpose of current matrix.
Definition: pzfmatrix.cpp:1073
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716
virtual void Point(int i, TPZVec< REAL > &pos, REAL &w) const =0
Returns i-th point at master element and related weight.
static void Shape(TPZVec< REAL > &pt, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi)