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