22using Args = kernels::InvariantsEvaluator3D::Buffers;
25static MFEM_HOST_DEVICE
inline
29 real_t dI1b[9], dI2[9], dI2b[9], dI3b[9];
30 kernels::InvariantsEvaluator3D ie(
Args()
41static MFEM_HOST_DEVICE
inline
46 kernels::InvariantsEvaluator3D ie(
Args().J(J).B(B).dI1b(dI1b).dI3b(dI3b));
51static MFEM_HOST_DEVICE
inline
55 kernels::InvariantsEvaluator3D ie(
Args().J(J).dI3b(dI3b));
58 const real_t I3b = ie.Get_I3b(sign_detJ);
59 kernels::Set(3,3, 2.0 * (I3b - 1.0), ie.Get_dI3b(sign_detJ), P);
64static MFEM_HOST_DEVICE
inline
68 kernels::InvariantsEvaluator3D ie(
Args().J(J).dI3b(dI3b));
71 const real_t I3b = ie.Get_I3b(sign_detJ);
72 kernels::Set(3,3, I3b - 1.0/(I3b * I3b * I3b), ie.Get_dI3b(sign_detJ), P);
76static MFEM_HOST_DEVICE
inline
80 real_t dI1[9], dI2[9], dI3b[9];
81 kernels::InvariantsEvaluator3D ie(
Args().J(J).B(B)
82 .dI1(dI1).dI2(dI2).dI3b(dI3b));
84 const real_t I3 = ie.Get_I3();
86 const real_t beta = -2.*ie.Get_I2()/(I3*ie.Get_I3b(sign_detJ));
92static MFEM_HOST_DEVICE
inline
96 real_t dI1b[9], dI2[9], dI2b[9], dI3b[9];
97 kernels::InvariantsEvaluator3D ie(
Args()
107 const real_t I3b = ie.Get_I3b(sign_detJ);
108 kernels::Add(3,3, w[1] * 2.0 * (I3b - 1.0), ie.Get_dI3b(sign_detJ), P);
112static MFEM_HOST_DEVICE
inline
116 real_t dI1b[9], dI2[9], dI2b[9], dI3b[9];
117 kernels::InvariantsEvaluator3D ie(
Args()
127 const real_t I3b = ie.Get_I3b(sign_detJ);
129 ie.Get_dI3b(sign_detJ), P);
133 const real_t metric_normal,
147 MFEM_VERIFY(mid == 302 || mid == 303 || mid == 315 || mid == 318 ||
148 mid == 321 || mid == 332 || mid == 338,
149 "3D metric not yet implemented!");
151 const bool const_m0 = mc_.
Size() == 1;
153 constexpr int DIM = 3;
154 const int D1D = T_D1D ? T_D1D : d1d;
155 const int Q1D = T_Q1D ? T_Q1D : q1d;
157 const auto MC = const_m0 ?
167 const real_t *metric_data = metric_param.
Read();
171 const int D1D = T_D1D ? T_D1D : d1d;
172 const int Q1D = T_Q1D ? T_Q1D : q1d;
173 constexpr int MQ1 = T_Q1D ? T_Q1D : T_MAX;
174 constexpr int MD1 = T_D1D ? T_D1D : T_MAX;
176 MFEM_SHARED
real_t s_BG[2][MQ1*MD1];
177 MFEM_SHARED
real_t s_DDD[3][MD1*MD1*MD1];
178 MFEM_SHARED
real_t s_DDQ[9][MD1*MD1*MQ1];
179 MFEM_SHARED
real_t s_DQQ[9][MD1*MQ1*MQ1];
180 MFEM_SHARED
real_t s_QQQ[9][MQ1*MQ1*MQ1];
182 kernels::internal::LoadX<MD1>(e,D1D,X,s_DDD);
183 kernels::internal::LoadBG<MD1,MQ1>(D1D,Q1D,
b,g,s_BG);
185 kernels::internal::GradX<MD1,MQ1>(D1D,Q1D,s_BG,s_DDD,s_DDQ);
186 kernels::internal::GradY<MD1,MQ1>(D1D,Q1D,s_BG,s_DDQ,s_DQQ);
187 kernels::internal::GradZ<MD1,MQ1>(D1D,Q1D,s_BG,s_DQQ,s_QQQ);
189 MFEM_FOREACH_THREAD(qz,z,Q1D)
191 MFEM_FOREACH_THREAD(qy,y,Q1D)
193 MFEM_FOREACH_THREAD(qx,x,Q1D)
195 const real_t *Jtr = &J(0,0,qx,qy,qz,e);
197 const real_t m_coef = const_m0 ? MC(0,0,0,0) : MC(qx,qy,qz,e);
198 const real_t weight = metric_normal * m_coef *
199 W(qx,qy,qz) * detJtr;
207 kernels::internal::PullGrad<MQ1>(Q1D,qx,qy,qz,s_QQQ,Jpr);
215 if (mid == 302) { EvalP_302(Jpt, P); }
216 if (mid == 303) { EvalP_303(Jpt, P); }
217 if (mid == 315) { EvalP_315(Jpt, P); }
218 if (mid == 318) { EvalP_318(Jpt, P); }
219 if (mid == 321) { EvalP_321(Jpt, P); }
220 if (mid == 332) { EvalP_332(Jpt, metric_data, P); }
221 if (mid == 338) { EvalP_338(Jpt, metric_data, P); }
222 for (
int i = 0; i < 9; i++) { P[i] *= weight; }
227 kernels::internal::PushGrad<MQ1>(Q1D,qx,qy,qz,A,s_QQQ);
232 kernels::internal::LoadBGt<MD1,MQ1>(D1D,Q1D,
b,g,s_BG);
233 kernels::internal::GradZt<MD1,MQ1>(D1D,Q1D,s_BG,s_QQQ,s_DQQ);
234 kernels::internal::GradYt<MD1,MQ1>(D1D,Q1D,s_BG,s_DQQ,s_DDQ);
235 kernels::internal::GradXt<MD1,MQ1>(D1D,Q1D,s_BG,s_DDQ,Y,e);
243 const int D1D =
PA.maps->ndof;
244 const int Q1D =
PA.maps->nqpt;
245 const int id = (D1D << 4 ) | Q1D;
259 MFEM_LAUNCH_TMOP_KERNEL(AddMultPA_Kernel_3D,
id,mn,
MC,mp,M,N,J,W,B,G,X,Y);
const T * Read(bool on_dev=true) const
Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).
Rank 3 tensor (array of matrices)
const real_t * Read(bool on_dev=true) const
Shortcut for mfem::Read( GetMemory(), TotalSize(), on_dev).
TMOP_QualityMetric * metric
struct mfem::TMOP_Integrator::@23 PA
void AddMultPA_3D(const Vector &, Vector &) const
virtual int Id() const
Return the metric ID.
virtual const real_t * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
virtual real_t * ReadWrite(bool on_dev=true)
Shortcut for mfem::ReadWrite(vec.GetMemory(), vec.Size(), on_dev).
int Size() const
Returns the size of the vector.
MFEM_HOST_DEVICE void CalcInverse(const T *data, T *inv_data)
Return the inverse of a matrix with given size and data into the matrix with data inv_data.
MFEM_HOST_DEVICE void Add(const int height, const int width, const TALPHA alpha, const TA *Adata, const TB *Bdata, TC *Cdata)
Compute C = A + alpha*B, where the matrices A, B and C are of size height x width with data Adata,...
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,...
MFEM_HOST_DEVICE void MultABt(const int Aheight, const int Awidth, const int Bheight, const TA *Adata, const TB *Bdata, TC *ABtdata)
Multiply a matrix of size Aheight x Awidth and data Adata with the transpose of a matrix of size Bhei...
MFEM_HOST_DEVICE void Set(const int height, const int width, const real_t alpha, const TA *Adata, TB *Bdata)
Compute B = alpha*A, where the matrices A and B are of size height x width with data Adata and Bdata.
MFEM_HOST_DEVICE T Det(const T *data)
Compute the determinant of a square matrix of size dim with given data.
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.
kernels::InvariantsEvaluator2D::Buffers Args
void forall_3D(int N, int X, int Y, int Z, lambda &&body)