1 // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2 // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3 // reserved. See files LICENSE and NOTICE for details. 4 // 5 // This file is part of CEED, a collection of benchmarks, miniapps, software 6 // libraries and APIs for efficient high-order finite element and spectral 7 // element discretizations for exascale applications. For more information and 8 // source code availability see http://github.com/ceed. 9 // 10 // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11 // a collaborative effort of two U.S. Department of Energy organizations (Office 12 // of Science and the National Nuclear Security Administration) responsible for 13 // the planning and preparation of a capable exascale ecosystem, including 14 // software, applications, hardware, advanced system engineering and early 15 // testbed platforms, in support of the nation's exascale computing imperative. 16 17 /// @file 18 /// libCEED QFunctions for mass operator example using PETSc 19 20 #ifndef bp2_h 21 #define bp2_h 22 23 #include <math.h> 24 25 // ----------------------------------------------------------------------------- 26 // This QFunction sets up the rhs and true solution for the problem 27 // ----------------------------------------------------------------------------- 28 CEED_QFUNCTION(SetupMassRhs3)(void *ctx, const CeedInt Q, 29 const CeedScalar *const *in, 30 CeedScalar *const *out) { 31 const CeedScalar *x = in[0], *w = in[1]; 32 CeedScalar *true_soln = out[0], *rhs = out[1]; 33 34 // Quadrature Point Loop 35 CeedPragmaSIMD 36 for (CeedInt i=0; i<Q; i++) { 37 // Component 1 38 true_soln[i+0*Q] = sqrt(x[i]*x[i] + x[i+Q]*x[i+Q] + x[i+2*Q]*x[i+2*Q]); 39 // Component 2 40 true_soln[i+1*Q] = 2 * true_soln[i+0*Q]; 41 // Component 3 42 true_soln[i+2*Q] = 3 * true_soln[i+0*Q]; 43 44 // Component 1 45 rhs[i+0*Q] = w[i] * true_soln[i+0*Q]; 46 // Component 2 47 rhs[i+1*Q] = 2 * rhs[i+0*Q]; 48 // Component 3 49 rhs[i+2*Q] = 3 * rhs[i+0*Q]; 50 } // End of Quadrature Point Loop 51 return 0; 52 } 53 54 // ----------------------------------------------------------------------------- 55 // This QFunction applies the mass operator for a vector field of 3 components. 56 // 57 // Inputs: 58 // u - Input vector at quadrature points 59 // q_data - Geometric factors 60 // 61 // Output: 62 // v - Output vector (test functions) at quadrature points 63 // 64 // ----------------------------------------------------------------------------- 65 CEED_QFUNCTION(Mass3)(void *ctx, const CeedInt Q, 66 const CeedScalar *const *in, CeedScalar *const *out) { 67 const CeedScalar *u = in[0], *q_data = in[1]; 68 CeedScalar *v = out[0]; 69 70 // Quadrature Point Loop 71 CeedPragmaSIMD 72 for (CeedInt i=0; i<Q; i++) { 73 // Component 1 74 v[i+0*Q] = q_data[i] * u[i+0*Q]; 75 // Component 2 76 v[i+1*Q] = q_data[i] * u[i+1*Q]; 77 // Component 3 78 v[i+2*Q] = q_data[i] * u[i+2*Q]; 79 } // End of Quadrature Point Loop 80 return 0; 81 } 82 // ----------------------------------------------------------------------------- 83 84 #endif // bp2_h 85