NeoPZ
pzgradientreconstruction.h
Go to the documentation of this file.
1 //
2 // pzgradientreconstruction.h
3 // PZ
4 //
5 // Created by Agnaldo Farias on 4/10/13.
6 //
7 //
8 
9 #ifndef __PZ__pzgradientreconstruction__
10 #define __PZ__pzgradientreconstruction__
11 
12 #include <iostream>
13 
14 #include "pzcompel.h"
15 #include "pzvec.h"
16 #include "pzcmesh.h"
17 #include "tpzautopointer.h"
18 #include "pzfunction.h"
19 
21 {
22 
23  /*
24  *@brief Class to calculate the gradient and slope limiter
25  */
27  {
28  public:
29  /*
30  *@param cel: computational element to reconstruct the gradient
31  *@param useweight [in]: if true indicates the choice of using weights in the distorted mesh
32  *@param paramk[in]: value equal 1 or 2
33  */
35 
37 
39 
41 
42  void SetCel(TPZCompEl *cel, bool useweight, REAL paramK);
43 
44 
45 // struct TNeighcell
46 // {
47 // int fIsBoundary;
48 // STATE fNeighSol;
49 // TPZManVector<REAL,3> fCenterNeighbour;
50 // TPZManVector<REAL,3> fCenterInterface;
51 // };
52 //
53 // TPZStack<TNeighcell> fData;
54 
55  void Print(std::ostream &out) const;
56 
57  void GetCenterPointAndCellAveraged(TPZCompEl *cel, TPZManVector<REAL,3> &xcenter, STATE &solcel);
58 
59  void InitializeGradData(TPZCompEl *cel);
60 
61  /*
62  *@brief Method to reconstruction gradient by Least Squares and apply the slope limiter
63  */
64  void ComputeGradient();
65 
67 
71  //para problema linear
72  void ComputeSlopeLimiter();
73 
74  //para problema linear
75  void ComputeSlopeLimiter2();
76 
77  //Para problema nao-linear
78  void ComputeSlopeLimiter3();
79 
83  void ComputeWeights(REAL paramk);
84 
90 
95  void InsertWeights(TPZFMatrix<REAL> &DeltaH, TPZFMatrix<REAL> &DifSol);
96 
97 
98  /*
99  *@brief Returns data from the computational element K (K cell)
100  */
101  void GetData(TPZManVector<REAL,3> &centerPoint, TPZManVector<STATE,3> &grad, STATE &cellAverage, STATE &slopeLimiter)
102  {
103  centerPoint = fCenterPointCellAndNeighbors[0];
104  grad = fGradient;
105  cellAverage = fSolCellAndNeighbors[0];
106  slopeLimiter = fSlopeLimiter;
107  }
108 
111 
117  {
118  fForcingFunctionExact = fp;
119  }
120 
122 
124  fUseForcinfFuncion=true;
125  }
127  fUseForcinfFuncion=false;
128  }
130  if(fUseForcinfFuncion){
131  return (fForcingFunctionExact != 0);
132  }
133  else{
134  fForcingFunctionExact = 0;
135  return 0;
136  }
137  }
138 
140 
141  fGhostNeighbor = true;
142 
143  fLxLyLz = LxLyLz;
144  fMatIdBC = MatIdBC;
145  fcoordminBC = coordmin;
146  fcoordmaxBC = coordmax;
147  }
148 
153  void CreateGhostsNeighbors(TPZCompEl *cel);
154 
155 
156  protected:
157 
160 
163 
166 
169 
172 
174  int fdim;
175 
178 
181 
184 
186  REAL fparamK;
187 
188 
189  //parameter the ghosts neighbors
192 
204  };
205 
206 public:
207 
208  /*
209  *@param distmesh: Parameter indicates if the mesh is distorted
210  *@param param: parameter used in the harmonic, equal 1 or 2, to calculate the weights
211  */
212  TPZGradientReconstruction(bool distmesh, REAL paramK);
213 
215 
217 
219 
220 
221  /*
222  *@brief Method to replace the solution by finite element method from the reconstruction of the gradient.
223  *Using the L2 projection
224  *@param cmesh [in]: Computational mesh
225  *@param datagradients [in]: Matrix of data about gradient in each element.
226  *@param matidl2proj [in]: Id of the l2 projection material
227  */
228  void ProjectionL2GradientReconstructed(TPZCompMesh *cmesh, int matidl2proj);
229 
230  //change material id current to material id of the L2Projection
231  void ChangeMaterialIdIntoCompElement(TPZCompEl *cel, int oldmatid, int newmatid);
232 
233  //assemble pos l2 projection
235 
236  void GetDataDistortedMesh(bool &useweight, REAL &paramK){
237  useweight = fDistortedMesh;
238  paramK = fparam;
239  }
240 
241  /*
242  *@brief Method to insert the data of the boundaries (No flux) that there are ghosts neighbors.
243  *@param LxLyLz [in]: Dimension of the domain: Lx X Ly X Lz
244  *@param MatIdBC [in]: Indices of the Neumann type boundary conditions (No flux).
245  *@param coordmin [in]: The minimum coordinate for each boundary (xmin,ymin,zmin).
246  *@param coordmax [in]: The maximum coordinate for each boundary (xmax,ymax,zmax).
247  */
248  void SetDataGhostsNeighbors(TPZVec<REAL> LxLyLz, TPZVec<int> MatIdBC, TPZManVector< TPZVec<REAL> > coordmin, TPZManVector< TPZVec<REAL> > coordmax);
249 
251 
252 protected:
253 
256 
258  REAL fparam;
259 };
260 
261 #endif /* defined(__PZ__pzgradientreconstruction__) */
void ProjectionL2GradientReconstructed(TPZCompMesh *cmesh, int matidl2proj)
TPZStack< TPZManVector< REAL, 3 > > fCenterPointCellAndNeighbors
void GetCenterPointAndCellAveraged(TPZCompEl *cel, TPZManVector< REAL, 3 > &xcenter, STATE &solcel)
void CreateGhostsNeighbors(TPZCompEl *cel)
Method to create ghosts neighbors of the element cel. This method is used only for regular domain...
Contains declaration of TPZCompEl class which defines the interface of a computational element...
Templated vector implementation.
void NodeCloserCenterX(TPZManVector< REAL, 3 > &nodecelX)
Method to choose the node of the cell closer of your center point.
void SetForcingFunctionExact(TPZAutoPointer< TPZFunction< STATE > > fp)
Sets a procedure as exact solution for the problem.
TPZAutoPointer< TPZFunction< STATE > > fForcingFunctionExact
Pointer to exact solution function, needed to calculate exact error.
void ComputeSlopeLimiter()
Methods to calculate the slope limiter (alphaK)
void QRFactorization(TPZFMatrix< REAL > &matA, TPZFMatrix< REAL > &vecb)
void UseGhostsNeighbors(TPZVec< REAL > LxLyLz, TPZVec< int > MatIdBC, TPZManVector< TPZVec< REAL > > coordmin, TPZManVector< TPZVec< REAL > > coordmax)
void ChangeMaterialIdIntoCompElement(TPZCompEl *cel, int oldmatid, int newmatid)
void GetData(TPZManVector< REAL, 3 > &centerPoint, TPZManVector< STATE, 3 > &grad, STATE &cellAverage, STATE &slopeLimiter)
TPZGradientData & operator=(const TPZGradientData &copy)
void ComputeWeights(REAL paramk)
Method to calculate the weights that we will use in distorted meshes.
void GetDataDistortedMesh(bool &useweight, REAL &paramK)
void InsertWeights(TPZFMatrix< REAL > &DeltaH, TPZFMatrix< REAL > &DifSol)
Method to insert the weights in the matrices of the system by least squares.
Contains declaration of the TPZAutoPointer class which has Increment and Decrement actions are mutexe...
Contains declaration of TPZCompMesh class which is a repository for computational elements...
This class associates an element matrix with the coeficients of its contribution in the global stiffn...
Definition: pzelmat.h:30
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
void SetCel(TPZCompEl *cel, bool useweight, REAL paramK)
void SetDataGhostsNeighbors(TPZVec< REAL > LxLyLz, TPZVec< int > MatIdBC, TPZManVector< TPZVec< REAL > > coordmin, TPZManVector< TPZVec< REAL > > coordmax)
TPZStack< TPZManVector< REAL, 3 > > fCenterPointInterface
void AssembleGlobalMatrix(TPZCompEl *el, TPZElementMatrix &ek, TPZElementMatrix &ef, TPZMatrix< STATE > &stiffmatrix, TPZFMatrix< STATE > &rhs)
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
TPZGradientReconstruction(bool distmesh, REAL paramK)
This class implements a reference counter mechanism to administer a dynamically allocated object...