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 #include <ceed.h> 8 9 #include "newtonian_state.h" 10 #include "newtonian_types.h" 11 #include "utils.h" 12 13 CEED_QFUNCTION_HELPER int VelocityGradientProjectionRHS(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out, 14 StateVariable state_var) { 15 const CeedScalar(*q)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0]; 16 const CeedScalar(*Grad_q)[5][CEED_Q_VLA] = (const CeedScalar(*)[5][CEED_Q_VLA])in[1]; 17 const CeedScalar(*q_data) = in[2]; 18 CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 19 20 NewtonianIdealGasContext context = (NewtonianIdealGasContext)ctx; 21 22 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 23 const CeedScalar qi[5] = {q[0][i], q[1][i], q[2][i], q[3][i], q[4][i]}; 24 CeedScalar wdetJ, dXdx[3][3]; 25 QdataUnpack_3D(Q, i, q_data, &wdetJ, dXdx); 26 27 const State s = StateFromQ(context, qi, state_var); 28 State grad_s[3]; 29 StatePhysicalGradientFromReference(Q, i, context, s, state_var, (CeedScalar *)Grad_q, dXdx, grad_s); 30 31 CeedScalar grad_velocity[3][3]; 32 VelocityGradient(grad_s, grad_velocity); 33 34 for (CeedInt j = 0; j < 3; j++) { 35 for (CeedInt k = 0; k < 3; k++) { 36 v[j * 3 + k][i] = wdetJ * grad_velocity[j][k]; 37 } 38 } 39 } 40 return 0; 41 } 42 43 CEED_QFUNCTION(VelocityGradientProjectionRHS_Conserv)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 44 return VelocityGradientProjectionRHS(ctx, Q, in, out, STATEVAR_CONSERVATIVE); 45 } 46 47 CEED_QFUNCTION(VelocityGradientProjectionRHS_Prim)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 48 return VelocityGradientProjectionRHS(ctx, Q, in, out, STATEVAR_PRIMITIVE); 49 } 50