58 rtstr =
"LeastSquares";
66 rtstr =
"TrnLeastSquares";
78 REAL delta = ( (10./3.)*cfl*cfl - (2./3.)*cfl + 1./10. );
87 if(fDelta < 0.)dX =-
fDelta;
90 STATE us, c, lambdaMax;
103 return dX /2. / lambdaMax;
118 return (1.0/(2.0*(REAL)degree+1.0));
124 int dim = M.NElements();
126 if(size<1 || size>3){
127 PZError <<
"TPZArtDiff::PointOperator: error data size";
130 Result.
Redim(M[0].fRows, M[0].fCols());
133 for (i=0;i<dim;i++)Result.
Add(M[i], dphi[i]);
139 int dim = TauDiv.NElements();
141 int neq = TauDiv[0].NElements();
142 if(size<1 || size>3){
143 PZError <<
"TPZArtDiff::PointOperator: error data size";
147 Result.
Fill(REAL(0.));
151 for(i=0;i<neq;i++)Result[i] += TauDiv[k][i] * dphi[k];
164 int nstate = Ai[0].Cols();
165 int dim = nstate - 2;
166 int nshape = dphi.
Cols();
175 for(i=0;i<nstate; i++)
176 for(j=0;j<nstate;j++)
178 Div[i] += Ai[k](i,j).
val() * dsol(k,j);
187 dDiv->
Redim(nstate, nstate * nshape);
190 for(l=0;l<nshape;l++)
191 for(j=0;j<nstate;j++)
192 for(i=0;i<nstate; i++)
197 buff+=Ai[k](i,j).
val()*dphi(k,l);
199 dDiv->operator()(i,j+l*nstate)=buff;
204 for( k = 0; k < dim; k++)
207 for(i = 0; i < nstate; i++)
210 for(j = 0; j < nstate; j++)
211 temp += Ai[k](i,j) * (T)dsol(k,j);
214 for(l=0;l<nshape;l++)
215 for(j=0;j<nstate;j++)
216 for(i=0;i<nstate; i++)
217 dDiv->operator()(i,j+l*nstate) +=
218 ADiv[i].
dx(j) * phi(l,0);
230 int nstate = Ai[0].Cols();
231 int dim = nstate - 2;
232 int nshape = dphi.
Cols();
241 for(i=0;i<nstate; i++)
242 for(j=0;j<nstate;j++)
244 Div[i]+=Ai[k](i,j)*dsol(k,j);
251 dDiv->
Redim(nstate, nstate * nshape);
254 for(l=0;l<nshape;l++)
255 for(j=0;j<nstate;j++)
256 for(i=0;i<nstate; i++)
261 buff+=Ai[k](i,j)*dphi(k,l);
263 dDiv->operator()(i,j+l*nstate)=buff;
274 int nstate = Ai[0].Cols();
275 int dim = nstate - 2;
283 for(i=0;i<nstate; i++)
286 for(j=0;j<nstate;j++)
288 Div[i]+=Ai[k](i,j)*dsol[j*dim+k];
305 SUPG(dim, sol, Ai, Tau);
308 LS(dim, sol, Ai, Tau);
311 Bornhaus(dim, jacinv, sol, Ai, Tau);
314 LST(dim, sol, Ai, Tau);
341 RTM. Multiply(X, Temp);
342 Temp. Multiply(LambdaSUPG, INVA2B2);
344 Temp. Multiply(RMi, INVA2B2);
346 for(
int i = 0; i < Ai.NElements();i++)
348 Ai[i].Multiply(INVA2B2, Tau[i]);
366 RotT. Multiply(M, Temp);
367 Temp. Multiply(X, INVA2B2);
369 Temp. Multiply(Xi, INVA2B2);
371 Temp. Multiply(Rot, INVA2B2);
373 for(
int i = 0; i < Ai.NElements();i++)
375 Ai[i].Multiply(INVA2B2, Tau[i]);
384 for(i = 0; i < dim; i++)
386 Ai[i].Transpose(Tau[i]);
393 for(i = 0; i < dim; i++)
405 int nstate = Ai[0].Rows();
410 BornhausTau(nstate, nstate),
420 BornhausTau.Redim(nstate, nstate);
422 for( i = 0; i < dim; i++)
424 for( j = 0; j < dim; j++)
425 alphas[j] = jacinv(i,j);
429 RTM. Multiply(BornhausTau, Temp);
432 for( i = 0; i < dim;i++)
434 Ai[i].Multiply(BornhausTau, Tau[i]);
440 int nstate = Ai[0].Rows();
446 BornhausTau(nstate, nstate),
457 for( i = 0; i < dim; i++)
459 for( j = 0; j < dim; j++)
460 alphas[j] = jacinv(i,j);
463 Y, Yi, LambdaBornhaus);
465 Y. Multiply(LambdaBornhaus, Temp);
468 BornhausTau.Add(Temp2);
471 RotT. Multiply(M, Temp);
472 Temp. Multiply(BornhausTau, Temp2);
473 Temp2. Multiply(Mi, Temp);
474 Temp. Multiply(Rot, BornhausTau);
476 BornhausTau.Inverse();
477 for( i = 0; i < dim;i++)
479 Ai[i].Multiply(BornhausTau, Tau[i]);
508 if(pTaudDiv) pdDiv = & dDiv;
513 if(pTaudDiv)pTaudDiv->Resize(dim);
520 Tau[k].Multiply(Div, TauDiv[k]);
521 if(pTaudDiv)Tau[k].Multiply(dDiv, pTaudDiv->operator[](k));
540 #ifdef TEST_PARTIAL_DIFF 546 { Ai[t](i,j).diff(0,30);
547 Tau[t](i,j).diff(0,30);
551 Tau[t](i,j).
dx(l)=0.;
564 Tau[k].Multiply(Div, TauDiv[k]);
587 const int nshape = phi.
Rows();
598 for(i = 0; i < nstate; i++)
601 FADsol[i].diff(i, nstate);
605 ComputeTau(dim, jacinv, FADsol, FADAi, FADTau);
607 for( k = 0; k < dim; k++)
609 Tau[k].Redim(nstate, nstate);
610 Ai [k].Redim(nstate, nstate);
611 for(i = 0; i < nstate; i++)
612 for( j = 0; j < nstate; j++)
614 Tau[k](i,j) = FADTau[k](i,j).val();
615 Ai [k](i,j) = FADAi [k](i,j).val();
623 Divergent(dsol, phi, dphi, FADAi, Div, &dDiv);
631 TauDiv [k].Resize(nstate);
632 dTauDiv[k].Redim(nstate, nstate);
634 FADTauDiv[k].
Resize(nstate);
635 for(i = 0; i < nstate; i++)
638 for(j = 0; j < nstate; j++)
639 temp += FADTau[k](i,j) * ((REAL)Div[j]);
640 FADTauDiv[k][i] = temp;
644 dTauDiv[k].Redim(nstate, nstate * nshape);
645 for(i = 0; i < nstate; i++)
647 TauDiv[k][i] = FADTauDiv[k][i].val();
648 for(j = 0; j < nstate; j++)
650 for(l = 0; l < nshape; l++)
651 dTauDiv[k](i,l * nstate + j) =
652 FADTauDiv[k][i].dx(j) * phi(l,0);
660 for(k = 0; k < dim; k++)
662 Tau[k].Multiply(dDiv, TaudDiv_k);
663 dTauDiv[k].Add(TaudDiv_k, 1.);
677 REAL delta =
Delta(deltaX, sol);
678 REAL constant = weight * delta * timeStep;
684 pTaudDiv = & TaudDiv;
689 int nshape = dphix.
Cols();
690 int nstate = dim + 2;
691 int neq = nstate*nshape;
696 for(l=0;l<nshape;l++)
697 for(i=0;i<nstate;i++)
700 buff = dphix(k,l) * constant;
701 ef(i+l*nstate,0) += buff * TauDiv[k][i];
703 ek(i+l*nstate,j) -= buff * TaudDiv[k](i,j);
709 REAL delta =
Delta(deltaX, sol);
710 REAL constant = weight * delta * timeStep;
717 int nshape = dphix.
Cols();
718 int nstate = dim + 2;
721 for(l=0;l<nshape;l++)
722 for(i=0;i<nstate;i++)
724 ef(i+l*nstate,0) += dphix(k,l) * TauDiv[k][i] * constant;
735 solReal[i] = sol[i].
val();
737 REAL delta =
Delta(deltaX, solReal);
738 REAL constant = delta * weight * timeStep;
748 int nstate = dim + 2;
749 int neq = sol[0].
size();
750 int nshape = neq/nstate;
752 for(l=0;l<nshape;l++)
755 gradv[k] = dsol[k].
dx(l*nstate);
757 for(i=0;i<nstate;i++)
759 ef(i+l*nstate,0) += constant * Diff[i].val();
761 ek(i+l*nstate, j) -= constant * Diff[i].dx(j);
769 REAL delta =
Delta(deltaX, sol);
770 REAL constant = weight * delta * timeStep;
776 PrepareFastestDiff<dim>( jacinv, sol, dsol, phi, dphi, TauDiv, dTauDiv);
779 int nshape = dphi.Cols();
780 int nstate = dim + 2;
781 int neq = nstate * nshape;
785 for(l=0;l<nshape;l++)
786 for(i=0;i<nstate;i++)
789 buff = dphi(k,l) * constant;
790 ef(i+l*nstate,0) += buff * TauDiv[k][i];
792 ek(i+l*nstate,j) -= buff * dTauDiv[k](i,j);
796 void TPZArtDiff::ContributeFastestImplDiff(
int dim,
TPZFMatrix<REAL> &jacinv,
TPZVec<STATE> &sol,
TPZFMatrix<STATE> &dsol,
TPZFMatrix<REAL> &phi,
TPZFMatrix<REAL> &dphi,
TPZFMatrix<STATE> &ek,
TPZFMatrix<STATE> &ef, REAL weight, REAL timeStep, REAL deltaX)
801 ContributeFastestImplDiff_dim<1>(jacinv, sol, dsol,
803 weight, timeStep, deltaX);
806 ContributeFastestImplDiff_dim<2>(jacinv, sol, dsol,
808 weight, timeStep, deltaX);
811 ContributeFastestImplDiff_dim<3>(jacinv, sol, dsol,
813 weight, timeStep, deltaX);
816 PZError <<
"\nTPZArtDiff::ContributeFastestImplDiff unhandled dimension\n";
841 buf.
Read(&ArtDiffType, 1);
849 return Hash(
"TPZArtDiff");
void Add(TPZDiffMatrix< T > &matrix, const T &scale=T(1.))
Adds element by element.
static void JacobFlux(REAL gamma, int dim, TPZVec< T > &U, TPZVec< TPZDiffMatrix< T > > &Ai)
Jacobian of the tensor flux of Euler.
void LST(int dim, TPZVec< T > &sol, TPZVec< TPZDiffMatrix< T > > &Ai, TPZVec< TPZDiffMatrix< T > > &Tau)
static void RMMatrix(TPZVec< T > &sol, T &us, REAL gamma, TPZDiffMatrix< T > &RTM, TPZDiffMatrix< T > &RMi)
No Artificial diffusion term is considered.
Use Least squares method to applied artificial diffusion term.
Templated vector implementation.
void ContributeApproxImplDiff(int dim, TPZFMatrix< REAL > &jacinv, TPZVec< STATE > &sol, TPZFMatrix< STATE > &dsol, TPZFMatrix< REAL > &dphix, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, REAL weight, REAL timeStep, REAL deltaX)
Contributes the diffusion term to the tangent matrix (ek-approximated) and residual vector (ef) ...
TPZString DiffusionName()
Returns the name of diffusive term.
void degree(int root, int adj_num, int adj_row[], int adj[], int mask[], int deg[], int *iccsze, int ls[], int node_num)
void SetDelta(REAL delta)
Sets the value for delta.
Contains the TPZEulerConsLaw class which implements the weak statement of the compressible euler equa...
void Write(TPZStream &buf, int withclassid) const override
Save the element data to a stream.
void ODotOperator(TPZVec< REAL > &dphi, TPZVec< TPZDiffMatrix< T > > &M, TPZDiffMatrix< T > &Result)
Operation product point in the diffusion term.
REAL val(STATE &number)
Returns value of the variable.
REAL fDelta
Scalar coefficient of the element in the diffusion term.
AutoPointerMutexArrayInit tmp
void SUPG(int dim, TPZVec< T > &sol, TPZVec< TPZDiffMatrix< T > > &Ai, TPZVec< TPZDiffMatrix< T > > &Tau)
This class adds to the term of diffusion to the variacional formulation of the differential equation...
static void uRes(TPZVec< T > &sol, T &us)
REAL Delta(REAL deltaX, TPZVec< STATE > &sol)
Returns the stored value for delta.
Use Supg method to applied artificial diffusion term.
void Divergent(TPZFMatrix< STATE > &dsol, TPZFMatrix< REAL > &dphi, TPZVec< TPZDiffMatrix< STATE > > &Ai, TPZVec< STATE > &Div, TPZDiffMatrix< STATE > *dDiv)
Evaluates the divergent of F.
REAL fGamma
Ratio between specific heat is constant and the specific heat the constant volume of a polytropic gas...
void Redim(const int64_t rows, const int64_t cols)
Resizes and zeroes the matrix.
static void EigenSystemBornhaus(TPZVec< T > &sol, T &us, T &c, REAL gamma, TPZVec< REAL > &aaS, TPZDiffMatrix< T > &Y, TPZDiffMatrix< T > &Yi, TPZDiffMatrix< T > &Lambda)
int64_t size() const
Returns the number of elements of the vector.
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...
static void EigenSystemSUPG(TPZVec< T > &sol, T &us, T &c, REAL gamma, TPZDiffMatrix< T > &X, TPZDiffMatrix< T > &Xi, TPZDiffMatrix< T > &Lambda)
expr_ dx(i) *cos(expr_.val())
virtual void Write(const bool val)
Contains TPZMatrixclass which implements full matrix (using column major representation).
Use Bornhaus method to applied artificial diffusion term.
void LS(int dim, TPZVec< T > &sol, TPZVec< TPZDiffMatrix< T > > &Ai, TPZVec< TPZDiffMatrix< T > > &Tau)
int64_t Rows() const
Returns number of rows.
Contains the TPZDiffusionConsLaw class which implements a Euler equation where is introduced a diffus...
void Read(TPZStream &buf, void *context) override
Read the element data from a stream.
TPZArtDiffType fArtDiffType
Kind of artificial diffusion term to apply.
Use Transpose of the Least Squares method to applied artificial diffusion term.
Implements strings as stack. Utility.
int32_t Hash(std::string str)
long double gamma(unsigned int n)
Evaluate the factorial of a integer.
void PrepareFastDiff(int dim, TPZFMatrix< REAL > &jacinv, TPZVec< STATE > &sol, TPZFMatrix< STATE > &dsol, TPZFMatrix< REAL > &dphi, TPZVec< TPZVec< STATE > > &TauDiv, TPZVec< TPZDiffMatrix< STATE > > *pTaudDiv=NULL)
Prepares the data to compute the diffusive term as fast as possible, sparing operations.
void Bornhaus(int dim, TPZFMatrix< REAL > &jacinv, TPZVec< T > &sol, TPZVec< TPZDiffMatrix< T > > &Ai, TPZVec< TPZDiffMatrix< T > > &Tau)
Contains the TPZArtDiff class which implements a numerical diffusivity coefficient.
REAL OptimalCFL(int degree=TPZCompEl::GetgOrder())
Returns the best value for based on the interpolation degree.
static void cSpeed(TPZVec< T > &sol, REAL gamma, T &c)
Evaluates the speed of sound in the fluid.
REAL OptimalDelta()
Returns the best value for delta based on the interpolation degree.
static void MMatrix(TPZVec< T > &sol, T &us, REAL gamma, TPZDiffMatrix< T > &M, TPZDiffMatrix< T > &Mi)
void Multiply(TPZVec< T > &In, TPZVec< T > &Out, const T &scale=T(1.))
Multiplies the matrix by a correspondent TPZVec vector. Dimensions are checked.
void SetArtDiffType(TPZArtDiffType type)
Configures the type of artificial diffusion.
static void Pressure(REAL gamma, int dim, T &press, TPZVec< T > &U)
pressure
TPZArtDiff()
Simple constructor.
void PrepareDiff(int dim, TPZFMatrix< REAL > &jacinv, TPZVec< T > &U, TPZVec< TPZDiffMatrix< T > > &Ai, TPZVec< TPZDiffMatrix< T > > &Tau)
Computes the common values A B C and Tau vector of matrixes for contributions.
Matrix class to hold the flux derivatives A B C and diffusive matrix coefficients. Matrix.
int ClassId() const override
Class identificator.
void Fill(const T ©, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
int64_t Cols() const
Returns number of cols.
void ComputeTau(int dim, TPZFMatrix< REAL > &jacinv, TPZVec< T > &Sol, TPZVec< TPZDiffMatrix< T > > &Ai, TPZVec< TPZDiffMatrix< T > > &Tau)
Computes the diffusive term according to the name.
Defines the interface for saving and reading data. Persistency.
int64_t NElements() const
Returns the number of elements of the vector.
Contains the declaration of TPZFlopCounter class and TPZCounter struct.
static void ContributeBornhaus(TPZVec< T > &sol, T &us, T &c, REAL gamma, TPZVec< REAL > &aaS, TPZDiffMatrix< T > &Mat)
static void Pressure(REAL gamma, int dim, T &press, TPZVec< T > &U)
Thermodynamic pressure determined by the law of an ideal gas.
TPZArtDiffType
Enumerate to define the possible types of artificial diffusion term to stabilize the numerical scheme...
void ContributeExplDiff(int dim, TPZFMatrix< REAL > &jacinv, TPZVec< STATE > &sol, TPZFMatrix< STATE > &dsol, TPZFMatrix< REAL > &dphix, TPZFMatrix< STATE > &ef, REAL weight, REAL timeStep, REAL deltaX)
Contributes the diffusion term to the tangent matrix (ek-approximated) and residual vector (ef) ...
#define PZError
Defines the output device to error messages and the DebugStop() function.
static void RotMatrix(TPZVec< T > &sol, T &us, TPZDiffMatrix< T > &Rot, TPZDiffMatrix< T > &RotT)
TPZArtDiffType ArtDiffType()
Returns the type of artifical diffusion.
virtual void Read(bool &val)