26 LoggerPtr fluxroe(Logger::getLogger(
"pz.fluxroe"));
27 LoggerPtr fluxappr(Logger::getLogger(
"pz.fluxappr"));
42 fArtDiff(artdiff, gamma),
70 return 1./((2.0*(REAL)degree) + 1.0);
80 REAL deltaT = CFL*deltax/maxveloc;
107 out <<
"Artificial Diffusion: " <<
109 out <<
"Number of State Variables: " <<
NStateVariables() << std::endl;
110 out <<
"Number of Fluxes: " <<
NFluxes() << std::endl;
115 out <<
"Explicit Diffusive term\n";
118 out <<
"ApproxImplicit Diffusive term\n";
121 out <<
"Implicit Diffusive term\n";
124 out <<
"No Diffusive term\n";
130 out <<
"Explicit Volume Convective term\n";
133 out <<
"Implicit Volume Convective term\n";
136 out <<
"No Volume Convective term\n";
142 out <<
"Explicit Face Convective term\n";
145 out <<
"Implicit Face Convective term\n";
148 out <<
"Approximate Implicit Face Convective term\n";
151 std::cout <<
"No Face Convective term\n";
158 if( !strcmp(name.c_str(),
"density") )
return 1;
159 if( !strcmp(name.c_str(),
"velocity") )
return 2;
160 if( !strcmp(name.c_str(),
"energy") )
return 3;
161 if( !strcmp(name.c_str(),
"pressure") )
return 4;
162 if( !strcmp(name.c_str(),
"solution") )
return 5;
163 if( !strcmp(name.c_str(),
"normvelocity") )
return 6;
164 if( !strcmp(name.c_str(),
"Mach") )
return 7;
165 std::cout <<
"TPZEulerConsLaw::VariableIndex not defined\n";
171 if(var == 1 || var == 3 || var == 4 || var == 6 || var == 7)
return 1;
175 std::cout <<
"TPZEulerConsLaw::NSolutionVariables not defined\n";
181 return REAL(2.) *
pow(
fabs(detJac),(REAL)(1./
fDim));
192 return Mat(0,0) * Mat(1,1) -
196 return Mat(0,0) * Mat(1,1) * Mat(2,2) +
197 Mat(1,0) * Mat(2,1) * Mat(0,2) +
198 Mat(2,0) * Mat(0,1) * Mat(1,2) -
199 Mat(0,2) * Mat(1,1) * Mat(2,0) -
200 Mat(1,2) * Mat(2,1) * Mat(0,0) -
201 Mat(2,2) * Mat(0,1) * Mat(1,0);
204 PZError <<
"TPZEulerConsLaw::Det error: unhandled matrix size: " <<
205 Mat.
Rows() << std::endl;
220 if(
fabs(Sol[0]) < 1.e-10) {
221 PZError <<
"\nTPZEulerConsLaw::Solution: Density almost null\n" 222 <<
"Density = " << Sol[0] << std::endl;
229 }
else if(var == 2) {
232 for(
int i=0;i<dim;i++) Solout[i] = Sol[i+1]/Sol[0];
234 }
else if(var == 3) {
237 Solout[0] = Sol[pos];
239 }
else if(var == 4) {
243 }
else if(var == 5) {
246 for(
int i=0;i<nstate;i++) Solout[i] = Sol[i];
248 }
else if(var == 6) {
251 REAL ro2 = Sol[0]*Sol[0];
253 for(
int i=1;i<nstate-1;i++) veloc += Sol[i]*Sol[i];
254 Solout[0] =
sqrt(veloc/ro2);
256 }
else if(var == 7) {
263 Solout[0] = us / cspeed;
281 void TPZEulerConsLaw::PrepareFAD(
288 int nShape = phi.
Rows();
289 int i_state, i_shape, k;
290 int nDer = nState * nShape;
293 FADREAL defaultFAD(nDer, REAL(0.), REAL(0.));
294 if(defaultFAD.dx(0)==1.)
PZError <<
"\nError: FAD doesn't have default constructor for parameters: (number of derivatives, default value, default derivative value) !";
296 FADsol.
Fill(defaultFAD);
299 FADdsol.
Fill(defaultFAD);
302 for(i_state = 0; i_state < nState; i_state++)
304 FADsol[i_state].val() = sol[i_state];
305 for(k = 0; k <
fDim; k ++)
306 FADdsol[i_state * fDim + k].
val() = dsol(k,i_state);
310 for(i_shape = 0; i_shape < nShape; i_shape++)
311 for(i_state = 0; i_state < nState; i_state++)
313 int index = i_state + i_shape * nState;
314 FADsol[i_state].fastAccessDx(index)=phi(i_shape,0);
315 for(k = 0; k <
fDim; k++)
316 FADdsol[i_state * fDim + k].
fastAccessDx(index)=dphi(k,i_shape);
320 void TPZEulerConsLaw::PrepareInterfaceFAD(
327 int nShapeL = phiL.
Rows();
328 int nShapeR = phiR.
Rows();
329 int i_state, i_shape;
330 int nDerL = nState * nShapeL;
331 int nDerR = nState * nShapeR;
334 FADREAL defaultFAD(nDerL + nDerR, REAL(0.), REAL(0.));
335 if(defaultFAD.dx(0)==1.)
PZError <<
"\nError: FAD doesn't have default constructor for parameters: (number of derivatives, default value, default derivative value) !";
337 FADsolL.
Fill(defaultFAD);
340 FADsolR.
Fill(defaultFAD);
343 for(i_state = 0; i_state < nState; i_state++)
345 FADsolL[i_state].val() = solL[i_state];
346 FADsolR[i_state].val() = solR[i_state];
350 for(i_shape = 0; i_shape < nShapeL; i_shape++)
351 for(i_state = 0; i_state < nState; i_state++)
353 int index = i_state + i_shape * nState;
354 FADsolL[i_state].fastAccessDx(index)=phiL(i_shape,0);
357 for(i_shape = 0; i_shape < nShapeR; i_shape++)
358 for(i_state = 0; i_state < nState; i_state++)
360 int index = i_state + (i_shape + nShapeL) * nState;
362 FADsolR[i_state].fastAccessDx(index)=phiR(i_shape,0);
367 void TPZEulerConsLaw::PrepareFastestInterfaceFAD(
373 int nVars = nState * 2;
378 for(
int i = 0; i < nState; i++)
380 FADsolL[i] = solL[i];
381 FADsolL[i].diff(i, nVars);
383 FADsolR[i] = solR[i];
384 FADsolR[i].diff(i + nState, nVars);
394 int numbersol = data.
sol.
size();
395 if (numbersol != 1) {
406 for(i = 0; i < nState; i++)
407 data.
sol[0][i] = res[i];
430 PZError <<
"TPZEulerConsLaw::Contribute> Unhandled Contribution Time";
435 int numbersol = data.
sol.
size();
436 if (numbersol != 1) {
447 for(i = 0; i < nState; i++)
448 data.
sol[i] = res[i];
471 PZError <<
"TPZEulerConsLaw::Contribute> Unhandled Contribution Time";
525 #ifdef FASTEST_IMPLICIT 526 ContributeFastestImplDiff(
fDim, x, jacinv, sol, dsol,
527 phi, dphi, weight, ek, ef);
530 PrepareFAD(sol, dsol, phi, dphi, FADsol, FADdsol);
531 ContributeImplDiff(x, jacinv, FADsol,FADdsol, weight, ek, ef);
534 std::cout <<
"TPZEulerConsLaw::Contribute> Implicit diffusive contribution: _AUTODIFF directive not configured -> Using an approximation to the tgMatrix";
581 if(fluxroe->isDebugEnabled()){
582 std::stringstream sout;
583 sout <<
"solL " << dataleft.
sol << std::endl <<
"solR " << dataright.
sol << std::endl;
588 int numbersol = dataleft.
sol.
size();
589 if (numbersol != 1) {
599 #ifdef FASTEST_IMPLICIT 600 ContributeFastestImplConvFace(
fDim, data.
x, dataleft.
sol[0], dataright.
sol[0],
601 weight, data.
normal, dataleft.
phi, dataright.
phi, ek, ef);
604 PrepareInterfaceFAD(dataleft.
sol[0], dataright.
sol[0], dataleft.
phi, dataright.
phi, FADsolL, FADsolR);
605 ContributeImplConvFace(data.
x,FADsolL,FADsolR, weight, data.
normal, dataleft.
phi, dataright.
phi, ek, ef);
607 if(fluxroe->isDebugEnabled()){
608 std::stringstream sout;
609 ek.
Print(
"computed tangent matrix",sout);
610 ef.
Print(
"computed rhs",sout);
617 std::cout <<
"TPZEulerConsLaw::ContributeInterface> Implicit face convective contribution: _AUTODIFF directive not configured";
626 PrepareInterfaceFAD(dataleft.
sol[0], dataright.
sol[0], dataleft.
phi, dataright.
phi, FADsolL, FADsolR);
630 if(fluxappr->isDebugEnabled()){
631 std::stringstream sout;
632 ek.
Print(
"computed tangent matrix",sout);
633 ef.
Print(
"computed rhs",sout);
671 for(i=0;i<nstate;i++) v2[i] = bc.
Val2()(i,0);
675 for(in = 0 ; in < phr; in++) {
676 for(i = 0 ; i < nstate; i++)
677 ef(in*nstate+i,0) +=
gBigNumber * weight * v2[i] * data.
phi(in,0);
678 for (jn = 0 ; jn < phr; jn++) {
679 for(i = 0 ; i < nstate; i++)
680 ek(in*nstate+i,jn*nstate+i) -=
gBigNumber * weight * data.
phi(in,0) * data.
phi(jn,0);
685 for(in = 0 ; in < data.
phi.
Rows(); in++) {
686 for(i = 0 ; i < nstate; i++)
687 ef(in*nstate+i,0) += v2[i] * data.
phi(in,0) * weight;
691 for(in = 0 ; in < data.
phi.
Rows(); in++) {
692 for(i = 0 ; i < nstate; i++)
693 ef(in*nstate+i, 0) += weight * v2[i] * data.
phi(in, 0);
694 for (jn = 0 ; jn < data.
phi.
Rows(); jn++) {
695 for(i = 0 ; i < nstate; i++)
for(j = 0 ; j < nstate; j++)
696 ek(in*nstate+i,jn*nstate+j) -= weight * bc.
Val1()(i,j) * data.
phi(in,0) * data.
phi(jn,0);
709 int numbersol = dataleft.
sol.
size();
710 if (numbersol != 1) {
739 #ifdef FASTEST_IMPLICIT 741 weight, data.
normal, dataleft.
phi, data.dphixl, data.axesleft, ek, ef, bc);
744 PrepareInterfaceFAD(dataleft.
sol[0], solR, dataleft.
phi, phiR, FADsolL, FADsolR);
746 ContributeImplConvFace(data.
x,FADsolL,FADsolR, weight, data.
normal, dataleft.
phi, phiR, ek, ef, entropyFix);
748 if(fluxroe->isDebugEnabled()){
749 std::stringstream sout;
750 ek.
Print(
"computed tangent matrix",sout);
751 ef.
Print(
"computed rhs",sout);
758 std::cout <<
"TPZEulerConsLaw::ContributeInterface> Implicit face convective contribution: _AUTODIFF directive not configured";
767 PrepareInterfaceFAD(dataleft.
sol[0], solR, dataleft.
phi, phiR, FADsolL, FADsolR);
769 ContributeApproxImplConvFace(data.
x,data.
HSize,FADsolL,FADsolR, weight, data.
normal, dataleft.
phi, phiR, ek, ef, entropyFix);
771 if(fluxappr->isDebugEnabled()){
772 std::stringstream sout;
773 ek.
Print(
"computed tangent matrix",sout);
774 ef.
Print(
"computed rhs",sout);
796 int numbersol = dataleft.
sol.
size();
797 if (numbersol != 1) {
819 normal2[0] = -data.
normal[0];
820 normal2[1] = -data.
normal[1];
823 Roe_Flux<STATE>(solR, dataleft.
sol[0], normal2,
fGamma, flux2);
824 STATE fluxs =
fabs(flux[0]+flux2[0])+
fabs(flux[1]+flux2[1])+
fabs(flux[2]+flux2[2])+
fabs(flux[3]+flux2[3]);
827 std::cout <<
"Fluxo nao simetrico fluxs = " << fluxs << std::endl;
832 REAL norflux = flux[1]*data.
normal[1]-flux[2]*data.
normal[0];
836 std::cout <<
"fluxo de parede errado 2 err " << err << std::endl;
846 dataleft.
phi,phiR,ef,entropyFix);
863 ContributeFastestBCInterface_dim<1>(x, solL, dsolL,
865 phiL, dphiL,axesleft,
869 ContributeFastestBCInterface_dim<2>(x, solL, dsolL,
871 phiL, dphiL,axesleft,
875 ContributeFastestBCInterface_dim<3>(x, solL, dsolL,
877 phiL, dphiL,axesleft,
881 PZError <<
"\nTPZEulerConsLaw::ContributeFastestBCInterface unhandled dimension\n";
916 for(
int i = 0; i < nstate; i++)
917 solL[i] = solR[i] = res[i];
923 PrepareFastestInterfaceFAD(solL, solR, FADsolL, FADsolR);
927 ContributeFastestImplConvFace_T(x, FADsolL, FADsolR,
947 T w1, w2, w5, uninf, usinf, cghost, usghost, unghost, p;
952 for(i=0;i<nstate; i++) solR[i] = bc.
Val2().operator()(i,0);
955 for(i=0;i<nstate; i++) solR[i] = solL[i];
958 for(i=1;i<nstate-1;i++) vpn += solL[i]*T(normal[i-1]);
959 for(i=1;i<nstate-1;i++) solR[i] = solL[i] - T(2.0*normal[i-1])*vpn;
961 solR[nstate-1] = solL[nstate-1];
965 for(i=0;i<nstate;i++) solR[i] = solL[i];
968 Mach = bc.
Val2().operator()(1,0);
969 solR[0] = bc.
Val2().operator()(0,0);
970 solR[nstate-1] = bc.
Val2().operator()(nstate - 1,0);
973 us =
sqrt(2 * temp * solR[nstate-1] /
974 ( solR[0] * (2 + temp)) );
976 for(i=1;i<nstate-1;i++) solR[i] = - us * normal[i-1];
983 Mach = bc.
Val2().operator()(1,0);
984 if(bc.
Val2().operator()(0,0) == 0.)
989 solR[0] = bc.
Val2().operator()(0,0);
993 us =
sqrt(T(2.) * temp * solR[nstate-1] /
994 ( solR[0] * (T(2.) + temp)) );
996 for(i=1;i<nstate-1;i++) solR[i] = us * normal[i-1];
1007 for(i = 1; i < nstate-1; i++)
1009 un += solL[i]/solL[0]*normal[i-1];
1010 us += solL[i] * solL[i] / solL[0] / solL[0];
1011 Mach += bc.
Val2()(i,0)*bc.
Val2()(i,0);
1021 p = (
fGamma - 1.) * (solL[nstate - 1] - solL[0] * us * us / T(2.));
1025 usinf = Mach * cinf;
1026 uninf = un / us * usinf;
1035 solR[0] = bc.
Val2()(0,0);
1037 for(i = 1; i < nstate-1; i++)
1038 solR[i] = (T)bc.
Val2()(0,0) *
1040 solL[i]/solL[0] / us;
1042 solR[nstate-1] = T(bc.
Val2()(nstate-1,0)) / T(
fGamma - 1.) +
1043 T(bc.
Val2()(0,0)) * usinf * usinf / T(2.);
1048 w1 = uninf - T(2.) * cinf/ T(
fGamma - 1.);
1053 w5 = un + T(2.) * c / T(
fGamma - 1.);
1056 cghost = (w5 - w1) * T((
fGamma - 1.)/4.);
1057 solR[0] =
pow(((T)cghost * cghost / (T(
fGamma) * w2)), (T)(1./(
fGamma - 1.)));
1058 unghost = (w1 + w5) / T(2.);
1059 usghost = us / un * unghost;
1060 for(i = 1; i < nstate - 1; i++)
1063 bc.
Val2()(i,0) / Mach;
1067 solR[nstate - 1] = solR[0] * (
1069 usghost * usghost / T(2.));
1099 for(i = 0; i < nstate; i++)
1107 solR[0] = solL[0] * (T)
pow(T(bc.
Val2()(nstate-1,0))/p, T(1./
fGamma));
1111 unghost = (c - cghost) * T(2./(
fGamma - 1.));
1114 for(i = 1; i < nstate - 1; i++)
1117 (solL[i] / solL[0] +
1118 unghost * normal[i-1]);
1119 usghost += solR[i] * solR[i] / solR[0] / solR[0];
1121 usghost =
sqrt(usghost);
1124 solR[nstate-1] = T(bc.
Val2()(nstate-1,0)/(
fGamma - 1.)) +
1125 solR[0] * usghost * usghost / T(2.);
1141 for(i = 1; i < nstate-1; i++)
1143 un += solL[i]/solL[0]*normal[i-1];
1144 us += solL[i] * solL[i] / solL[0] / solL[0];
1145 Mach += bc.
Val2()(i,0)*bc.
Val2()(i,0);
1155 p = (
fGamma - 1.) * (solL[nstate - 1] - solL[0] * us * us / T(2.));
1159 usinf = Mach * cinf;
1160 uninf = un / us * usinf;
1167 solR[0] = bc.
Val2()(0,0);
1169 for(i = 1; i < nstate-1; i++)
1170 solR[i] = T(bc.
Val2()(0,0)) *
1172 solL[i]/solL[0] / us;
1174 solR[nstate-1] = T(bc.
Val2()(nstate-1,0)) / T(
fGamma - 1.) +
1175 T(bc.
Val2()(0,0)) * usinf * usinf / T(2.);
1180 w1 = uninf - T(2.) * cinf/ T(
fGamma - 1.);
1185 w5 = un + T(2.) * c / T(
fGamma - 1.);
1188 cghost = (w5 - w1) * T((
fGamma - 1.)/4.);
1189 solR[0] =
pow(cghost * cghost / (T(
fGamma) * w2),(T)(1./(
fGamma - 1.)));
1190 unghost = (w1 + w5) / T(2.);
1191 usghost = us / un * unghost;
1192 for(i = 1; i < nstate - 1; i++)
1195 bc.
Val2()(i,0) / Mach;
1199 solR[nstate - 1] = solR[0] * (
1201 usghost * usghost / T(2.));
1215 for(i = 1; i < nstate-1; i++)
1217 un += solL[i]/solL[0]*normal[i-1];
1218 us += solL[i] * solL[i] / solL[0] / solL[0];
1223 p = (
fGamma - 1.) * (solL[nstate - 1] - solL[0] * us * us / T(2.));
1229 cghost = c + T((
fGamma - 1.)/2.)*un;
1232 solR[0] =
pow(cghost * cghost *
pow(T(solL[0]),T(
fGamma))/(T(p *
fGamma)), (T)(1./(fGamma - 1.)));
1236 for(i = 1; i < nstate-1; i++)
1239 solR[i] = solR[0] * (solL[i]/ solL[0] - un * normal[i-1]);
1240 usghost += solR[i] * solR[i] / solR[0] / solR[0];
1242 usghost =
sqrt(usghost);
1245 solR[nstate - 1] = solR[0] * (
1246 cghost * cghost /T(fGamma * (fGamma - 1.)) +
1247 usghost * usghost / T(2.));
1250 for(i=1;i<nstate-1;i++) vpn += solL[i]*T(normal[i-1]);
1251 for(i=1;i<nstate-1;i++) solR[i] = solL[i] - T(2.0*normal[i-1])*vpn;
1253 solR[nstate-1] = solL[nstate-1];
1257 for(i=0;i<nstate;i++) solR[i] = 0.;
1307 void TPZEulerConsLaw::ContributeImplDiff(
TPZVec<REAL> &x,
1334 fArtDiff.ContributeFastestImplDiff(dim, jacinv, sol, dsol, phi, dphi,
1355 Roe_Flux<STATE>(solL, solR, normal,
fGamma, flux, entropyFix);
1356 int nShapeL = phiL.
Rows(),
1357 nShapeR = phiR.
Rows(),
1361 REAL constant = weight;
1363 REAL constant =
TimeStep() * weight;
1368 for(i_shape = 0; i_shape < nShapeL; i_shape ++)
1369 for(i_state = 0; i_state < nState; i_state++)
1370 ef(i_shape*nState + i_state,0) +=
1371 flux[i_state] * phiL(i_shape,0) * constant;
1376 for(i_shape = 0; i_shape < nShapeR; i_shape ++)
1377 for(i_state = 0; i_state < nState; i_state++)
1378 ef((nShapeL + i_shape)*nState + i_state,0) -=
1379 flux[i_state] * phiR(i_shape,0) * constant;
1409 int nShapeL = phiL.
Rows(),
1410 nShapeR = phiR.
Rows(),
1411 i_shape, i_state, j,
1412 nDer = (nShapeL + nShapeR) * nState;
1416 REAL constant = weight;
1418 REAL constant =
TimeStep() * weight;
1422 for(i_shape = 0; i_shape < nShapeL; i_shape ++)
1423 for(i_state = 0; i_state < nState; i_state++)
1425 int index = i_shape*nState + i_state;
1427 flux[i_state].val() * phiL(i_shape,0) * constant;
1428 for(j = 0; j < nDer; j++)
1429 ek(index, j) -= flux[i_state].dx(j) *
1430 phiL(i_shape,0) * constant;
1436 for(i_shape = 0; i_shape < nShapeR; i_shape ++)
1437 for(i_state = 0; i_state < nState; i_state++)
1439 int index = (nShapeL + i_shape)*nState + i_state;
1441 flux[i_state].val() * phiR(i_shape,0) * constant;
1442 for(j = 0; j < nDer; j++)
1443 ek(index, j) += flux[i_state].dx(j) *
1444 phiR(i_shape,0) * constant;
1462 Flux(solR, FR[0], FR[1], FR[2]);
1471 int nShapeL = phiL.
Rows(),
1472 nShapeR = phiR.
Rows(),
1473 i_shape, i_state, i, j_state, j_shape;
1478 REAL constant = weight;
1480 REAL constant =
TimeStep() * weight;
1483 for(i_state=0; i_state<nState; i_state++)
1485 FN[i_state]= -(faceSize/constant)*(solR[i_state]-solL[i_state]);
1486 DFNL(i_state,i_state) = (faceSize/constant);
1487 DFNR(i_state,i_state) = -(faceSize/constant);
1488 for(i=0; i<
fDim; i++)
1490 FN[i_state]+=0.5*normal[i]*(
FL[i][i_state]+FR[i][i_state]);
1491 for(j_state=0; j_state<nState; j_state++)
1493 DFNL(i_state,j_state) +=0.5*normal[i]*(AL[i](i_state,j_state));
1494 DFNR(i_state,j_state) +=0.5*normal[i]*(AR[i](i_state,j_state));
1499 for(i_shape = 0; i_shape < nShapeL; i_shape ++)
1500 for(i_state = 0; i_state < nState; i_state++)
1502 int index = i_shape*nState + i_state;
1504 fluxroe[i_state] * phiL(i_shape,0) * constant;
1505 for(j_shape = 0; j_shape < nShapeL; j_shape++)
1508 for(j_state = 0; j_state < nState; j_state++)
1510 int jndex = j_shape*nState + j_state;
1511 ek(index,jndex) -= DFNL(i_state,j_state) *phiL(i_shape,0) * phiL(j_shape,0) * constant;
1514 for(j_shape = 0; j_shape < nShapeR; j_shape++)
1517 for(j_state = 0; j_state < nState; j_state++)
1519 int jndex = (nShapeL+j_shape)*nState + j_state;
1520 ek(index,jndex) -= DFNR(i_state,j_state) *phiL(i_shape,0) * phiR(j_shape,0) * constant;
1530 for(i_shape = 0; i_shape < nShapeR; i_shape ++)
1531 for(i_state = 0; i_state < nState; i_state++)
1533 int index = (nShapeL + i_shape)*nState + i_state;
1535 fluxroe[i_state] * phiR(i_shape,0) * constant;
1536 for(j_shape = 0; j_shape < nShapeL; j_shape++)
1539 for(j_state = 0; j_state < nState; j_state++)
1541 int jndex = j_shape*nState + j_state;
1542 ek(index,jndex) += DFNL(i_state,j_state) *phiR(i_shape,0) * phiL(j_shape,0) * constant;
1545 for(j_shape = 0; j_shape < nShapeR; j_shape++)
1548 for(j_state = 0; j_state < nState; j_state++)
1550 int jndex = (nShapeL+j_shape)*nState + j_state;
1551 ek(index,jndex) += DFNR(i_state,j_state) *phiR(i_shape,0) * phiR(j_shape,0) * constant;
1561 void TPZEulerConsLaw::ContributeImplConvFace(
TPZVec<REAL> &x,
1587 int nShapeL = phiL.
Rows(),
1588 nShapeR = phiR.
Rows(),
1589 i_shape, i_state, j,
1590 nDer = (nShapeL + nShapeR) * nState;
1594 REAL constant = weight;
1596 REAL constant =
TimeStep() * weight;
1600 for(i_shape = 0; i_shape < nShapeL; i_shape ++)
1601 for(i_state = 0; i_state < nState; i_state++)
1603 int index = i_shape*nState + i_state;
1605 flux[i_state].val() * phiL(i_shape,0) * constant;
1606 for(j = 0; j < nDer; j++)
1607 ek(index, j) -= flux[i_state].dx(j) *
1608 phiL(i_shape,0) * constant;
1614 for(i_shape = 0; i_shape < nShapeR; i_shape ++)
1615 for(i_state = 0; i_state < nState; i_state++)
1617 int index = (nShapeL + i_shape)*nState + i_state;
1619 flux[i_state].val() * phiR(i_shape,0) * constant;
1620 for(j = 0; j < nDer; j++)
1621 ek(index, j) += flux[i_state].dx(j) *
1622 phiR(i_shape,0) * constant;
1626 void TPZEulerConsLaw::ContributeFastestImplConvFace(
int dim,
1637 ContributeFastestImplConvFace_dim<1>(x, solL, solR, weight, normal,
1638 phiL, phiR, ek, ef, entropyFix);
1641 ContributeFastestImplConvFace_dim<2>(x, solL, solR, weight, normal,
1642 phiL, phiR, ek, ef, entropyFix);
1645 ContributeFastestImplConvFace_dim<3>(x, solL, solR, weight, normal,
1646 phiL, phiR, ek, ef, entropyFix);
1649 PZError <<
"\nTPZEulerConsLaw::ContributeFastestImplConvFace unhandled dimension\n";
1655 void TPZEulerConsLaw::ContributeFastestImplConvFace_dim(
1676 PrepareFastestInterfaceFAD(solL, solR, FADsolL, FADsolR);
1678 ContributeFastestImplConvFace_T(x, FADsolL, FADsolR, weight, normal,
1679 phiL, phiR, ek, ef, entropyFix);
1683 void TPZEulerConsLaw::ContributeFastestImplConvFace_T(
TPZVec<REAL> &x,
1694 int nShapeL = phiL.
Rows(),
1695 nShapeR = phiR.
Rows(),
1696 i_shape, i_state, j, k,
1697 nDerL = nShapeL * nState;
1701 REAL constant = weight;
1703 REAL constant =
TimeStep() * weight;
1710 for(i_shape = 0; i_shape < nShapeL; i_shape ++)
1711 for(i_state = 0; i_state < nState; i_state++)
1713 int index = i_shape*nState + i_state;
1715 FADflux[i_state].val() * phiL(i_shape,0) * constant;
1716 for(k = 0; k < nState; k++)
1718 for(j = 0; j < nShapeL; j++)
1719 ek(index, j * nState + k) -=
1720 FADflux[i_state].dx(k) *
1724 for(j = 0; j < nShapeR; j++)
1725 ek(index, j*nState + k + nDerL) -=
1726 FADflux[i_state].dx(k + nState) *
1736 for(i_shape = 0; i_shape < nShapeR; i_shape ++)
1737 for(i_state = 0; i_state < nState; i_state++)
1739 int index = (nShapeL + i_shape) * nState + i_state;
1741 FADflux[i_state].val() * phiR(i_shape,0) * constant;
1742 for(k = 0; k < nState; k++)
1744 for(j = 0; j < nShapeL; j++)
1745 ek(index, j * nState + k) +=
1746 FADflux[i_state].dx(k) *
1750 for(j = 0; j < nShapeR; j++)
1751 ek(index, j * nState + k + nDerL) +=
1752 FADflux[i_state].dx(k + nState) *
1770 Flux(sol, F[0], F[1], F[2]);
1774 REAL constant = -weight;
1776 REAL constant = -
TimeStep() * weight;
1779 int i_state, i_shape, nShape = phi.
Rows(), k;
1782 for(i_shape=0; i_shape<nShape; i_shape++)
1783 for(i_state = 0; i_state<nState; i_state++)
1785 int index = i_state + i_shape * nState;
1786 for(k=0; k<
fDim; k++)
1787 ef(index,0) += (F[k])[i_state] * dphi(k, i_shape) * constant;
1801 Flux(sol, F[0], F[1], F[2]);
1804 REAL constant = -weight;
1806 REAL constant = -
TimeStep() * weight;
1811 int j_shape, j_state;
1812 int i_state, i_shape, nShape = phi.
Rows(), k;
1815 for(i_shape=0; i_shape<nShape; i_shape++)
1816 for(i_state = 0; i_state<nState; i_state++)
1818 int index = i_state + i_shape * nState;
1819 for(k=0; k<
fDim; k++)
1822 ef(index,0) += (F[k])[i_state] * dphi(k, i_shape)
1824 for(j_shape = 0; j_shape < nShape; j_shape++)
1825 for(j_state = 0; j_state < nState; j_state++)
1826 ek(index, j_state + j_shape * nState) -=
1827 Ai[k](i_state, j_state) *
1848 std::cout << __PRETTY_FUNCTION__ <<
" Zero timestep bailing out\n";
1852 int i_shape, ij_state;
1854 int nShape = phi.
Rows();
1857 REAL constant = weight /
TimeStep();
1859 REAL constant = weight;
1862 for(i_shape = 0; i_shape < nShape; i_shape++)
1863 for(ij_state = 0; ij_state < nState; ij_state++)
1865 int index = i_shape * nState + ij_state;
1868 sol[ij_state] * phi(i_shape,0) *
1881 std::cout << __PRETTY_FUNCTION__ <<
" Zero timestep bailing out\n";
1885 int i_shape, ij_state, j_shape;
1887 int nShape = phi.
Rows();
1890 REAL constant = weight /
TimeStep();
1892 REAL constant = weight;
1895 for(i_shape = 0; i_shape < nShape; i_shape++)
1896 for(ij_state = 0; ij_state < nState; ij_state++)
1898 int index = i_shape * nState + ij_state;
1901 sol[ij_state] * phi(i_shape,0) *
1904 for(j_shape = 0; j_shape < nShape; j_shape++)
1905 ek(index, j_shape * nState + ij_state) -=
1920 std::cout << __PRETTY_FUNCTION__ <<
" Zero timestep bailing out\n";
1924 int i_shape, i_state;
1926 int nShape = phi.
Rows();
1929 REAL constant = weight /
TimeStep();
1931 REAL constant = weight;
1934 for(i_shape = 0; i_shape < nShape; i_shape++)
1935 for(i_state = 0; i_state < nState; i_state++)
1937 int index = i_shape * nState + i_state;
1940 sol[i_state] * phi(i_shape,0) *
1950 int tmp = static_cast <
int > (
fDiff);
1995 ApproxRoe_Flux<T>(solL[0], solL[1], solL[2], solL[3], solL[4],
1996 solR[0], solR[1], solR[2], solR[3], solR[4],
1997 normal[0], normal[1], normal[2],
1999 flux[0], flux[1], flux[2], flux[3], flux[4], entropyFix);
2001 }
else if(nState == 4)
2003 ApproxRoe_Flux<T>(solL[0], solL[1], solL[2], solL[3],
2004 solR[0], solR[1], solR[2], solR[3],
2005 normal[0], normal[1],
2007 flux[0], flux[1], flux[2], flux[3], entropyFix);
2008 }
else if(nState == 3)
2015 ApproxRoe_Flux<T>(solL[0], solL[1], auxL, solL[2],
2016 solR[0], solR[1], auxR, solR[2],
2019 flux[0], flux[1], fluxaux, flux[2], entropyFix);
2022 PZError <<
"No flux on " << nState <<
" state variables.\n";
2031 void TPZEulerConsLaw::ApproxRoe_Flux<FADREAL>(
const FADREAL & rho_f,
2032 const FADREAL & rhou_f,
2033 const FADREAL & rhov_f,
2034 const FADREAL & rhow_f,
2035 const FADREAL & rhoE_f,
2036 const FADREAL & rho_t,
2037 const FADREAL & rhou_t,
2038 const FADREAL & rhov_t,
2039 const FADREAL & rhow_t,
2040 const FADREAL & rhoE_t,
2046 FADREAL & flux_rhou,
2047 FADREAL & flux_rhov,
2048 FADREAL & flux_rhow,
2049 FADREAL & flux_rhoE,
int entropyFix)
2054 REAL a1,a2,a3,a4,a5,b1,b2,b3,b4,b5;
2058 T delta_rho, delta_rhou, delta_rhov, delta_rhow, delta_rhoE;
2068 REAL gam1 = gam - 1.0;
2069 REAL irho_f = REAL(1.0)/rho_f.val();
2070 REAL irho_t = REAL(1.0)/rho_t.val();
2076 REAL coef1 =
sqrt(rho_f.val());
2077 REAL coef2 =
sqrt(rho_t.val());
2078 REAL somme_coef = coef1 + coef2;
2079 REAL isomme_coef = REAL(1.0)/somme_coef;
2080 REAL u_f = rhou_f.val()*irho_f;
2081 REAL v_f = rhov_f.val()*irho_f;
2082 REAL w_f = rhow_f.val()*irho_f;
2083 REAL h_f = (gam * rhoE_f.val()*irho_f) - (.5*gam1) * (u_f * u_f + v_f * v_f + w_f * w_f);
2084 REAL u_t = rhou_t.val()*irho_t;
2085 REAL v_t = rhov_t.val()*irho_t;
2086 REAL w_t = rhow_t.val()*irho_t;
2087 REAL h_t = (gam * rhoE_t.val()*irho_t) - (.5*gam1) * (u_t * u_t + v_t * v_t + w_t * w_t);
2091 REAL u_ave = (coef1 * u_f + coef2 * u_t) * isomme_coef;
2092 REAL v_ave = (coef1 * v_f + coef2 * v_t) * isomme_coef;
2093 REAL w_ave = (coef1 * w_f + coef2 * w_t) * isomme_coef;
2094 REAL h_ave = (coef1 * h_f + coef2 * h_t) * isomme_coef;
2097 REAL scal = u_ave * nx + v_ave * ny + w_ave * nz;
2098 REAL norme =
sqrt(nx * nx + ny * ny + nz * nz);
2099 REAL inorme = REAL(1.0)/norme;
2100 REAL u2pv2pw2 = u_ave * u_ave + v_ave * v_ave + w_ave * w_ave;
2101 REAL c_speed = gam1 * (h_ave - REAL(0.5) * u2pv2pw2);
2102 if(c_speed < REAL(1e-6)) c_speed = 1e-6;
2103 c_speed =
sqrt(c_speed);
2104 REAL c_speed2 = c_speed * norme;
2107 REAL eig_val1 = scal - c_speed2;
2108 REAL eig_val2 = scal;
2109 REAL eig_val3 = scal + c_speed2;
2118 if(eig_val2 <= REAL(0.0)) {
2119 T irho_t = REAL(1.0)/rho_t;
2120 T u_t = rhou_t*irho_t;
2121 T v_t = rhov_t*irho_t;
2122 T w_t = rhow_t*irho_t;
2123 T h_t = (gam * rhoE_t*irho_t) - (.5*gam1) * (u_t * u_t + v_t * v_t + w_t * w_t);
2125 T p_t,ep_t,rhouv_t,rhouw_t,rhovw_t;
2126 REAL lambda_f,lambda_t;
2127 p_t = gam1 * (rhoE_t - REAL(0.5) * (rhou_t * rhou_t +
2128 rhov_t * rhov_t + rhow_t * rhow_t) * irho_t);
2129 ep_t = rhoE_t + p_t;
2130 rhouv_t = rhou_t * v_t;
2131 rhouw_t = rhou_t * w_t;
2132 rhovw_t = rhov_t * w_t;
2133 flux_rho = rhou_t * nx + rhov_t * ny + rhow_t * nz;
2134 flux_rhou = (rhou_t * u_t + p_t) * nx + rhouv_t * ny + rhouw_t * nz;
2135 flux_rhov = rhouv_t * nx + (rhov_t * v_t + p_t) * ny + rhovw_t * nz;
2136 flux_rhow = rhouw_t * nx + rhovw_t * ny + (rhow_t * w_t + p_t) * nz;
2137 flux_rhoE = ep_t * (u_t * nx + v_t * ny + w_t * nz);
2141 REAL p_f = gam1 * (rhoE_f.val() - REAL(0.5) * (rhou_f.val() * rhou_f.val() + rhov_f.val() * rhov_f.val()
2142 + rhow_f.val() * rhow_f.val()) * irho_f);
2143 lambda_f = u_f * nx + v_f * ny + w_f * nz + norme
2144 *
sqrt(gam * p_f * irho_f);
2145 lambda_t = u_t.val() * nx + v_t.val() * ny + w_t.val() * nz + norme
2146 *
sqrt(gam * p_t.val() * irho_t.val());
2147 if (entropyFix && (lambda_f < REAL(0.)) && (lambda_t > REAL(0.))) {
2148 eig_val3 = lambda_t * (eig_val3 - lambda_f) / (lambda_t - lambda_f);
2151 if (eig_val3 > REAL(0.0)) {
2154 T alpha1,alpha2,alpha3,alpha4,alpha5,alpha;
2155 delta_rho = rho_t - rho_f;
2156 delta_rhou = rhou_t - rhou_f;
2157 delta_rhov = rhov_t - rhov_f;
2158 delta_rhow = rhow_t - rhow_f;
2159 delta_rhoE = rhoE_t - rhoE_f;
2161 scal = scal * inorme;
2165 usc = REAL(1.0)/c_speed;
2166 tempo11 = gam1 * usc;
2169 a2 = u_ave * usc + hnx;
2170 a3 = v_ave * usc + hny;
2171 a4 = w_ave * usc + hnz;
2172 a5 = REAL(0.5) * u2pv2pw2 * usc + REAL(2.5) * c_speed + scal;
2174 b1 = REAL(0.5) * (REAL(0.5) * tempo11 * u2pv2pw2 - scal);
2175 b2 = REAL(0.5) * (hnx - tempo11 * u_ave);
2176 b3 = REAL(0.5) * (hny - tempo11 * v_ave);
2177 b4 = REAL(0.5) * (hnz - tempo11 * w_ave);
2178 b5 = REAL(0.5) * tempo11;
2180 alpha1 = b1 * delta_rho;
2181 alpha2 = b2 * delta_rhou;
2182 alpha3 = b3 * delta_rhov;
2183 alpha4 = b4 * delta_rhow;
2184 alpha5 = b5 * delta_rhoE;
2185 alpha = eig_val3 * (alpha1 + alpha2 + alpha3 + alpha4 + alpha5);
2187 flux_rho -= a1 * alpha;
2188 flux_rhou -= a2 * alpha;
2189 flux_rhov -= a3 * alpha;
2190 flux_rhow -= a4 * alpha;
2191 flux_rhoE -= a5 * alpha;
2195 if(eig_val2 > REAL(0.0)) {
2196 T p_f,ep_f,rhouv_f,rhovw_f,rhouw_f;
2197 T irho_f = REAL(1.0)/rho_f.val();
2199 T u_f = rhou_f.val()*irho_f;
2200 T v_f = rhov_f.val()*irho_f;
2201 T w_f = rhow_f.val()*irho_f;
2202 T h_f = (gam * rhoE_f.val()*irho_f) - (.5*gam1) * (u_f * u_f + v_f * v_f + w_f * w_f);
2203 p_f = gam1 * (rhoE_f - REAL(0.5) * (rhou_f * rhou_f +
2204 rhov_f * rhov_f + rhow_f * rhow_f) * irho_f);
2205 ep_f = rhoE_f + p_f;
2206 rhouv_f = rhou_f * v_f;
2207 rhouw_f = rhou_f * w_f;
2208 rhovw_f = rhov_f * w_f;
2209 flux_rho = rhou_f * nx + rhov_f * ny + rhow_f * nz;
2210 flux_rhou = (rhou_f * u_f + p_f) * nx + rhouv_f * ny + rhouw_f * nz;
2211 flux_rhov = rhouv_f * nx + (rhov_f * v_f + p_f) * ny + rhovw_f * nz;
2212 flux_rhow = rhouw_f * nx + rhovw_f * ny + (rhow_f * w_f + p_f) * nz;
2213 flux_rhoE = ep_f * (u_f * nx + v_f * ny + w_f * nz);
2217 REAL p_t = gam1 * (rhoE_t.val() - REAL(0.5) * (rhou_t.val() * rhou_t.val() +
2218 rhov_t.val() * rhov_t.val() + rhow_t.val() * rhow_t.val()) * irho_t);
2219 REAL lambda_f = u_f.val() * nx + v_f.val() * ny + w_f.val() * nz - norme
2220 *
sqrt(gam * p_f.val() * irho_f.val());
2221 REAL lambda_t = u_t * nx + v_t * ny + w_t * nz - norme
2222 *
sqrt(gam * p_t * irho_t);
2223 if (entropyFix && (lambda_f < REAL(0.)) && (lambda_t > REAL(0.))) {
2224 eig_val1 = lambda_f * (lambda_t - eig_val1) / (lambda_t - lambda_f);
2227 if (eig_val1 < REAL(0.0)) {
2230 T alpha1,alpha2,alpha3,alpha4,alpha5,alpha;
2231 delta_rho = rho_t - rho_f;
2232 delta_rhou = rhou_t - rhou_f;
2233 delta_rhov = rhov_t - rhov_f;
2234 delta_rhow = rhow_t - rhow_f;
2235 delta_rhoE = rhoE_t - rhoE_f;
2237 scal = scal * inorme;
2241 usc = REAL(1.0)/c_speed;
2242 tempo11 = gam1 * usc;
2245 a2 = u_ave * usc - hnx;
2246 a3 = v_ave * usc - hny;
2247 a4 = w_ave * usc - hnz;
2248 a5 = REAL(0.5) * u2pv2pw2 * usc + REAL(2.5) * c_speed - scal;
2250 b1 = REAL(0.5) * (REAL(0.5) * tempo11 * u2pv2pw2 + scal);
2251 b2 = -REAL(0.5) * (hnx + tempo11 * u_ave);
2252 b3 = -REAL(0.5) * (hny + tempo11 * v_ave);
2253 b4 = -REAL(0.5) * (hnz + tempo11 * w_ave);
2254 b5 = REAL(0.5) * tempo11;
2256 alpha1 = b1 * delta_rho;
2257 alpha2 = b2 * delta_rhou;
2258 alpha3 = b3 * delta_rhov;
2259 alpha4 = b4 * delta_rhow;
2260 alpha5 = b5 * delta_rhoE;
2261 alpha = eig_val1 * (alpha1 + alpha2 + alpha3 + alpha4 + alpha5);
2263 flux_rho += a1 * alpha;
2264 flux_rhou += a2 * alpha;
2265 flux_rhov += a3 * alpha;
2266 flux_rhow += a4 * alpha;
2267 flux_rhoE += a5 * alpha;
2278 void TPZEulerConsLaw::ApproxRoe_Flux<FADREAL>(
const FADREAL & rho_f,
2279 const FADREAL & rhou_f,
2280 const FADREAL & rhov_f,
2281 const FADREAL & rhoE_f,
2282 const FADREAL & rho_t,
2283 const FADREAL & rhou_t,
2284 const FADREAL & rhov_t,
2285 const FADREAL & rhoE_t,
2292 FADREAL &flux_rhoE,
int entropyFix)
2295 typedef REAL locREAL;
2296 locREAL rho_fv, rhou_fv, rhov_fv, rhoE_fv, rho_tv, rhou_tv, rhov_tv, rhoE_tv;
2298 rho_fv = rho_f.val();
2299 rhou_fv = rhou_f.val();
2300 rhov_fv = rhov_f.val();
2301 rhoE_fv = rhoE_f.val();
2302 rho_tv = rho_t.val();
2303 rhou_tv = rhou_t.val();
2304 rhov_tv = rhov_t.val();
2305 rhoE_tv = rhoE_t.val();
2323 locREAL u_fv = rhou_fv/rho_fv;
2324 locREAL v_fv = rhov_fv/rho_fv;
2325 locREAL u_tv = rhou_tv/rho_tv;
2326 locREAL v_tv = rhov_tv/rho_tv;
2327 REAL gam1 = gam - REAL(1.0);
2328 locREAL p_tv = gam1 * (rhoE_tv - REAL(0.5) * (rhou_tv * rhou_tv + rhov_tv * rhov_tv) / rho_tv);
2329 locREAL p_fv = gam1 * (rhoE_fv - REAL(0.5) * (rhou_fv * rhou_fv + rhov_fv * rhov_fv) / rho_fv);
2330 REAL norme =
sqrt(nx * nx + ny * ny);
2331 locREAL scal,c_speed;
2332 locREAL u_ave,v_ave,u2pv2;
2347 locREAL coef1 =
sqrt(rho_fv);
2348 locREAL coef2 =
sqrt(rho_tv);
2349 locREAL somme_coef = coef1 + coef2;
2350 locREAL h_f = (gam * rhoE_fv/rho_fv) - (u_fv * u_fv + v_fv * v_fv) * (gam1 / REAL(2.0));
2351 locREAL h_t = (gam * rhoE_tv/rho_tv) - (u_tv * u_tv + v_tv * v_tv) * (gam1 / REAL(2.0));
2356 u_ave = (coef1 * u_fv + coef2 * u_tv) / somme_coef;
2357 v_ave = (coef1 * v_fv + coef2 * v_tv) / somme_coef;
2358 locREAL h_ave = (coef1 * h_f + coef2 * h_t) / somme_coef;
2361 scal = u_ave * nx + v_ave * ny;
2362 u2pv2 = u_ave * u_ave + v_ave * v_ave;
2363 c_speed = gam1 * (h_ave - REAL(0.5) * u2pv2);
2365 if(c_speed < REAL(1e-6)) c_speed = REAL(1e-6);
2366 c_speed =
sqrt(c_speed);
2367 c_speed2 = c_speed * norme;
2370 eig_val1 = scal - c_speed2;
2372 eig_val3 = scal + c_speed2;
2383 if(eig_val2 <= REAL(0.0)) {
2385 p_t = gam1 * (rhoE_t - REAL(0.5) * (rhou_t * rhou_t + rhov_t * rhov_t) / rho_t);
2386 ep_t = rhoE_t + p_t;
2387 T u_t = rhou_t/rho_t;
2388 T v_t = rhov_t/rho_t;
2389 T rhouv_t = rhou_t * v_t;
2390 flux_rho = rhou_t * nx + rhov_t * ny;
2391 flux_rhou = (rhou_t * u_t + p_t) * nx + rhouv_t * ny;
2392 flux_rhov = rhouv_t * nx + (rhov_t * v_t + p_t) * ny;
2393 flux_rhoE = ep_t * (u_t * nx + v_t * ny);
2397 locREAL lambda_f = u_fv * nx + v_fv * ny + norme *
sqrt(gam * p_fv / rho_fv);
2398 locREAL lambda_t = u_tv * nx + v_tv * ny + norme
2399 *
sqrt(gam * p_tv / rho_tv);
2400 if (entropyFix && (lambda_f < REAL(0.)) && (lambda_t > REAL(0.))) {
2401 eig_val3 = lambda_t * (eig_val3 - lambda_f) / (lambda_t - lambda_f);
2404 if (eig_val3 > REAL(0.0)) {
2407 T alpha1,alpha2,alpha3,alpha4,alpha;
2408 locREAL a1,a2,a3,a4,b1,b2,b3,b4;
2409 T delta_rho, delta_rhou,delta_rhov, delta_rhoE;
2410 delta_rho = rho_t - rho_f;
2411 delta_rhou = rhou_t - rhou_f;
2412 delta_rhov = rhov_t - rhov_f;
2413 delta_rhoE = rhoE_t - rhoE_f;
2415 scal = scal / norme;
2416 REAL hnx = nx / norme;
2417 REAL hny = ny / norme;
2418 locREAL usc = REAL(1.0)/c_speed;
2419 locREAL tempo11 = gam1 * usc;
2422 a2 = u_ave * usc + hnx;
2423 a3 = v_ave * usc + hny;
2424 a4 = REAL(0.5) * u2pv2 * usc + REAL(2.5) * c_speed + scal;
2426 b1 = REAL(0.5) * eig_val3 * (REAL(0.5) * tempo11 * u2pv2 - scal);
2427 b2 = REAL(0.5) * eig_val3 * (hnx - tempo11 * u_ave);
2428 b3 = REAL(0.5) * eig_val3 * (hny - tempo11 * v_ave);
2429 b4 = REAL(0.5) * eig_val3 * tempo11;
2431 alpha1 = a1 * b1 * delta_rho;
2432 alpha2 = a1 * b2 * delta_rhou;
2433 alpha3 = a1 * b3 * delta_rhov;
2434 alpha4 = a1 * b4 * delta_rhoE;
2435 alpha = alpha1 + alpha2 + alpha3 + alpha4;
2438 flux_rhou -= a2 * b1 * delta_rho + a2 * b2 * delta_rhou +
2439 a2 * b3 * delta_rhov + a2 * b4 * delta_rhoE;
2440 flux_rhov -= a3 * b1 * delta_rho + a3 * b2 * delta_rhou +
2441 a3 * b3 * delta_rhov + a3 * b4 * delta_rhoE;
2442 flux_rhoE -= a4 * b1 * delta_rho + a4 * b2 * delta_rhou +
2443 a4 * b3 * delta_rhov + a4 * b4 * delta_rhoE;
2447 if(eig_val2 > REAL(0.0)) {
2449 T u_f = rhou_f/rho_f;
2450 T v_f = rhov_f/rho_f;
2451 p_f = gam1 * (rhoE_f - REAL(0.5) * (rhou_f * rhou_f +
2452 rhov_f * rhov_f) / rho_f);
2453 ep_f = rhoE_f + p_f;
2454 T rhouv_f = rhou_f * v_f;
2455 flux_rho = rhou_f * nx + rhov_f * ny;
2456 flux_rhou = (rhou_f * u_f + p_f) * nx + rhouv_f * ny;
2457 flux_rhov = rhouv_f * nx + (rhov_f * v_f + p_f) * ny;
2458 flux_rhoE = ep_f * (u_f * nx + v_f * ny);
2462 locREAL lambda_f = u_fv * nx + v_fv * ny - norme *
sqrt(gam * p_fv / rho_fv);
2463 locREAL lambda_t = u_tv * nx + v_tv * ny - norme *
sqrt(gam * p_tv / rho_tv);
2464 if (entropyFix && (lambda_f < REAL(0.)) && (lambda_t > REAL(0.))) {
2465 eig_val1 = lambda_f * (lambda_t - eig_val1) / (lambda_t - lambda_f);
2468 if (eig_val1 < REAL(0.0)) {
2471 T alpha1,alpha2,alpha3,alpha4,alpha;
2472 locREAL a1,a2,a3,a4,b1,b2,b3,b4;
2473 T delta_rho, delta_rhou,delta_rhov, delta_rhoE;
2474 delta_rho = rho_t - rho_f;
2475 delta_rhou = rhou_t - rhou_f;
2476 delta_rhov = rhov_t - rhov_f;
2477 delta_rhoE = rhoE_t - rhoE_f;
2479 scal = scal / norme;
2480 REAL hnx = nx / norme;
2481 REAL hny = ny / norme;
2482 locREAL usc = REAL(1.0)/c_speed;
2483 locREAL tempo11 = gam1 * usc;
2486 a2 = u_ave * usc - hnx;
2487 a3 = v_ave * usc - hny;
2488 a4 = REAL(0.5) * u2pv2 * usc + REAL(2.5) * c_speed - scal;
2490 b1 = REAL(0.5) * eig_val1 * (REAL(0.5) * tempo11 * u2pv2 + scal);
2491 b2 = -REAL(0.5) * eig_val1 * (hnx + tempo11 * u_ave);
2492 b3 = -REAL(0.5) * eig_val1 * (hny + tempo11 * v_ave);
2493 b4 = REAL(0.5) * eig_val1 * tempo11;
2495 alpha1 = a1 * b1 * delta_rho;
2496 alpha2 = a1 * b2 * delta_rhou;
2497 alpha3 = a1 * b3 * delta_rhov;
2498 alpha4 = a1 * b4 * delta_rhoE;
2499 alpha = alpha1 + alpha2 + alpha3 + alpha4;
2502 flux_rhou += a2 * b1 * delta_rho + a2 * b2 * delta_rhou +
2503 a2 * b3 * delta_rhov + a2 * b4 * delta_rhoE;
2504 flux_rhov += a3 * b1 * delta_rho + a3 * b2 * delta_rhou +
2505 a3 * b3 * delta_rhov + a3 * b4 * delta_rhoE;
2506 flux_rhoE += a4 * b1 * delta_rho + a4 * b2 * delta_rhou +
2507 a4 * b3 * delta_rhov + a4 * b4 * delta_rhoE;
virtual void ContributeAdv(TPZVec< REAL > &x, TPZFMatrix< REAL > &jacinv, TPZVec< STATE > &sol, TPZFMatrix< STATE > &dsol, REAL weight, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
virtual void Solution(TPZMaterialData &data, int var, TPZVec< STATE > &Solout)
Returns the solution associated with the var index based on the finite element approximation.
virtual void Execute(const TPZVec< REAL > &x, TPZVec< TVar > &f, TPZFMatrix< TVar > &df)
Performs function computation.
This material implements the weak statement of the compressible euler equations.
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_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
TPZResidualType fResidualType
Variable to indicate the type of residual to be computed by Assemble.
static void JacobFlux(REAL gamma, int dim, TPZVec< T > &U, TPZVec< TPZDiffMatrix< T > > &Ai)
Jacobian of the tensor flux of Euler.
Contains declaration of the TPZSavable class which defines the interface to save and restore objects ...
TPZManVector< REAL, 3 > normal
normal to the element at the integration point
virtual int VariableIndex(const std::string &name) override
Returns the relative index of a variable according to its name.
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
TPZManVector< REAL, 3 > x
value of the coordinate at the integration point
void SetTimeStep(REAL timeStep)
Sets the time step used for time integration.
virtual void ContributeBCInterface(TPZMaterialData &data, TPZMaterialData &dataleft, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
It computes a contribution to stiffness matrix and load vector at one BC integration point...
clarg::argBool bc("-bc", "binary checkpoints", false)
Use Least squares method to applied artificial diffusion term.
virtual int ClassId() const override
Class identificator.
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) ...
void ContributeExplConvFace(TPZVec< REAL > &x, TPZVec< STATE > &solL, TPZVec< STATE > &solR, REAL weight, TPZVec< REAL > &normal, TPZFMatrix< REAL > &phiL, TPZFMatrix< REAL > &phiR, TPZFMatrix< STATE > &ef, int entropyFix=1)
Semi implicit time discretization.
void ComputeGhostState(TPZVec< T > &solL, TPZVec< T > &solR, TPZVec< REAL > &normal, TPZBndCond &bc, int &entropyFix)
Computes the ghost state variables bsed on the BC type.
int Dimension() const override
Returns the dimension of the problem.
void SetDelta(REAL delta)
Sets the delta parameter inside the artifficial diffusion term.
TPZString DiffusionName()
Returns the name of diffusive term.
virtual int VariableIndex(const std::string &name)
Returns the variable index associated with the name.
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...
virtual void ContributeBC(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc) override
Contributes to the residual vector the boundary conditions.
TPZGradSolVec dsol
vector of the derivatives of the solution at the integration point
void Write(TPZStream &buf, int withclassid) const override
Save the element data to a stream.
TPZFNMatrix< 9, REAL > jacinv
value of the inverse of the jacobian at the integration point
void Flux(TPZVec< T > &U, TPZVec< T > &Fx, TPZVec< T > &Fy, TPZVec< T > &Fz)
tensor of the three-dimensional flux of Euler
const char * Str() const
Explicitly convertes a TPZString into a const null ended char string.
REAL val(STATE &number)
Returns value of the variable.
AutoPointerMutexArrayInit tmp
TPZTimeDiscr
Indicates the type of time discretization.
static void uRes(TPZVec< T > &sol, T &us)
void ContributeApproxImplDiff(TPZVec< REAL > &x, TPZFMatrix< REAL > &jacinv, TPZVec< STATE > &sol, TPZFMatrix< STATE > &dsol, REAL weight, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
void ContributeApproxImplConvFace(TPZVec< REAL > &x, REAL faceSize, TPZVec< STATE > &solL, TPZVec< STATE > &solR, REAL weight, TPZVec< REAL > &normal, TPZFMatrix< REAL > &phiL, TPZFMatrix< REAL > &phiR, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, int entropyFix=1)
TPZFMatrix< STATE > & Val2(int loadcase=0)
TPZFNMatrix< 220, REAL > phi
vector of shapefunctions (format is dependent on the value of shapetype)
virtual void Write(TPZStream &buf, int withclassid) const override
Saves the element data to a stream.
virtual int NFluxes() override
Returns the number of fluxes associated to this material.
static void ApproxRoe_Flux(TPZVec< T > &solL, TPZVec< T > &solR, TPZVec< REAL > &normal, REAL gamma, TPZVec< T > &flux, int entropyFix=1)
This flux encapsulates the two and three dimensional fluxes acquired from the Mouse program...
virtual void Print(std::ostream &out) override
Prints the state of internal variables.
void Read(TPZStream &buf, void *context) override
Reads the element data from a stream.
TPZFNMatrix< 660, REAL > dphix
values of the derivative of the shape functions
REAL Det(TPZFMatrix< REAL > &Mat)
Computes the determinant of a 2d or 3d matrix. Used by recompute the element size.
void ContributeImplT1(TPZVec< REAL > &x, TPZVec< STATE > &sol, TPZFMatrix< STATE > &dsol, REAL weight, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
virtual void Print(std::ostream &out=std::cout)
Prints out the data associated with the material.
Contains declaration of TPZElementMatrix struct which associates an element matrix with the coeficien...
REAL TimeStep()
Returns the value of the time step.
int fDim
Dimension of the problem.
Contains the TPZBndCond class which implements a boundary condition for TPZMaterial objects...
void ContributeExplT2(TPZVec< REAL > &x, TPZVec< STATE > &sol, REAL weight, TPZFMatrix< REAL > &phi, TPZFMatrix< STATE > &ef)
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...
void ContributeFastestBCInterface(int dim, TPZVec< REAL > &x, TPZVec< STATE > &solL, TPZFMatrix< STATE > &dsolL, REAL weight, TPZVec< REAL > &normal, TPZFMatrix< REAL > &phiL, TPZFMatrix< REAL > &dphiL, TPZFMatrix< REAL > &axesleft, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc)
virtual void Write(const bool val)
REAL DeltaX(REAL detJac)
Estimates the deltax (element diameter) based on the inverse of the jacobian.
TPZArtDiff fArtDiff
diffusive term
void SetTimeDiscr(TPZTimeDiscr Diff, TPZTimeDiscr ConvVol, TPZTimeDiscr ConvFace)
Configures the time discretization of some contributions.
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
This class defines the boundary condition for TPZMaterial objects.
virtual void ContributeLast(TPZVec< REAL > &x, TPZFMatrix< REAL > &jacinv, TPZVec< STATE > &sol, TPZFMatrix< STATE > &dsol, REAL weight, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi, TPZFMatrix< STATE > &ef)
int64_t Rows() const
Returns number of rows.
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
void ContributeFastestBCInterface_dim(TPZVec< REAL > &x, TPZVec< STATE > &solL, TPZFMatrix< STATE > &dsolL, REAL weight, TPZVec< REAL > &normal, TPZFMatrix< REAL > &phiL, TPZFMatrix< REAL > &dphiL, TPZFMatrix< REAL > &axesleft, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef, TPZBndCond &bc)
TPZFMatrix< STATE > & Val1()
expr_ expr_ fastAccessDx(i) *cos(expr_.val())) FAD_FUNC_MACRO(TFadFuncTan
REAL HSize
measure of the size of the element
virtual void ContributeInterface(TPZMaterialData &data, TPZMaterialData &dataleft, TPZMaterialData &dataright, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
Contributes to the residual vector and tangent matrix the face-based quantities.
void ContributeExplT1(TPZVec< REAL > &x, TPZVec< STATE > &sol, TPZFMatrix< STATE > &dsol, REAL weight, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi, TPZFMatrix< STATE > &ef)
virtual int NStateVariables() const override
Object-based overload.
static REAL gBigNumber
Big number to penalization method, used for Dirichlet conditions.
REAL OptimalCFL(int degree)
returns the best value for the CFL number based on the interpolation degree.
int32_t Hash(std::string str)
long double gamma(unsigned int n)
Evaluate the factorial of a integer.
void ContributeExplDiff(TPZVec< REAL > &x, TPZFMatrix< REAL > &jacinv, TPZVec< STATE > &sol, TPZFMatrix< STATE > &dsol, REAL weight, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi, TPZFMatrix< STATE > &ef)
Contains TPZMatrix<TVar>class, root matrix class.
Implements the interface for conservation laws, keeping track of the timestep as well.
Contains the TPZArtDiff class which implements a numerical diffusivity coefficient.
static void cSpeed(TPZVec< T > &sol, REAL gamma, T &c)
Evaluates the speed of sound in the fluid.
TPZFlopCounter pow(const TPZFlopCounter &orig, const TPZFlopCounter &xp)
Returns the power and increments the counter of the power.
void Write(TPZStream &buf, int withclassid) const override
Save the element data to a stream.
#define FL(A)
Function for dynamic cast of the material based on map A (second data)
REAL CFL()
Returns the CFL number.
virtual void Solution(TPZVec< STATE > &Sol, TPZFMatrix< STATE > &DSol, TPZFMatrix< REAL > &axes, int var, TPZVec< STATE > &Solout) override
TPZAutoPointer< TPZFunction< STATE > > fForcingFunction
Pointer to forcing function, it is the right member at differential equation.
void ContributeExplConvVol(TPZVec< REAL > &x, TPZVec< STATE > &sol, REAL weight, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi, TPZFMatrix< STATE > &ef)
TPZTimeDiscr fDiff
variables indication whether the following terms are implicit
static void Roe_Flux(TPZVec< T > &solL, TPZVec< T > &solR, TPZVec< REAL > &normal, REAL gamma, TPZVec< T > &flux, int entropyFix=1)
This flux encapsulates the two and three dimensional fluxes acquired from the Mouse program...
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.
REAL fGamma
Ratio between specific heat is constant and the specific heat the constant volume of a polytropic gas...
virtual void Print(std::ostream &out) const
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.
Implicit time discretization.
int ClassId() const override
Define the class id associated with the class.
void ContributeImplConvVol(TPZVec< REAL > &x, TPZVec< STATE > &sol, TPZFMatrix< STATE > &dsol, REAL weight, TPZFMatrix< REAL > &phi, TPZFMatrix< REAL > &dphi, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef)
virtual int NSolutionVariables(int var) override
Returns the number of variables associated with the variable indexed by var.
TPZContributeTime fContributionTime
Variable indicating the context of the solution.
static void Pressure(REAL gamma, int dim, T &press, TPZVec< T > &U)
Thermodynamic pressure determined by the law of an ideal gas.
TPZSolVec sol
vector of the solutions at the integration point
TPZArtDiffType
Enumerate to define the possible types of artificial diffusion term to stabilize the numerical scheme...
virtual void Print(std::ostream &out) override
Prints the state of internal variables.
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) ...
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
#define PZError
Defines the output device to error messages and the DebugStop() function.
virtual REAL SetTimeStep(REAL maxveloc, REAL deltax, int degree) override
See declaration in base class.
virtual void Read(bool &val)
Explicit time discretization. Can to be Euler method, Runge Kutta method, etc.
virtual void Contribute(TPZMaterialData &data, REAL weight, TPZFMatrix< STATE > &ek, TPZFMatrix< STATE > &ef) override
Contributes to the residual vector and tangent matrix the volume-based quantities.