NeoPZ
tpzarc3d.h
Go to the documentation of this file.
1 
6 #ifndef TPZARC3D_H
7 #define TPZARC3D_H
8 
9 #include "pzgeoel.h"
10 #include "pznoderep.h"
11 #include "tpzline.h"
12 #include "tpzgeoelrefpattern.h"
13 #include "tpzgeomid.h"
14 
15 #include <iostream>
16 
17 namespace pzgeom
18 {
19 
26  class TPZArc3D : public pzgeom::TPZNodeRep<3,pztopology::TPZLine> {
27 
28  public:
31  enum {NNodes = 3};
32 
34  TPZArc3D(const TPZArc3D &cp,std::map<int64_t,int64_t> & gl2lcNdMap) :
36  pzgeom::TPZNodeRep<NNodes,pztopology::TPZLine>(cp,gl2lcNdMap){
37  this->fICnBase = cp.fICnBase;
38  this->fIBaseCn = cp.fIBaseCn;
39  this->fCenter3D = cp.fCenter3D;
40  this->finitialVector = cp.finitialVector;
41 
42  this->fRadius = cp.fRadius;
43  this->fAngle = cp.fAngle;
44  this->fXcenter = cp.fXcenter;
45  this->fYcenter = cp.fYcenter;
46  }
47  /*
48  TPZFNMatrix<9> fICnBase, fIBaseCn;
49  TPZManVector< REAL,3 > fCenter3D, finitialVector;
50 #ifdef REALpzfpcounter
51  double fAngle, fRadius, fXcenter, fYcenter;
52 #else
53  REAL fAngle, fRadius, fXcenter, fYcenter;
54 #endif
55 */
59  fAngle(0.), fRadius(0.), fXcenter(0.), fYcenter(0.) {
60  }
64  this->fICnBase = cp.fICnBase;
65  this->fIBaseCn = cp.fIBaseCn;
66  this->fCenter3D = cp.fCenter3D;
67  this->finitialVector = cp.finitialVector;
68  this->fRadius = cp.fRadius;
69  this->fAngle = cp.fAngle;
70  this->fXcenter = cp.fXcenter;
71  this->fYcenter = cp.fYcenter;
72  }
73 
76  {
78  this->fICnBase = cp.fICnBase;
79  this->fIBaseCn = cp.fIBaseCn;
80  this->fCenter3D = cp.fCenter3D;
81  this->finitialVector = cp.finitialVector;
82  this->fRadius = cp.fRadius;
83  this->fAngle = cp.fAngle;
84  this->fXcenter = cp.fXcenter;
85  this->fYcenter = cp.fYcenter;
86  return *this;
87  }
88 
92  this->fICnBase = cp.fICnBase;
93  this->fIBaseCn = cp.fIBaseCn;
94  this->fCenter3D = cp.fCenter3D;
95  this->finitialVector = cp.finitialVector;
96  this->fRadius = cp.fRadius;
97  this->fAngle = cp.fAngle;
98  this->fXcenter = cp.fXcenter;
99  this->fYcenter = cp.fYcenter;
100  }
101 
103  pzgeom::TPZNodeRep<NNodes,pztopology::TPZLine>(nodeindexes), fICnBase(3,3), fIBaseCn(3,3), fCenter3D(3,0.), finitialVector(3,0.),
104  fAngle(0.), fRadius(0.), fXcenter(0.), fYcenter(0.) {
105  int64_t nnod = nodeindexes.NElements();
106  if(nnod != 3)
107  {
108  std::cout << "Arc geometry created with " << nnod << " nodes, bailing out\n";
109  DebugStop();
110  }
111  }
112 
114  fAngle(0.), fRadius(0.), fXcenter(0.), fYcenter(0.){
115  ComputeAtributes(coord);
116  }
117 
119  void Initialize(TPZGeoEl *refel)
120  {
121  int nnod = 3;
122  TPZFNMatrix<9,REAL> coord(3,nnod);
123  int nod, co;
124  for(nod=0; nod<3; nod++)
125  {
126  for(co=0; co<3; co++)
127  {
128  coord(co,nod) = refel->NodePtr(nod)->Coord(co);
129  }
130  }
131  ComputeAtributes(coord);
132  }
133 
134  template<class T>
135  void X(TPZFMatrix<REAL> &coord,TPZVec<T> &loc,TPZVec<T> &result) const
136  {
138  TPZManVector<T,3> MappedBASE2D(3,0.);
139 
140  TPZFNMatrix<4,T> RotMatrix(2,2);
141  T deflection = fAngle * fRadius * (loc[0] + 1.) / (2.*fRadius);
142  RotMatrix(0,0) = cos(deflection); RotMatrix(0,1) = sin(deflection);
143  RotMatrix(1,0) = -sin(deflection); RotMatrix(1,1) = cos(deflection);
144 
146  T centerCoord, vectRotated = 0.;
147  for(int i = 0; i < 2; i++)
148  {
149  vectRotated = 0.;
150  for(int j = 0; j < 2; j++) vectRotated += RotMatrix(i,j)*finitialVector[j];
151  centerCoord = (1-i)*fXcenter + i*fYcenter;
152  MappedBASE2D[i] = centerCoord + vectRotated;
153  }
154 
156  MappedBASE2D[2] = 0.;
157  for(int i = 0; i < 3; i++)
158  {
159  vectRotated = 0.;
160  for(int j = 0; j < 3; j++)
161  {
162  vectRotated += fIBaseCn.GetVal(i,j)*MappedBASE2D[j];
163  }
164  result[i] = vectRotated + coord(i,2);
165  }
166 
167  }
168 // void Jacobian(TPZFMatrix<REAL> &coord, TPZVec<REAL> &par, TPZFMatrix<REAL> &jacobian, TPZFMatrix<REAL> &axes, REAL &detjac, TPZFMatrix<REAL> &jacinv) const;
169 
170 // template<class T>
171 // void X(const TPZGeoEl &gel,TPZVec<T> &loc,TPZVec<T> &result) const
172 // {
173 // TPZFNMatrix<3*NNodes> coord(3,NNodes);
174 // CornerCoordinates(gel, coord);
175 // X(coord,loc,result);
176 // }
177 
178  template<class T>
179  void GradX(TPZFMatrix<REAL> &coord, TPZVec<T> &par, TPZFMatrix<T> &gradx) const
180  {
181 
183  TPZManVector< T > Vpc(3), Vpa(3), Vpb(3), Vt(3), OUTv(3);
184 
185  TPZManVector< T > middle(1, 0.);
186  X(coord,middle,OUTv);
187 
189  Vpa[0] = coord(0,0) - OUTv[0]; Vpa[1] = coord(1,0) - OUTv[1]; Vpa[2] = coord(2,0) - OUTv[2];
190 
192  Vpb[0] = coord(0,1) - OUTv[0]; Vpb[1] = coord(1,1) - OUTv[1]; Vpb[2] = coord(2,1) - OUTv[2];
193 
194  X(coord,par,OUTv);
195 
197  Vpc[0] = fCenter3D[0] - OUTv[0]; Vpc[1] = fCenter3D[1] - OUTv[1]; Vpc[2] = fCenter3D[2] - OUTv[2];
198 
200  gradx(0) = Vpa[1]*Vpb[0]*Vpc[1] - Vpa[0]*Vpb[1]*Vpc[1] + Vpa[2]*Vpb[0]*Vpc[2] - Vpa[0]*Vpb[2]*Vpc[2];
201  gradx(1) = -Vpa[1]*Vpb[0]*Vpc[0] + Vpa[0]*Vpb[1]*Vpc[0] + Vpa[2]*Vpb[1]*Vpc[2] - Vpa[1]*Vpb[2]*Vpc[2];
202  gradx(2) = -Vpa[2]*Vpb[0]*Vpc[0] + Vpa[0]*Vpb[2]*Vpc[0] - Vpa[2]*Vpb[1]*Vpc[1] + Vpa[1]*Vpb[2]*Vpc[1];
203 
204  T Vtnorm = 0.;
205  for(int i = 0; i < 3; i++)
206  {
207  if( fabs(Vt[i]) < 1.E-12 ) Vt[i] = 0.;
208  Vtnorm += gradx(i)*gradx(i);
209  }
210  if(Vtnorm < 0.) DebugStop();
211 // if(sqrt(Vtnorm) < 1e-16) DebugStop();
212  T scale = fAngle*fRadius/(2.*sqrt(Vtnorm));
213  for(int j = 0; j < 3; j++) gradx(j) = gradx(j)*scale;
214 
215  }
216 
217 // void Jacobian(const TPZGeoEl &gel,TPZVec<REAL> &param,TPZFMatrix<REAL> &jacobian,TPZFMatrix<REAL> &axes,REAL &detjac,TPZFMatrix<REAL> &jacinv) const
218 // {
219 // TPZFNMatrix<3*NNodes> coord(3,NNodes);
220 // CornerCoordinates(gel, coord);
221 // Jacobian(coord, param, jacobian, axes, detjac, jacinv);
222 // }
223 
224 
225  static std::string TypeName() { return "Linear";}
226 
227  static bool IsLinearMapping(int side)
228  {
229  return false;
230  }
231 
232  // static TPZGeoEl * CreateBCGeoEl(TPZGeoEl *orig, int side,int bc);
233 
234  public:
236  // static TPZGeoEl *CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
237  // TPZVec<int64_t>& nodeindexes,
238  // int matid,
239  // int64_t& index);
240  void Print(std::ostream &out) const
241  {
243  out << "fCenter3D " << fCenter3D << " finitialVector " << finitialVector << std::endl;
244  out << "fAngle " << fAngle << " fRadius " << fRadius << " fXcenter " << fXcenter << " fYcenter " << fYcenter << std::endl;
245  fICnBase.Print("fICnBase", out);
246  fIBaseCn.Print("fIBaseCn", out);
247  }
248 
249  void Read(TPZStream& buf, void* context) override
250  {
252  fICnBase.Read(buf,0);
253  fIBaseCn.Read(buf,0);
254  buf.Read<3>( fCenter3D);
255  buf.Read<3>(finitialVector);
256  buf.Read(&fAngle,1);
257  buf.Read(&fRadius,1);
258  buf.Read(&fXcenter,1);
259  buf.Read(&fYcenter,1);
260  }
261 
262  void Write(TPZStream &buf, int withclassid) const override
263  {
265  fICnBase.Write(buf,0);
266  fIBaseCn.Write(buf,0);
267  buf.Write( fCenter3D);
268  buf.Write(finitialVector);
269  buf.Write(&fAngle,1);
270  buf.Write(&fRadius,1);
271  buf.Write(&fXcenter,1);
272  buf.Write(&fYcenter,1);
273  }
274 
275  //virtual void ParametricDomainNodeCoord(int node, TPZVec<REAL> &nodeCoord);
276  public:
277 int ClassId() const override;
278  public:
279  static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size);
280 
281 
282  protected:
283 
284  void ComputeAtributes(TPZFMatrix<REAL> &coord);
285  void ComputeR2Points(TPZFMatrix<REAL> &coord, double &xa, double &ya, double &xb, double &yb);
286  double ArcAngle(TPZFMatrix<REAL> &coord, double xa, double ya, double xb, double yb) const;
287 
295 #ifdef REALpzfpcounter
296  double fAngle, fRadius, fXcenter, fYcenter;
297 #else
299 #endif
300 
302  };
303 
304 };
305 
306 #endif
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
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
Definition: tfadfunc.h:140
TPZGeoNode * NodePtr(int i) const
Returns a pointer to the ith node of the element.
Definition: pzgeoel.cpp:2566
TPZArc3D & operator=(const TPZArc3D &cp)
Copy constructor.
Definition: tpzarc3d.h:75
void Read(TPZStream &buf, void *context) override
Definition: pznoderep.h:97
Implements a line. Utility.
Definition: pzline.h:18
void Print(std::ostream &out) const
Creates a geometric element according to the type of the father element.
Definition: tpzarc3d.h:240
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: tpzarc3d.h:262
REAL Coord(int i) const
Returns i-th coordinate of the current node.
Definition: pzgnode.h:99
void X(TPZFMatrix< REAL > &coord, TPZVec< T > &loc, TPZVec< T > &result) const
Definition: tpzarc3d.h:135
double ArcAngle(TPZFMatrix< REAL > &coord, double xa, double ya, double xb, double yb) const
Definition: tpzarc3d.cpp:187
TPZManVector< REAL, 3 > finitialVector
Definition: tpzarc3d.h:294
void ComputeR2Points(TPZFMatrix< REAL > &coord, double &xa, double &ya, double &xb, double &yb)
Definition: tpzarc3d.cpp:161
int ClassId() const override
Define the class id associated with the class.
Definition: tpzarc3d.cpp:393
TPZArc3D()
Default constructor.
Definition: tpzarc3d.h:57
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)
Definition: tpzarc3d.cpp:339
sin
Definition: fadfunc.h:63
Groups all classes defining the structure of the master element.
Definition: PrismExtend.cpp:15
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pzfmatrix.h:783
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
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
TPZManVector< REAL, 3 > fCenter3D
Definition: tpzarc3d.h:294
Contains the TPZNodeRep class which implements ... Clase intermediaria que guarda.
static std::string TypeName()
Definition: tpzarc3d.h:225
void GradX(TPZFMatrix< REAL > &coord, TPZVec< T > &par, TPZFMatrix< T > &gradx) const
Definition: tpzarc3d.h:179
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
Definition: tfadfunc.h:120
Contains declaration of TPZGeoElRefPattern class which implements a generic geometric element which i...
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: tpzarc3d.h:249
void ComputeAtributes(TPZFMatrix< REAL > &coord)
Definition: tpzarc3d.cpp:25
REAL co[8][3]
Coordinates of the eight nodes.
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
TPZArc3D(const TPZArc3D &cp)
Copy constructor.
Definition: tpzarc3d.h:62
TPZArc3D(const TPZArc3D &cp, std::map< int64_t, int64_t > &gl2lcNdMap)
Copy constructor with map of nodes.
Definition: tpzarc3d.h:34
void Initialize(TPZGeoEl *refel)
Initialize the internal data structure of the arc using the coordinates of the nodes.
Definition: tpzarc3d.h:119
TPZArc3D(const TPZArc3D &cp, TPZGeoMesh &)
Another copy constructor.
Definition: tpzarc3d.h:90
TPZFNMatrix< 9 > fICnBase
Definition: tpzarc3d.h:293
Implements three dimensional arc. Geometry.
Definition: tpzarc3d.h:26
void Write(TPZStream &buf, int withclassid) const override
Definition: pznoderep.h:102
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
TPZFNMatrix< 9 > fIBaseCn
Definition: tpzarc3d.h:293
void Print(std::ostream &out) const
Definition: pznoderep.h:133
static bool IsLinearMapping(int side)
Definition: tpzarc3d.h:227
virtual void Print(std::ostream &out) const
Definition: pzmatrix.h:253
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
Contains the TPZLine class which defines the topology of a line element.
TPZArc3D(TPZVec< int64_t > &nodeindexes)
Definition: tpzarc3d.h:102
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
pztopology::TPZLine Top
Definition: tpzarc3d.h:29
TPZFlopCounter cos(const TPZFlopCounter &orig)
Returns the cosine in radians and increments the counter of the Cosine.
Definition: pzreal.h:514
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
TPZArc3D(TPZFMatrix< REAL > &coord)
Definition: tpzarc3d.h:113
virtual void Read(bool &val)
Definition: TPZStream.cpp:91