23 inline REAL
val(STATE & number)
343 REAL weight, REAL timeStep,
363 REAL weight, REAL timeStep,
380 void ContributeImplDiff(
int dim,
384 REAL weight, REAL timeStep,
405 REAL weight, REAL timeStep,
409 void ContributeFastestImplDiff_dim(
414 REAL weight, REAL timeStep,
442 int dim = nstate - 2;
444 T u, v, w, u2, v2, w2, uspuInv, usInv;
455 Rot.
Redim(nstate,nstate);
458 Rot(1,1) = u * usInv;
459 Rot(1,2) = v * usInv;
460 Rot(2,1) = - Rot(1,2);
472 uspuInv = T(1.)/(us + u);
476 Rot.
Redim(nstate,nstate);
479 Rot(1,1) = u * usInv;
480 Rot(1,2) = v * usInv;
481 Rot(1,3) = w * usInv;
482 Rot(2,1) = -Rot(1,2);
483 Rot(2,2) = Rot(1,1) + w2 * uspuInv;
484 Rot(2,3) = - w*v * uspuInv;
485 Rot(3,1) = -Rot(1,3);
487 Rot(3,3) = Rot(1,1) + v2 * uspuInv;
493 PZError <<
"TPZArtDiff::RotMatrix Error: Invalid Dimension\n";
503 int dim = nstate - 2;
511 rhoInv = T(1.)/sol[0];
513 M.
Redim(nstate,nstate);
518 M(3,0) = us * us /2.;
519 M(3,1) = sol[0] * us;
520 M(3,3) = T(1.)/(gamma-1.);
522 Mi.
Redim(nstate,nstate);
524 Mi(1,0) = - rhoInv * us;
527 Mi(3,0) = T((gamma-1.)/2.) * us * us;
528 Mi(3,1) = T(1.-gamma)*us;
534 rhoInv = T(1.)/sol[0];
536 M.
Redim(nstate,nstate);
542 M(4,0) = us * us /2.;
543 M(4,1) = sol[0] * us;
544 M(4,4) = T(1.)/(gamma-1.);
546 Mi.
Redim(nstate,nstate);
548 Mi(1,0) = - rhoInv * us;
552 Mi(4,0) = T((gamma-1.)/2.) * us * us;
553 Mi(4,1) = T(1.-gamma)*us;
558 PZError <<
"TPZArtDiff::MMatrix Error: Invalid Dimension\n";
567 int dim = nstate - 2;
569 T u, v, w, u2, v2, w2,
570 rhoInv, usInv, uspu, uspuInv;
578 rhoInv = T(1.)/sol[0];
580 kt = sol[1]/sol[0]/us;
581 st = sol[2]/sol[0]/us;
583 RTM.
Redim(nstate,nstate);
586 RTM(1,1) = sol[0] * kt;
587 RTM(1,2) = -sol[0] * st;
589 RTM(2,1) = -RTM(1,2);
591 RTM(3,0) = us * us /2.;
592 RTM(3,1) = sol[0] * us;
593 RTM(3,3) = 1./(gamma-1.);
595 RMi.
Redim(nstate,nstate);
597 RMi(1,0) = - rhoInv * us;
598 RMi(1,1) = rhoInv * kt;
599 RMi(1,2) = rhoInv * st;
600 RMi(2,1) = - RMi(1,2);
602 RMi(3,0) = T((gamma-1.)/2.) * us * us;
603 RMi(3,1) = T(1.-gamma)*us*kt;
604 RMi(3,2) = T(1.-gamma)*us*st;
616 uspuInv = T(1.)/uspu;
618 kt = T(1.)/(sol[0] * us * (uspu * u + v2 + w2));
620 RTM.
Redim(nstate,nstate);
622 RTM(1,0) = u2 * usInv;
623 RTM(1,1) = sol[1]*usInv;
624 RTM(1,2) = sol[2]*usInv;
625 RTM(1,3) = sol[3]*usInv;
626 RTM(2,0) = - u * v * usInv;
627 RTM(2,1) = - RTM(1,2);
628 RTM(2,2) = RTM(1,1) + sol[3] * w * uspuInv * usInv;
629 RTM(2,3) = - RTM(1,2) * w * uspuInv;
630 RTM(3,0) = - u * w * usInv;
631 RTM(3,1) = -RTM(1,3);
633 RTM(3,3) = RTM(1,1) + sol[2] * v * uspuInv * usInv;
636 RTM(4,4) = 1./(gamma-1.);
638 RMi.
Redim(nstate,nstate);
640 RMi(1,0) = - u / sol[0];
641 RMi(1,1) = - RMi(1,0) * usInv;
642 RMi(1,2) = - v * usInv / sol[0];
643 RMi(1,3) = - w * usInv / sol[0];
644 RMi(2,1) = - RMi(1,2);
645 RMi(2,2) = (u * v2 + uspu * (u2+w2)) * kt;
646 RMi(2,3) = (u - uspu) * v * w * kt;
647 RMi(3,1) = - RMi(1,3);
649 RMi(3,3) = (uspu * (u2+v2) + u* w2) * kt;
650 RMi(4,0) = u2 * T((gamma-1.)/2.);
651 RMi(4,1) = - u2 * usInv * T(gamma - 1.);
652 RMi(4,2) = u * v * usInv * T(gamma -1.);
653 RMi(4,3) = u * w * usInv * T(gamma -1.);
654 RMi(4,4) = gamma -1.;
657 RTM.
Redim(nstate,nstate);
660 RTM(1,1) = sol[1]*usInv;
661 RTM(1,2) = - sol[2]*usInv;
662 RTM(1,3) = - sol[3]*usInv;
664 RTM(2,1) = - RTM(1,2);
665 RTM(2,2) = RTM(1,1) + sol[3] * w * uspuInv * usInv;
666 RTM(2,3) = RTM(1,2) * w * uspuInv;
668 RTM(3,1) = -RTM(1,3);
670 RTM(3,3) = RTM(1,1) + sol[2] * v * uspuInv * usInv;
671 RTM(4,0) = us * us /2.;
672 RTM(4,1) = sol[0] * us;
673 RTM(4,4) = 1./(gamma-1.);
675 RMi.
Redim(nstate,nstate);
677 RMi(1,0) = - us / sol[0];
678 RMi(1,1) = u * usInv / sol[0];
679 RMi(1,2) = v * usInv / sol[0];
680 RMi(1,3) = w * usInv / sol[0];
681 RMi(2,1) = - RMi(1,2);
682 RMi(2,2) = (u * v2 + uspu * (u2+w2)) * kt;
683 RMi(2,3) = (u - uspu) * v * w * kt;
684 RMi(3,1) = - RMi(1,3);
686 RMi(3,3) = (uspu * (u2+v2) + u* w2) * kt;
687 RMi(4,0) = us * us * T((gamma-1.)/2.);
688 RMi(4,1) = u * T(1.-gamma);
689 RMi(4,2) = v * T(1.-gamma);
690 RMi(4,3) = w * T(1.-gamma);
691 RMi(4,4) = gamma -1.;
696 PZError <<
"TPZArtDiff::MMatrix Error: Invalid Dimension\n";
706 int dim = nstate - 2;
708 T us2, c2, s, rho_c_us;
712 rho_c_us = sol[0] * c * us;
717 s =
sqrt(c2 + us2 * REAL(16.));
719 X.
Redim(nstate,nstate);
721 X(0,2) = REAL(4.) * sol[0] * us / c2;
726 X(3,2) = REAL(4.) * sol[0] * us;
729 Xi.
Redim(nstate,nstate);
731 Xi(0,3) = REAL(- 1.) / c2;
733 Xi(2,1) = - c / (REAL(2.) * s);
734 Xi(2,3) = (s-c)/(REAL(8.) * sol[0] * s * us);
736 Xi(3,3) = (s+c)/(REAL(8.) * sol[0] * s * us);
738 Lambda.
Redim(nstate,nstate);
739 Lambda(0,0) = REAL(1.)/us;
740 Lambda(1,1) = REAL(1.)/
sqrt(us2 + c2);
741 Lambda(2,2) = REAL(1.)/
sqrt(us2 + REAL(1.5) * c2 - REAL(.5) * c * s);
742 Lambda(3,3) = 1./
sqrt(us2 + REAL(1.5) * c2 + REAL(.5) * c * s);
747 s =
sqrt(c2 + us2 * REAL(4.));
749 X.
Redim(nstate,nstate);
751 X(0,3) = REAL(1.) / c2;
753 X(1,3) = (-s-c)/(REAL(2.) * rho_c_us);
754 X(1,4) = ( s-c)/(REAL(2.) * rho_c_us);
761 Xi.
Redim(nstate,nstate);
763 Xi(0,4) = REAL(- 1.) / c2;
766 Xi(3,1) = - rho_c_us / s;
767 Xi(3,4) = REAL(.5) - c / (REAL(2.) * s);
769 Xi(4,4) = REAL(.5) + c / (REAL(2.) * s);
771 Lambda.
Redim(nstate,nstate);
772 Lambda(0,0) = REAL(1.)/us;
773 Lambda(1,1) = REAL(1.)/
sqrt(us2 + c2);
774 Lambda(2,2) = Lambda(1,1);
775 Lambda(3,3) = REAL(1.)/
sqrt(us2 + REAL(2.) * c2 - c * s);
776 Lambda(4,4) = REAL(1.)/
sqrt(us2 + REAL(2.) * c2 + c * s);
780 PZError <<
"TPZArtDiff::EigenSystemSUPG Error: Invalid Dimension\n";
791 int dim = nstate - 2;
793 T k, us2, c2, rho_c, temp1, temp2, temp3, k2;
802 k2 = aaS[0]*aaS[0] + aaS[1]*aaS[1];
806 Y.
Redim(nstate,nstate);
808 Y(0,2) = REAL(1.) / c2;
811 Y(1,2) = -aaS[0] / (k * rho_c);
814 Y(2,2) = -aaS[1] / (k * rho_c);
819 Yi.
Redim(nstate,nstate);
820 Yi(0,1) = - aaS[1] / k2;
821 Yi(0,2) = aaS[0] / k2;
823 Yi(1,3) = REAL(-1.) / c2;
824 Yi(2,1) = - aaS[0] * rho_c / (REAL(2.) * k);
825 Yi(2,2) = - aaS[1] * rho_c / (REAL(2.) * k);
832 if(
val(temp1) < 0)temp1 = -temp1;
833 temp2 = aaS[0] * us - k * c;
834 if(
val(temp2) < 0)temp2 = -temp2;
835 temp3 = aaS[0] * us + k * c;
836 if(
val(temp3) < 0)temp3 = -temp3;
838 Lambda.
Redim(nstate,nstate);
846 k2 = aaS[0]*aaS[0] + aaS[1]*aaS[1] + aaS[2]*aaS[2];
849 Y.
Redim(nstate,nstate);
851 Y(0,3) = REAL(1.) / c2;
853 Y(1,0) = -aaS[2]/aaS[0];
854 Y(1,1) = -aaS[1]/aaS[0];
855 Y(1,3) = -aaS[0]/(k * rho_c);
858 Y(2,3) = -aaS[1]/(k * rho_c);
861 Y(3,3) = -aaS[2]/(k * rho_c);
866 Yi.
Redim(nstate,nstate);
867 Yi(0,1) = - aaS[0] * aaS[2] / k2;
868 Yi(0,2) = - aaS[1] * aaS[2] / k2;
869 Yi(0,3) = (aaS[0] * aaS[0] + aaS[1] * aaS[1]) / k2;
870 Yi(1,1) = - aaS[0] * aaS[1] / k2;
871 Yi(1,2) = (aaS[0] * aaS[0] + aaS[2] * aaS[2]) / k2;
874 Yi(2,4) = REAL(-1.) / c2;
875 Yi(3,1) = - aaS[0] * rho_c / (REAL(2.) * k);
876 Yi(3,2) = - aaS[1] * rho_c / (REAL(2.) * k);
877 Yi(3,3) = - aaS[2] * rho_c / (REAL(2.) * k);
885 if(
val(temp1) < 0)temp1 = -temp1;
886 temp2 = aaS[0] * us - k * c;
887 if(
val(temp2) < 0)temp2 = -temp2;
888 temp3 = aaS[0] * us + k * c;
889 if(
val(temp3) < 0)temp3 = -temp3;
891 Lambda.
Redim(nstate,nstate);
900 PZError <<
"TPZArtDiff::EigenSystemBornhaus Error: Invalid Dimension\n";
910 int dim = nstate - 2;
912 T k, l1, l3, l4, l5, lstar,
913 lsum, ldiff, twoCK, c2, temp1, temp2, k2;
923 k2 = aaS[0]*aaS[0] + aaS[1]*aaS[1];
925 twoCK = c * T(k * REAL(2.));
928 if(
val(l1) < 0.)l1 = -l1;
929 l3 = aaS[0] * us - k * c;
930 if(
val(l3) < 0.)l3 = -l3;
931 l4 = aaS[0] * us + k * c;
932 if(
val(l4) < 0.)l4 = -l4;
934 temp1 = (l4 - l3) * sol[0] / twoCK;
935 temp2 = l3 + l4 - REAL(2.)*l1;
937 Mat(0,1) += aaS[0] * temp1;
938 Mat(0,2) += aaS[1] * temp1;
939 Mat(0,3) += temp2 / (REAL(2.) * c2);
940 Mat(1,1) += (aaS[1]*aaS[1] * l1 + aaS[0]*aaS[0] * (l3+l4) *REAL(.5))/k2;
941 Mat(1,2) += aaS[0]*aaS[1] * temp2/(REAL(2.) * k2);
942 Mat(1,3) += aaS[0]*(l4-l3)/(c * k * sol[0] * REAL(2.));
943 Mat(2,1) += aaS[0]*aaS[1] * temp2/(REAL(2.) * k2);
944 Mat(2,2) += (aaS[0]*aaS[0] * l1 + aaS[1]*aaS[1] * (l3+l4) *REAL(.5))/k2;
945 Mat(2,3) += aaS[1]*(l4-l3)/(c * k * sol[0] * REAL(2.));
946 Mat(3,1) += aaS[0] * c2 * temp1;
947 Mat(3,2) += aaS[1] * c2 * temp1;
948 Mat(3,3) += (l3 + l4)/REAL(2.);
953 k2 = aaS[0]*aaS[0] + aaS[1]*aaS[1] + aaS[2]*aaS[2];
957 if(
val(l1) < 0.)l1 = -l1;
958 l4 = aaS[0] * us - k * c;
959 if(
val(l3) < 0.)l3 = -l3;
960 l5 = aaS[0] * us + k * c;
961 if(
val(l4) < 0.)l4 = -l4;
965 lstar = lsum - REAL(2.)*l1;
967 twoCK = c * k * REAL(2.);
969 Mat.
Redim(nstate,nstate);
971 Mat(0,1) += aaS[0] * sol[0] * ldiff / twoCK;
972 Mat(0,2) += aaS[1] * sol[0] * ldiff / twoCK;
973 Mat(0,3) += aaS[2] * sol[0] * ldiff / twoCK;
974 Mat(0,4) += lstar / ( c2 * REAL(2.) );
975 Mat(1,1) += aaS[0] * aaS[0] * lstar / (k2 * REAL(2.)) + l1;
976 Mat(1,2) += aaS[0] * aaS[1] * lstar / (k2 * REAL(2.));
977 Mat(1,3) += aaS[0] * aaS[2] * lstar / (k2 * REAL(2.));
978 Mat(1,4) += aaS[0] / twoCK / sol[0] * ldiff;
979 Mat(2,1) += aaS[0] * aaS[1] * lstar / (k2 * REAL(2.));
980 Mat(2,2) += aaS[1] * aaS[1] * lstar / (k2 * REAL(2.)) + l1;
981 Mat(2,3) += aaS[1] * aaS[2] * lstar / (k2 * REAL(2.));
982 Mat(2,4) += aaS[1] / twoCK / sol[0] * ldiff;
983 Mat(3,1) += aaS[0] * aaS[2] * lstar / (k2 * REAL(2.));
984 Mat(3,2) += aaS[1] * aaS[2] * lstar / (k2 * REAL(2.));
985 Mat(3,3) += aaS[2] * aaS[2] * lstar / (k2 * REAL(2.)) + l1;
986 Mat(3,4) += aaS[2] / twoCK / sol[0] * ldiff;
987 Mat(4,1) += aaS[0] * c * sol[0] * ldiff / (k * REAL(2.));
988 Mat(4,2) += aaS[1] * c * sol[0] * ldiff / (k * REAL(2.));
989 Mat(4,3) += aaS[2] * c * sol[0] * ldiff / (k * REAL(2.));
990 Mat(4,4) += lstar/REAL(2.) + l1;
994 PZError <<
"TPZArtDiff::EigenSystemBornhaus Error: Invalid Dimension\n";
Contains declaration of the TPZSavable class which defines the interface to save and restore objects ...
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)
Contains TPZDiffMatrix class which to hold the flux derivatives A B C and diffusive matrix coefficien...
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.
TPZDiffMatrix< T > & Transpose(TPZDiffMatrix< T > &matrix)
Transposes the matrix onto the parameter object.
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.
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.
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...
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)
static void EigenSystemSUPG(TPZVec< T > &sol, T &us, T &c, REAL gamma, TPZDiffMatrix< T > &X, TPZDiffMatrix< T > &Xi, TPZDiffMatrix< T > &Lambda)
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)
void Read(TPZStream &buf, void *context) override
Read the element data from a stream.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
TPZArtDiffType fArtDiffType
Kind of artificial diffusion term to apply.
static int GetgOrder()
Set the default value of the interpolation order.
Contains declaration of TPZCompelDisc class which implements a computational element for discontinuou...
Use Transpose of the Least Squares method to applied artificial diffusion term.
Implements strings as stack. Utility.
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)
REAL OptimalCFL(int degree=TPZCompEl::GetgOrder())
Returns the best value for based on the interpolation degree.
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 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 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.
static void ContributeBornhaus(TPZVec< T > &sol, T &us, T &c, REAL gamma, TPZVec< REAL > &aaS, TPZDiffMatrix< T > &Mat)
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
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.