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 for a vector field on the sphere using PETSc 19 20 #ifndef bp2sphere_h 21 #define bp2sphere_h 22 #include <ceed.h> 23 24 #ifndef __CUDACC__ 25 # include <math.h> 26 #endif 27 28 // ***************************************************************************** 29 // This QFunction sets up the rhs and true solution for the problem 30 // ***************************************************************************** 31 32 // ----------------------------------------------------------------------------- 33 CEED_QFUNCTION(SetupMassRhs3)(void *ctx, const CeedInt Q, 34 const CeedScalar *const *in, 35 CeedScalar *const *out) { 36 // Inputs 37 const CeedScalar *X = in[0], *qdata = in[1]; 38 // Outputs 39 CeedScalar *true_soln = out[0], *rhs = out[1]; 40 41 // Context 42 const CeedScalar *context = (const CeedScalar*)ctx; 43 const CeedScalar R = context[0]; 44 45 // Quadrature Point Loop 46 CeedPragmaSIMD 47 for (CeedInt i=0; i<Q; i++) { 48 // Compute latitude 49 const CeedScalar theta = asin(X[i+2*Q] / R); 50 51 // Use absolute value of latitute for true solution 52 // Component 1 53 true_soln[i+0*Q] = fabs(theta); 54 // Component 2 55 true_soln[i+1*Q] = 2 * true_soln[i+0*Q]; 56 // Component 3 57 true_soln[i+2*Q] = 3 * true_soln[i+0*Q]; 58 59 // Component 1 60 rhs[i+0*Q] = qdata[i] * true_soln[i]; 61 // Component 2 62 rhs[i+1*Q] = 2 * rhs[i+0*Q]; 63 // Component 3 64 rhs[i+2*Q] = 3 * rhs[i+0*Q]; 65 } // End of Quadrature Point Loop 66 67 return 0; 68 } 69 70 // ***************************************************************************** 71 // This QFunction applies the mass operator for a vector field of 3 components. 72 // 73 // Inputs: 74 // u - Input vector at quadrature points 75 // qdata - Geometric factors 76 // 77 // Output: 78 // v - Output vector (test functions) at quadrature points 79 // 80 // ***************************************************************************** 81 82 // ----------------------------------------------------------------------------- 83 CEED_QFUNCTION(Mass3)(void *ctx, const CeedInt Q, 84 const CeedScalar *const *in, CeedScalar *const *out) { 85 const CeedScalar *u = in[0], *qdata = in[1]; 86 CeedScalar *v = out[0]; 87 88 // Quadrature Point Loop 89 CeedPragmaSIMD 90 for (CeedInt i=0; i<Q; i++) { 91 const CeedScalar r = qdata[i]; 92 // Component 1 93 v[i+0*Q] = r * u[i+0*Q]; 94 // Component 2 95 v[i+1*Q] = r * u[i+1*Q]; 96 // Component 3 97 v[i+2*Q] = r * u[i+2*Q]; 98 } // End of Quadrature Point Loop 99 100 return 0; 101 } 102 // ----------------------------------------------------------------------------- 103 104 #endif // bp2sphere_h 105