| 1 |
// Copyright (c) 2010-2025, Lawrence Livermore National Security, LLC. Produced |
| 2 |
// at the Lawrence Livermore National Laboratory. All Rights reserved. See files |
| 3 |
// LICENSE and NOTICE for details. LLNL-CODE-806117. |
| 4 |
// |
| 5 |
// This file is part of the MFEM library. For more information and source code |
| 6 |
// availability visit https://mfem.org. |
| 7 |
// |
| 8 |
// MFEM is free software; you can redistribute it and/or modify it under the |
| 9 |
// terms of the BSD-3 license. We welcome feedback and contributions, see file |
| 10 |
// CONTRIBUTING.md for details. |
| 11 |
|
| 12 |
#include "../pa.hpp" |
| 13 |
#include "../../tmop.hpp" |
| 14 |
#include "../../../general/forall.hpp" |
| 15 |
|
| 16 |
namespace mfem |
| 17 |
{ |
| 18 |
|
| 19 |
template <int MD1, int MQ1, int T_D1D = 0, int T_Q1D = 0> |
| 20 |
void TMOP_AssembleDiagPA_C0_2D(const int NE, |
| 21 |
const ConstDeviceMatrix &B, |
| 22 |
const DeviceTensor<5, const real_t> &H0, |
| 23 |
DeviceTensor<4> &D, |
| 24 |
const int d1d, const int q1d) |
| 25 |
{ |
| 26 |
const int D1D = T_D1D ? T_D1D : d1d; |
| 27 |
const int Q1D = T_Q1D ? T_Q1D : q1d; |
| 28 |
|
| 29 |
mfem::forall_2D(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE(int e) |
| 30 |
{ |
| 31 |
MFEM_SHARED real_t qd[MQ1 * MD1]; |
| 32 |
DeviceTensor<2, real_t> QD(qd, MQ1, MD1); |
| 33 |
|
| 34 |
for (int v = 0; v < 2; v++) |
| 35 |
{ |
| 36 |
MFEM_FOREACH_THREAD_DIRECT(qx, x, Q1D) |
| 37 |
{ |
| 38 |
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D) |
| 39 |
{ |
| 40 |
QD(qx, dy) = 0.0; |
| 41 |
for (int qy = 0; qy < Q1D; ++qy) |
| 42 |
{ |
| 43 |
const real_t bb = B(qy, dy) * B(qy, dy); |
| 44 |
QD(qx, dy) += bb * H0(v, v, qx, qy, e); |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
MFEM_SYNC_THREAD; |
| 49 |
MFEM_FOREACH_THREAD_DIRECT(dy, y, D1D) |
| 50 |
{ |
| 51 |
MFEM_FOREACH_THREAD_DIRECT(dx, x, D1D) |
| 52 |
{ |
| 53 |
real_t d = 0.0; |
| 54 |
for (int qx = 0; qx < Q1D; ++qx) |
| 55 |
{ |
| 56 |
const real_t bb = B(qx, dx) * B(qx, dx); |
| 57 |
d += bb * QD(qx, dy); |
| 58 |
} |
| 59 |
D(dx, dy, v, e) += d; |
| 60 |
} |
| 61 |
} |
| 62 |
MFEM_SYNC_THREAD; |
| 63 |
} |
| 64 |
}); |
| 65 |
} |
| 66 |
|
| 67 |
MFEM_TMOP_MDQ_REGISTER(TMOPAssembleDiagCoef2D, TMOP_AssembleDiagPA_C0_2D); |
| 68 |
MFEM_TMOP_MDQ_SPECIALIZE(TMOPAssembleDiagCoef2D); |
| 69 |
|
| 70 |
void TMOP_Integrator::AssembleDiagonalPA_C0_2D(Vector &diagonal) const |
| 71 |
{ |
| 72 |
const int NE = PA.ne, d = PA.maps->ndof, q = PA.maps->nqpt; |
| 73 |
MFEM_VERIFY(d <= DeviceDofQuadLimits::Get().MAX_D1D, ""); |
| 74 |
MFEM_VERIFY(q <= DeviceDofQuadLimits::Get().MAX_Q1D, ""); |
| 75 |
|
| 76 |
const auto B = Reshape(PA.maps->B.Read(), q, d); |
| 77 |
const auto H0 = Reshape(PA.H0.Read(), 2, 2, q, q, NE); |
| 78 |
auto D = Reshape(diagonal.ReadWrite(), d, d, 2, NE); |
| 79 |
|
| 80 |
TMOPAssembleDiagCoef2D::Run(d, q, NE, B, H0, D, d, q); |
| 81 |
} |
| 82 |
|
| 83 |
} // namespace mfem |