1b8edc0e7SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2b8edc0e7SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3b8edc0e7SJeremy L Thompson // 4b8edc0e7SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 5b8edc0e7SJeremy L Thompson // 6b8edc0e7SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 7b8edc0e7SJeremy L Thompson 8b8edc0e7SJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, 9b8edc0e7SJeremy L Thompson const CeedScalar *const *in, 10b8edc0e7SJeremy L Thompson CeedScalar *const *out) { 11b8edc0e7SJeremy L Thompson const CeedScalar *weight = in[0], *J = in[1]; 12b8edc0e7SJeremy L Thompson CeedScalar *rho = out[0]; 13b8edc0e7SJeremy L Thompson for (CeedInt i=0; i<Q; i++) { 14b8edc0e7SJeremy L Thompson rho[i] = weight[i] * (J[i+Q*0]*J[i+Q*3] - J[i+Q*1]*J[i+Q*2]); 15b8edc0e7SJeremy L Thompson } 16b8edc0e7SJeremy L Thompson return 0; 17b8edc0e7SJeremy L Thompson } 18b8edc0e7SJeremy L Thompson 19b8edc0e7SJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, 20b8edc0e7SJeremy L Thompson CeedScalar *const *out) { 21*10a06a06SJeremy L Thompson // *INDENT-OFF* 22*10a06a06SJeremy L Thompson const CeedScalar (*q_data) = (const CeedScalar(*))in[0], 23*10a06a06SJeremy L Thompson (*u)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[1]; 24*10a06a06SJeremy L Thompson CeedScalar (*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 25*10a06a06SJeremy L Thompson // *INDENT-ON* 26b8edc0e7SJeremy L Thompson 27*10a06a06SJeremy L Thompson const CeedScalar num_comp = 2; 28b8edc0e7SJeremy L Thompson const CeedScalar scale[2][2] = { 29b8edc0e7SJeremy L Thompson {1.0, 2.0}, 30b8edc0e7SJeremy L Thompson {3.0, 4.0}, 31b8edc0e7SJeremy L Thompson }; 32b8edc0e7SJeremy L Thompson 33b8edc0e7SJeremy L Thompson for (CeedInt i = 0; i < Q; i++) { 34*10a06a06SJeremy L Thompson for (CeedInt c_out = 0; c_out < num_comp; c_out++) { 35*10a06a06SJeremy L Thompson v[c_out][i] = 0.0; 36*10a06a06SJeremy L Thompson for (CeedInt c_in = 0; c_in < num_comp; c_in++) { 37*10a06a06SJeremy L Thompson v[c_out][i] += q_data[i] * u[c_in][i] * scale[c_in][c_out]; 38b8edc0e7SJeremy L Thompson } 39b8edc0e7SJeremy L Thompson } 40b8edc0e7SJeremy L Thompson } 41b8edc0e7SJeremy L Thompson return 0; 42b8edc0e7SJeremy L Thompson } 43