21using Args = kernels::InvariantsEvaluator2D::Buffers;
23static MFEM_HOST_DEVICE
inline
27 kernels::InvariantsEvaluator2D ie(
Args().J(Jpt).dI1(dI1));
31static MFEM_HOST_DEVICE
inline
35 kernels::InvariantsEvaluator2D ie(
Args().J(Jpt).dI1b(dI1b).dI2b(dI2b));
39static MFEM_HOST_DEVICE
inline
42 real_t dI1[4], dI2[4], dI2b[4];
43 kernels::InvariantsEvaluator2D ie(
Args().J(Jpt).dI1(dI1)
44 .dI2(dI2).dI2b(dI2b));
45 const real_t I2 = ie.Get_I2();
47 -ie.Get_I1() / (I2*I2), ie.Get_dI2(), P);
51static MFEM_HOST_DEVICE
inline
55 kernels::InvariantsEvaluator2D ie(
Args().J(Jpt).dI2b(dI2b));
56 const real_t I2b = ie.Get_I2b();
57 kernels::Set(2,2, 0.5 * (1.0 - 1.0 / (I2b * I2b)), ie.Get_dI2b(), P);
60static MFEM_HOST_DEVICE
inline
64 kernels::InvariantsEvaluator2D ie(
Args().
67 const real_t I2 = ie.Get_I2();
68 kernels::Set(2,2, 0.5 * (1.0 - 1.0 / (I2 * I2)), ie.Get_dI2(), P);
72static MFEM_HOST_DEVICE
inline
75 real_t dI1b[4], dI2[4], dI2b[4];
76 kernels::InvariantsEvaluator2D ie(
Args().J(Jpt).
77 dI1b(dI1b).dI2(dI2).dI2b(dI2b));
81 const real_t I2 = ie.Get_I2();
82 kernels::Add(2,2, w[1] * 0.5 * (1.0 - 1.0 / (I2 * I2)), ie.Get_dI2(), P);
86static MFEM_HOST_DEVICE
inline
90 kernels::InvariantsEvaluator2D ie(
Args().J(Jpt).
91 dI1b(dI1b).dI2b(dI2b));
95 const real_t I2b = ie.Get_I2b();
96 kernels::Add(2,2, w[1] * 0.5 * (1.0 - 1.0 / (I2b * I2b)), ie.Get_dI2b(), P);
100 const real_t metric_normal,
114 MFEM_VERIFY(mid == 1 || mid == 2 || mid == 7 || mid == 77
115 || mid == 80 || mid == 94,
116 "2D metric not yet implemented!");
118 const bool const_m0 = mc_.
Size() == 1;
120 constexpr int DIM = 2;
121 constexpr int NBZ = 1;
123 const int D1D = T_D1D ? T_D1D : d1d;
124 const int Q1D = T_Q1D ? T_Q1D : q1d;
126 const auto MC = const_m0 ?
136 const real_t *metric_data = metric_param.
Read();
140 constexpr int NBZ = 1;
141 constexpr int MQ1 = T_Q1D ? T_Q1D : T_MAX;
142 constexpr int MD1 = T_D1D ? T_D1D : T_MAX;
143 const int D1D = T_D1D ? T_D1D : d1d;
144 const int Q1D = T_Q1D ? T_Q1D : q1d;
146 MFEM_SHARED
real_t BG[2][MQ1*MD1];
147 MFEM_SHARED
real_t XY[2][NBZ][MD1*MD1];
148 MFEM_SHARED
real_t DQ[4][NBZ][MD1*MQ1];
149 MFEM_SHARED
real_t QQ[4][NBZ][MQ1*MQ1];
151 kernels::internal::LoadX<MD1,NBZ>(e,D1D,X,XY);
152 kernels::internal::LoadBG<MD1,MQ1>(D1D,Q1D,
b,g,BG);
154 kernels::internal::GradX<MD1,MQ1,NBZ>(D1D,Q1D,BG,XY,DQ);
155 kernels::internal::GradY<MD1,MQ1,NBZ>(D1D,Q1D,BG,DQ,QQ);
157 MFEM_FOREACH_THREAD(qy,y,Q1D)
159 MFEM_FOREACH_THREAD(qx,x,Q1D)
161 const real_t *Jtr = &J(0,0,qx,qy,e);
163 const real_t m_coef = const_m0 ? MC(0,0,0) : MC(qx,qy,e);
164 const real_t weight = metric_normal * m_coef *
173 kernels::internal::PullGrad<MQ1,NBZ>(Q1D,qx,qy,QQ,Jpr);
181 if (mid == 1) { EvalP_001(Jpt, P); }
182 if (mid == 2) { EvalP_002(Jpt, P); }
183 if (mid == 7) { EvalP_007(Jpt, P); }
184 if (mid == 56) { EvalP_056(Jpt, P); }
185 if (mid == 77) { EvalP_077(Jpt, P); }
186 if (mid == 80) { EvalP_080(Jpt, metric_data, P); }
187 if (mid == 94) { EvalP_094(Jpt, metric_data, P); }
188 for (
int i = 0; i < 4; i++) { P[i] *= weight; }
193 kernels::internal::PushGrad<MQ1,NBZ>(Q1D,qx,qy,A,QQ);
197 kernels::internal::LoadBGt<MD1,MQ1>(D1D,Q1D,
b,g,BG);
198 kernels::internal::GradYt<MD1,MQ1,NBZ>(D1D,Q1D,BG,QQ,DQ);
199 kernels::internal::GradXt<MD1,MQ1,NBZ>(D1D,Q1D,BG,DQ,Y,e);
207 const int D1D =
PA.maps->ndof;
208 const int Q1D =
PA.maps->nqpt;
209 const int id = (D1D << 4 ) | Q1D;
223 MFEM_LAUNCH_TMOP_KERNEL(AddMultPA_Kernel_2D,
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
void AddMultPA_2D(const Vector &, Vector &) const
struct mfem::TMOP_Integrator::@23 PA
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.
void forall_2D_batch(int N, int X, int Y, int BZ, lambda &&body)
kernels::InvariantsEvaluator2D::Buffers Args