28 fA(0,0), fB(0,0), fC(0,0) {
49 return (1.0/(2.0*(REAL)degree+1.0));
59 REAL cfl =
CFL(degree);
60 REAL delta = ( (10./3.)*cfl*cfl - (2./3.)*cfl + 1./10. );
71 diverg.
Redim(nstate,1);
74 for(i=0;i<nstate;i++)
for(j=0;j<nstate;j++) diverg(i,0) += diffterm(i,j);
85 cout <<
"TPZDiffusionConsLaw::PointOperator error data size";
89 diff_term.
Redim(nstate,nstate);
96 for(i=0;i<nstate;i++){
97 for(j=0;j<nstate;j++){
98 diff_term(i,j) = dphi[0] * Trx(i,j) + dphi[1] * Try(i,j) + dphi[2] * Trz(i,j);
117 cout <<
"\nTPZDiffusionConsLaw::Tau case not implemented\n";
121 cout <<
"TPZDiffusionConsLaw:: SUPG artificial diffusion SUPG not implemented\n";
132 cout <<
"TPZDiffusionConsLaw::Bornhaus artificial diffusion Bornhaus not implemented\n";
137 if(
fabs(U[0]) < 1.e-6) {
138 cout <<
"\nTPZDiffusionConsLaw::JacobFlux: Densidade quase nula, o jacobiano falha\n";
139 cout <<
"Densidade = " << U[0] << endl;
141 cout <<
"Nova densidade = " << U[0] << endl;
147 if(cap < 3 || cap > 5){
148 cout <<
"\n\nTPZDiffusionConsLaw::JacobFlux case not trated\n\n";
157 REAL gamma2 = gamma1/2.;
182 A(1,0) = gamma2*vel-u2;
200 A(4,0) = -
fGamma*e*u + gamma1*u*vel;
201 A(4,1) =
fGamma*e - gamma1*u2 - gamma2*vel;
202 A(4,2) = -gamma1*u*v;
203 A(4,3) = -gamma1*u*w;
218 B(2,0) = gamma2*vel-v2;
230 B(4,0) = -
fGamma*e*v + gamma1*v*vel;
231 B(4,1) = -gamma1*u*v;
232 B(4,2) =
fGamma*e - gamma1*v2 - gamma2*vel;
233 B(4,3) = -gamma1*v*w;
254 C(3,0) = gamma2*vel-w2;
260 C(4,0) = -
fGamma*e*w + gamma1*w*vel;
261 C(4,1) = -gamma1*u*w;
262 C(4,2) = -gamma1*v*w;
263 C(4,3) =
fGamma*e - gamma1*w2 - gamma2*vel;
285 A(1,0) = gamma2*vel-u2;
295 A(3,0) = -
fGamma*e*u + gamma1*u*vel;
296 A(3,1) =
fGamma*e - gamma1*u2 - gamma2*vel;
297 A(3,2) = -gamma1*u*v;
310 B(2,0) = gamma2*vel-v2;
315 B(3,0) = -
fGamma*e*v + gamma1*v*vel;
316 B(3,1) = -gamma1*u*v;
317 B(3,2) =
fGamma*e - gamma1*v2 - gamma2*vel;
336 A(1,0) = gamma2*vel-u2;
340 A(2,0) = -
fGamma*e*u + gamma1*u*vel;
341 A(2,1) =
fGamma*e - gamma1*u2 - gamma2*vel;
348 REAL rho_f, REAL rhou_f, REAL rhov_f, REAL rhow_f,
349 REAL rhoE_f,REAL rho_t, REAL rhou_t, REAL rhov_t, REAL rhow_t,
350 REAL rhoE_t, REAL nx, REAL ny, REAL nz, REAL gam,
351 REAL &flux_rho, REAL &flux_rhou, REAL &flux_rhov,
352 REAL &flux_rhow, REAL &flux_rhoE){
354 REAL alpha1,alpha2,alpha3,alpha4,alpha5,alpha;
355 REAL a1,a2,a3,a4,a5,b1,b2,b3,b4,b5;
356 REAL ep_t, ep_f, p_t, p_f;
357 REAL rhouv_t, rhouv_f, rhouw_t, rhouw_f, rhovw_t, rhovw_f;
358 REAL lambda_f, lambda_t;
359 REAL delta_rho, delta_rhou, delta_rhov, delta_rhow, delta_rhoE;
369 REAL gam1 = gam - 1.0;
370 REAL irho_f = 1.0/rho_f;
371 REAL irho_t = 1.0/rho_t;
377 REAL coef1 =
sqrt(rho_f);
378 REAL coef2 =
sqrt(rho_t);
379 REAL somme_coef = coef1 + coef2;
380 REAL isomme_coef = 1.0/somme_coef;
381 REAL u_f = rhou_f*irho_f;
382 REAL v_f = rhov_f*irho_f;
383 REAL w_f = rhow_f*irho_f;
384 REAL h_f = (gam * rhoE_f*irho_f) - (.5*gam1) * (u_f * u_f + v_f * v_f + w_f * w_f);
385 REAL u_t = rhou_t*irho_t;
386 REAL v_t = rhov_t*irho_t;
387 REAL w_t = rhow_t*irho_t;
388 REAL h_t = (gam * rhoE_t*irho_t) - (.5*gam1) * (u_t * u_t + v_t * v_t + w_t * w_t);
392 REAL u_ave = (coef1 * u_f + coef2 * u_t) * isomme_coef;
393 REAL v_ave = (coef1 * v_f + coef2 * v_t) * isomme_coef;
394 REAL w_ave = (coef1 * w_f + coef2 * w_t) * isomme_coef;
395 REAL h_ave = (coef1 * h_f + coef2 * h_t) * isomme_coef;
398 REAL scal = u_ave * nx + v_ave * ny + w_ave * nz;
399 REAL norme =
sqrt(nx * nx + ny * ny + nz * nz);
400 REAL inorme = 1.0/norme;
401 REAL u2pv2pw2 = u_ave * u_ave + v_ave * v_ave + w_ave * w_ave;
402 REAL c_speed = gam1 * (h_ave - 0.5 * u2pv2pw2);
403 if(c_speed < 1e-6) c_speed = 1e-6;
404 c_speed =
sqrt(c_speed);
405 REAL c_speed2 = c_speed * norme;
408 REAL eig_val1 = scal - c_speed2;
409 REAL eig_val2 = scal;
410 REAL eig_val3 = scal + c_speed2;
419 if(eig_val2 <= 0.0) {
420 p_t = gam1 * (rhoE_t - 0.5 * (rhou_t * rhou_t +
421 rhov_t * rhov_t + rhow_t * rhow_t) * irho_t);
423 rhouv_t = rhou_t * v_t;
424 rhouw_t = rhou_t * w_t;
425 rhovw_t = rhov_t * w_t;
426 flux_rho = rhou_t * nx + rhov_t * ny + rhow_t * nz;
427 flux_rhou = (rhou_t * u_t + p_t) * nx + rhouv_t * ny + rhouw_t * nz;
428 flux_rhov = rhouv_t * nx + (rhov_t * v_t + p_t) * ny + rhovw_t * nz;
429 flux_rhow = rhouw_t * nx + rhovw_t * ny + (rhow_t * w_t + p_t) * nz;
430 flux_rhoE = ep_t * (u_t * nx + v_t * ny + w_t * nz);
434 p_f = gam1 * (rhoE_f - 0.5 * (rhou_f * rhou_f + rhov_f * rhov_f
435 + rhow_f * rhow_f) * irho_f);
436 lambda_f = u_f * nx + v_f * ny + w_f * nz + norme
437 *
sqrt(gam * p_f * irho_f);
438 lambda_t = u_t * nx + v_t * ny + w_t * nz + norme
439 *
sqrt(gam * p_t * irho_t);
440 if ((lambda_f < 0.) && (lambda_t > 0.)) {
441 eig_val3 = lambda_t * (eig_val3 - lambda_f) / (lambda_t - lambda_f);
444 if (eig_val3 > 0.0) {
447 delta_rho = rho_t - rho_f;
448 delta_rhou = rhou_t - rhou_f;
449 delta_rhov = rhov_t - rhov_f;
450 delta_rhow = rhow_t - rhow_f;
451 delta_rhoE = rhoE_t - rhoE_f;
453 scal = scal * inorme;
458 tempo11 = gam1 * usc;
461 a2 = u_ave * usc + hnx;
462 a3 = v_ave * usc + hny;
463 a4 = w_ave * usc + hnz;
464 a5 = 0.5 * u2pv2pw2 * usc + 2.5 * c_speed + scal;
466 b1 = 0.5 * (0.5 * tempo11 * u2pv2pw2 - scal);
467 b2 = 0.5 * (hnx - tempo11 * u_ave);
468 b3 = 0.5 * (hny - tempo11 * v_ave);
469 b4 = 0.5 * (hnz - tempo11 * w_ave);
472 alpha1 = b1 * delta_rho;
473 alpha2 = b2 * delta_rhou;
474 alpha3 = b3 * delta_rhov;
475 alpha4 = b4 * delta_rhow;
476 alpha5 = b5 * delta_rhoE;
477 alpha = eig_val3 * (alpha1 + alpha2 + alpha3 + alpha4 + alpha5);
479 flux_rho -= a1 * alpha;
480 flux_rhou -= a2 * alpha;
481 flux_rhov -= a3 * alpha;
482 flux_rhow -= a4 * alpha;
483 flux_rhoE -= a5 * alpha;
488 p_f = gam1 * (rhoE_f - 0.5 * (rhou_f * rhou_f +
489 rhov_f * rhov_f + rhow_f * rhow_f) * irho_f);
491 rhouv_f = rhou_f * v_f;
492 rhouw_f = rhou_f * w_f;
493 rhovw_f = rhov_f * w_f;
494 flux_rho = rhou_f * nx + rhov_f * ny + rhow_f * nz;
495 flux_rhou = (rhou_f * u_f + p_f) * nx + rhouv_f * ny + rhouw_f * nz;
496 flux_rhov = rhouv_f * nx + (rhov_f * v_f + p_f) * ny + rhovw_f * nz;
497 flux_rhow = rhouw_f * nx + rhovw_f * ny + (rhow_f * w_f + p_f) * nz;
498 flux_rhoE = ep_f * (u_f * nx + v_f * ny + w_f * nz);
502 p_t = gam1 * (rhoE_t - 0.5 * (rhou_t * rhou_t +
503 rhov_t * rhov_t + rhow_t * rhow_t) * irho_t);
504 lambda_f = u_f * nx + v_f * ny + w_f * nz - norme
505 *
sqrt(gam * p_f * irho_f);
506 lambda_t = u_t * nx + v_t * ny + w_t * nz - norme
507 *
sqrt(gam * p_t * irho_t);
508 if ((lambda_f < 0.) && (lambda_t > 0.)) {
509 eig_val1 = lambda_f * (lambda_t - eig_val1) / (lambda_t - lambda_f);
512 if (eig_val1 < 0.0) {
515 delta_rho = rho_t - rho_f;
516 delta_rhou = rhou_t - rhou_f;
517 delta_rhov = rhov_t - rhov_f;
518 delta_rhow = rhow_t - rhow_f;
519 delta_rhoE = rhoE_t - rhoE_f;
521 scal = scal * inorme;
526 tempo11 = gam1 * usc;
529 a2 = u_ave * usc - hnx;
530 a3 = v_ave * usc - hny;
531 a4 = w_ave * usc - hnz;
532 a5 = 0.5 * u2pv2pw2 * usc + 2.5 * c_speed - scal;
534 b1 = 0.5 * (0.5 * tempo11 * u2pv2pw2 + scal);
535 b2 = -0.5 * (hnx + tempo11 * u_ave);
536 b3 = -0.5 * (hny + tempo11 * v_ave);
537 b4 = -0.5 * (hnz + tempo11 * w_ave);
540 alpha1 = b1 * delta_rho;
541 alpha2 = b2 * delta_rhou;
542 alpha3 = b3 * delta_rhov;
543 alpha4 = b4 * delta_rhow;
544 alpha5 = b5 * delta_rhoE;
545 alpha = eig_val1 * (alpha1 + alpha2 + alpha3 + alpha4 + alpha5);
547 flux_rho += a1 * alpha;
548 flux_rhou += a2 * alpha;
549 flux_rhov += a3 * alpha;
550 flux_rhow += a4 * alpha;
551 flux_rhoE += a5 * alpha;
558 REAL rho_t, REAL rhou_t, REAL rhov_t, REAL rhoE_t,
559 REAL nx, REAL ny, REAL gam,
560 REAL &flux_rho, REAL &flux_rhou,REAL &flux_rhov, REAL &flux_rhoE){
562 REAL alpha1,alpha2,alpha3,alpha4,a1,a2,a3,a4,b1,b2,b3,b4,alpha;
563 REAL ep_t, ep_f, p_t, p_f;
564 REAL rhouv_t, rhouv_f;
565 REAL lambda_f, lambda_t;
566 REAL delta_rho, delta_rhou,delta_rhov, delta_rhoE;
575 REAL gam1 = gam - 1.0;
583 REAL coef1 =
sqrt(rho_f);
584 REAL coef2 =
sqrt(rho_t);
585 REAL somme_coef = coef1 + coef2;
586 REAL u_f = rhou_f/rho_f;
587 REAL v_f = rhov_f/rho_f;
588 REAL h_f = (gam * rhoE_f/rho_f) - (gam1 / 2.0) * (u_f * u_f + v_f * v_f);
589 REAL u_t = rhou_t/rho_t;
590 REAL v_t = rhov_t/rho_t;
591 REAL h_t = (gam * rhoE_t/rho_t) - (gam1 / 2.0) * (u_t * u_t + v_t * v_t);
595 REAL u_ave = (coef1 * u_f + coef2 * u_t) / somme_coef;
596 REAL v_ave = (coef1 * v_f + coef2 * v_t) / somme_coef;
597 REAL h_ave = (coef1 * h_f + coef2 * h_t) / somme_coef;
600 REAL scal = u_ave * nx + v_ave * ny;
601 REAL norme =
sqrt(nx * nx + ny * ny);
602 REAL u2pv2 = u_ave * u_ave + v_ave * v_ave;
603 REAL c_speed = gam1 * (h_ave - 0.5 * u2pv2);
604 if(c_speed < 1e-6) c_speed = 1e-6;
605 c_speed =
sqrt(c_speed);
606 REAL c_speed2 = c_speed * norme;
609 REAL eig_val1 = scal - c_speed2;
610 REAL eig_val2 = scal;
611 REAL eig_val3 = scal + c_speed2;
620 if(eig_val2 <= 0.0) {
621 p_t = gam1 * (rhoE_t - 0.5 * (rhou_t * rhou_t + rhov_t * rhov_t) / rho_t);
623 rhouv_t = rhou_t * v_t;
624 flux_rho = rhou_t * nx + rhov_t * ny;
625 flux_rhou = (rhou_t * u_t + p_t) * nx + rhouv_t * ny;
626 flux_rhov = rhouv_t * nx + (rhov_t * v_t + p_t) * ny;
627 flux_rhoE = ep_t * (u_t * nx + v_t * ny);
631 p_f = gam1 * (rhoE_f - 0.5 * (rhou_f * rhou_f + rhov_f * rhov_f) / rho_f);
632 lambda_f = u_f * nx + v_f * ny + norme *
sqrt(gam * p_f / rho_f);
633 lambda_t = u_t * nx + v_t * ny + norme
634 *
sqrt(gam * p_t / rho_t);
635 if ((lambda_f < 0.) && (lambda_t > 0.)) {
636 eig_val3 = lambda_t * (eig_val3 - lambda_f) / (lambda_t - lambda_f);
639 if (eig_val3 > 0.0) {
642 delta_rho = rho_t - rho_f;
643 delta_rhou = rhou_t - rhou_f;
644 delta_rhov = rhov_t - rhov_f;
645 delta_rhoE = rhoE_t - rhoE_f;
651 tempo11 = gam1 * usc;
654 a2 = u_ave * usc + hnx;
655 a3 = v_ave * usc + hny;
656 a4 = 0.5 * u2pv2 * usc + 2.5 * c_speed + scal;
658 b1 = 0.5 * eig_val3 * (0.5 * tempo11 * u2pv2 - scal);
659 b2 = 0.5 * eig_val3 * (hnx - tempo11 * u_ave);
660 b3 = 0.5 * eig_val3 * (hny - tempo11 * v_ave);
661 b4 = 0.5 * eig_val3 * tempo11;
663 alpha1 = a1 * b1 * delta_rho;
664 alpha2 = a1 * b2 * delta_rhou;
665 alpha3 = a1 * b3 * delta_rhov;
666 alpha4 = a1 * b4 * delta_rhoE;
667 alpha = alpha1 + alpha2 + alpha3 + alpha4;
670 flux_rhou -= a2 * b1 * delta_rho + a2 * b2 * delta_rhou +
671 a2 * b3 * delta_rhov + a2 * b4 * delta_rhoE;
672 flux_rhov -= a3 * b1 * delta_rho + a3 * b2 * delta_rhou +
673 a3 * b3 * delta_rhov + a3 * b4 * delta_rhoE;
674 flux_rhoE -= a4 * b1 * delta_rho + a4 * b2 * delta_rhou +
675 a4 * b3 * delta_rhov + a4 * b4 * delta_rhoE;
680 p_f = gam1 * (rhoE_f - REAL(0.5) * (rhou_f * rhou_f +
681 rhov_f * rhov_f) / rho_f);
683 rhouv_f = rhou_f * v_f;
684 flux_rho = rhou_f * nx + rhov_f * ny;
685 flux_rhou = (rhou_f * u_f + p_f) * nx + rhouv_f * ny;
686 flux_rhov = rhouv_f * nx + (rhov_f * v_f + p_f) * ny;
687 flux_rhoE = ep_f * (u_f * nx + v_f * ny);
691 p_t = gam1 * (rhoE_t - REAL(0.5) * (rhou_t * rhou_t +
692 rhov_t * rhov_t) / rho_t);
693 lambda_f = u_f * nx + v_f * ny - norme *
sqrt(gam * p_f / rho_f);
694 lambda_t = u_t * nx + v_t * ny - norme *
sqrt(gam * p_t / rho_t);
695 if ((lambda_f < 0.) && (lambda_t > 0.)) {
696 eig_val1 = lambda_f * (lambda_t - eig_val1) / (lambda_t - lambda_f);
699 if (eig_val1 < 0.0) {
702 delta_rho = rho_t - rho_f;
703 delta_rhou = rhou_t - rhou_f;
704 delta_rhov = rhov_t - rhov_f;
705 delta_rhoE = rhoE_t - rhoE_f;
711 tempo11 = gam1 * usc;
714 a2 = u_ave * usc - hnx;
715 a3 = v_ave * usc - hny;
716 a4 = 0.5 * u2pv2 * usc + 2.5 * c_speed - scal;
718 b1 = 0.5 * eig_val1 * (0.5 * tempo11 * u2pv2 + scal);
719 b2 = -0.5 * eig_val1 * (hnx + tempo11 * u_ave);
720 b3 = -0.5 * eig_val1 * (hny + tempo11 * v_ave);
721 b4 = 0.5 * eig_val1 * tempo11;
723 alpha1 = a1 * b1 * delta_rho;
724 alpha2 = a1 * b2 * delta_rhou;
725 alpha3 = a1 * b3 * delta_rhov;
726 alpha4 = a1 * b4 * delta_rhoE;
727 alpha = alpha1 + alpha2 + alpha3 + alpha4;
730 flux_rhou += a2 * b1 * delta_rho + a2 * b2 * delta_rhou +
731 a2 * b3 * delta_rhov + a2 * b4 * delta_rhoE;
732 flux_rhov += a3 * b1 * delta_rho + a3 * b2 * delta_rhou +
733 a3 * b3 * delta_rhov + a3 * b4 * delta_rhoE;
734 flux_rhoE += a4 * b1 * delta_rho + a4 * b2 * delta_rhou +
735 a4 * b3 * delta_rhov + a4 * b4 * delta_rhoE;
static std::string fArtificialDiffusion
Term that adds stability to the numerical method of approach: SUPG, LS, Bornhaus. ...
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
TPZFMatrix< REAL > fA
Matrix computation derivatives of fluxes: dFx/dx, dFy/dy, dFz/dz.
void SUPG(TPZFMatrix< REAL > &Tx, TPZFMatrix< REAL > &Ty, TPZFMatrix< REAL > &Tz)
void Divergence(TPZVec< REAL > &dphi, TPZFMatrix< REAL > &diverg)
void PointOperator(TPZVec< REAL > &dphi, TPZFMatrix< REAL > &diff_term)
Operation product point in the diffusion term.
Templated vector implementation.
void degree(int root, int adj_num, int adj_row[], int adj[], int mask[], int deg[], int *iccsze, int ls[], int node_num)
static REAL fDelta
Coefficient of size ratio of the element in the diffusion term.
void Tau(TPZFMatrix< REAL > &Tx, TPZFMatrix< REAL > &Ty, TPZFMatrix< REAL > &Tz)
int Zero() override
Makes Zero all the elements.
static void JacobFlux(TPZVec< REAL > U, TPZFMatrix< REAL > &A, TPZFMatrix< REAL > &B, TPZFMatrix< REAL > &C)
Jacobiano of the tensor flux of Euler.
Contains TPZMatrixclass which implements full matrix (using column major representation).
int64_t Rows() const
Returns number of rows.
Contains the TPZDiffusionConsLaw class which implements a Euler equation where is introduced a diffus...
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
static int GetgOrder()
Set the default value of the interpolation order.
Contains declaration of TPZCompelDisc class which implements a computational element for discontinuou...
int fDimension
Problem dimension.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
long double gamma(unsigned int n)
Evaluate the factorial of a integer.
void Bornhaus(TPZFMatrix< REAL > &Tx, TPZFMatrix< REAL > &Ty, TPZFMatrix< REAL > &Tz)
~TPZDiffusionConsLaw()
Destructor.
void LS(TPZFMatrix< REAL > &Tx, TPZFMatrix< REAL > &Ty, TPZFMatrix< REAL > &Tz)
void GradientOfTheFlow(TPZFMatrix< REAL > &DF1, TPZFMatrix< REAL > &DF2, TPZFMatrix< REAL > &DF3)
static REAL fCFL
Parameter that it limits the condition of stability of the numerical approach.
int64_t NElements() const
Returns the number of elements of the vector.
Contains the declaration of TPZFlopCounter class and TPZCounter struct.
void Transpose(TPZMatrix< TVar > *const T) const override
It makes *T the transpose of current matrix.
TPZDiffusionConsLaw()
Default constructor.
static REAL fGamma
Ratio between specific heat is constant and the specific heat the constant volume of a polytropic gas...
static void Roe_Flux(REAL rho_f, REAL rhou_f, REAL rhov_f, REAL rhow_f, REAL rhoE_f, REAL rho_t, REAL rhou_t, REAL rhov_t, REAL rhow_t, REAL rhoE_t, REAL nx, REAL ny, REAL nz, REAL gam, REAL &flux_rho, REAL &flux_rhou, REAL &flux_rhov, REAL &flux_rhow, REAL &flux_rhoE)
Flux of Roe (MOUSE program)