NeoPZ
TPZWavyLine.h
Go to the documentation of this file.
1 //
2 // TPZWavyLine.h
3 // PZ
4 //
5 // Created by Philippe Devloo on 3/21/14.
6 //
7 //
8 
9 #ifndef __PZ__TPZWavyLine__
10 #define __PZ__TPZWavyLine__
11 
12 #include <iostream>
13 #include "TPZGeoLinear.h"
14 
15 namespace pzgeom {
16 
17  class TPZWavyLine : public TPZGeoLinear
18  {
19  int fNumWaves;
21 
22  public:
23 
24  int ClassId() const override;
25 
26 
29  TPZGeoLinear(nodeindexes), fNumWaves(0), fWaveDir()
30  {
31  }
32 
35  TPZGeoLinear(), fNumWaves(0), fWaveDir()
36  {
37  }
38 
41  std::map<int64_t,int64_t> & gl2lcNdMap) : TPZRegisterClassId(&TPZWavyLine::ClassId),
42  TPZGeoLinear(cp,gl2lcNdMap), fNumWaves(cp.fNumWaves), fWaveDir(cp.fWaveDir)
43  {
44  }
45 
48  TPZGeoLinear(cp), fNumWaves(cp.fNumWaves), fWaveDir(cp.fWaveDir)
49  {
50  }
51 
54  TPZGeoLinear(cp), fNumWaves(cp.fNumWaves), fWaveDir(cp.fWaveDir)
55  {
56  }
57 
58  void SetData(TPZVec<REAL> &wavedir, int numwaves)
59  {
60 #ifdef PZDEBUG
61  if (wavedir.size() != 3) {
62  DebugStop();
63  }
64 #endif
65  fWaveDir = wavedir;
66  fNumWaves = numwaves;
67  }
68 
69  static bool IsLinearMapping(int side)
70  {
71  return false;
72  }
73 
75  static std::string TypeName() { return "Wavy";}
76 
77  /* @brief Computes the coordinate of a point given in parameter space */
78 // template<class T>
79 // void X(const TPZGeoEl &gel,TPZVec<T> &loc,TPZVec<T> &result) const
80 // {
81 // TPZFNMatrix<3*NNodes> coord(3,NNodes);
82 // CornerCoordinates(gel, coord);
83 // X(coord,loc,result);
84 // }
85 
86 // template<class T>
87 // void GradX(const TPZGeoEl &gel, TPZVec<T> &par, TPZFMatrix<T> &gradx) const
88 // {
89 // gradx.Resize(3,1);
90 // gradx.Zero();
91 // TPZFNMatrix<3*NNodes> coord(3,NNodes);
92 // CornerCoordinates(gel, coord);
93 // T cosval = cos(fNumWaves*M_PI*par[0]);
94 // for (int i=0; i<3; i++) {
95 // gradx(i) = (coord(i,1)-coord(i,0))/2. + fNumWaves*M_PI*cosval*fWaveDir[i];
96 // }
97 // }
98  template<class T>
99  void GradX(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc, TPZFMatrix<T> &gradx) const {
100 
101  int nrow = nodes.Rows();
102  int ncol = nodes.Cols();
103 
104  gradx.Resize(nrow,1);
105  gradx.Zero();
106 
107  T cosval = cos(fNumWaves*M_PI*loc[0]);
108  for (int i=0; i<3; i++) {
109  gradx(i) = (nodes.GetVal(i,1)-nodes.GetVal(i,0))/2. + fNumWaves*M_PI*cosval*fWaveDir[i];
110  }
111 
112  }
113  /* @brief Computes the jacobian of the map between the master element and deformed element */
114 // void Jacobian(const TPZGeoEl &gel,TPZVec<REAL> &param,TPZFMatrix<REAL> &jacobian,TPZFMatrix<REAL> &axes,REAL &detjac,TPZFMatrix<REAL> &jacinv) const
115 // {
116 // jacobian.Resize(1,1); axes.Resize(1,3); jacinv.Resize(1,1);
117 // TPZFNMatrix<3*NNodes> coord(3,NNodes);
118 // TPZManVector<REAL,3> gradx(3);
119 // CornerCoordinates(gel, coord);
120 // REAL cosval = cos(fNumWaves*M_PI*param[0]);
121 // for (int i=0; i<3; i++) {
122 // gradx[i] = (coord(i,1)-coord(i,0))/2. + fNumWaves*M_PI*cosval*fWaveDir[i];
123 // }
124 // REAL normv = 0.;
125 // for (int i=0; i<3; i++) {
126 // normv += gradx[i]*gradx[i];
127 // }
128 // normv = sqrt(normv);
129 // jacobian(0,0) = normv;
130 // detjac = normv;
131 // jacinv(0,0) = 1./normv;
132 // for (int i=0; i<3; i++) {
133 // axes(0,i) = gradx[i]/normv;
134 // }
135 // }
136 
137  template<class T>
138  void X(const TPZFMatrix<REAL> &nodes,TPZVec<T> &loc,TPZVec<T> &result) const
139  {
140  TPZGeoLinear::X(nodes,loc,result);
141  T sinval = sin(this->fNumWaves*M_PI*loc[0]);
142 
143  for (int i=0; i<3; i++) {
144  result[i] += this->fWaveDir[i]*sinval;
145  }
146 
147  }
148 
149 
150  // static TPZGeoEl *CreateBCGeoEl(TPZGeoEl *gel, int side,int bc);
151 
152  // /** @brief Creates a geometric element according to the type of the father element */
153  // static TPZGeoEl *CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
154  // TPZVec<int64_t>& nodeindexes,
155  // int matid,
156  // int64_t& index);
157 
158  void Read(TPZStream& buf, void* context) override {
160  buf.Read(&fNumWaves,1);
161  buf.Read<3>( fWaveDir);
162  }
163 
164  void Write(TPZStream &buf, int withclassid) const override{
165  pzgeom::TPZGeoLinear::Write(buf, withclassid);
166  buf.Write(&fNumWaves,1);
167  buf.Write( fWaveDir);
168  }
169 
170  static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size);
171 
172 
173  };
174 
175 
176 }
177 
178 #endif /* defined(__PZ__TPZWavyLine__) */
void Read(TPZStream &buf, void *context) override
read objects from the stream
TPZWavyLine(const TPZWavyLine &cp, TPZGeoMesh &)
Copy constructor.
Definition: TPZWavyLine.h:53
void X(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZVec< T > &result) const
Definition: TPZWavyLine.h:138
static std::string TypeName()
Returns the type name of the element.
Definition: TPZWavyLine.h:75
void Read(TPZStream &buf, void *context) override
Creates a geometric element according to the type of the father element.
Definition: TPZWavyLine.h:158
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)
Definition: TPZWavyLine.cpp:59
int ClassId() const override
Creates a geometric element according to the type of the father element.
Definition: TPZWavyLine.cpp:55
TPZWavyLine()
Empty constructor.
Definition: TPZWavyLine.h:34
TPZManVector< REAL, 3 > fWaveDir
Definition: TPZWavyLine.h:20
Implements the geometry of a one dimensional linear element. Geometry.
Definition: TPZGeoLinear.h:30
static bool IsLinearMapping(int side)
Definition: TPZWavyLine.h:69
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: TPZWavyLine.h:164
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
sin
Definition: fadfunc.h:63
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
void SetData(TPZVec< REAL > &wavedir, int numwaves)
Definition: TPZWavyLine.h:58
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
TPZWavyLine(TPZVec< int64_t > &nodeindexes)
Constructor with list of nodes.
Definition: TPZWavyLine.h:28
void GradX(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZFMatrix< T > &gradx) const
Definition: TPZWavyLine.h:99
TPZWavyLine(const TPZWavyLine &cp, std::map< int64_t, int64_t > &gl2lcNdMap)
Constructor with node map.
Definition: TPZWavyLine.h:40
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
static void X(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZVec< T > &x)
Compute X mapping from element nodes and local parametric coordinates.
Definition: TPZGeoLinear.h:119
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
Definition: pzfmatrix.cpp:1016
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
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
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
TPZWavyLine(const TPZWavyLine &cp)
Copy constructor.
Definition: TPZWavyLine.h:47
virtual void Read(bool &val)
Definition: TPZStream.cpp:91