// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. // // SPDX-License-Identifier: BSD-2-Clause // // This file is part of CEED: http://github.com/ceed /// @file /// Operator for Navier-Stokes example using PETSc #ifndef newtonian_h #define newtonian_h #include #include #include "newtonian_types.h" #ifndef M_PI #define M_PI 3.14159265358979323846 #endif typedef struct { CeedScalar pressure; CeedScalar velocity[3]; CeedScalar temperature; } StatePrimitive; typedef struct { CeedScalar density; CeedScalar momentum[3]; CeedScalar E_total; } StateConservative; typedef struct { StateConservative U; StatePrimitive Y; } State; CEED_QFUNCTION_HELPER StatePrimitive StatePrimitiveFromConservative( NewtonianIdealGasContext gas, StateConservative U, const CeedScalar x[3]) { StatePrimitive Y; for (int i=0; i<3; i++) Y.velocity[i] = U.momentum[i] / U.density; CeedScalar e_kinetic = .5 * Dot3(Y.velocity, Y.velocity); CeedScalar e_potential = -Dot3(gas->g, x); CeedScalar e_total = U.E_total / U.density; CeedScalar e_internal = e_total - e_kinetic - e_potential; Y.temperature = e_internal / gas->cv; Y.pressure = (gas->cp / gas->cv - 1) * U.density * e_internal; return Y; } CEED_QFUNCTION_HELPER StatePrimitive StatePrimitiveFromConservative_fwd( NewtonianIdealGasContext gas, State s, StateConservative dU, const CeedScalar x[3], const CeedScalar dx[3]) { StatePrimitive dY; for (int i=0; i<3; i++) { dY.velocity[i] = (dU.momentum[i] - s.Y.velocity[i] * dU.density) / s.U.density; } CeedScalar e_kinetic = .5 * Dot3(s.Y.velocity, s.Y.velocity); CeedScalar de_kinetic = Dot3(dY.velocity, s.Y.velocity); CeedScalar e_potential = -Dot3(gas->g, x); CeedScalar de_potential = -Dot3(gas->g, dx); CeedScalar e_total = s.U.E_total / s.U.density; CeedScalar de_total = (dU.E_total - e_total * dU.density) / s.U.density; CeedScalar e_internal = e_total - e_kinetic - e_potential; CeedScalar de_internal = de_total - de_kinetic - de_potential; dY.temperature = de_internal / gas->cv; dY.pressure = (gas->cp / gas->cv - 1) * (dU.density * e_internal + s.U.density * de_internal); return dY; } CEED_QFUNCTION_HELPER State StateFromU(NewtonianIdealGasContext gas, const CeedScalar U[5], const CeedScalar x[3]) { State s; s.U.density = U[0]; s.U.momentum[0] = U[1]; s.U.momentum[1] = U[2]; s.U.momentum[2] = U[3]; s.U.E_total = U[4]; s.Y = StatePrimitiveFromConservative(gas, s.U, x); return s; } CEED_QFUNCTION_HELPER State StateFromU_fwd(NewtonianIdealGasContext gas, State s, const CeedScalar dU[5], const CeedScalar x[3], const CeedScalar dx[3]) { State ds; ds.U.density = dU[0]; ds.U.momentum[0] = dU[1]; ds.U.momentum[1] = dU[2]; ds.U.momentum[2] = dU[3]; ds.U.E_total = dU[4]; ds.Y = StatePrimitiveFromConservative_fwd(gas, s, ds.U, x, dx); return ds; } CEED_QFUNCTION_HELPER void FluxInviscid(NewtonianIdealGasContext gas, State s, StateConservative Flux[3]) { for (int i=0; i<3; i++) { Flux[i].density = s.U.momentum[i]; for (int j=0; j<3; j++) Flux[i].momentum[j] = s.U.momentum[i] * s.Y.velocity[j] + s.Y.pressure * (i == j); Flux[i].E_total = (s.U.E_total + s.Y.pressure) * s.Y.velocity[i]; } } CEED_QFUNCTION_HELPER void FluxInviscid_fwd(NewtonianIdealGasContext gas, State s, State ds, StateConservative dFlux[3]) { for (int i=0; i<3; i++) { dFlux[i].density = ds.U.momentum[i]; for (int j=0; j<3; j++) dFlux[i].momentum[j] = ds.U.momentum[i] * s.Y.velocity[j] + s.U.momentum[i] * ds.Y.velocity[j] + ds.Y.pressure * (i == j); dFlux[i].E_total = (ds.U.E_total + ds.Y.pressure) * s.Y.velocity[i] + (s.U.E_total + s.Y.pressure) * ds.Y.velocity[i]; } } // Kelvin-Mandel notation CEED_QFUNCTION_HELPER void KMStrainRate(const State grad_s[3], CeedScalar strain_rate[6]) { const CeedScalar weight = 1 / sqrt(2.); strain_rate[0] = grad_s[0].Y.velocity[0]; strain_rate[1] = grad_s[1].Y.velocity[1]; strain_rate[2] = grad_s[2].Y.velocity[2]; strain_rate[3] = weight * (grad_s[2].Y.velocity[1] + grad_s[1].Y.velocity[2]); strain_rate[4] = weight * (grad_s[2].Y.velocity[0] + grad_s[0].Y.velocity[2]); strain_rate[5] = weight * (grad_s[1].Y.velocity[0] + grad_s[0].Y.velocity[1]); } CEED_QFUNCTION_HELPER void KMUnpack(const CeedScalar v[6], CeedScalar A[3][3]) { const CeedScalar weight = 1 / sqrt(2.); A[0][0] = v[0]; A[1][1] = v[1]; A[2][2] = v[2]; A[2][1] = A[1][2] = weight * v[3]; A[2][0] = A[0][2] = weight * v[4]; A[1][0] = A[0][1] = weight * v[5]; } CEED_QFUNCTION_HELPER void NewtonianStress(NewtonianIdealGasContext gas, const CeedScalar strain_rate[6], CeedScalar stress[6]) { CeedScalar div_u = strain_rate[0] + strain_rate[1] + strain_rate[2]; for (int i=0; i<6; i++) { stress[i] = gas->mu * (2 * strain_rate[i] + gas->lambda * div_u * (i < 3)); } } CEED_QFUNCTION_HELPER void ViscousEnergyFlux(NewtonianIdealGasContext gas, StatePrimitive Y, const State grad_s[3], const CeedScalar stress[3][3], CeedScalar Fe[3]) { for (int i=0; i<3; i++) { Fe[i] = - Y.velocity[0] * stress[0][i] - Y.velocity[1] * stress[1][i] - Y.velocity[2] * stress[2][i] - gas->k * grad_s[i].Y.temperature; } } CEED_QFUNCTION_HELPER void ViscousEnergyFlux_fwd(NewtonianIdealGasContext gas, StatePrimitive Y, StatePrimitive dY, const State grad_ds[3], const CeedScalar stress[3][3], const CeedScalar dstress[3][3], CeedScalar dFe[3]) { for (int i=0; i<3; i++) { dFe[i] = - Y.velocity[0] * dstress[0][i] - dY.velocity[0] * stress[0][i] - Y.velocity[1] * dstress[1][i] - dY.velocity[1] * stress[1][i] - Y.velocity[2] * dstress[2][i] - dY.velocity[2] * stress[2][i] - gas->k * grad_ds[i].Y.temperature; } } // ***************************************************************************** // Helper function for computing flux Jacobian // ***************************************************************************** CEED_QFUNCTION_HELPER void computeFluxJacobian_NS(CeedScalar dF[3][5][5], const CeedScalar rho, const CeedScalar u[3], const CeedScalar E, const CeedScalar gamma, const CeedScalar g[3], const CeedScalar x[3]) { CeedScalar u_sq = u[0]*u[0] + u[1]*u[1] + u[2]*u[2]; // Velocity square CeedScalar e_potential = -(g[0]*x[0] + g[1]*x[1] + g[2]*x[2]); for (CeedInt i=0; i<3; i++) { // Jacobian matrices for 3 directions for (CeedInt j=0; j<3; j++) { // Rows of each Jacobian matrix dF[i][j+1][0] = ((i==j) ? ((gamma-1.)*(u_sq/2. - e_potential)) : 0.) - u[i]*u[j]; for (CeedInt k=0; k<3; k++) { // Columns of each Jacobian matrix dF[i][0][k+1] = ((i==k) ? 1. : 0.); dF[i][j+1][k+1] = ((j==k) ? u[i] : 0.) + ((i==k) ? u[j] : 0.) - ((i==j) ? u[k] : 0.) * (gamma-1.); dF[i][4][k+1] = ((i==k) ? (E*gamma/rho - (gamma-1.)*u_sq/2.) : 0.) - (gamma-1.)*u[i]*u[k]; } dF[i][j+1][4] = ((i==j) ? (gamma-1.) : 0.); } dF[i][4][0] = u[i] * ((gamma-1.)*u_sq - E*gamma/rho); dF[i][4][4] = u[i] * gamma; } } // ***************************************************************************** // Helper function for computing flux Jacobian of Primitive variables // ***************************************************************************** CEED_QFUNCTION_HELPER void computeFluxJacobian_NSp(CeedScalar dF[3][5][5], const CeedScalar rho, const CeedScalar u[3], const CeedScalar E, const CeedScalar Rd, const CeedScalar cv) { CeedScalar u_sq = u[0]*u[0] + u[1]*u[1] + u[2]*u[2]; // Velocity square // TODO Add in gravity's contribution CeedScalar T = ( E / rho - u_sq / 2. ) / cv; CeedScalar drdT = -rho / T; CeedScalar drdP = 1. / ( Rd * T); CeedScalar etot = E / rho ; CeedScalar e2p = drdP * etot + 1. ; CeedScalar e3p = ( E + rho * Rd * T ); CeedScalar e4p = drdT * etot + rho * cv ; for (CeedInt i=0; i<3; i++) { // Jacobian matrices for 3 directions for (CeedInt j=0; j<3; j++) { // j counts F^{m_j} // [row][col] of A_i dF[i][j+1][0] = drdP * u[i] * u[j] + ((i==j) ? 1. : 0.); // F^{{m_j} wrt p for (CeedInt k=0; k<3; k++) { // k counts the wrt vel_k dF[i][0][k+1] = ((i==k) ? rho : 0.); // F^c wrt u_k dF[i][j+1][k+1] = (((j==k) ? u[i] : 0.) + // F^m_j wrt u_k ((i==k) ? u[j] : 0.) ) * rho; dF[i][4][k+1] = rho * u[i] * u[k] + ((i==k) ? e3p : 0.) ; // F^e wrt u_k } dF[i][j+1][4] = drdT * u[i] * u[j]; // F^{m_j} wrt T } dF[i][4][0] = u[i] * e2p; // F^e wrt p dF[i][4][4] = u[i] * e4p; // F^e wrt T dF[i][0][0] = u[i] * drdP; // F^c wrt p dF[i][0][4] = u[i] * drdT; // F^c wrt T } } CEED_QFUNCTION_HELPER void PrimitiveToConservative_fwd(const CeedScalar rho, const CeedScalar u[3], const CeedScalar E, const CeedScalar Rd, const CeedScalar cv, const CeedScalar dY[5], CeedScalar dU[5]) { CeedScalar u_sq = u[0]*u[0] + u[1]*u[1] + u[2]*u[2]; CeedScalar T = ( E / rho - u_sq / 2. ) / cv; CeedScalar drdT = -rho / T; CeedScalar drdP = 1. / ( Rd * T); dU[0] = drdP * dY[0] + drdT * dY[4]; CeedScalar de_kinetic = 0; for (CeedInt i=0; i<3; i++) { dU[1+i] = dU[0] * u[i] + rho * dY[1+i]; de_kinetic += u[i] * dY[1+i]; } dU[4] = rho * cv * dY[4] + dU[0] * cv * T // internal energy: rho * e + rho * de_kinetic + .5 * dU[0] * u_sq; // kinetic energy: .5 * rho * |u|^2 } // ***************************************************************************** // Helper function for computing Tau elements (stabilization constant) // Model from: // PHASTA // // Tau[i] = itau=0 which is diagonal-Shakib (3 values still but not spatial) // // Where NOT UPDATED YET // ***************************************************************************** CEED_QFUNCTION_HELPER void Tau_diagPrim(CeedScalar Tau_d[3], const CeedScalar dXdx[3][3], const CeedScalar u[3], const CeedScalar cv, const NewtonianIdealGasContext newt_ctx, const CeedScalar mu, const CeedScalar dt, const CeedScalar rho) { // Context const CeedScalar Ctau_t = newt_ctx->Ctau_t; const CeedScalar Ctau_v = newt_ctx->Ctau_v; const CeedScalar Ctau_C = newt_ctx->Ctau_C; const CeedScalar Ctau_M = newt_ctx->Ctau_M; const CeedScalar Ctau_E = newt_ctx->Ctau_E; CeedScalar gijd[6]; CeedScalar tau; CeedScalar dts; CeedScalar fact; //*INDENT-OFF* gijd[0] = dXdx[0][0] * dXdx[0][0] + dXdx[1][0] * dXdx[1][0] + dXdx[2][0] * dXdx[2][0]; gijd[1] = dXdx[0][0] * dXdx[0][1] + dXdx[1][0] * dXdx[1][1] + dXdx[2][0] * dXdx[2][1]; gijd[2] = dXdx[0][1] * dXdx[0][1] + dXdx[1][1] * dXdx[1][1] + dXdx[2][1] * dXdx[2][1]; gijd[3] = dXdx[0][0] * dXdx[0][2] + dXdx[1][0] * dXdx[1][2] + dXdx[2][0] * dXdx[2][2]; gijd[4] = dXdx[0][1] * dXdx[0][2] + dXdx[1][1] * dXdx[1][2] + dXdx[2][1] * dXdx[2][2]; gijd[5] = dXdx[0][2] * dXdx[0][2] + dXdx[1][2] * dXdx[1][2] + dXdx[2][2] * dXdx[2][2]; //*INDENT-ON* dts = Ctau_t / dt ; tau = rho*rho*((4. * dts * dts) + u[0] * ( u[0] * gijd[0] + 2. * ( u[1] * gijd[1] + u[2] * gijd[3])) + u[1] * ( u[1] * gijd[2] + 2. * u[2] * gijd[4]) + u[2] * u[2] * gijd[5]) + Ctau_v* mu * mu * (gijd[0]*gijd[0] + gijd[2]*gijd[2] + gijd[5]*gijd[5] + + 2. * (gijd[1]*gijd[1] + gijd[3]*gijd[3] + gijd[4]*gijd[4])); fact=sqrt(tau); Tau_d[0] = Ctau_C * fact / (rho*(gijd[0] + gijd[2] + gijd[5]))*0.125; Tau_d[1] = Ctau_M / fact; Tau_d[2] = Ctau_E / ( fact * cv ); // consider putting back the way I initially had it Ctau_E * Tau_d[1] /cv // to avoid a division if the compiler is smart enough to see that cv IS // a constant that it could invert once for all elements // but in that case energy tau is scaled by the product of Ctau_E * Ctau_M // OR we could absorb cv into Ctau_E but this puts more burden on user to // know how to change constants with a change of fluid or units. Same for // Ctau_v * mu * mu IF AND ONLY IF we don't add viscosity law =f(T) } // ***************************************************************************** // This QFunction sets a "still" initial condition for generic Newtonian IG problems // ***************************************************************************** CEED_QFUNCTION(ICsNewtonianIG)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { // Inputs const CeedScalar (*X)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0]; // Outputs CeedScalar (*q0)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; // Context const SetupContext context = (SetupContext)ctx; const CeedScalar theta0 = context->theta0; const CeedScalar P0 = context->P0; const CeedScalar cv = context->cv; const CeedScalar cp = context->cp; const CeedScalar *g = context->g; const CeedScalar Rd = cp - cv; // Quadrature Point Loop CeedPragmaSIMD for (CeedInt i=0; imu; const CeedScalar cv = context->cv; const CeedScalar cp = context->cp; const CeedScalar *g = context->g; const CeedScalar dt = context->dt; const CeedScalar gamma = cp / cv; const CeedScalar Rd = cp - cv; CeedPragmaSIMD // Quadrature Point Loop for (CeedInt i=0; istabilization) { case STAB_NONE: // Galerkin break; case STAB_SU: // SU Tau_diagPrim(Tau_d, dXdx, s.Y.velocity, cv, context, mu, dt, s.U.density); tau_strong_conv[0] = Tau_d[0] * strong_conv[0]; tau_strong_conv[1] = Tau_d[1] * strong_conv[1]; tau_strong_conv[2] = Tau_d[1] * strong_conv[2]; tau_strong_conv[3] = Tau_d[1] * strong_conv[3]; tau_strong_conv[4] = Tau_d[2] * strong_conv[4]; PrimitiveToConservative_fwd(s.U.density, s.Y.velocity, s.U.E_total, Rd, cv, tau_strong_conv, tau_strong_conv_conservative); for (CeedInt j=0; j<3; j++) for (CeedInt k=0; k<5; k++) for (CeedInt l=0; l<5; l++) stab[k][j] += jacob_F_conv[j][k][l] * tau_strong_conv_conservative[l]; for (CeedInt j=0; j<5; j++) for (CeedInt k=0; k<3; k++) Grad_v[k][j][i] -= wdetJ*(stab[j][0] * dXdx[k][0] + stab[j][1] * dXdx[k][1] + stab[j][2] * dXdx[k][2]); break; case STAB_SUPG: // SUPG is not implemented for explicit scheme break; } } // End Quadrature Point Loop // Return return 0; } // ***************************************************************************** // This QFunction implements the Navier-Stokes equations (mentioned above) with // implicit time stepping method // // SU = Galerkin + grad(v) . ( Ai^T * Tau * (Aj q,j) ) // SUPG = Galerkin + grad(v) . ( Ai^T * Tau * (q_dot + Aj q,j - body force) ) // (diffussive terms will be added later) // // ***************************************************************************** CEED_QFUNCTION(IFunction_Newtonian)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { // *INDENT-OFF* // Inputs const CeedScalar (*q)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0], (*Grad_q)[5][CEED_Q_VLA] = (const CeedScalar(*)[5][CEED_Q_VLA])in[1], (*q_dot)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[2], (*q_data)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[3], (*x)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[4]; // Outputs CeedScalar (*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0], (*Grad_v)[5][CEED_Q_VLA] = (CeedScalar(*)[5][CEED_Q_VLA])out[1], (*jac_data)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[2]; // *INDENT-ON* // Context NewtonianIdealGasContext context = (NewtonianIdealGasContext)ctx; const CeedScalar mu = context->mu; const CeedScalar cv = context->cv; const CeedScalar cp = context->cp; const CeedScalar *g = context->g; const CeedScalar dt = context->dt; const CeedScalar gamma = cp / cv; const CeedScalar Rd = cp-cv; CeedPragmaSIMD // Quadrature Point Loop for (CeedInt i=0; istabilization) { case STAB_NONE: // Galerkin break; case STAB_SU: // SU Tau_diagPrim(Tau_d, dXdx, s.Y.velocity, cv, context, mu, dt, s.U.density); tau_strong_conv[0] = Tau_d[0] * strong_conv[0]; tau_strong_conv[1] = Tau_d[1] * strong_conv[1]; tau_strong_conv[2] = Tau_d[1] * strong_conv[2]; tau_strong_conv[3] = Tau_d[1] * strong_conv[3]; tau_strong_conv[4] = Tau_d[2] * strong_conv[4]; PrimitiveToConservative_fwd(s.U.density, s.Y.velocity, s.U.E_total, Rd, cv, tau_strong_conv, tau_strong_conv_conservative); for (CeedInt j=0; j<3; j++) for (CeedInt k=0; k<5; k++) for (CeedInt l=0; l<5; l++) stab[k][j] += jacob_F_conv[j][k][l] * tau_strong_conv_conservative[l]; for (CeedInt j=0; j<5; j++) for (CeedInt k=0; k<3; k++) Grad_v[k][j][i] += wdetJ*(stab[j][0] * dXdx[k][0] + stab[j][1] * dXdx[k][1] + stab[j][2] * dXdx[k][2]); break; case STAB_SUPG: // SUPG Tau_diagPrim(Tau_d, dXdx, s.Y.velocity, cv, context, mu, dt, s.U.density); tau_strong_res[0] = Tau_d[0] * strong_res[0]; tau_strong_res[1] = Tau_d[1] * strong_res[1]; tau_strong_res[2] = Tau_d[1] * strong_res[2]; tau_strong_res[3] = Tau_d[1] * strong_res[3]; tau_strong_res[4] = Tau_d[2] * strong_res[4]; // Alternate route (useful later with primitive variable code) // this function was verified against PHASTA for as IC that was as close as possible // computeFluxJacobian_NSp(jacob_F_conv_p, rho, u, E, Rd, cv); // it has also been verified to compute a correct through the following // stab[k][j] += jacob_F_conv_p[j][k][l] * tau_strong_res[l] // flux Jacobian wrt primitive // applied in the triple loop below // However, it is more flops than using the existing Jacobian wrt q after q_{,Y} viz PrimitiveToConservative_fwd(s.U.density, s.Y.velocity, s.U.E_total, Rd, cv, tau_strong_res, tau_strong_res_conservative); for (CeedInt j=0; j<3; j++) for (CeedInt k=0; k<5; k++) for (CeedInt l=0; l<5; l++) stab[k][j] += jacob_F_conv[j][k][l] * tau_strong_res_conservative[l]; for (CeedInt j=0; j<5; j++) for (CeedInt k=0; k<3; k++) Grad_v[k][j][i] += wdetJ*(stab[j][0] * dXdx[k][0] + stab[j][1] * dXdx[k][1] + stab[j][2] * dXdx[k][2]); break; } for (CeedInt j=0; j<5; j++) jac_data[j][i] = U[j]; for (CeedInt j=0; j<6; j++) jac_data[5+j][i] = kmstress[j]; for (CeedInt j=0; j<3; j++) jac_data[5+6+j][i] = Tau_d[j]; } // End Quadrature Point Loop // Return return 0; } CEED_QFUNCTION(IJacobian_Newtonian)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { // *INDENT-OFF* // Inputs const CeedScalar (*dq)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0], (*Grad_dq)[5][CEED_Q_VLA] = (const CeedScalar(*)[5][CEED_Q_VLA])in[1], (*q_data)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[2], (*x)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[3], (*jac_data)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[4]; // Outputs CeedScalar (*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0], (*Grad_v)[5][CEED_Q_VLA] = (CeedScalar(*)[5][CEED_Q_VLA])out[1]; // *INDENT-ON* // Context NewtonianIdealGasContext context = (NewtonianIdealGasContext)ctx; const CeedScalar *g = context->g; const CeedScalar cp = context->cp; const CeedScalar cv = context->cv; const CeedScalar Rd = cp - cv; const CeedScalar gamma = cp / cv; CeedPragmaSIMD // Quadrature Point Loop for (CeedInt i=0; iijacobian_time_shift * dU[j] - dbody_force[j]); if (1) { CeedScalar jacob_F_conv[3][5][5] = {0}; computeFluxJacobian_NS(jacob_F_conv, s.U.density, s.Y.velocity, s.U.E_total, gamma, g, x_i); CeedScalar grad_dU[5][3]; for (int j=0; j<3; j++) { grad_dU[0][j] = grad_ds[j].U.density; for (int k=0; k<3; k++) grad_dU[k+1][j] = grad_ds[j].U.momentum[k]; grad_dU[4][j] = grad_ds[j].U.E_total; } CeedScalar dstrong_conv[5] = {0}; for (int j=0; j<3; j++) for (int k=0; k<5; k++) for (int l=0; l<5; l++) dstrong_conv[k] += jacob_F_conv[j][k][l] * grad_dU[l][j]; CeedScalar dstrong_res[5]; for (int j=0; j<5; j++) dstrong_res[j] = context->ijacobian_time_shift * dU[j] + dstrong_conv[j] - dbody_force[j]; CeedScalar dtau_strong_res[5] = {0.}, dtau_strong_res_conservative[5] = {0}; dtau_strong_res[0] = Tau_d[0] * dstrong_res[0]; dtau_strong_res[1] = Tau_d[1] * dstrong_res[1]; dtau_strong_res[2] = Tau_d[1] * dstrong_res[2]; dtau_strong_res[3] = Tau_d[1] * dstrong_res[3]; dtau_strong_res[4] = Tau_d[2] * dstrong_res[4]; PrimitiveToConservative_fwd(s.U.density, s.Y.velocity, s.U.E_total, Rd, cv, dtau_strong_res, dtau_strong_res_conservative); CeedScalar dstab[5][3] = {0}; for (int j=0; j<3; j++) for (int k=0; k<5; k++) for (int l=0; l<5; l++) dstab[k][j] += jacob_F_conv[j][k][l] * dtau_strong_res_conservative[l]; for (int j=0; j<5; j++) for (int k=0; k<3; k++) Grad_v[k][j][i] += wdetJ*(dstab[j][0] * dXdx[k][0] + dstab[j][1] * dXdx[k][1] + dstab[j][2] * dXdx[k][2]); } } // End Quadrature Point Loop return 0; } // ***************************************************************************** #endif // newtonian_h