1 // Copyright (c) 2017-2025, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 8 /// @file 9 /// libCEED QFunctions for BP examples using PETSc 10 11 #include <ceed/types.h> 12 13 // ----------------------------------------------------------------------------- 14 CEED_QFUNCTION(Error)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 15 const CeedScalar *u = in[0], *target = in[1], *q_data = in[2]; 16 CeedScalar *error = out[0]; 17 for (CeedInt i = 0; i < Q; i++) { 18 error[i] = (u[i] - target[i]) * (u[i] - target[i]) * q_data[i]; 19 } 20 return 0; 21 } 22 23 // ----------------------------------------------------------------------------- 24 CEED_QFUNCTION(Error3)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 25 const CeedScalar *u = in[0], *target = in[1], *q_data = in[2]; 26 CeedScalar *error = out[0]; 27 for (CeedInt i = 0; i < Q; i++) { 28 error[i + 0 * Q] = (u[i + 0 * Q] - target[i + 0 * Q]) * (u[i + 0 * Q] - target[i + 0 * Q]) * q_data[i]; 29 error[i + 1 * Q] = (u[i + 1 * Q] - target[i + 1 * Q]) * (u[i + 1 * Q] - target[i + 1 * Q]) * q_data[i]; 30 error[i + 2 * Q] = (u[i + 2 * Q] - target[i + 2 * Q]) * (u[i + 2 * Q] - target[i + 2 * Q]) * q_data[i]; 31 } 32 return 0; 33 } 34 // ----------------------------------------------------------------------------- 35