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 8c9c2c079SJeremy L Thompson #include <ceed.h> 9c9c2c079SJeremy L Thompson 10*2b730f8bSJeremy 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 19*2b730f8bSJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 2010a06a06SJeremy L Thompson // *INDENT-OFF* 21*2b730f8bSJeremy L Thompson const CeedScalar(*q_data) = (const CeedScalar(*))in[0], (*u)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[1]; 2210a06a06SJeremy L Thompson CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 2310a06a06SJeremy L Thompson // *INDENT-ON* 24b8edc0e7SJeremy L Thompson 2510a06a06SJeremy L Thompson const CeedScalar num_comp = 2; 26b8edc0e7SJeremy L Thompson const CeedScalar scale[2][2] = { 27b8edc0e7SJeremy L Thompson {1.0, 2.0}, 28b8edc0e7SJeremy L Thompson {3.0, 4.0}, 29b8edc0e7SJeremy L Thompson }; 30b8edc0e7SJeremy L Thompson 31b8edc0e7SJeremy L Thompson for (CeedInt i = 0; i < Q; i++) { 3210a06a06SJeremy L Thompson for (CeedInt c_out = 0; c_out < num_comp; c_out++) { 3310a06a06SJeremy L Thompson v[c_out][i] = 0.0; 3410a06a06SJeremy L Thompson for (CeedInt c_in = 0; c_in < num_comp; c_in++) { 3510a06a06SJeremy L Thompson v[c_out][i] += q_data[i] * u[c_in][i] * scale[c_in][c_out]; 36b8edc0e7SJeremy L Thompson } 37b8edc0e7SJeremy L Thompson } 38b8edc0e7SJeremy L Thompson } 39b8edc0e7SJeremy L Thompson return 0; 40b8edc0e7SJeremy L Thompson } 41