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