1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
33091a1caSvaleriabarra //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
53091a1caSvaleriabarra //
63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed
73091a1caSvaleriabarra
82b730f8bSJeremy L Thompson #include <ceed.h>
92b730f8bSJeremy L Thompson
Build2DSimplex(CeedScalar * q_ref,CeedScalar * q_weight,CeedScalar * interp,CeedScalar * grad)104fee36f0SJeremy L Thompson static void Build2DSimplex(CeedScalar *q_ref, CeedScalar *q_weight, CeedScalar *interp, CeedScalar *grad) {
1152bfb9bbSJeremy L Thompson CeedInt P = 6, Q = 4;
1252bfb9bbSJeremy L Thompson
13d1d35e2fSjeremylt q_ref[0] = 0.2;
14d1d35e2fSjeremylt q_ref[1] = 0.6;
15d1d35e2fSjeremylt q_ref[2] = 1. / 3.;
16d1d35e2fSjeremylt q_ref[3] = 0.2;
17d1d35e2fSjeremylt q_ref[4] = 0.2;
18d1d35e2fSjeremylt q_ref[5] = 0.2;
19d1d35e2fSjeremylt q_ref[6] = 1. / 3.;
20d1d35e2fSjeremylt q_ref[7] = 0.6;
21d1d35e2fSjeremylt q_weight[0] = 25. / 96.;
22d1d35e2fSjeremylt q_weight[1] = 25. / 96.;
23d1d35e2fSjeremylt q_weight[2] = -27. / 96.;
24d1d35e2fSjeremylt q_weight[3] = 25. / 96.;
2552bfb9bbSJeremy L Thompson
2652bfb9bbSJeremy L Thompson // Loop over quadrature points
2752bfb9bbSJeremy L Thompson for (int i = 0; i < Q; i++) {
28d1d35e2fSjeremylt CeedScalar x1 = q_ref[0 * Q + i], x2 = q_ref[1 * Q + i];
2952bfb9bbSJeremy L Thompson // Interp
3052bfb9bbSJeremy L Thompson interp[i * P + 0] = 2. * (x1 + x2 - 1.) * (x1 + x2 - 1. / 2.);
3152bfb9bbSJeremy L Thompson interp[i * P + 1] = -4. * x1 * (x1 + x2 - 1.);
3252bfb9bbSJeremy L Thompson interp[i * P + 2] = 2. * x1 * (x1 - 1. / 2.);
3352bfb9bbSJeremy L Thompson interp[i * P + 3] = -4. * x2 * (x1 + x2 - 1.);
3452bfb9bbSJeremy L Thompson interp[i * P + 4] = 4. * x1 * x2;
3552bfb9bbSJeremy L Thompson interp[i * P + 5] = 2. * x2 * (x2 - 1. / 2.);
3652bfb9bbSJeremy L Thompson // Grad
3752bfb9bbSJeremy L Thompson grad[(i + 0) * P + 0] = 2. * (1. * (x1 + x2 - 1. / 2.) + (x1 + x2 - 1.) * 1.);
3852bfb9bbSJeremy L Thompson grad[(i + Q) * P + 0] = 2. * (1. * (x1 + x2 - 1. / 2.) + (x1 + x2 - 1.) * 1.);
3952bfb9bbSJeremy L Thompson grad[(i + 0) * P + 1] = -4. * (1. * (x1 + x2 - 1.) + x1 * 1.);
4052bfb9bbSJeremy L Thompson grad[(i + Q) * P + 1] = -4. * (x1 * 1.);
4152bfb9bbSJeremy L Thompson grad[(i + 0) * P + 2] = 2. * (1. * (x1 - 1. / 2.) + x1 * 1.);
4252bfb9bbSJeremy L Thompson grad[(i + Q) * P + 2] = 2. * 0.;
4352bfb9bbSJeremy L Thompson grad[(i + 0) * P + 3] = -4. * (x2 * 1.);
4452bfb9bbSJeremy L Thompson grad[(i + Q) * P + 3] = -4. * (1. * (x1 + x2 - 1.) + x2 * 1.);
4552bfb9bbSJeremy L Thompson grad[(i + 0) * P + 4] = 4. * (1. * x2);
4652bfb9bbSJeremy L Thompson grad[(i + Q) * P + 4] = 4. * (x1 * 1.);
4752bfb9bbSJeremy L Thompson grad[(i + 0) * P + 5] = 2. * 0.;
4852bfb9bbSJeremy L Thompson grad[(i + Q) * P + 5] = 2. * (1. * (x2 - 1. / 2.) + x2 * 1.);
4952bfb9bbSJeremy L Thompson }
5052bfb9bbSJeremy L Thompson }
51