NeoPZ
pzgradient.h
Go to the documentation of this file.
1 
6 #ifndef PZGRADIENTH
7 #define PZGRADIENTH
8 
9 #include "pzfunction.h"
10 
11 #include <iostream>
12 
13 
14 class TPZGradient : public TPZFunction<STATE>
15 {
16  //center of the element K
18 
19  //gradient estimate on the element K
21 
22  //cell averaged value
23  STATE fUc;
24 
25  //Slope limiter
26  STATE falphaK;
27 
28 public:
29  TPZGradient();
30 
31  TPZGradient(const TPZGradient &cp);
32 
34  }
35 
37  fCenter = copy.fCenter;
38  fGradient = copy.fGradient;
39  fUc = copy.fUc;
40  falphaK = copy.falphaK;
41  return *this;
42  }
43 
44  /*
45  *@brief Enter the data of the reconstruction gradient
46  *@param center value of the coordinate at the center of the element
47  *@param grad gradient reconstructed
48  *@param u0 value of the approximate solution (by FEM) at the center point (cell averaged)
49  *@param alphak: value of the slope limiter
50  */
51  void SetData(TPZManVector<REAL,3> &center, TPZManVector<STATE,3> &grad, STATE u0, STATE alphak){
52 
53  fCenter = center;
54  fGradient = grad;
55  fUc = u0;
56  falphaK = alphak;
57  }
58 
59  /*
60  *@brief fill the function used in the l2 projection
61  *@param pt points where the function is calculated
62  *@param f function projected into finite element space
63  */
64  virtual void Execute(const TPZVec<REAL> &pt, TPZVec<STATE> &f){
65 
66  int nr = fGradient.size();
67 
68  f[0] = fUc;
69  for(int i = 0; i<nr; i++)
70  {
71  f[0] += (STATE)(pt[i] - fCenter[i])*falphaK*fGradient[i];
72  }
73  }
74 
75  virtual void Execute(const TPZVec<REAL> &x, REAL ftime, TPZVec<STATE> &f, TPZFMatrix<STATE> &gradf){
76  DebugStop();
77  }
78 
80  virtual void Execute(const TPZVec<REAL> &x, const TPZFMatrix<REAL> &axes, TPZVec<STATE> &f, TPZFMatrix<STATE> &df){
81  DebugStop();
82  }
83 
90  virtual void Execute(const TPZVec<REAL> &x, TPZVec<STATE> &f, TPZFMatrix<STATE> &df) {
91  DebugStop();
92  }
93 
94 
96  virtual int NFunctions()const {return 1;}
97 
100  virtual int PolynomialOrder() const {return -1;}
101 
102  };
103 
104 #endif
virtual int NFunctions() const
Returns number of functions.
Definition: pzgradient.h:96
virtual void Execute(const TPZVec< REAL > &x, const TPZFMatrix< REAL > &axes, TPZVec< STATE > &f, TPZFMatrix< STATE > &df)
Execute method receiving axes. It is used in shape functions.
Definition: pzgradient.h:80
STATE fUc
Definition: pzgradient.h:23
TPZManVector< STATE, 3 > fGradient
Definition: pzgradient.h:20
Implements a function. Utility.
Definition: pzfunction.h:19
TPZGradient & operator=(const TPZGradient &copy)
Definition: pzgradient.h:36
virtual int PolynomialOrder() const
Polynomial order of this function.
Definition: pzgradient.h:100
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
f
Definition: test.py:287
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
void SetData(TPZManVector< REAL, 3 > &center, TPZManVector< STATE, 3 > &grad, STATE u0, STATE alphak)
Definition: pzgradient.h:51
STATE falphaK
Definition: pzgradient.h:26
virtual void Execute(const TPZVec< REAL > &pt, TPZVec< STATE > &f)
Simpler version of Execute method which does not compute function derivatives.
Definition: pzgradient.h:64
TPZManVector< REAL, 3 > fCenter
Definition: pzgradient.h:17
virtual void Execute(const TPZVec< REAL > &x, TPZVec< STATE > &f, TPZFMatrix< STATE > &df)
Performs function computation.
Definition: pzgradient.h:90
virtual void Execute(const TPZVec< REAL > &x, REAL ftime, TPZVec< STATE > &f, TPZFMatrix< STATE > &gradf)
Performs time dependent function computation.
Definition: pzgradient.h:75