NeoPZ
TPZTriangleTorus.h
Go to the documentation of this file.
1 //
2 // TPZTriangleTorus.h
3 // PZ
4 //
5 // Created by Philippe Devloo on 3/21/14.
6 //
7 //
8 
9 #ifndef __PZ__TPZTriangleTorus__
10 #define __PZ__TPZTriangleTorus__
11 
12 #include <iostream>
13 #include "pzgeotriangle.h"
14 
15 namespace pzgeom {
16 
18  {
19  REAL fR = 0;
20  REAL fr = 0;
21 
23 
25 
26  public:
27 
28  public:
29 int ClassId() const override;
30 
31 
33  TPZTriangleTorus(TPZVec<int64_t> &nodeindexes) : TPZGeoTriangle(nodeindexes), fR(0), fr(0), fOrigin(3,0), fPhiTheta(2,3,0.)
34  {
35  }
36 
38  TPZTriangleTorus() : TPZGeoTriangle(), fR(0), fr(0), fOrigin(3,0), fPhiTheta(2,3,0.)
39  {
40  }
41 
44  std::map<int64_t,int64_t> & gl2lcNdMap) : TPZGeoTriangle(cp,gl2lcNdMap), fR(cp.fR), fr(cp.fr), fOrigin(cp.fOrigin), fPhiTheta(cp.fPhiTheta)
45  {
46  }
47 
49  TPZTriangleTorus(const TPZTriangleTorus &cp) : TPZGeoTriangle(cp), fR(cp.fR), fr(cp.fr), fOrigin(cp.fOrigin), fPhiTheta(cp.fPhiTheta)
50  {
51  }
52 
54  TPZTriangleTorus(const TPZTriangleTorus &cp, TPZGeoMesh &) : TPZGeoTriangle(cp), fR(cp.fR), fr(cp.fr), fOrigin(cp.fOrigin), fPhiTheta(cp.fPhiTheta)
55  {
56  }
57 
59  {
60  TPZGeoTriangle::operator=(cp);
61  fR = cp.fR;
62  fr = cp.fr;
63  fOrigin = cp.fOrigin;
64  fPhiTheta = cp.fPhiTheta;
65  return *this;
66  }
67 
68  void SetDataPhiTheta(const TPZFMatrix<REAL> &phitheta)
69  {
70 #ifdef PZDEBUG
71  if (phitheta.Rows() != 2 || phitheta.Cols() != 3) {
72  DebugStop();
73  }
74 #endif
75  fPhiTheta = phitheta;
76  }
77 
78  void SetDataRadius(const REAL &R, const REAL &r)
79  {
80 #ifdef PZDEBUG
81  if (R < r)
82  {
83  DebugStop();
84  }
85 #endif
86  fR = R;
87  fr = r;
88  }
89 
90  void SetOrigin(TPZVec<REAL> &origin)
91  {
92  fOrigin = origin;
93  }
94 
95 
96 
98  static std::string TypeName() { return "Wavy";}
99 
100  /* @brief Computes the coordinate of a point given in parameter space */
101  template<class T>
102  void X(TPZFMatrix<REAL> &coord,TPZVec<T> &loc,TPZVec<T> &result) const
103  {
104  TPZGeoTriangle::X(this->fPhiTheta,loc,result);
105  TPZVec <T> toro(3,0.0);
106 
107  toro[0] = (fR + fr*cos(result[0]))*cos(result[1]);
108  toro[1] = (fR + fr*cos(result[0]))*sin(result[1]);
109  toro[2] = fr*sin(result[0]);
110  result=toro;
111  }
112 
113  template<class T>
115  {
116  TPZFNMatrix<6,T> DxDphi(3,2,0.), gradphi(2,2);
117  TPZManVector<T,3> ft(3,0.);
118  TPZGeoTriangle::X(fPhiTheta,par,ft);
119  TPZGeoTriangle::GradX(fPhiTheta, par, gradphi);
120 
121  DxDphi(0,0) = -cos(ft[1]) * sin(ft[0]);
122  DxDphi(0,1) = -(3. + cos(ft[0])) * sin(ft[1]);
123  DxDphi(1,0) = -sin(ft[1]) * sin(ft[0]);
124  DxDphi(1,1) = cos(ft[1]) * (3. + cos(ft[0]));
125  DxDphi(2,0) = cos(ft[0]);
126  DxDphi(2,1) = 0.;
127  DxDphi.Multiply(gradphi, gradx);
128 
129 
130  }
131 
132  /* @brief Computes the jacobian of the map between the master element and deformed element */
133 // void Jacobian(const TPZGeoEl &gel,TPZVec<REAL> &param,TPZFMatrix<REAL> &jacobian,TPZFMatrix<REAL> &axes,REAL &detjac,TPZFMatrix<REAL> &jacinv) const
134 // {
135 // std::cout << __PRETTY_FUNCTION__ << "PLEASE IMPLEMENT ME!!!\n";
136 // DebugStop();
137 // //TPZGeoTriangle::Jacobian(gel, param, jacobian , axes, detjac, jacinv);
138 // }
139 
140  template<class T>
141  void X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &result) const
142  {
143 
144  TPZManVector<T,2> resloc(2);
145  TPZGeoTriangle::X(this->fPhiTheta,loc,resloc);
146 
147  result[0] = (fR + fr*cos(resloc[0]))*cos(resloc[1]);
148  result[1] = (fR + fr*cos(resloc[0]))*sin(resloc[1]);
149  result[2] = fr*sin(resloc[0]);
150 
151  }
152 
153 
154  // static TPZGeoEl *CreateBCGeoEl(TPZGeoEl *gel, int side,int bc);
155 
156  // /** @brief Creates a geometric element according to the type of the father element */
157  // static TPZGeoEl *CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
158  // TPZVec<int64_t>& nodeindexes,
159  // int matid,
160  // int64_t& index);
161 
162  void Read(TPZStream& buf, void* context) override
163  {
165  buf.Read(&fR);
166  buf.Read(&fr);
167  fPhiTheta.Read(buf,0);
168  }
169 
170  void Write(TPZStream &buf, int withclassid) const override
171  {
172  pzgeom::TPZGeoTriangle::Write(buf, withclassid);
173  buf.Write(&fR);
174  buf.Write(&fr);
175  fPhiTheta.Write(buf, 0);
176  }
177 
178  static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size);
179 
180 
181  };
182 
183 
184 }
185 
186 #endif /* defined(__PZ__TPZTriangleTorus__) */
void Read(TPZStream &buf, void *context) override
read objects from the stream
static REAL cornerco[8][3]
static std::string TypeName()
Returns the type name of the element.
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
static void X(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZVec< T > &x)
Definition: pzgeotriangle.h:79
TPZTriangleTorus(const TPZTriangleTorus &cp, std::map< int64_t, int64_t > &gl2lcNdMap)
Constructor with node map.
TPZTriangleTorus(const TPZTriangleTorus &cp)
Copy constructor.
void SetOrigin(TPZVec< REAL > &origin)
void SetDataRadius(const REAL &R, const REAL &r)
void X(TPZFMatrix< REAL > &coord, TPZVec< T > &loc, TPZVec< T > &result) const
TPZManVector< REAL > fOrigin
TPZTriangleTorus(const TPZTriangleTorus &cp, TPZGeoMesh &)
Copy constructor.
sin
Definition: fadfunc.h:63
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pzfmatrix.h:783
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
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.
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
TPZTriangleTorus & operator=(const TPZTriangleTorus &cp)
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
void GradX(TPZFMatrix< REAL > &cornerco, TPZVec< T > &par, TPZFMatrix< T > &gradx) const
TPZFNMatrix< 12, REAL > fPhiTheta
Implements the geometry of a triangle element. Geometry.
Definition: pzgeotriangle.h:28
void X(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZVec< T > &result) const
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
void SetDataPhiTheta(const TPZFMatrix< REAL > &phitheta)
void Read(TPZStream &buf, void *context) override
Creates a geometric element according to the type of the father element.
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
int ClassId() const override
Creates a geometric element according to the type of the father element.
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
TPZTriangleTorus()
Empty constructor.
TPZTriangleTorus(TPZVec< int64_t > &nodeindexes)
Constructor with list of nodes.
virtual void Read(bool &val)
Definition: TPZStream.cpp:91