MFEM  v4.6.0
Finite element discretization library
tmop_pa_h3m_c0.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2023, 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 "../linearform.hpp"
15 #include "../../general/forall.hpp"
16 #include "../../linalg/kernels.hpp"
17 
18 namespace mfem
19 {
20 
21 MFEM_REGISTER_TMOP_KERNELS(void, AddMultGradPA_Kernel_C0_3D,
22  const int NE,
23  const Array<double> &b_,
24  const Vector &h0_,
25  const Vector &r_,
26  Vector &c_,
27  const int d1d,
28  const int q1d)
29 {
30  constexpr int DIM = 3;
31 
32  const int D1D = T_D1D ? T_D1D : d1d;
33  const int Q1D = T_Q1D ? T_Q1D : q1d;
34 
35  const auto H0 = Reshape(h0_.Read(), DIM, DIM, Q1D, Q1D, Q1D, NE);
36  const auto b = Reshape(b_.Read(), Q1D, D1D);
37  const auto R = Reshape(r_.Read(), D1D, D1D, D1D, DIM, NE);
38 
39  auto Y = Reshape(c_.ReadWrite(), D1D, D1D, D1D, DIM, NE);
40 
41  mfem::forall_3D(NE, Q1D, Q1D, Q1D, [=] MFEM_HOST_DEVICE (int e)
42  {
43  constexpr int DIM = 3;
44  const int D1D = T_D1D ? T_D1D : d1d;
45  const int Q1D = T_Q1D ? T_Q1D : q1d;
46  constexpr int MQ1 = T_Q1D ? T_Q1D : T_MAX;
47  constexpr int MD1 = T_D1D ? T_D1D : T_MAX;
48 
49  MFEM_SHARED double B[MQ1*MD1];
50 
51  MFEM_SHARED double DDD[3][MD1*MD1*MD1];
52  MFEM_SHARED double DDQ[3][MD1*MD1*MQ1];
53  MFEM_SHARED double DQQ[3][MD1*MQ1*MQ1];
54  MFEM_SHARED double QQQ[3][MQ1*MQ1*MQ1];
55 
56  kernels::internal::LoadX<MD1>(e,D1D,R,DDD);
57  kernels::internal::LoadB<MD1,MQ1>(D1D,Q1D,b,B);
58 
59  kernels::internal::EvalX<MD1,MQ1>(D1D,Q1D,B,DDD,DDQ);
60  kernels::internal::EvalY<MD1,MQ1>(D1D,Q1D,B,DDQ,DQQ);
61  kernels::internal::EvalZ<MD1,MQ1>(D1D,Q1D,B,DQQ,QQQ);
62 
63  MFEM_FOREACH_THREAD(qz,z,Q1D)
64  {
65  MFEM_FOREACH_THREAD(qy,y,Q1D)
66  {
67  MFEM_FOREACH_THREAD(qx,x,Q1D)
68  {
69  // Xh = X^T . Sh
70  double Xh[3];
71  kernels::internal::PullEval<MQ1>(Q1D,qx,qy,qz,QQQ,Xh);
72 
73  double H_data[9];
74  DeviceMatrix H(H_data,3,3);
75  for (int i = 0; i < DIM; i++)
76  {
77  for (int j = 0; j < DIM; j++)
78  {
79  H(i,j) = H0(i,j,qx,qy,qz,e);
80  }
81  }
82 
83  // p2 = H . Xh
84  double p2[3];
85  kernels::Mult(3,3,H_data,Xh,p2);
86  kernels::internal::PushEval<MQ1>(Q1D,qx,qy,qz,p2,QQQ);
87  }
88  }
89  }
90  MFEM_SYNC_THREAD;
91  kernels::internal::LoadBt<MD1,MQ1>(D1D,Q1D,b,B);
92  kernels::internal::EvalXt<MD1,MQ1>(D1D,Q1D,B,QQQ,DQQ);
93  kernels::internal::EvalYt<MD1,MQ1>(D1D,Q1D,B,DQQ,DDQ);
94  kernels::internal::EvalZt<MD1,MQ1>(D1D,Q1D,B,DDQ,Y,e);
95  });
96 }
97 
99 {
100  const int N = PA.ne;
101  const int D1D = PA.maps->ndof;
102  const int Q1D = PA.maps->nqpt;
103  const int id = (D1D << 4 ) | Q1D;
104  const Array<double> &B = PA.maps->B;
105  const Vector &H0 = PA.H0;
106 
107  MFEM_LAUNCH_TMOP_KERNEL(AddMultGradPA_Kernel_C0_3D,id,N,B,H0,R,C);
108 }
109 
110 } // namespace mfem
const T * Read(bool on_dev=true) const
Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).
Definition: array.hpp:307
void forall_3D(int N, int X, int Y, int Z, lambda &&body)
Definition: forall.hpp:763
struct mfem::TMOP_Integrator::@23 PA
virtual const double * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
Definition: vector.hpp:453
constexpr int DIM
MFEM_REGISTER_TMOP_KERNELS(void, DatcSize, const int NE, const int ncomp, const int sizeidx, const double input_min_size, const DenseMatrix &w_, const Array< double > &b_, const Vector &x_, const Vector &nc_reduce, DenseTensor &j_, const int d1d, const int q1d)
Definition: tmop_pa_da3.cpp:20
double b
Definition: lissajous.cpp:42
A basic generic Tensor class, appropriate for use on the GPU.
Definition: dtensor.hpp:81
MFEM_HOST_DEVICE void Mult(const int height, const int width, const TA *data, const TX *x, TY *y)
Matrix vector multiplication: y = A x, where the matrix A is of size height x width with given data...
Definition: kernels.hpp:163
virtual double * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), on_dev).
Definition: vector.hpp:469
Vector data type.
Definition: vector.hpp:58
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 AddMultGradPA_C0_3D(const Vector &, Vector &) const