1 // Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 8 /// @file 9 /// Operator for Navier-Stokes example using PETSc 10 11 #ifndef newtonian_h 12 #define newtonian_h 13 14 #include <ceed.h> 15 #include <math.h> 16 #include <stdlib.h> 17 18 #include "newtonian_state.h" 19 #include "newtonian_types.h" 20 #include "stabilization.h" 21 #include "utils.h" 22 23 CEED_QFUNCTION_HELPER void InternalDampingLayer(const NewtonianIdealGasContext context, const State s, const CeedScalar sigma, CeedScalar damp_Y[5], 24 CeedScalar damp_residual[5]) { 25 ScaleN(damp_Y, sigma, 5); 26 State damp_s = StateFromY_fwd(context, s, damp_Y); 27 28 CeedScalar U[5]; 29 UnpackState_U(damp_s.U, U); 30 for (int i = 0; i < 5; i++) damp_residual[i] += U[i]; 31 } 32 33 // ***************************************************************************** 34 // This QFunction sets a "still" initial condition for generic Newtonian IG problems 35 // ***************************************************************************** 36 CEED_QFUNCTION_HELPER int ICsNewtonianIG(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out, StateVariable state_var) { 37 // Inputs 38 39 // Outputs 40 CeedScalar(*q0)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 41 42 // Context 43 const SetupContext context = (SetupContext)ctx; 44 45 // Quadrature Point Loop 46 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 47 CeedScalar q[5] = {0.}; 48 State s = StateFromPrimitive(&context->gas, context->reference); 49 StateToQ(&context->gas, s, q, state_var); 50 for (CeedInt j = 0; j < 5; j++) q0[j][i] = q[j]; 51 } // End of Quadrature Point Loop 52 return 0; 53 } 54 55 CEED_QFUNCTION(ICsNewtonianIG_Prim)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 56 return ICsNewtonianIG(ctx, Q, in, out, STATEVAR_PRIMITIVE); 57 } 58 CEED_QFUNCTION(ICsNewtonianIG_Conserv)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 59 return ICsNewtonianIG(ctx, Q, in, out, STATEVAR_CONSERVATIVE); 60 } 61 62 // ***************************************************************************** 63 // This QFunction implements the following formulation of Navier-Stokes with explicit time stepping method 64 // 65 // This is 3D compressible Navier-Stokes in conservation form with state variables of density, momentum density, and total energy density. 66 // 67 // State Variables: q = ( rho, U1, U2, U3, E ) 68 // rho - Mass Density 69 // Ui - Momentum Density, Ui = rho ui 70 // E - Total Energy Density, E = rho (cv T + (u u)/2 + g z) 71 // 72 // Navier-Stokes Equations: 73 // drho/dt + div( U ) = 0 74 // dU/dt + div( rho (u x u) + P I3 ) + rho g khat = div( Fu ) 75 // dE/dt + div( (E + P) u ) = div( Fe ) 76 // 77 // Viscous Stress: 78 // Fu = mu (grad( u ) + grad( u )^T + lambda div ( u ) I3) 79 // 80 // Thermal Stress: 81 // Fe = u Fu + k grad( T ) 82 // Equation of State 83 // P = (gamma - 1) (E - rho (u u) / 2 - rho g z) 84 // 85 // Stabilization: 86 // Tau = diag(TauC, TauM, TauM, TauM, TauE) 87 // f1 = rho sqrt(ui uj gij) 88 // gij = dXi/dX * dXi/dX 89 // TauC = Cc f1 / (8 gii) 90 // TauM = min( 1 , 1 / f1 ) 91 // TauE = TauM / (Ce cv) 92 // 93 // SU = Galerkin + grad(v) . ( Ai^T * Tau * (Aj q,j) ) 94 // 95 // Constants: 96 // lambda = - 2 / 3, From Stokes hypothesis 97 // mu , Dynamic viscosity 98 // k , Thermal conductivity 99 // cv , Specific heat, constant volume 100 // cp , Specific heat, constant pressure 101 // g , Gravity 102 // gamma = cp / cv, Specific heat ratio 103 // 104 // We require the product of the inverse of the Jacobian (dXdx_j,k) and its transpose (dXdx_k,j) to properly compute integrals of the form: int( gradv 105 // gradu ) 106 // ***************************************************************************** 107 CEED_QFUNCTION(RHSFunction_Newtonian)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 108 // Inputs 109 const CeedScalar(*q)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0]; 110 const CeedScalar(*Grad_q) = in[1]; 111 const CeedScalar(*q_data) = in[2]; 112 113 // Outputs 114 CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 115 CeedScalar(*Grad_v)[5][CEED_Q_VLA] = (CeedScalar(*)[5][CEED_Q_VLA])out[1]; 116 117 // Context 118 NewtonianIdealGasContext context = (NewtonianIdealGasContext)ctx; 119 const CeedScalar *g = context->g; 120 const CeedScalar dt = context->dt; 121 122 // Quadrature Point Loop 123 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 124 CeedScalar U[5], wdetJ, dXdx[3][3]; 125 for (int j = 0; j < 5; j++) U[j] = q[j][i]; 126 StoredValuesUnpack(Q, i, 0, 1, q_data, &wdetJ); 127 StoredValuesUnpack(Q, i, 1, 9, q_data, (CeedScalar *)dXdx); 128 State s = StateFromU(context, U); 129 130 State grad_s[3]; 131 StatePhysicalGradientFromReference(Q, i, context, s, STATEVAR_CONSERVATIVE, Grad_q, dXdx, grad_s); 132 133 CeedScalar strain_rate[6], kmstress[6], stress[3][3], Fe[3]; 134 KMStrainRate_State(grad_s, strain_rate); 135 NewtonianStress(context, strain_rate, kmstress); 136 KMUnpack(kmstress, stress); 137 ViscousEnergyFlux(context, s.Y, grad_s, stress, Fe); 138 139 StateConservative F_inviscid[3]; 140 FluxInviscid(context, s, F_inviscid); 141 142 // Total flux 143 CeedScalar Flux[5][3]; 144 FluxTotal(F_inviscid, stress, Fe, Flux); 145 146 for (CeedInt j = 0; j < 5; j++) { 147 for (CeedInt k = 0; k < 3; k++) Grad_v[k][j][i] = wdetJ * (dXdx[k][0] * Flux[j][0] + dXdx[k][1] * Flux[j][1] + dXdx[k][2] * Flux[j][2]); 148 } 149 150 const CeedScalar body_force[5] = {0, s.U.density * g[0], s.U.density * g[1], s.U.density * g[2], Dot3(s.U.momentum, g)}; 151 for (int j = 0; j < 5; j++) v[j][i] = wdetJ * body_force[j]; 152 153 // -- Stabilization method: none (Galerkin), SU, or SUPG 154 CeedScalar Tau_d[3], stab[5][3], U_dot[5] = {0}; 155 Tau_diagPrim(context, s, dXdx, dt, Tau_d); 156 Stabilization(context, s, Tau_d, grad_s, U_dot, body_force, stab); 157 158 for (CeedInt j = 0; j < 5; j++) { 159 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]); 160 } 161 } // End Quadrature Point Loop 162 163 // Return 164 return 0; 165 } 166 167 // ***************************************************************************** 168 // This QFunction implements the Navier-Stokes equations (mentioned above) with implicit time stepping method 169 // 170 // SU = Galerkin + grad(v) . ( Ai^T * Tau * (Aj q,j) ) 171 // SUPG = Galerkin + grad(v) . ( Ai^T * Tau * (q_dot + Aj q,j - body force) ) 172 // (diffusive terms will be added later) 173 // ***************************************************************************** 174 CEED_QFUNCTION_HELPER int IFunction_Newtonian(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out, StateVariable state_var) { 175 // Inputs 176 const CeedScalar(*q)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0]; 177 const CeedScalar(*Grad_q) = in[1]; 178 const CeedScalar(*q_dot)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[2]; 179 const CeedScalar(*q_data) = in[3]; 180 const CeedScalar(*x)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[4]; 181 182 // Outputs 183 CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 184 CeedScalar(*Grad_v)[5][CEED_Q_VLA] = (CeedScalar(*)[5][CEED_Q_VLA])out[1]; 185 CeedScalar(*jac_data) = out[2]; 186 187 // Context 188 NewtonianIdealGasContext context = (NewtonianIdealGasContext)ctx; 189 const CeedScalar *g = context->g; 190 const CeedScalar dt = context->dt; 191 const CeedScalar P0 = context->P0; 192 193 // Quadrature Point Loop 194 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 195 const CeedScalar qi[5] = {q[0][i], q[1][i], q[2][i], q[3][i], q[4][i]}; 196 const CeedScalar x_i[3] = {x[0][i], x[1][i], x[2][i]}; 197 const State s = StateFromQ(context, qi, state_var); 198 199 CeedScalar wdetJ, dXdx[3][3]; 200 QdataUnpack_3D(Q, i, q_data, &wdetJ, dXdx); 201 State grad_s[3]; 202 StatePhysicalGradientFromReference(Q, i, context, s, state_var, Grad_q, dXdx, grad_s); 203 204 CeedScalar strain_rate[6], kmstress[6], stress[3][3], Fe[3]; 205 KMStrainRate_State(grad_s, strain_rate); 206 NewtonianStress(context, strain_rate, kmstress); 207 KMUnpack(kmstress, stress); 208 ViscousEnergyFlux(context, s.Y, grad_s, stress, Fe); 209 210 StateConservative F_inviscid[3]; 211 FluxInviscid(context, s, F_inviscid); 212 213 // Total flux 214 CeedScalar Flux[5][3]; 215 FluxTotal(F_inviscid, stress, Fe, Flux); 216 217 for (CeedInt j = 0; j < 5; j++) { 218 for (CeedInt k = 0; k < 3; k++) { 219 Grad_v[k][j][i] = -wdetJ * (dXdx[k][0] * Flux[j][0] + dXdx[k][1] * Flux[j][1] + dXdx[k][2] * Flux[j][2]); 220 } 221 } 222 223 const CeedScalar body_force[5] = {0, s.U.density * g[0], s.U.density * g[1], s.U.density * g[2], Dot3(s.U.momentum, g)}; 224 225 // -- Stabilization method: none (Galerkin), SU, or SUPG 226 CeedScalar Tau_d[3], stab[5][3], U_dot[5] = {0}, qi_dot[5]; 227 for (int j = 0; j < 5; j++) qi_dot[j] = q_dot[j][i]; 228 State s_dot = StateFromQ_fwd(context, s, qi_dot, state_var); 229 UnpackState_U(s_dot.U, U_dot); 230 231 for (CeedInt j = 0; j < 5; j++) v[j][i] = wdetJ * (U_dot[j] - body_force[j]); 232 if (context->idl_enable) { 233 const CeedScalar sigma = LinearRampCoefficient(context->idl_amplitude, context->idl_length, context->idl_start, x_i[0]); 234 StoredValuesPack(Q, i, 14, 1, &sigma, jac_data); 235 CeedScalar damp_state[5] = {s.Y.pressure - P0, 0, 0, 0, 0}, idl_residual[5] = {0.}; 236 InternalDampingLayer(context, s, sigma, damp_state, idl_residual); 237 for (int j = 0; j < 5; j++) v[j][i] += wdetJ * idl_residual[j]; 238 } 239 240 Tau_diagPrim(context, s, dXdx, dt, Tau_d); 241 Stabilization(context, s, Tau_d, grad_s, U_dot, body_force, stab); 242 243 for (CeedInt j = 0; j < 5; j++) { 244 for (CeedInt k = 0; k < 3; k++) { 245 Grad_v[k][j][i] += wdetJ * (stab[j][0] * dXdx[k][0] + stab[j][1] * dXdx[k][1] + stab[j][2] * dXdx[k][2]); 246 } 247 } 248 StoredValuesPack(Q, i, 0, 5, qi, jac_data); 249 StoredValuesPack(Q, i, 5, 6, kmstress, jac_data); 250 StoredValuesPack(Q, i, 11, 3, Tau_d, jac_data); 251 252 } // End Quadrature Point Loop 253 254 // Return 255 return 0; 256 } 257 258 CEED_QFUNCTION(IFunction_Newtonian_Conserv)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 259 return IFunction_Newtonian(ctx, Q, in, out, STATEVAR_CONSERVATIVE); 260 } 261 262 CEED_QFUNCTION(IFunction_Newtonian_Prim)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 263 return IFunction_Newtonian(ctx, Q, in, out, STATEVAR_PRIMITIVE); 264 } 265 266 // ***************************************************************************** 267 // This QFunction implements the jacobian of the Navier-Stokes equations for implicit time stepping method. 268 // ***************************************************************************** 269 CEED_QFUNCTION_HELPER int IJacobian_Newtonian(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out, StateVariable state_var) { 270 // Inputs 271 const CeedScalar(*dq)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0]; 272 const CeedScalar(*Grad_dq) = in[1]; 273 const CeedScalar(*q_data) = in[2]; 274 const CeedScalar(*jac_data) = in[3]; 275 276 // Outputs 277 CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 278 CeedScalar(*Grad_v)[5][CEED_Q_VLA] = (CeedScalar(*)[5][CEED_Q_VLA])out[1]; 279 280 // Context 281 NewtonianIdealGasContext context = (NewtonianIdealGasContext)ctx; 282 const CeedScalar *g = context->g; 283 284 // Quadrature Point Loop 285 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 286 CeedScalar wdetJ, dXdx[3][3]; 287 QdataUnpack_3D(Q, i, q_data, &wdetJ, dXdx); 288 289 CeedScalar qi[5], kmstress[6], Tau_d[3]; 290 StoredValuesUnpack(Q, i, 0, 5, jac_data, qi); 291 StoredValuesUnpack(Q, i, 5, 6, jac_data, kmstress); 292 StoredValuesUnpack(Q, i, 11, 3, jac_data, Tau_d); 293 State s = StateFromQ(context, qi, state_var); 294 295 CeedScalar dqi[5]; 296 for (int j = 0; j < 5; j++) dqi[j] = dq[j][i]; 297 State ds = StateFromQ_fwd(context, s, dqi, state_var); 298 299 State grad_ds[3]; 300 StatePhysicalGradientFromReference(Q, i, context, s, state_var, Grad_dq, dXdx, grad_ds); 301 302 CeedScalar dstrain_rate[6], dkmstress[6], stress[3][3], dstress[3][3], dFe[3]; 303 KMStrainRate_State(grad_ds, dstrain_rate); 304 NewtonianStress(context, dstrain_rate, dkmstress); 305 KMUnpack(dkmstress, dstress); 306 KMUnpack(kmstress, stress); 307 ViscousEnergyFlux_fwd(context, s.Y, ds.Y, grad_ds, stress, dstress, dFe); 308 309 StateConservative dF_inviscid[3]; 310 FluxInviscid_fwd(context, s, ds, dF_inviscid); 311 312 // Total flux 313 CeedScalar dFlux[5][3]; 314 FluxTotal(dF_inviscid, dstress, dFe, dFlux); 315 316 for (int j = 0; j < 5; j++) { 317 for (int k = 0; k < 3; k++) Grad_v[k][j][i] = -wdetJ * (dXdx[k][0] * dFlux[j][0] + dXdx[k][1] * dFlux[j][1] + dXdx[k][2] * dFlux[j][2]); 318 } 319 320 const CeedScalar dbody_force[5] = {0, ds.U.density * g[0], ds.U.density * g[1], ds.U.density * g[2], Dot3(ds.U.momentum, g)}; 321 CeedScalar dU[5] = {0.}; 322 UnpackState_U(ds.U, dU); 323 for (int j = 0; j < 5; j++) v[j][i] = wdetJ * (context->ijacobian_time_shift * dU[j] - dbody_force[j]); 324 325 if (context->idl_enable) { 326 const CeedScalar sigma = jac_data[14 * Q + i]; 327 CeedScalar damp_state[5] = {ds.Y.pressure, 0, 0, 0, 0}, idl_residual[5] = {0.}; 328 // This is a Picard-type linearization of the damping and could be replaced by an InternalDampingLayer_fwd that uses s and ds. 329 InternalDampingLayer(context, s, sigma, damp_state, idl_residual); 330 for (int j = 0; j < 5; j++) v[j][i] += wdetJ * idl_residual[j]; 331 } 332 333 // -- Stabilization method: none (Galerkin), SU, or SUPG 334 CeedScalar dstab[5][3], U_dot[5] = {0}; 335 for (CeedInt j = 0; j < 5; j++) U_dot[j] = context->ijacobian_time_shift * dU[j]; 336 Stabilization(context, s, Tau_d, grad_ds, U_dot, dbody_force, dstab); 337 338 for (int j = 0; j < 5; j++) { 339 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]); 340 } 341 } // End Quadrature Point Loop 342 return 0; 343 } 344 345 CEED_QFUNCTION(IJacobian_Newtonian_Conserv)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 346 return IJacobian_Newtonian(ctx, Q, in, out, STATEVAR_CONSERVATIVE); 347 } 348 349 CEED_QFUNCTION(IJacobian_Newtonian_Prim)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 350 return IJacobian_Newtonian(ctx, Q, in, out, STATEVAR_PRIMITIVE); 351 } 352 353 // ***************************************************************************** 354 // Compute boundary integral (ie. for strongly set inflows) 355 // ***************************************************************************** 356 CEED_QFUNCTION_HELPER int BoundaryIntegral(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out, StateVariable state_var) { 357 const CeedScalar(*q)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0]; 358 const CeedScalar(*Grad_q) = in[1]; 359 const CeedScalar(*q_data_sur) = in[2]; 360 361 CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 362 CeedScalar(*jac_data_sur) = out[1]; 363 364 const NewtonianIdealGasContext context = (NewtonianIdealGasContext)ctx; 365 const bool is_implicit = context->is_implicit; 366 367 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 368 const CeedScalar qi[5] = {q[0][i], q[1][i], q[2][i], q[3][i], q[4][i]}; 369 State s = StateFromQ(context, qi, state_var); 370 371 CeedScalar wdetJb, dXdx[2][3], norm[3]; 372 QdataBoundaryUnpack_3D(Q, i, q_data_sur, &wdetJb, dXdx, norm); 373 wdetJb *= is_implicit ? -1. : 1.; 374 375 State grad_s[3]; 376 StatePhysicalGradientFromReference_Boundary(Q, i, context, s, state_var, Grad_q, dXdx, grad_s); 377 378 CeedScalar strain_rate[6], kmstress[6], stress[3][3], Fe[3]; 379 KMStrainRate_State(grad_s, strain_rate); 380 NewtonianStress(context, strain_rate, kmstress); 381 KMUnpack(kmstress, stress); 382 ViscousEnergyFlux(context, s.Y, grad_s, stress, Fe); 383 384 StateConservative F_inviscid[3]; 385 FluxInviscid(context, s, F_inviscid); 386 387 CeedScalar Flux[5]; 388 FluxTotal_Boundary(F_inviscid, stress, Fe, norm, Flux); 389 390 for (CeedInt j = 0; j < 5; j++) v[j][i] = -wdetJb * Flux[j]; 391 392 StoredValuesPack(Q, i, 0, 5, qi, jac_data_sur); 393 StoredValuesPack(Q, i, 5, 6, kmstress, jac_data_sur); 394 } 395 return 0; 396 } 397 398 CEED_QFUNCTION(BoundaryIntegral_Conserv)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 399 return BoundaryIntegral(ctx, Q, in, out, STATEVAR_CONSERVATIVE); 400 } 401 402 CEED_QFUNCTION(BoundaryIntegral_Prim)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 403 return BoundaryIntegral(ctx, Q, in, out, STATEVAR_PRIMITIVE); 404 } 405 406 // ***************************************************************************** 407 // Jacobian for "set nothing" boundary integral 408 // ***************************************************************************** 409 CEED_QFUNCTION_HELPER int BoundaryIntegral_Jacobian(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out, 410 StateVariable state_var) { 411 // Inputs 412 const CeedScalar(*dq)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0]; 413 const CeedScalar(*Grad_dq) = in[1]; 414 const CeedScalar(*q_data_sur) = in[2]; 415 const CeedScalar(*jac_data_sur) = in[4]; 416 417 // Outputs 418 CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 419 420 const NewtonianIdealGasContext context = (NewtonianIdealGasContext)ctx; 421 const bool is_implicit = context->is_implicit; 422 423 // Quadrature Point Loop 424 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 425 CeedScalar wdetJb, dXdx[2][3], norm[3]; 426 QdataBoundaryUnpack_3D(Q, i, q_data_sur, &wdetJb, dXdx, norm); 427 wdetJb *= is_implicit ? -1. : 1.; 428 429 CeedScalar qi[5], kmstress[6], dqi[5]; 430 StoredValuesUnpack(Q, i, 0, 5, jac_data_sur, qi); 431 StoredValuesUnpack(Q, i, 5, 6, jac_data_sur, kmstress); 432 for (int j = 0; j < 5; j++) dqi[j] = dq[j][i]; 433 434 State s = StateFromQ(context, qi, state_var); 435 State ds = StateFromQ_fwd(context, s, dqi, state_var); 436 437 State grad_ds[3]; 438 StatePhysicalGradientFromReference_Boundary(Q, i, context, s, state_var, Grad_dq, dXdx, grad_ds); 439 440 CeedScalar dstrain_rate[6], dkmstress[6], stress[3][3], dstress[3][3], dFe[3]; 441 KMStrainRate_State(grad_ds, dstrain_rate); 442 NewtonianStress(context, dstrain_rate, dkmstress); 443 KMUnpack(dkmstress, dstress); 444 KMUnpack(kmstress, stress); 445 ViscousEnergyFlux_fwd(context, s.Y, ds.Y, grad_ds, stress, dstress, dFe); 446 447 StateConservative dF_inviscid[3]; 448 FluxInviscid_fwd(context, s, ds, dF_inviscid); 449 450 CeedScalar dFlux[5]; 451 FluxTotal_Boundary(dF_inviscid, dstress, dFe, norm, dFlux); 452 453 for (int j = 0; j < 5; j++) v[j][i] = -wdetJb * dFlux[j]; 454 } // End Quadrature Point Loop 455 return 0; 456 } 457 458 CEED_QFUNCTION(BoundaryIntegral_Jacobian_Conserv)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 459 return BoundaryIntegral_Jacobian(ctx, Q, in, out, STATEVAR_CONSERVATIVE); 460 } 461 462 CEED_QFUNCTION(BoundaryIntegral_Jacobian_Prim)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 463 return BoundaryIntegral_Jacobian(ctx, Q, in, out, STATEVAR_PRIMITIVE); 464 } 465 466 #endif // newtonian_h 467