NeoPZ
pzgradientflux.cpp
Go to the documentation of this file.
1 
6 #include "pzgradientflux.h"
7 #include "pzmaterialdata.h"
8 
10 
11 }
12 
14 
15 }
16 
18 
19 }
20 
22  const int nstate = 5;
23  const int dim = 3;
24  F.Resize(nstate*dim);
25  F.Fill(0.);
26  for(int i = 0; i < nstate; i++){
27  for(int id = 0; id < dim; id++){
28  F[i*dim+id] = 0.5*(solL[i]+solR[i])*normal[id];
29  }//for id
30  }//for i
31 }//void
32 
34  int numbersol = dataleft.sol.size();
35  if (numbersol != 1) {
36  DebugStop();
37  }
38 
39  const int nstate = 5;
40  const int dim = 3;
41  TPZManVector<STATE,dim> dL(dim), dR(dim);
42  for(int id = 0; id < dim; id++){
43  dL[id] = data.x[id] - dataleft.XCenter[id];
44  dR[id] = data.x[id] - dataright.XCenter[id];
45  }//for id
46 
47  TPZManVector<STATE,dim> gradL(3), gradR(3);
48  for(int is = 0; is < nstate; is++){
49  for(int id = 0; id < dim; id++){
50  gradL[id] = dataleft.sol[0][ nstate + is*dim +id ];
51  gradR[id] = dataright.sol[0][ nstate + is*dim +id ];
52  }//for id
53  TPZManVector<STATE,3> stnormal(3);
54  for (int i=0; i<3; i++) {
55  stnormal[i] = data.normal[i];
56  }
57  this->ApplyVanAlbadaLimiter(dataleft.sol[0][is], dataright.sol[0][is], gradL, gradR, stnormal, dL, dR);
58  // this->ApplyMinModLimiter(data.soll[is], data.solr[is], gradL, gradR, data.normal, dL, dR);
59  }//for is
60 }//void
61 
62 void TPZGradientFlux::ApplyMinModLimiter(STATE &soll, STATE &solr,
63  const TPZVec<STATE>& gradL, const TPZVec<STATE> &gradR,
64  const TPZVec<STATE> &normal,
65  const TPZVec<STATE> &dL, const TPZVec<STATE> & dR){
66  const STATE sL = this->Dot(gradL,normal);
67  const STATE sR = this->Dot(gradR,normal);
68  if((sL*sR) < 0.){
69  return;
70  }
71  const STATE k = 0.5;
72  if(fabs(sL) < fabs(sR)){
73  soll = soll + k*this->Dot(gradL,dL);
74  solr = solr + k*this->Dot(gradL,dR);
75  return;
76  }
77  if(fabs(sL) > fabs(sR)){
78  soll = soll + k*this->Dot(gradR,dL);
79  solr = solr + k*this->Dot(gradR,dR);
80  return;
81  }
82  //if (sL == sR)
83  soll = soll + k*this->Dot(gradL,dL);
84  solr = solr + k*this->Dot(gradR,dR);
85 }//void
86 
87 void TPZGradientFlux::ApplyVanAlbadaLimiter(STATE &soll, STATE &solr,
88  const TPZVec<STATE>& gradL, const TPZVec<STATE> &gradR,
89  const TPZVec<STATE> &normal,
90  const TPZVec<STATE> &dL, const TPZVec<STATE> & dR){
91  const double sL = this->Dot(gradL,normal);
92  const double sR = this->Dot(gradR,normal);
93  if(fabs(sL) < 1e-12){
94  return;
95  }
96  const double r = sR/sL;
97  double phi = (r <= 0.) ? 0. : ((r*r+r)/(1.+r*r));
98  phi *= 0.5;
99  soll = soll + phi*this->Dot(gradL,dL);
100  solr = solr + phi*this->Dot(gradR,dR);
101 
102 }//void
void ApplyVanAlbadaLimiter(STATE &soll, STATE &solr, const TPZVec< STATE > &gradL, const TPZVec< STATE > &gradR, const TPZVec< STATE > &normal, const TPZVec< STATE > &dL, const TPZVec< STATE > &dR)
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
TPZManVector< REAL, 3 > normal
normal to the element at the integration point
Contains the TPZGradientFlux class.
TPZManVector< REAL, 3 > x
value of the coordinate at the integration point
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
void ApplyLimiter(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright)
Apply limiter.
void ComputeFlux(TPZVec< STATE > &solL, TPZVec< STATE > &solR, const TPZVec< REAL > &normal, TPZVec< STATE > &F)
Computes numerical flux.
STATE Dot(const TPZVec< STATE > &A, const TPZVec< STATE > &B)
Computes the dot product (scalar)
int64_t size() const
Returns the number of elements of the vector.
Definition: pzvec.h:196
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
Definition: pzvec.h:373
TPZManVector< REAL, 3 > XCenter
value of the coordinate at the center of the element
~TPZGradientFlux()
Destructor.
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
void ApplyMinModLimiter(STATE &soll, STATE &solr, const TPZVec< STATE > &gradL, const TPZVec< STATE > &gradR, const TPZVec< STATE > &normal, const TPZVec< STATE > &dL, const TPZVec< STATE > &dR)
It corrects and values.
Contains the TPZMaterialData class which implements an interface between TPZCompEl::CalcStiff and TPZ...
void Fill(const T &copy, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
Definition: pzvec.h:460
TPZGradientFlux()
Default constructor.
TPZSolVec sol
vector of the solutions at the integration point
DESCRIBE PLEASE.