MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
tmop_pa_h2d_c0.cpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, 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 "../tmop.hpp"
13#include "tmop_pa.hpp"
16
17namespace mfem
18{
19
20MFEM_REGISTER_TMOP_KERNELS(void, AssembleDiagonalPA_Kernel_C0_2D,
21 const int NE,
22 const Array<real_t> &b,
23 const Vector &h0,
24 Vector &diagonal,
25 const int d1d,
26 const int q1d)
27{
28 constexpr int DIM = 2;
29
30 const int D1D = T_D1D ? T_D1D : d1d;
31 const int Q1D = T_Q1D ? T_Q1D : q1d;
32
33 const auto B = Reshape(b.Read(), Q1D, D1D);
34 const auto H0 = Reshape(h0.Read(), DIM, DIM, Q1D, Q1D, NE);
35
36 auto D = Reshape(diagonal.ReadWrite(), D1D, D1D, DIM, NE);
37
38 mfem::forall_2D(NE, Q1D, Q1D, [=] MFEM_HOST_DEVICE (int e)
39 {
40 constexpr int DIM = 2;
41 const int D1D = T_D1D ? T_D1D : d1d;
42 const int Q1D = T_Q1D ? T_Q1D : q1d;
43 constexpr int MD1 = T_D1D ? T_D1D : DofQuadLimits::MAX_D1D;
44 constexpr int MQ1 = T_Q1D ? T_Q1D : DofQuadLimits::MAX_Q1D;
45
46 MFEM_SHARED real_t qd[MQ1*MD1];
47 DeviceTensor<2,real_t> QD(qd, MQ1, MD1);
48
49 for (int v = 0; v < DIM; v++)
50 {
51 MFEM_FOREACH_THREAD(qx,x,Q1D)
52 {
53 MFEM_FOREACH_THREAD(dy,y,D1D)
54 {
55 QD(qx,dy) = 0.0;
56 MFEM_UNROLL(MQ1)
57 for (int qy = 0; qy < Q1D; ++qy)
58 {
59 const real_t bb = B(qy,dy) * B(qy,dy);
60 QD(qx,dy) += bb * H0(v,v,qx,qy,e);
61 }
62 }
63 }
64 MFEM_SYNC_THREAD;
65 MFEM_FOREACH_THREAD(dy,y,D1D)
66 {
67 MFEM_FOREACH_THREAD(dx,x,D1D)
68 {
69 real_t d = 0.0;
70 MFEM_UNROLL(MQ1)
71 for (int qx = 0; qx < Q1D; ++qx)
72 {
73 const real_t bb = B(qx,dx) * B(qx,dx);
74 d += bb * QD(qx,dy);
75 }
76 D(dx,dy,v,e) += d;
77 }
78 }
79 MFEM_SYNC_THREAD;
80 }
81 });
82}
83
85{
86 const int N = PA.ne;
87 const int D1D = PA.maps->ndof;
88 const int Q1D = PA.maps->nqpt;
89 const int id = (D1D << 4 ) | Q1D;
90 const Array<real_t> &B = PA.maps->B;
91 const Vector &H0 = PA.H0;
92
93 MFEM_LAUNCH_TMOP_KERNEL(AssembleDiagonalPA_Kernel_C0_2D,id,N,B,H0,D);
94}
95
96} // namespace mfem
A basic generic Tensor class, appropriate for use on the GPU.
Definition dtensor.hpp:82
void AssembleDiagonalPA_C0_2D(Vector &) const
struct mfem::TMOP_Integrator::@23 PA
Vector data type.
Definition vector.hpp:80
virtual const real_t * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
Definition vector.hpp:474
virtual real_t * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), on_dev).
Definition vector.hpp:490
real_t b
Definition lissajous.cpp:42
constexpr int DIM
MFEM_REGISTER_TMOP_KERNELS(void, DatcSize, const int NE, const int ncomp, const int sizeidx, const real_t input_min_size, const DenseMatrix &w_, const Array< real_t > &b_, const Vector &x_, const Vector &nc_reduce, DenseTensor &j_, const int d1d, const int q1d)
MFEM_HOST_DEVICE DeviceTensor< sizeof...(Dims), T > Reshape(T *ptr, Dims... dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
Definition dtensor.hpp:131
void forall_2D(int N, int X, int Y, lambda &&body)
Definition forall.hpp:763
float real_t
Definition config.hpp:43