xref: /libCEED/tests/t320-basis.h (revision d1d35e2f02dc969aee8debf3fd943dd784aa847a)
13091a1caSvaleriabarra // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
23091a1caSvaleriabarra // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
33091a1caSvaleriabarra // All Rights reserved. See files LICENSE and NOTICE for details.
43091a1caSvaleriabarra //
53091a1caSvaleriabarra // This file is part of CEED, a collection of benchmarks, miniapps, software
63091a1caSvaleriabarra // libraries and APIs for efficient high-order finite element and spectral
73091a1caSvaleriabarra // element discretizations for exascale applications. For more information and
83091a1caSvaleriabarra // source code availability see http://github.com/ceed.
93091a1caSvaleriabarra //
103091a1caSvaleriabarra // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
113091a1caSvaleriabarra // a collaborative effort of two U.S. Department of Energy organizations (Office
123091a1caSvaleriabarra // of Science and the National Nuclear Security Administration) responsible for
133091a1caSvaleriabarra // the planning and preparation of a capable exascale ecosystem, including
143091a1caSvaleriabarra // software, applications, hardware, advanced system engineering and early
153091a1caSvaleriabarra // testbed platforms, in support of the nation's exascale computing imperative.
163091a1caSvaleriabarra 
17*d1d35e2fSjeremylt static void buildmats(CeedScalar *q_ref, CeedScalar *q_weight,
18*d1d35e2fSjeremylt                       CeedScalar *interp,
1952bfb9bbSJeremy L Thompson                       CeedScalar *grad) {
2052bfb9bbSJeremy L Thompson   CeedInt P = 6, Q = 4;
2152bfb9bbSJeremy L Thompson 
22*d1d35e2fSjeremylt   q_ref[0] = 0.2;
23*d1d35e2fSjeremylt   q_ref[1] = 0.6;
24*d1d35e2fSjeremylt   q_ref[2] = 1./3.;
25*d1d35e2fSjeremylt   q_ref[3] = 0.2;
26*d1d35e2fSjeremylt   q_ref[4] = 0.2;
27*d1d35e2fSjeremylt   q_ref[5] = 0.2;
28*d1d35e2fSjeremylt   q_ref[6] = 1./3.;
29*d1d35e2fSjeremylt   q_ref[7] = 0.6;
30*d1d35e2fSjeremylt   q_weight[0] = 25./96.;
31*d1d35e2fSjeremylt   q_weight[1] = 25./96.;
32*d1d35e2fSjeremylt   q_weight[2] = -27./96.;
33*d1d35e2fSjeremylt   q_weight[3] = 25./96.;
3452bfb9bbSJeremy L Thompson 
3552bfb9bbSJeremy L Thompson   // Loop over quadrature points
3652bfb9bbSJeremy L Thompson   for (int i=0; i<Q; i++) {
37*d1d35e2fSjeremylt     CeedScalar x1 = q_ref[0*Q+i], x2 = q_ref[1*Q+i];
3852bfb9bbSJeremy L Thompson     // Interp
3952bfb9bbSJeremy L Thompson     interp[i*P+0] =  2.*(x1+x2-1.)*(x1+x2-1./2.);
4052bfb9bbSJeremy L Thompson     interp[i*P+1] = -4.*x1*(x1+x2-1.);
4152bfb9bbSJeremy L Thompson     interp[i*P+2] =  2.*x1*(x1-1./2.);
4252bfb9bbSJeremy L Thompson     interp[i*P+3] = -4.*x2*(x1+x2-1.);
4352bfb9bbSJeremy L Thompson     interp[i*P+4] =  4.*x1*x2;
4452bfb9bbSJeremy L Thompson     interp[i*P+5] =  2.*x2*(x2-1./2.);
4552bfb9bbSJeremy L Thompson     // Grad
4652bfb9bbSJeremy L Thompson     grad[(i+0)*P+0] =  2.*(1.*(x1+x2-1./2.)+(x1+x2-1.)*1.);
4752bfb9bbSJeremy L Thompson     grad[(i+Q)*P+0] =  2.*(1.*(x1+x2-1./2.)+(x1+x2-1.)*1.);
4852bfb9bbSJeremy L Thompson     grad[(i+0)*P+1] = -4.*(1.*(x1+x2-1.)+x1*1.);
4952bfb9bbSJeremy L Thompson     grad[(i+Q)*P+1] = -4.*(x1*1.);
5052bfb9bbSJeremy L Thompson     grad[(i+0)*P+2] =  2.*(1.*(x1-1./2.)+x1*1.);
5152bfb9bbSJeremy L Thompson     grad[(i+Q)*P+2] =  2.*0.;
5252bfb9bbSJeremy L Thompson     grad[(i+0)*P+3] = -4.*(x2*1.);
5352bfb9bbSJeremy L Thompson     grad[(i+Q)*P+3] = -4.*(1.*(x1+x2-1.)+x2*1.);
5452bfb9bbSJeremy L Thompson     grad[(i+0)*P+4] =  4.*(1.*x2);
5552bfb9bbSJeremy L Thompson     grad[(i+Q)*P+4] =  4.*(x1*1.);
5652bfb9bbSJeremy L Thompson     grad[(i+0)*P+5] =  2.*0.;
5752bfb9bbSJeremy L Thompson     grad[(i+Q)*P+5] =  2.*(1.*(x2-1./2.)+x2*1.);
5852bfb9bbSJeremy L Thompson   }
5952bfb9bbSJeremy L Thompson }
60