15aed82e4SJeremy L Thompson // Copyright (c) 2017-2024, 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 8*c0b5abf0SJeremy L Thompson #include <ceed/types.h> 9c9c2c079SJeremy L Thompson 102b730f8bSJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, const CeedScalar *const *in, 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 192b730f8bSJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 202b730f8bSJeremy L Thompson const CeedScalar(*q_data) = (const CeedScalar(*))in[0], (*u)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[1]; 2110a06a06SJeremy L Thompson CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 22b8edc0e7SJeremy L Thompson 2310a06a06SJeremy L Thompson const CeedScalar num_comp = 2; 24b8edc0e7SJeremy L Thompson const CeedScalar scale[2][2] = { 25b8edc0e7SJeremy L Thompson {1.0, 2.0}, 26b8edc0e7SJeremy L Thompson {3.0, 4.0}, 27b8edc0e7SJeremy L Thompson }; 28b8edc0e7SJeremy L Thompson 29b8edc0e7SJeremy L Thompson for (CeedInt i = 0; i < Q; i++) { 3010a06a06SJeremy L Thompson for (CeedInt c_out = 0; c_out < num_comp; c_out++) { 3110a06a06SJeremy L Thompson v[c_out][i] = 0.0; 3210a06a06SJeremy L Thompson for (CeedInt c_in = 0; c_in < num_comp; c_in++) { 3310a06a06SJeremy L Thompson v[c_out][i] += q_data[i] * u[c_in][i] * scale[c_in][c_out]; 34b8edc0e7SJeremy L Thompson } 35b8edc0e7SJeremy L Thompson } 36b8edc0e7SJeremy L Thompson } 37b8edc0e7SJeremy L Thompson return 0; 38b8edc0e7SJeremy L Thompson } 39