1dc936754SJeremy L Thompson // Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors. 2692bc0d9SJames Wright // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3692bc0d9SJames Wright // 4692bc0d9SJames Wright // SPDX-License-Identifier: BSD-2-Clause 5692bc0d9SJames Wright // 6692bc0d9SJames Wright // This file is part of CEED: http://github.com/ceed 7692bc0d9SJames Wright #include <ceed.h> 8692bc0d9SJames Wright #include <math.h> 9692bc0d9SJames Wright 10692bc0d9SJames Wright #include "newtonian_state.h" 11692bc0d9SJames Wright #include "newtonian_types.h" 12692bc0d9SJames Wright #include "utils.h" 13692bc0d9SJames Wright 14692bc0d9SJames Wright // @brief Set initial condition for Taylor-Green Vortex problem 15692bc0d9SJames Wright CEED_QFUNCTION(ICsTaylorGreen)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 16692bc0d9SJames Wright const CeedScalar(*X)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0]; 17692bc0d9SJames Wright 18692bc0d9SJames Wright CeedScalar(*q0)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 19692bc0d9SJames Wright 20692bc0d9SJames Wright const SetupContext context = (SetupContext)ctx; 21*9b103f75SJames Wright const NewtonianIdealGasContext gas = &context->gas; 22692bc0d9SJames Wright CeedScalar R = GasConstant(gas); 23692bc0d9SJames Wright StatePrimitive reference = context->reference; 24692bc0d9SJames Wright const CeedScalar V0 = sqrt(Dot3(reference.velocity, reference.velocity)); 25692bc0d9SJames Wright const CeedScalar density0 = reference.pressure / (reference.temperature * R); 26692bc0d9SJames Wright 27692bc0d9SJames Wright CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 28692bc0d9SJames Wright CeedScalar x[] = {X[0][i], X[1][i], X[2][i]}; 29692bc0d9SJames Wright CeedScalar q[5] = {0}, Y[5]; 30692bc0d9SJames Wright ScaleN(x, 2 * M_PI / context->lx, 3); 31692bc0d9SJames Wright 32692bc0d9SJames Wright Y[0] = reference.pressure + (density0 * Square(V0) / 16) * (cos(2 * x[0]) + cos(2 * x[1])) * (cos(2 * x[2] + 2)); 33692bc0d9SJames Wright Y[1] = V0 * sin(x[0]) * cos(x[1]) * cos(x[2]); 34692bc0d9SJames Wright Y[2] = -V0 * cos(x[0]) * sin(x[1]) * cos(x[2]); 35692bc0d9SJames Wright Y[3] = 0; 36692bc0d9SJames Wright Y[4] = reference.temperature; 37692bc0d9SJames Wright 38edcfef1bSKenneth E. Jansen State s = StateFromY(gas, Y); 39*9b103f75SJames Wright StateToQ(gas, s, q, gas->state_var); 40692bc0d9SJames Wright for (CeedInt j = 0; j < 5; j++) q0[j][i] = q[j]; 41692bc0d9SJames Wright } 42692bc0d9SJames Wright return 0; 43692bc0d9SJames Wright } 44