1dc936754SJeremy L Thompson // Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors. 282fc53c5SJames Wright // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 382fc53c5SJames Wright // 482fc53c5SJames Wright // SPDX-License-Identifier: BSD-2-Clause 582fc53c5SJames Wright // 682fc53c5SJames Wright // This file is part of CEED: http://github.com/ceed 782fc53c5SJames Wright #include <ceed.h> 882fc53c5SJames Wright 982fc53c5SJames Wright #include "newtonian_state.h" 1082fc53c5SJames Wright #include "newtonian_types.h" 1182fc53c5SJames Wright #include "utils.h" 1282fc53c5SJames Wright 1382fc53c5SJames Wright CEED_QFUNCTION_HELPER int VelocityGradientProjectionRHS(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out, 148fff8293SJames Wright StateVariable state_var) { 1582fc53c5SJames Wright const CeedScalar(*q)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0]; 1682fc53c5SJames Wright const CeedScalar(*Grad_q)[5][CEED_Q_VLA] = (const CeedScalar(*)[5][CEED_Q_VLA])in[1]; 17ade49511SJames Wright const CeedScalar(*q_data) = in[2]; 1882fc53c5SJames Wright CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 1982fc53c5SJames Wright 2082fc53c5SJames Wright NewtonianIdealGasContext context = (NewtonianIdealGasContext)ctx; 2182fc53c5SJames Wright 2282fc53c5SJames Wright CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 2382fc53c5SJames Wright const CeedScalar qi[5] = {q[0][i], q[1][i], q[2][i], q[3][i], q[4][i]}; 24ade49511SJames Wright CeedScalar wdetJ, dXdx[3][3]; 25ade49511SJames Wright QdataUnpack_3D(Q, i, q_data, &wdetJ, dXdx); 2682fc53c5SJames Wright 27edcfef1bSKenneth E. Jansen const State s = StateFromQ(context, qi, state_var); 2882fc53c5SJames Wright State grad_s[3]; 295e604c93SJames Wright StatePhysicalGradientFromReference(Q, i, context, s, state_var, (CeedScalar *)Grad_q, dXdx, grad_s); 3082fc53c5SJames Wright 3182fc53c5SJames Wright CeedScalar grad_velocity[3][3]; 3282fc53c5SJames Wright VelocityGradient(grad_s, grad_velocity); 3382fc53c5SJames Wright 3482fc53c5SJames Wright for (CeedInt j = 0; j < 3; j++) { 3582fc53c5SJames Wright for (CeedInt k = 0; k < 3; k++) { 3682fc53c5SJames Wright v[j * 3 + k][i] = wdetJ * grad_velocity[j][k]; 3782fc53c5SJames Wright } 3882fc53c5SJames Wright } 3982fc53c5SJames Wright } 4082fc53c5SJames Wright return 0; 4182fc53c5SJames Wright } 4282fc53c5SJames Wright 4382fc53c5SJames Wright CEED_QFUNCTION(VelocityGradientProjectionRHS_Conserv)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 448fff8293SJames Wright return VelocityGradientProjectionRHS(ctx, Q, in, out, STATEVAR_CONSERVATIVE); 4582fc53c5SJames Wright } 4682fc53c5SJames Wright 4782fc53c5SJames Wright CEED_QFUNCTION(VelocityGradientProjectionRHS_Prim)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 488fff8293SJames Wright return VelocityGradientProjectionRHS(ctx, Q, in, out, STATEVAR_PRIMITIVE); 4982fc53c5SJames Wright } 50*9b103f75SJames Wright 51*9b103f75SJames Wright CEED_QFUNCTION(VelocityGradientProjectionRHS_Entropy)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 52*9b103f75SJames Wright return VelocityGradientProjectionRHS(ctx, Q, in, out, STATEVAR_ENTROPY); 53*9b103f75SJames Wright } 54