MFEM  v4.5.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
tmop_pa_h2d_c0.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2022, 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"
14 #include "../../general/forall.hpp"
15 #include "../../linalg/kernels.hpp"
16 
17 namespace mfem
18 {
19 
20 MFEM_REGISTER_TMOP_KERNELS(void, AssembleDiagonalPA_Kernel_C0_2D,
21  const int NE,
22  const Array<double> &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(e, NE, Q1D, Q1D, 1,
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 : MAX_D1D;
44  constexpr int MQ1 = T_Q1D ? T_Q1D : MAX_Q1D;
45 
46  MFEM_SHARED double qd[MQ1*MD1];
47  DeviceTensor<2,double> 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 double 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  double d = 0.0;
70  MFEM_UNROLL(MQ1)
71  for (int qx = 0; qx < Q1D; ++qx)
72  {
73  const double 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<double> &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
struct mfem::TMOP_Integrator::@23 PA
constexpr int DIM
const int MAX_Q1D
Definition: forall.hpp:29
void AssembleDiagonalPA_C0_2D(Vector &) const
double b
Definition: lissajous.cpp:42
MFEM_REGISTER_TMOP_KERNELS(void, DatcSize, const int NE, const int ncomp, const int sizeidx, const DenseMatrix &w_, const Array< double > &b_, const Vector &x_, DenseTensor &j_, const int d1d, const int q1d)
Definition: tmop_pa_da3.cpp:20
const T * Read(bool on_dev=true) const
Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).
Definition: array.hpp:304
A basic generic Tensor class, appropriate for use on the GPU.
Definition: dtensor.hpp:81
virtual double * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), on_dev).
Definition: vector.hpp:465
const int MAX_D1D
Definition: forall.hpp:28
Vector data type.
Definition: vector.hpp:60
virtual const double * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
Definition: vector.hpp:449
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