NeoPZ
TPZCylinder.h
Go to the documentation of this file.
1 //
2 // TPZCylinder.hpp
3 // pz
4 //
5 // Created by Philippe Devloo on 04/05/18.
6 //
7 
8 #ifndef TPZCylinder_hpp
9 #define TPZCylinder_hpp
10 
11 #include <stdio.h>
12 
13 #include "pzgeotriangle.h"
14 
15 namespace pzgeom {
16 
17  template<class TGeo>
18  class TPZCylinderMap : public TGeo
19  {
22 
25 
27  REAL fRadius;
28 
31 
32  public:
33 
34  TPZCylinderMap() : TGeo(), fCornerCo(2*TGeo::NNodes,-1), fOrigin(3,0.), fRadius(0.), fRotation(3,3,0.)
35  {
36  fRotation.Identity();
37  }
38 
39  TPZCylinderMap(TPZVec<int64_t> &nodeindices) : TGeo(nodeindices), fCornerCo(2*TGeo::NNodes,-1), fOrigin(3,0.), fRadius(0.), fRotation(3,3,0.)
40  {
41  fRotation.Identity();
42  }
43 
44  TPZCylinderMap(const TPZCylinderMap &cp) : TGeo(cp), fCornerCo(cp.fCor), fRadius(cp.fRadius), fRotation(cp.fRotation)
45  {
46  }
47 
49  {
50  TGeo::operator=(cp);
51  fCornerCo = cp.fCornerCo;
52  fOrigin = cp.fOrigin;
53  fRadius = cp.fRadius;
54  fRotation = cp.fRotation;
55  return *this;
56  }
57 
58  void SetOrigin(TPZVec<REAL> &origin, REAL radius)
59  {
60  fOrigin = origin;
61  fRadius = radius;
62  }
63 
65  void SetCylinderAxis(const TPZVec<REAL> &axis);
66 
69 
71  static std::string TypeName() { return "CylinderMap";}
72 
73  /* @brief Computes the coordinate of a point given in parameter space */
74  template<class T>
75  void X(const TPZGeoEl &gel,TPZVec<T> &loc,TPZVec<T> &result) const
76  {
77  TPZFNMatrix<3*TGeo::NNodes> coord(3,TGeo::NNodes);
78  CornerCoordinates(gel, coord);
79  X(coord,loc,result);
80  }
81 
82  template<class T>
83  void GradX(const TPZGeoEl &gel, TPZVec<T> &par, TPZFMatrix<T> &gradx) const
84  {
85 
86 
87  TPZFNMatrix<6,T> DxDphi(3,2,0.), gradphi(2,2), gradxloc(3,2);
88  TPZManVector<T,3> ft(2,0.);
89  TGeo::X(fCornerCo,par,ft);
90  TGeo::GradX(fCornerCo, par, gradphi);
91 
92  gradxloc(0,0) = -fRadius*sin(ft[0])*gradphi(0,0);
93  gradxloc(1,0) = fRadius*cos(ft[0])*gradphi(0,0);
94  gradxloc(2,0) = gradphi(1,0);
95  gradxloc(0,1) = -fRadius*sin(ft[0])*gradphi(0,1);
96  gradxloc(1,1) = fRadius*cos(ft[0])*gradphi(0,1);
97  gradxloc(2,1) = gradphi(1,1);
98 
99  for (int64_t i=0; i<3; i++) {
100  for (int64_t j=0; j<2; j++) {
101  gradx(i,j) = 0.;
102  for (int64_t k=0; k<3; k++) {
103  gradx(i,j) += fRotation.GetVal(k,i)*gradxloc(k,j);
104  }
105  }
106  }
107  }
108 
109  template<class T>
110  void X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &result) const
111  {
112  TPZManVector<T,2> localcylinder(2);
113  TGeo::X(this->fCornerCo,loc,localcylinder);
114  TPZManVector<T,3> localcartesian(3);
115 
116  localcartesian[0] = fRadius*cos(localcylinder[0]);
117  localcartesian[1] = fRadius*sin(localcylinder[0]);
118  localcartesian[2] = localcylinder[1];
119 
120  for (int64_t i=0; i<3; i++) {
121  result[i] = fOrigin[i];
122  for (int64_t j=0; j<3; j++) {
123  result[i] += fRotation.GetVal(j,i)*localcartesian[j];
124  }
125  }
126  }
127 
128 
129  // static TPZGeoEl *CreateBCGeoEl(TPZGeoEl *gel, int side,int bc);
130 
132  // static TPZGeoEl *CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
133  // TPZVec<int64_t>& nodeindexes,
134  // int matid,
135  // int64_t& index);
136 
137  void Read(TPZStream& buf, void* context) override
138  {
139  TGeo::Read(buf,0);
140  fCornerCo.Read(buf,0);
141  }
142 
143  void Write(TPZStream &buf, int withclassid) const override
144  {
145  TGeo::Write(buf, withclassid);
146  fCornerCo.Write(buf,0);
147  }
148 
149  static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size);
150 
151 
152  };
153 
154 };
155 
156 #endif /* TPZCylinder_hpp */
TPZCylinderMap & operator=(const TPZCylinderMap &cp)
Definition: TPZCylinder.h:48
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: pzfmatrix.h:789
TPZManVector< REAL, 3 > fOrigin
node around which we rotate the coordinates
Definition: TPZCylinder.h:24
TPZCylinderMap(TPZVec< int64_t > &nodeindices)
Definition: TPZCylinder.h:39
REAL fRadius
radius of the cylinder
Definition: TPZCylinder.h:27
static std::string TypeName()
Returns the type name of the element.
Definition: TPZCylinder.h:71
void X(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZVec< T > &result) const
Definition: TPZCylinder.h:110
virtual void Identity()
Converts the matrix in an identity matrix.
Definition: pzmatrix.cpp:199
void SetCylinderAxis(const TPZVec< REAL > &axis)
axis direction with the vertical axis
Definition: TPZCylinder.cpp:15
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)
void X(const TPZGeoEl &gel, TPZVec< T > &loc, TPZVec< T > &result) const
Definition: TPZCylinder.h:75
void Read(TPZStream &buf, void *context) override
Creates a geometric element according to the type of the father element.
Definition: TPZCylinder.h:137
void SetOrigin(TPZVec< REAL > &origin, REAL radius)
Definition: TPZCylinder.h:58
TPZFNMatrix< 9, REAL > fRotation
rotation matrix
Definition: TPZCylinder.h:30
sin
Definition: fadfunc.h:63
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pzfmatrix.h:783
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
TPZFNMatrix< TGeo::NNodes *3, REAL > fCornerCo
corner coordinates in cylindrical system (theta, z)
Definition: TPZCylinder.h:21
TPZCylinderMap(const TPZCylinderMap &cp)
Definition: TPZCylinder.h:44
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
void GradX(const TPZGeoEl &gel, TPZVec< T > &par, TPZFMatrix< T > &gradx) const
Definition: TPZCylinder.h:83
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
void Write(TPZStream &buf, int withclassid) const override
Definition: TPZCylinder.h:143
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
TPZFlopCounter cos(const TPZFlopCounter &orig)
Returns the cosine in radians and increments the counter of the Cosine.
Definition: pzreal.h:514
void ComputeCornerCoordinates(TPZGeoMesh &gmesh)
compute the corner coordinates of the corner nodes
Definition: TPZCylinder.cpp:40
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