12 #include "../tmop.hpp" 14 #include "../linearform.hpp" 15 #include "../../general/forall.hpp" 16 #include "../../linalg/kernels.hpp" 17 #include "../../linalg/dinvariants.hpp" 22 using Args = kernels::InvariantsEvaluator2D::Buffers;
24 static MFEM_HOST_DEVICE
inline 25 double EvalW_001(
const double *Jpt)
27 kernels::InvariantsEvaluator2D ie(
Args().J(Jpt));
31 static MFEM_HOST_DEVICE
inline 32 double EvalW_002(
const double *Jpt)
34 kernels::InvariantsEvaluator2D ie(
Args().J(Jpt));
35 return 0.5 * ie.Get_I1b() - 1.0;
38 static MFEM_HOST_DEVICE
inline 39 double EvalW_007(
const double *Jpt)
41 kernels::InvariantsEvaluator2D ie(
Args().J(Jpt));
42 return ie.Get_I1() * (1.0 + 1.0/ie.Get_I2()) - 4.0;
46 static MFEM_HOST_DEVICE
inline 47 double EvalW_056(
const double *Jpt)
49 kernels::InvariantsEvaluator2D ie(
Args().J(Jpt));
50 const double I2b = ie.Get_I2b();
51 return 0.5*(I2b + 1.0/I2b) - 1.0;
54 static MFEM_HOST_DEVICE
inline 55 double EvalW_077(
const double *Jpt)
57 kernels::InvariantsEvaluator2D ie(
Args().J(Jpt));
58 const double I2b = ie.Get_I2b();
59 return 0.5*(I2b*I2b + 1./(I2b*I2b) - 2.);
62 static MFEM_HOST_DEVICE
inline 63 double EvalW_080(
const double *Jpt,
const double *w)
65 return w[0] * EvalW_002(Jpt) + w[1] * EvalW_077(Jpt);
68 static MFEM_HOST_DEVICE
inline 69 double EvalW_094(
const double *Jpt,
const double *w)
71 return w[0] * EvalW_002(Jpt) + w[1] * EvalW_056(Jpt);
75 const double metric_normal,
89 MFEM_VERIFY(mid == 1 || mid == 2 || mid == 7 || mid == 77
90 || mid == 80 || mid == 94,
91 "2D metric not yet implemented!");
93 constexpr
int DIM = 2;
94 constexpr
int NBZ = 1;
96 const int D1D = T_D1D ? T_D1D : d1d;
97 const int Q1D = T_Q1D ? T_Q1D : q1d;
107 const double *metric_data = metric_param.
Read();
111 constexpr
int NBZ = 1;
112 constexpr
int MQ1 = T_Q1D ? T_Q1D : T_MAX;
113 constexpr
int MD1 = T_D1D ? T_D1D : T_MAX;
114 const int D1D = T_D1D ? T_D1D : d1d;
115 const int Q1D = T_Q1D ? T_Q1D : q1d;
117 MFEM_SHARED
double BG[2][MQ1*MD1];
118 MFEM_SHARED
double XY[2][NBZ][MD1*MD1];
119 MFEM_SHARED
double DQ[4][NBZ][MD1*MQ1];
120 MFEM_SHARED
double QQ[4][NBZ][MQ1*MQ1];
122 kernels::internal::LoadX<MD1,NBZ>(e,D1D,X,XY);
123 kernels::internal::LoadBG<MD1,MQ1>(D1D,Q1D,
b,g,BG);
125 kernels::internal::GradX<MD1,MQ1,NBZ>(D1D,Q1D,BG,XY,DQ);
126 kernels::internal::GradY<MD1,MQ1,NBZ>(D1D,Q1D,BG,DQ,QQ);
128 MFEM_FOREACH_THREAD(qy,y,Q1D)
130 MFEM_FOREACH_THREAD(qx,x,Q1D)
132 const double *Jtr = &J(0,0,qx,qy,e);
133 const double detJtr = kernels::Det<2>(Jtr);
134 const double weight = metric_normal * W(qx,qy) * detJtr;
138 kernels::CalcInverse<2>(Jtr, Jrt);
142 kernels::internal::PullGrad<MQ1,NBZ>(Q1D,qx,qy,QQ,Jpr);
150 mid == 1 ? EvalW_001(Jpt) :
151 mid == 2 ? EvalW_002(Jpt) :
152 mid == 7 ? EvalW_007(Jpt) :
153 mid == 77 ? EvalW_077(Jpt) :
154 mid == 80 ? EvalW_080(Jpt, metric_data) :
155 mid == 94 ? EvalW_094(Jpt, metric_data) : 0.0;
157 E(qx,qy,e) = weight * EvalW;
161 return energy * ones;
168 const int D1D =
PA.maps->ndof;
169 const int Q1D =
PA.maps->nqpt;
170 const int id = (D1D << 4 ) | Q1D;
180 if (
auto m = dynamic_cast<TMOP_Combo_QualityMetric *>(
metric))
185 MFEM_LAUNCH_TMOP_KERNEL(EnergyPA_2D,
id,mn,mp,M,N,J,W,B,G,X,
O,
E);
const T * Read(bool on_dev=true) const
Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).
struct mfem::TMOP_Integrator::@23 PA
TMOP_QualityMetric * metric
virtual const double * Read(bool on_dev=true) const
Shortcut for mfem::Read(vec.GetMemory(), vec.Size(), on_dev).
const double * Read(bool on_dev=true) const
Shortcut for mfem::Read( GetMemory(), TotalSize(), on_dev).
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)
virtual int Id() const
Return the metric ID.
virtual double * Write(bool on_dev=true)
Shortcut for mfem::Write(vec.GetMemory(), vec.Size(), on_dev).
void forall_2D_batch(int N, int X, int Y, int BZ, lambda &&body)
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...
kernels::InvariantsEvaluator2D::Buffers Args
double GetLocalStateEnergyPA_2D(const Vector &) const
MFEM_HOST_DEVICE DeviceTensor< sizeof...(Dims), T > Reshape(T *ptr, Dims... dims)
Wrap a pointer as a DeviceTensor with automatically deduced template parameters.
Rank 3 tensor (array of matrices)