NeoPZ
tpzgeoblend.h
Go to the documentation of this file.
1 
6 #ifndef TPZGEOBLEND_H
7 #define TPZGEOBLEND_H
8 
9 #include "pzgeotriangle.h"
10 #include "TPZGeoCube.h"
11 #include "pzgeoprism.h"
12 #include "pzgeoel.h"
13 #include "pznoderep.h"
14 #include "pzgeoelside.h"
15 
16 #include <iostream>
17 
18 namespace pzgeom {
19 
26  template<class TGeo>
27  class TPZGeoBlend : public TGeo {
28 
29  public:
30 
31  int ClassId() const override;
32 
33  bool IsLinearMapping(int side) const;
34 
35  bool IsGeoBlendEl() const {
36  return true;
37  }
38  typedef typename TGeo::Top Top;
41  TGeo(nodeindexes) {
42  }
43 
46  TGeo() {
47  }
48 
50  TPZGeoBlend(const TPZGeoBlend &cp, std::map<int64_t, int64_t> &gl2lcNdMap) : TPZRegisterClassId(
51  &TPZGeoBlend::ClassId),
52  TGeo(cp, gl2lcNdMap) {
53  }
54 
56  TPZGeoBlend(const TPZGeoBlend &cp) : TPZRegisterClassId(&TPZGeoBlend::ClassId), TGeo(cp) {
57  for (int is = 0; is < 1 + TGeo::NSides - TGeo::NNodes; is++) {
58  fNeighbours[is] = cp.fNeighbours[is];
59  fTrans[is] = cp.fTrans[is];
60  }
61  }
62 
64  TPZGeoBlend(const TPZGeoBlend &cp, TPZGeoMesh &) : TPZRegisterClassId(&TPZGeoBlend::ClassId), TGeo(cp) {
65  for (int is = 0; is < 1 + TGeo::NSides - TGeo::NNodes; is++) {
66  fNeighbours[is] = cp.fNeighbours[is];
67  fTrans[is] = cp.fTrans[is];
68  }
69  }
70 
71  void Read(TPZStream &buf, void *context) override{
72  TGeo::Read(buf, context);
73  for (int is = 0; is < 1 + TGeo::NSides - TGeo::NNodes; is++) {
74  fNeighbours[is].Read(buf, context);
75  }
76  for (int is = 0; is < 1 + TGeo::NSides - TGeo::NNodes; is++) {
77  fTrans[is].Read(buf, context);
78  }
79  }
80 
81  void Write(TPZStream &buf, int withclassid) const override{
82  TGeo::Write(buf, withclassid);
83  for (int is = 0; is < 1 + TGeo::NSides - TGeo::NNodes; is++) {
84  fNeighbours[is].Write(buf, withclassid);
85  }
86  for (int is = 0; is < 1 + TGeo::NSides - TGeo::NNodes; is++) {
87  fTrans[is].Write(buf, withclassid);
88  }
89  }
90 
91  void SetNeighbourInfo(int side, TPZGeoElSide &neigh, TPZTransform<> &trans) override;
92 
93  bool ResetBlendConnectivity(const int64_t &side, const int64_t &index);
94 
95  TPZGeoElSide Neighbour(int side, TPZGeoMesh *gmesh) const {
96  if (side < TGeo::NNodes) {
97  DebugStop();
98  }
99  return TPZGeoElSide(fNeighbours[side - TGeo::NNodes], gmesh);
100  }
101 
102  template<class T>
103  void TransfBetweenNeigh(int side, TPZTransform<T> &tr) const {
104  tr.CopyFrom(fTrans[side - TGeo::NNodes]);
105  }
106 
108  static std::string TypeName() { return TGeo::TypeName(); }
109 
111  template<class T>
112  void X(TPZFMatrix<REAL> &cornerco, TPZVec<T> &par, TPZVec<T> &result) const;
113 
115  void Jacobian(TPZFMatrix<REAL> &cornerco, TPZVec<REAL> &par, TPZFMatrix<REAL> &jacobian, TPZFMatrix<REAL> &axes,
116  REAL &detjac, TPZFMatrix<REAL> &jacinv) const;
117 
119  template<class T>
120  void GradX(TPZFMatrix<REAL> &cornerco, TPZVec<T> &par, TPZFMatrix<T> &gradx) const;
121 
123  void Print(std::ostream &out = std::cout) const;
124 
133  void Initialize(TPZGeoEl *refel);
134 
135  //void Initialize(TPZVec<int> &nodeindexes, TPZGeoMesh &mesh);
136 
137  // /**
138  // * @brief Method which creates a geometric boundary condition
139  // * element based on the current geometric element,
140  // * a side and a boundary condition number
141  // */
142  // TPZGeoEl *CreateBCGeoEl(TPZGeoEl *orig, int side, int bc);
143 
144  // TPZGeoEl *CreateBCGeoBlendEl(TPZGeoEl *orig, int side, int bc);
145 
146 // TPZGeoEl *CreateGeoBlend(TPZGeoMesh &mesh, MElementType type, TPZVec<int64_t>& nodeindexes, int matid, int64_t& index);
147 
148 
149 
150  public:
151 
153  /* @param gmesh mesh in which the element should be inserted
154  @param matid material id of the element
155  @param lowercorner (in/out) on input lower corner o the cube where the element should be created, on exit position of the next cube
156  @param size (in) size of space where the element should be created
157  */
158  static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size);
159 
163  // static TPZGeoEl *CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
164  // TPZVec<int64_t> &nodeindexes,
165  // int matid,
166  // int64_t &index);
167 
168  protected:
169 
171  template<class T>
172  bool MapToNeighSide(int side, int sidedim, TPZVec<T> &InternalPar, TPZVec<T> &NeighPar,
173  TPZFMatrix<T> &JacNeighSide) const;
175  //TPZGeoElSideIndex fNeighbours[1+TGeo::NSides - TGeo::NNodes];
177  TPZGeoElSideIndex fNeighbours[1 + TGeo::NSides - TGeo::NNodes];
178  TPZTransform<> fTrans[1 + TGeo::NSides - TGeo::NNodes];
179  };
180 
181 
182  template<class TGeo>
183  template<class T>
184  inline bool
185  pzgeom::TPZGeoBlend<TGeo>::MapToNeighSide(int side, int SideDim, TPZVec<T> &InternalPar, TPZVec<T> &NeighPar,
186  TPZFMatrix<T> &JacNeighSide) const {
187  TPZFNMatrix<9, T> JacSide;
188 
189  TPZManVector<T, 3> SidePar(SideDim);
190  const bool check = TGeo::CheckProjectionForSingularity(side, InternalPar);
191 
192  this->MapToSide(side, InternalPar, SidePar, JacSide);
193  if (!check) {
194  #ifdef LOG4CXX2
195  td::stringstream sout;
196  sout << "side " << side << std::endl;
197  sout << "InternalPar: ";
198  for(int i = 0; i < InternalPar.NElements(); i++) sout << InternalPar[i] << "\t";
199  sout << "\n";
200  sout << "\tmapping is not regular"<<std::endl;
201  LOGPZ_DEBUG(logger,sout.str())
202  #endif
203  return false;
204  }
205 #ifdef LOG4CXX2
206  if(logger->isDebugEnabled())
207  {
208  std::stringstream sout;
209  sout << "side " << side << std::endl;
210  sout << "InternalPar: ";
211  for(int i = 0; i < InternalPar.NElements(); i++) sout << InternalPar[i] << "\t";
212  sout << "\n";
213 
214  sout << "SidePar: ";
215  for(int i = 0; i < SidePar.NElements(); i++) sout << SidePar[i] << "\t";
216  sout << "\n";
217 
218  JacSide.Print("JacSide = ",sout);
219  LOGPZ_DEBUG(logger,sout.str())
220  }
221 #endif
222 
223  NeighPar.Resize(SideDim);
224  TPZTransform<T> tr;
225  TransfBetweenNeigh(side, tr);
226  tr.Apply(SidePar, NeighPar);
227 
228  JacNeighSide.Resize(0, 0);
229  TransfBetweenNeigh(side, tr);
230  JacNeighSide.Resize(tr.Mult().Rows(), JacSide.Cols());
231  tr.Mult().Multiply(JacSide, JacNeighSide);
232 
233 #ifdef LOG4CXX2
234  if(logger->isDebugEnabled())
235  {
236  std::stringstream sout;
237 
238  sout << "NeighPar: ";
239  for(int i = 0; i < NeighPar.NElements(); i++) sout << NeighPar[i] << "\t";
240  sout << "\n";
241 
242  JacNeighSide.Print("JacNeighSide = ",sout);
243  LOGPZ_DEBUG(logger,sout.str())
244  }
245 #endif
246 
247  return true;
248  }
249 
250 
251  template<class TGeo>
253  return Hash("TPZGeoBlend") ^ TGeo::ClassId() << 1;
254  }
255 
256 };
257 #endif
static REAL cornerco[8][3]
Contains declaration of TPZGeoElSide class which represents an element and its side, and TPZGeoElSideIndex class which represents an TPZGeoElSide index.
int ClassId() const override
Definition: tpzgeoblend.h:252
TPZTransform fTrans[1+TGeo::NSides - TGeo::NNodes]
Definition: tpzgeoblend.h:178
void CopyFrom(const TPZTransform< REAL > &cp)
Create a copy form a real transformation.
Definition: pztrnsform.cpp:62
const TPZFMatrix< T > & Mult() const
Definition: pztrnsform.h:64
Implements a blending map from curved boundaries to the interior of the element. Geometry.
Definition: tpzgeoblend.h:27
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: pztrnsform.h:97
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
TPZGeoBlend(const TPZGeoBlend &cp, std::map< int64_t, int64_t > &gl2lcNdMap)
Constructor with node map.
Definition: tpzgeoblend.h:50
TPZGeoElSide Neighbour(int side, TPZGeoMesh *gmesh) const
Definition: tpzgeoblend.h:95
void X(TPZFMatrix< REAL > &cornerco, TPZVec< T > &par, TPZVec< T > &result) const
Get the coordinates of the point at geometric elements from coordinates of the parametric point at th...
void Print(std::ostream &out=std::cout) const
Print all relevant data of the element to cout.
TPZGeoBlend(const TPZGeoBlend &cp, TPZGeoMesh &)
Copy constructor.
Definition: tpzgeoblend.h:64
TPZGeoBlend(const TPZGeoBlend &cp)
Copy constructor.
Definition: tpzgeoblend.h:56
Utility class which represents an element index with its side. Geometry.
Definition: pzgeoelside.h:33
void Initialize(TPZGeoEl *refel)
Initialize the element checking connectivity on all sides.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
Definition: pzvec.h:373
bool IsGeoBlendEl() const
Definition: tpzgeoblend.h:35
bool MapToNeighSide(int side, int sidedim, TPZVec< T > &InternalPar, TPZVec< T > &NeighPar, TPZFMatrix< T > &JacNeighSide) const
Creates a geometric element according to the type of the father element.
Definition: tpzgeoblend.h:185
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
void Write(TPZStream &buf, int withclassid) const override
Definition: tpzgeoblend.h:81
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
Definition: pzlog.h:87
bool ResetBlendConnectivity(const int64_t &side, const int64_t &index)
Definition: tpzgeoblend.cpp:48
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pztrnsform.h:90
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
Contains the TPZNodeRep class which implements ... Clase intermediaria que guarda.
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)
Method which creates a geometric boundary condition element based on the current geometric element...
TPZGeoBlend(TPZVec< int64_t > &nodeindexes)
Constructor with list of nodes.
Definition: tpzgeoblend.h:40
void GradX(TPZFMatrix< REAL > &cornerco, TPZVec< T > &par, TPZFMatrix< T > &gradx) const
Computes the gradient of the transformation for parametric point at master element.
Definition: tpzgeoblend.cpp:84
TPZGeoBlend()
Empty constructor.
Definition: tpzgeoblend.h:45
void Read(TPZStream &buf, void *context) override
Definition: tpzgeoblend.h:71
Contains the TPZGeoCube class which implements the geometry of hexahedra element. ...
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
void Jacobian(TPZFMatrix< REAL > &cornerco, TPZVec< REAL > &par, TPZFMatrix< REAL > &jacobian, TPZFMatrix< REAL > &axes, REAL &detjac, TPZFMatrix< REAL > &jacinv) const
Computes the Jacobian for parametric point at master element.
void TransfBetweenNeigh(int side, TPZTransform< T > &tr) const
Definition: tpzgeoblend.h:103
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
void SetNeighbourInfo(int side, TPZGeoElSide &neigh, TPZTransform<> &trans) override
Definition: tpzgeoblend.cpp:57
virtual void Multiply(const TPZFMatrix< TVar > &A, TPZFMatrix< TVar > &res, int opt=0) const
It mutiplies itself by TPZMatrix<TVar>A putting the result in res.
Definition: pzmatrix.cpp:1916
static std::string TypeName()
Returns the type name of the element.
Definition: tpzgeoblend.h:108
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
TPZGeoElSideIndex fNeighbours[1+TGeo::NSides - TGeo::NNodes]
Definition: tpzgeoblend.h:177
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: pzgeoelside.cpp:60
virtual void Print(std::ostream &out) const
Definition: pzmatrix.h:253
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
Definition: pzfmatrix.cpp:1016
bool IsLinearMapping(int side) const
Definition: tpzgeoblend.cpp:20
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
Implements an affine transformation between points in parameter space. Topology Utility.
Definition: pzmganalysis.h:14
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pzgeoelside.cpp:55
Contains the TPZGeoPrism class which implements the geometry of a prism element.
TPZGeoEl * fGeoEl
Vector of indexes of the neighbours.
Definition: tpzgeoblend.h:176
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
void Apply(TPZVec< T > &vectorin, TPZVec< T > &vectorout)
Transforms the vector.
Definition: pztrnsform.cpp:121